17 Commits

Author SHA1 Message Date
Yuta Saito
99c5c0c62a
[wasm] Stop requiring TZDIR and TZDEFAULT on WASI (#1248)
Those constants are not used on WASI in Swift side, so there's no
need to require them in the C headers.
2025-04-14 13:53:58 -07:00
3405691582
03fe46f43b
OpenBSD support. (#1126)
* Advise porter on where to make necessary change.

In #1075 the change was already made for BSD (thank you!); my working
edit had this guidance to ensure future porters get an error directing
them where to make a necessary change.

Otherwise, the FoundationEssentials build will fail and complain these
variables are not defined but not have guidance as to where they are
sourced from.

* OpenBSD does not support extended attributes.

* OpenBSD does not have secure_getenv.

* Remaining OpenBSD changes.

* OpenBSD also needs `pthread_mutex_t?`.

* Originally I followed Darwin's check with `d_namlen`, but this should
  work too.

* Correct statvfs type casts for OpenBSD.

On OpenBSD, fsblkcnt_t -- the type of f_blocks -- is a UInt64; therefore,
so must `blockSize` be.

Ultimately, both sides of the `totalSizeBytes` multiplication should
probably be type cast for all platforms, but that's a more significant
functional change for another time.

* Default activeProcessorCount to 1, not 0.

After a rather tedious debugging session trying to figure out why
swiftpm-bootstrap appeared to be deadlocked, this turned out to be the
culprit. Perhaps this should be #error instead, but for now, set a
sensible default.

* Use sysconf for activeProcessorCount.

This is what Dispatch does in some places for OpenBSD anyway, so do
likewise here.
2025-04-07 10:46:18 -07:00
Yuta Saito
320c5837e2
[wasm] Add O_NONBLOCK shim (#1235)
05975959e67f57063445baabb652262dd764cc72 added a use of `O_NONBLOCK` but
the constant cannot be imported from wasi-libc through ClangImporter
directly, so we need to add a shim for it as well as other constants.
2025-03-31 08:54:37 -07:00
Tina Liu
b673ae7f95
Swift-Foundation support for Unicode 16 (#1154)
Update bitmaps for Unicode 16. The tables are autogenerated.

Resolves 143910395
2025-02-03 15:52:56 -08:00
michael-yuji
5ed6c72484
[FreeBSD] Fix FreeBSD build/support (#1075)
* FreeBSD platform specific fixes

- Use "/usr/share/zoneinfo"
- Use platform specific types and values
- Implement extattr ops for FreeBSD
- Use copy_file_range(2) for file cloning

* Revise patch to ProcessInfo to reduce potential impact to other platforms

* Fix macOS build

* typo

* take suggested change
2025-01-10 14:20:27 -08:00
Yuta Saito
c0532f8c99
Follow-up fixes to make it work with wasi-libc (#1095)
* Gate `fchown` and `fchmod` calls behind `os(WASI)`

They are not available on WASI, so we gate them behind `os(WASI)`.

* Add missing constant shims for wasi-libc

* Use `futimens` instead of legacy `futimes`

wasi-libc does not provide `futimes` as it is a legacy function.
574b88da48/libc-top-half/musl/include/sys/time.h (L34)
2024-12-16 11:19:39 -08:00
Charles Hu
7bb410015a
OpenStep plist decoding via PropertyListDecoder is not available on Windows and Linux (#1002)
resolves: rdar://136243566

Co-authored-by: Kevin Perry <kperry@apple.com>
2024-10-23 14:24:27 -07:00
Jeremy Schonfeld
889c38fdb9
Fix TimeZone.current lookup on Windows (#975) 2024-10-11 10:49:46 -07:00
Yuta Saito
586c460cbc
Remove the #include <setjmp.h> from _CStdlib.h (#873)
It seems like we don't use neither setjmp nor longjmp in the Foundation
codebase, so we can safely remove this include.
The main motivation for this change is to fix the build with the latest
wasi-libc version. Recent wasi-libc versions started to provide
`setjmp.h` header but it raises compilation errors unless Exception
Handling feature (still under standardization process) is enabled.

See https://github.com/WebAssembly/wasi-libc/blob/wasi-sdk-22/libc-top-half/musl/include/setjmp.h
2024-08-19 13:11:55 -07:00
Yuta Saito
bc47ca221d
Port directory enumeration related code to WASI (#836)
* Port directory enumeration related code to WASI

For now wasi-libc does not include fts(3) implementation, so mark
features depending on it as unsupported on WASI. Once wasi-libc includes
fts or we decide to implement and maintain our own fts-like API, we can
remove these `#if os(WASI)` guards.

wasi-libc issue tracking fts support:
https://github.com/WebAssembly/wasi-libc/issues/520

Also, wasi-libc defines some constants in a way that ClangImporter can't
understand, so we need to grab them manually through _FoundationCShims in
function call form.

* Delegate error throwing decisions to the delegate
2024-08-12 19:52:15 -07:00
Yuta Saito
4440638a17
Use platform shims for clock ids to support wasi-libc (#781) 2024-08-09 01:34:20 +09:00
Alex Lorenz
8bf4cb0b9b
do not import stdatomic as it doesn't work with c++ interop on windows (#830)
* [windows] do not import stdatomic on windows as it doesn't work with c++ interop enabled

Works around https://github.com/swiftlang/swift/issues/75720

* remove the stdatomic include alltogether
2024-08-06 16:51:27 -07:00
Yuta Saito
c86692f7e7
Enable wasi-libc emulation features (#777)
* Enable wasi-libc emulation features

Those features require explicit macro definitions to be enabled, so add
them to the package definition. Only affects WASI builds.

* Prefer `TARGET_OS_WASI` over `__wasi__`

And explain why we need definition checks for `signal.h` and `sys/mman.h`
2024-08-06 02:20:54 +09:00
Yuta Saito
8f34f38f30
Add explicit void type parameter to C functions without parameters (#775)
C functions with `()` as parameter list can take any number of
parameters. But WebAssembly requires static signature information for
every function call, so we need to explicitly specify `(void)` to
indicate that the function takes no parameters.
2024-08-01 09:02:11 -07:00
Jeremy Schonfeld
acae3d26b6
Implement isoLatin1 and macOSRoman encoding (#743)
* Implement isoLatin1 and macOSRoman encoding

* Limit new behavior to non-framework build
2024-07-25 08:52:30 -07:00
Saleem Abdulrasool
93a5ecef26
FoundationCShims: introduce TARGET_OS_ANDROID (#702)
Add the target conditional to identify android which is required to
enable the package to build for Android.
2024-06-25 17:03:49 -07:00
Charles Hu
60506f3af4
Renamed _CShims to _FoundationCShims (#656)
Rationale: _CShims will effectivly become semi-public in the toolchain. We add the Foundation prefix to make it less generic.
2024-06-21 16:18:38 -07:00