diff --git a/stdlib/public/Platform/WASI.modulemap b/stdlib/public/Platform/WASI.modulemap new file mode 100644 index 0000000000000..795e9c401d96d --- /dev/null +++ b/stdlib/public/Platform/WASI.modulemap @@ -0,0 +1,231 @@ +//===--- WASI.modulemap.gyb ----------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2020 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +/// This is a semi-complete modulemap that maps WASI headers in a roughly +/// similar way to the Darwin SDK modulemap. We do not take care to list every +/// single header which may be included by a particular submodule, so there can +/// still be issues if imported into the same context as one in which someone +/// included those headers directly. +/// +/// It's not named just WASI so that it doesn't conflict in the event of a +/// future official WASI modulemap. +module SwiftWASI [system] { + // C standard library + module C { + module ctype { + header "${GLIBC_INCLUDE_PATH}/ctype.h" + export * + } + module errno { + header "${GLIBC_INCLUDE_PATH}/errno.h" + export * + } + + module fenv { + header "${GLIBC_INCLUDE_PATH}/fenv.h" + export * + } + + // note: supplied by compiler + // module float { + // header "${GLIBC_INCLUDE_PATH}/float.h" + // export * + // } + + module inttypes { + header "${GLIBC_INCLUDE_PATH}/inttypes.h" + export * + } + + // note: potentially supplied by compiler + // module iso646 { + // header "${GLIBC_INCLUDE_PATH}/iso646.h" + // export * + // } + // module limits { + // header "${GLIBC_INCLUDE_PATH}/limits.h" + // export * + // } + + module locale { + header "${GLIBC_INCLUDE_PATH}/locale.h" + export * + } + module math { + header "${GLIBC_INCLUDE_PATH}/math.h" + export * + } + module signal { + header "${GLIBC_INCLUDE_PATH}/signal.h" + export * + } + + // note: supplied by the compiler + // module stdarg { + // header "${GLIBC_INCLUDE_PATH}/stdarg.h" + // export * + // } + // module stdbool { + // header "${GLIBC_INCLUDE_PATH}/stdbool.h" + // export * + // } + // module stddef { + // header "${GLIBC_INCLUDE_PATH}/stddef.h" + // export * + // } + // module stdint { + // header "${GLIBC_INCLUDE_PATH}/stdint.h" + // export * + // } + + module stdio { + header "${GLIBC_INCLUDE_PATH}/stdio.h" + export * + } + module stdlib { + header "${GLIBC_INCLUDE_PATH}/stdlib.h" + export * + export stddef + } + module string { + header "${GLIBC_INCLUDE_PATH}/string.h" + export * + } + + // note: supplied by the compiler + // explicit module tgmath { + // header "${GLIBC_INCLUDE_PATH}/tgmath.h" + // export * + // } + + module time { + header "${GLIBC_INCLUDE_PATH}/time.h" + export * + } + } + + // POSIX + module POSIX { + module arpa { + module inet { + header "${GLIBC_INCLUDE_PATH}/arpa/inet.h" + export * + } + export * + } + module dirent { + header "${GLIBC_INCLUDE_PATH}/dirent.h" + export * + } + module fcntl { + header "${GLIBC_INCLUDE_PATH}/fcntl.h" + export * + } + module fnmatch { + header "${GLIBC_INCLUDE_PATH}/fnmatch.h" + export * + } + module ioctl { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/ioctl.h" + export * + } + module libgen { + header "${GLIBC_INCLUDE_PATH}/libgen.h" + export * + } + module netinet { + module in { + header "${GLIBC_INCLUDE_PATH}/netinet/in.h" + export * + + exclude header "${GLIBC_INCLUDE_PATH}/netinet6/in6.h" + } + module tcp { + header "${GLIBC_INCLUDE_PATH}/netinet/tcp.h" + export * + } + } + module poll { + header "${GLIBC_INCLUDE_PATH}/poll.h" + export * + } + module regex { + header "${GLIBC_INCLUDE_PATH}/regex.h" + export * + } + module sched { + header "${GLIBC_INCLUDE_PATH}/sched.h" + export * + } + module semaphore { + header "${GLIBC_INCLUDE_PATH}/semaphore.h" + export * + } + module strings { + header "${GLIBC_INCLUDE_PATH}/strings.h" + export * + } + + module sys { + export * + + module mman { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/mman.h" + export * + } + module resource { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/resource.h" + export * + } + module select { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/select.h" + export * + } + module socket { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/socket.h" + export * + } + module stat { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/stat.h" + export * + } + module time { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/time.h" + export * + } + module times { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/times.h" + export * + } + module types { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/types.h" + export * + } + module uio { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/uio.h" + export * + } + module un { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/un.h" + export * + } + module utsname { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/utsname.h" + export * + } + } + module unistd { + header "${GLIBC_INCLUDE_PATH}/unistd.h" + export * + } + } +} diff --git a/stdlib/public/Platform/WASI.swift b/stdlib/public/Platform/WASI.swift new file mode 100644 index 0000000000000..ee0b8f8137753 --- /dev/null +++ b/stdlib/public/Platform/WASI.swift @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2020 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +@_exported import SwiftWASI // Clang module + +public let MAP_FAILED: UnsafeMutableRawPointer! = UnsafeMutableRawPointer(bitPattern: -1) + +// WebAssembly's error.h uses a macro that Swift can't import. +public let EINTR:Int32 = 27 +public let EINVAL:Int32 = 28