-
Notifications
You must be signed in to change notification settings - Fork 10.5k
stdlib: add wasi.modulemap.gyb
for WebAssembly support
#39360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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 SwiftWASILibc // Clang module | ||
|
||
// Constants defined by <math.h> | ||
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.") | ||
public let M_PI = Double.pi | ||
|
||
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 2' or '.pi / 2' to get the value of correct type and avoid casting.") | ||
public let M_PI_2 = Double.pi / 2 | ||
|
||
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi / 4' or '.pi / 4' to get the value of correct type and avoid casting.") | ||
public let M_PI_4 = Double.pi / 4 | ||
|
||
@available(swift, deprecated: 3.0, message: "Please use '2.squareRoot()'.") | ||
public let M_SQRT2 = 2.squareRoot() | ||
|
||
@available(swift, deprecated: 3.0, message: "Please use '0.5.squareRoot()'.") | ||
public let M_SQRT1_2 = 0.5.squareRoot() | ||
|
||
// Constants defined by <float.h> | ||
@available(swift, deprecated: 3.0, message: "Please use 'T.radix' to get the radix of a FloatingPoint type 'T'.") | ||
public let FLT_RADIX = Double.radix | ||
|
||
%for type, prefix in [('Float', 'FLT'), ('Double', 'DBL')]: | ||
// Where does the 1 come from? C counts the usually-implicit leading | ||
// significand bit, but Swift does not. Neither is really right or wrong. | ||
@available(swift, deprecated: 3.0, message: "Please use '${type}.significandBitCount + 1'.") | ||
public let ${prefix}_MANT_DIG = ${type}.significandBitCount + 1 | ||
|
||
// Where does the 1 come from? C models floating-point numbers as having a | ||
// significand in [0.5, 1), but Swift (following IEEE 754) considers the | ||
// significand to be in [1, 2). This rationale applies to ${prefix}_MIN_EXP | ||
// as well. | ||
@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude.exponent + 1'.") | ||
public let ${prefix}_MAX_EXP = ${type}.greatestFiniteMagnitude.exponent + 1 | ||
|
||
@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude.exponent + 1'.") | ||
public let ${prefix}_MIN_EXP = ${type}.leastNormalMagnitude.exponent + 1 | ||
|
||
@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude' or '.greatestFiniteMagnitude'.") | ||
public let ${prefix}_MAX = ${type}.greatestFiniteMagnitude | ||
|
||
@available(swift, deprecated: 3.0, message: "Please use '${type}.ulpOfOne' or '.ulpOfOne'.") | ||
public let ${prefix}_EPSILON = ${type}.ulpOfOne | ||
|
||
@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude' or '.leastNormalMagnitude'.") | ||
public let ${prefix}_MIN = ${type}.leastNormalMagnitude | ||
|
||
@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNonzeroMagnitude' or '.leastNonzeroMagnitude'.") | ||
public let ${prefix}_TRUE_MIN = ${type}.leastNonzeroMagnitude | ||
|
||
%end | ||
|
||
public let MAP_FAILED: UnsafeMutableRawPointer! = UnsafeMutableRawPointer(bitPattern: -1) | ||
|
||
// wasi-libc's error.h uses a macro that Swift can't import. | ||
@available(*, deprecated, message: "Please use 'POSIXErrorCode.EINTR'.") | ||
public let EINTR: Int32 = 27 | ||
@available(*, deprecated, message: "Please use 'POSIXErrorCode.EINVAL'.") | ||
public let EINVAL: Int32 = 28 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 SwiftWASILibc [system] { | ||
// C standard library | ||
module C { | ||
module ctype { | ||
header "${LIBC_INCLUDE_PATH}/ctype.h" | ||
export * | ||
} | ||
module errno { | ||
header "${LIBC_INCLUDE_PATH}/errno.h" | ||
export * | ||
} | ||
|
||
module fenv { | ||
header "${LIBC_INCLUDE_PATH}/fenv.h" | ||
export * | ||
} | ||
|
||
// note: supplied by compiler | ||
// module float { | ||
// header "${LIBC_INCLUDE_PATH}/float.h" | ||
// export * | ||
// } | ||
|
||
module inttypes { | ||
header "${LIBC_INCLUDE_PATH}/inttypes.h" | ||
export * | ||
} | ||
|
||
// note: potentially supplied by compiler | ||
// module iso646 { | ||
// header "${LIBC_INCLUDE_PATH}/iso646.h" | ||
// export * | ||
// } | ||
// module limits { | ||
// header "${LIBC_INCLUDE_PATH}/limits.h" | ||
// export * | ||
// } | ||
|
||
module locale { | ||
header "${LIBC_INCLUDE_PATH}/locale.h" | ||
export * | ||
} | ||
module math { | ||
header "${LIBC_INCLUDE_PATH}/math.h" | ||
export * | ||
} | ||
module signal { | ||
header "${LIBC_INCLUDE_PATH}/signal.h" | ||
export * | ||
} | ||
|
||
// note: supplied by the compiler | ||
// module stdarg { | ||
// header "${LIBC_INCLUDE_PATH}/stdarg.h" | ||
// export * | ||
// } | ||
// module stdbool { | ||
// header "${LIBC_INCLUDE_PATH}/stdbool.h" | ||
// export * | ||
// } | ||
// module stddef { | ||
// header "${LIBC_INCLUDE_PATH}/stddef.h" | ||
// export * | ||
// } | ||
// module stdint { | ||
// header "${LIBC_INCLUDE_PATH}/stdint.h" | ||
// export * | ||
// } | ||
|
||
module stdio { | ||
header "${LIBC_INCLUDE_PATH}/stdio.h" | ||
export * | ||
} | ||
module stdlib { | ||
header "${LIBC_INCLUDE_PATH}/stdlib.h" | ||
export * | ||
export stddef | ||
} | ||
module string { | ||
header "${LIBC_INCLUDE_PATH}/string.h" | ||
export * | ||
} | ||
|
||
// note: supplied by the compiler | ||
// explicit module tgmath { | ||
// header "${LIBC_INCLUDE_PATH}/tgmath.h" | ||
// export * | ||
// } | ||
|
||
module time { | ||
header "${LIBC_INCLUDE_PATH}/time.h" | ||
export * | ||
} | ||
} | ||
|
||
// POSIX | ||
module POSIX { | ||
module arpa { | ||
module inet { | ||
header "${LIBC_INCLUDE_PATH}/arpa/inet.h" | ||
export * | ||
} | ||
export * | ||
} | ||
module dirent { | ||
header "${LIBC_INCLUDE_PATH}/dirent.h" | ||
export * | ||
} | ||
module fcntl { | ||
header "${LIBC_INCLUDE_PATH}/fcntl.h" | ||
export * | ||
} | ||
module fnmatch { | ||
header "${LIBC_INCLUDE_PATH}/fnmatch.h" | ||
export * | ||
} | ||
module ioctl { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/ioctl.h" | ||
export * | ||
} | ||
module libgen { | ||
header "${LIBC_INCLUDE_PATH}/libgen.h" | ||
export * | ||
} | ||
module netinet { | ||
module in { | ||
header "${LIBC_INCLUDE_PATH}/netinet/in.h" | ||
export * | ||
|
||
exclude header "${LIBC_INCLUDE_PATH}/netinet6/in6.h" | ||
} | ||
module tcp { | ||
header "${LIBC_INCLUDE_PATH}/netinet/tcp.h" | ||
export * | ||
} | ||
} | ||
module poll { | ||
header "${LIBC_INCLUDE_PATH}/poll.h" | ||
export * | ||
} | ||
module regex { | ||
header "${LIBC_INCLUDE_PATH}/regex.h" | ||
export * | ||
} | ||
module sched { | ||
header "${LIBC_INCLUDE_PATH}/sched.h" | ||
export * | ||
} | ||
module semaphore { | ||
header "${LIBC_INCLUDE_PATH}/semaphore.h" | ||
export * | ||
} | ||
module strings { | ||
header "${LIBC_INCLUDE_PATH}/strings.h" | ||
export * | ||
} | ||
|
||
module sys { | ||
export * | ||
|
||
module mman { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/mman.h" | ||
export * | ||
} | ||
module resource { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/resource.h" | ||
export * | ||
} | ||
module select { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/select.h" | ||
export * | ||
} | ||
module socket { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/socket.h" | ||
export * | ||
} | ||
module stat { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/stat.h" | ||
export * | ||
} | ||
module time { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/time.h" | ||
export * | ||
} | ||
module times { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/times.h" | ||
export * | ||
} | ||
module types { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/types.h" | ||
export * | ||
} | ||
module uio { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/uio.h" | ||
export * | ||
} | ||
module un { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/un.h" | ||
export * | ||
} | ||
module utsname { | ||
header "${LIBC_ARCH_INCLUDE_PATH}/sys/utsname.h" | ||
export * | ||
} | ||
} | ||
module unistd { | ||
header "${LIBC_INCLUDE_PATH}/unistd.h" | ||
export * | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kateinoigakukun not quite sure why we're copying it to both
lib/swift
andlib/swift_static
here, could you clarify please?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I remember, it's just a workaround because some components only include /lib/swift even passing -static-stdlib. But not cure if it's still necessary. Sorry.