25 Commits

Author SHA1 Message Date
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
Johannes Weiss
601e847faa
always @preconcurrency import Glibc (#1175)
Co-authored-by: Johannes Weiss <johannes@jweiss.io>
2025-03-04 09:25:51 -08:00
Alex Lorenz
ab00100419
[android] fix the android build (#999)
Platform.swift regressed after 71eefee7fca08ecbeacc89098b74ab80319baa6b
2024-10-29 13:00:11 -07:00
Jeremy Schonfeld
71eefee7fc
Fetching user/group info causes race conditions (#994)
* Avoid racy stdlib functions for fetching user/group info

* Refactor naming

* Fix build failure
2024-10-23 09:18:15 -07:00
finagolfin
53ffff0600
[Android] Enable more code and tests (#871)
* [Android] Enable more code and tests

while disabling setting extended file attributes and a test creating a hard link,
features not normally allowed on Android.

* Remove incorrect WASI check
2024-09-17 08:40:40 -07:00
finagolfin
c15a5e1f5c
[Android] Use the Bionic module in more places (#842)
Also, use `canImport()` wherever importing APIs, reserving `os(Android)` for
platform differences.
2024-08-15 14:34:15 -07:00
Evan Wilde
aecc1b158c
[main] Get Swift-Foundation building against MUSL for Swift Static SDK (#848)
* Get FoundationEssentials building

Adding the missing musl imports to get FoundationEssentials building for
the Swift static SDKs again.

Also providing an option to disable building the macros. The macros
aren't necessary for building the library and will not be run as part of
the static SDK. No need to bloat the SDK or build times further. For
Swift 6, the macros should be provided by the toolchain since the
toolchain and SDK are current revlocked due to swiftmodules.

* Get FoundationInternationalization building

Adding the missing Musl imports to get FoundationInternationalization
building for the static SDK.
2024-08-14 13:34:15 -07:00
Charles Hu
0c124a94ed
Fix ProcessInfo.processName for Windows (#839)
Instead of relying on hard coding PATH_SEPARATOR, use existing .lastPathComponent that already works on Windows
2024-08-09 12:48:41 -07:00
Yuta Saito
0b3974d351
Guard out user/group related code on WASI (#783)
* Guard out user/group related code on WASI

This change guards out the user/group related code on WASI, as WASI does
not have the concept of users or groups.

* Throw explicit unsupported error if trying to set user or group on WASI

Instead of implicitly ignoring user-given values, we should throw
exception to make it clear that those values cannot be set on WASI.
2024-08-01 09:23:13 -07:00
Saleem Abdulrasool
a7692238a8
FoundationEssentials: initial pass to add Android support (#704)
This adds the necessary guards and includes for the Android modules.
While the module does not compile currently due to nullability
differences (and in some cases missing declarations), this at least
brings the module to a point where we can start working on the errors
and differences to create a maintainable codebase for Android.
2024-06-26 16:00:37 -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
Tony Parker
caa08cf226
Enable complete concurrency checking in Foundation 2024-06-04 10:41:59 -07:00
Saleem Abdulrasool
47d12f9d4a
(128010594) FoundationEssentials: protect against a failed query on Windows (#605)
In the case that the query fails due to a reason other than an
insufficient buffer, the returned value is 0. However, a 0 sized
allocation can trigger an issue, so ensure that we always have a
non-zero buffer size before we attempt an allocation.
2024-05-13 13:04:36 -07:00
Saleem Abdulrasool
5a04c75885
FoundationEssentials: repair the hostname query logic (#577)
Adjust the hostname querying to properly respond to the result.
2024-05-01 14:22:57 -07:00
Jeremy Schonfeld
ad9d6d4d7a
(127135444) Add ProcessInfo implementations for other platforms (#559)
* Add ProcessInfo implementations for other platforms

* Update Platform.getHostname for Windows

Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>

* Add alternate platform implementations of ProcessInfo tests

* Clean up windows switch statement

* Use nonzeroBitCount on Windows

* Add Linux implementation for retrieving active processor count

* Apply Windows additions from code review

Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>

* Apply additional Windows suggestions

* TotalMemoryKB -> totalMemoryKB

* Fix conditional os directive

* Update process name

---------

Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
2024-04-29 15:35:18 -07:00
Saleem Abdulrasool
32b136e9b2
FoundationEssentials: improve Windows coverage for Platform.swift (#546)
Adjust the codepaths to improve Windows support in the file. This is
simply blindly trying to match semantics to reduce the errors reported
during building `FoundationEssentials`.
2024-04-15 11:42:46 -07:00
Jeremy Schonfeld
544ec6c816
(123714904) Ensure stable home directory for processes calling seteuid
* (123714904) Ensure stable home directory for processes calling seteuid

* (123714904) Add comments
2024-03-21 13:16:19 -07:00
Jeremy Schonfeld
e5211f2926
(122981400) Standardize on using internal import 2024-03-06 13:42:02 -08:00
Charles Hu
d5ac168636
ProcessInfo Bincompact: always use full executable path for arg0 (#460) 2024-03-06 09:03:24 -08:00
Jeremy Schonfeld
33856a556d
(120741818) Port FileManager to swift-foundation
* (120741818) Port FileManager to swift-foundation

* (120741818) Fix linux test failures

* (120741818) Fix build failures
2024-02-09 15:03:43 -08:00
Charles Hu
4bc61cf900
Rewrite ProcessInfo in Swift (#353) 2024-01-10 16:08:03 -08:00
Charles Hu
7272a47c0b
Refactoring some import conditions (#298) 2023-10-25 15:11:37 -07:00
Charles Hu
14eb5a1f60
Addressed compiler warnings and updated the incorrect license headers (#190) 2023-06-28 11:00:02 -07:00
Tony Parker
0106af2723 rdar://105186248 (Fix more warnings in Swift) 2023-03-28 19:35:50 -07:00
Charles Hu
363e0c9a89 FoundationPreview: Initial release 2023-02-07 18:36:16 -08:00