Files
swift-nio/Sources/CNIOWASI/include/CNIOWASI.h
Max DesiatovandFranz Busch 730713e47f Add support for WASILibc (#2671)
Dispatch is not supported on WASI, and only Unix domain sockets are
supported, which means we have to exclude those APIs on this platform.

There's work in progress to enable tests for this on CI, but nothing I
can provide for this PR at the current moment.

---------

Co-authored-by: Franz Busch <f.busch@apple.com>
2024-09-12 13:18:25 +01:00

33 lines
966 B
C

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) YEARS Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#pragma once
#if __wasi__
#include <fcntl.h>
#include <time.h>
static inline void CNIOWASI_gettime(struct timespec *tv) {
// ClangImporter doesn't support `CLOCK_MONOTONIC` declaration in WASILibc, thus we have to define a bridge manually
clock_gettime(CLOCK_MONOTONIC, tv);
}
static inline int CNIOWASI_O_CREAT() {
// ClangImporter doesn't support `O_CREATE` declaration in WASILibc, thus we have to define a bridge manually
return O_CREAT;
}
#endif