Commit Graph

12 Commits

Author SHA1 Message Date
Saleem Abdulrasool
ca39bb5b10 stubs: avoid reaching up-tree, prefer inclusion options
This removes the explicit tree structure reference in the stubs to
locate the shims.  Instead, it expects that the `SwiftShims` directory
will be added to the header search path.
2022-01-14 09:34:56 -08:00
Kuba (Brecka) Mracek
3d08df9f3c Avoid including unistd.h and replace write(STDERR) with fputs(stderr) (#40177) 2021-11-15 18:41:49 -08:00
Zoe Carver
7eff49c1b6 [cxx-interop] [nfc] Remove swift namespace from SwiftShims in C++ mode. (#32715)
Most SwiftShims were put in the swift namespace in C++ mode which broke certain things when importing them in a swift file in C++ mode. This was OK when they were only imported as part of the swift runtime but, now they are used in C++ mode both in the swift runtime and when C++ interop is enabled.

This broke when C++ interop was enabled because the `Swift` module contains references to symbols in the SwiftShims headers which are built without C++ interop enabled (no "swift" namespace). But, when C++ interop is enabled, the SwiftShims headers would put everything in the swift namespace meaning the symbols couldn't be found in the global namespace. Then, the compiler would error when trying to deserialize the Swift module.
2020-07-08 08:43:26 -07:00
Max Desiatov
44a6475566 [WebAssembly] enable shims and stubs for WASI (#29505)
* [WebAssembly] enable shims and stubs for WASI

* Implement _swift_stdlib_getUnsafeArgvArgc for WASI

* Make include unconditional, add JIRA links
2020-01-28 18:29:52 -08:00
David Zarzycki
1473e20c15 [Runtime] NFC: Fix -Wgnu-statement-expression warning 2019-08-19 08:10:49 +01:00
Cory Benfield
c2b6c8aa16 Avoid uninitialized "random" bytes on Windows.
__swift_size_t on Windows is a size_t, which makes it potentially a
64-bit integer. ULONG, however, is always a 32-bit integer, and so this
cast risks shrinking the apparent size of the cbBuffer argument to
BCryptGenRandom. The effect of that will be to underfill the buffer,
leaving it full of uninitialized memory that we would treat as random.

The actual risk from this in the current implementation is basically
zero, as user code can only ever invoke this with an argument size of 8.
There's no good reason to leave this sharp edge on the API though.
2019-07-23 17:50:34 +01:00
Saleem Abdulrasool
68ec9d4a0f stdlib: correct case for the bcrypt import library
On Windows the filesystem is not case sensitive and this will link just fine.
However, the Windows SDK provides the import library with the lowercase name.
Adjust the name so that the link actually succeeds on case-sensitive file
systems (like on Linux).  This fixes the Windows cross-compile.
2018-10-05 11:21:20 -07:00
Saleem Abdulrasool
6729aacaef stdlib: include "Windows.h" before "Bcrypt.h"
The system header depends on Windows.h but does not include it itself.  This
results in base Windows types (e.g. ULONG) to be undefined.  Include the header
to include the needed typedefs.
2018-10-05 11:20:23 -07:00
Mike Ash
1e9741a3f8 [Stdlib] Fix Linux detection for malloc_size. Silence const cast warnings. Fix Linux implementation in Random.cpp to actually compile. 2018-10-03 14:31:39 -04:00
Mike Ash
5391abbf4b [Stdlib] Clean up includes in LibcShims and Random. 2018-10-03 11:16:37 -04:00
Mike Ash
c4d5db404b [Stdlib] Change _swift_stdlib_random SPI to swift_stdlib_random API. 2018-10-03 09:55:34 -04:00
Mike Ash
6926fbd363 [Stdlib] Pull _swift_stdlib_random into a separate file. 2018-10-03 09:55:34 -04:00