25 Commits

Author SHA1 Message Date
Charles Hu
dc49e156cd
Hide Windows magic environment values from ProcessInfo.environment (#853)
Windows GetEnvironmentStringsW API can return magic environment variables set by the cmd shell that starts with "=". We should hide these values to avoid surprising behavior.

resolves: https://github.com/apple/swift-foundation/issues/847
2024-08-15 10:47:07 -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
Alex Lorenz
ad6ca71b4e
[android] fix the LP32 armv7/i686 android build (#846)
* [android] fix the LP32 armv7/i686 android build

* Update Sources/FoundationEssentials/Android+Extensions.swift

Co-authored-by: Jeremy Schonfeld <1004103+jmschonfeld@users.noreply.github.com>

* drop the android Lp32 specific operator &

---------

Co-authored-by: Jeremy Schonfeld <1004103+jmschonfeld@users.noreply.github.com>
2024-08-14 10:56:25 -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
4440638a17
Use platform shims for clock ids to support wasi-libc (#781) 2024-08-09 01:34:20 +09:00
Yuta Saito
c82d1673eb
Add WASI platform conditions for libc imports and word size (#776)
* Add `import WASILibc` statements to libc import chains

* Declare wasm32 arch as 32-bit environment

* Switch to _pointerBitWidth for architecture checks

This change switches the architecture checks in Data.swift to use the
_pointerBitWidth instead of the arch() checks for consistency with newer
platforms.
2024-08-02 09:55:56 -07:00
Yuta Saito
a8f12255db
Fix operatingSystemVersion on WASI (#782)
The `operatingSystemVersion` property type is a tuple but the it was
returning an `OperatingSystemVersion` instance on unknown platforms.
2024-08-01 09:15:23 -07:00
Jeremy Schonfeld
d3610e9523
[Windows] Fix Int32(bitPattern:) call failure (#708)
* Fix Int32(bitPattern:) call failure

* Avoid trap for identifiers within Int32.max ..< UInt32.max
2024-06-27 15:26:02 -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
Jeremy Schonfeld
543a9e4cd7
Use URL in JSON/Data APIs (#588)
* Use URL in JSON/Data APIs

* path -> URL

* Use fileSystemPath instead of path(percentEncoded:)

* Correct resource loading on linux
2024-05-08 12:58:00 -07:00
Saleem Abdulrasool
4e2aa38ff7
FoundationEssentials: properly handle env duplication (#583)
The terminator is a valid string and will give a valid pointer. However,
the string itself is empty (`\0\0`) and indicates the termination of the
process environment block. Handle this properly to avoid a buffer
overrun.
2024-05-03 11:48:27 -07:00
Saleem Abdulrasool
e5a435f422
FoundationEssentials: repair ProcessInfo on Windows (#578)
Use a dynamically allocated buffer to avoid truncation/underruns that
are not possible to recover from. Fix some parameter passing to match
the type signature of the C function. Fix some syntactic issues in the
code.
2024-05-02 10:49:20 -07:00
Saleem Abdulrasool
3e4077fcaf
FoundationEssentials: clean up some Windows warnings (#571)
Use the Windows POSIX API spellings to avoid the warnings. Take the
opportunity to change the environment handling to ensure that we are
able to handle weird unicode environment variables which may not be
rendered properly in the ASCII environment representation. Adjust some
types to better match the implementation on Windows which is a minor uop
to avoid unnecessary `trunc` and `sext` or `zext`.
2024-05-01 13:40:29 -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
Charles Hu
c4e1a33848
Change ProcessInfo.procssName to be lazily loaded (#569) 2024-04-29 10:19:46 -07:00
Charles Hu
7c8859bcb9
Add bounds check for CommandLine.arguments since it could be empty (#481) 2024-03-14 13:03:03 -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
Charles Hu
c2e623badc
ProcessInfo.environment should create String values outside of lock (#461) 2024-03-06 09:02:50 -08:00
Charles Hu
014e26c0c3
Add lock when retrieving ProcessInfo.environment (#420)
Resolves: rdar://122515578

Co-authored-by: Charles Hu <charle@hu.codes>
2024-02-14 17:20:06 -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
c67a494187
Removed import XPC since it's not needed (#405) 2024-02-07 17:10:23 -08:00
Charles Hu
b27cf2e8b6
Addressed the Sendable warnings in ProcessInfo (#383) 2024-01-17 17:28:28 -08:00
Charles Hu
4bc61cf900
Rewrite ProcessInfo in Swift (#353) 2024-01-10 16:08:03 -08:00