Commit Graph

1231 Commits

Author SHA1 Message Date
3405691582
5847726f51 Preliminary support for OpenBSD in the stdlib.
These should hopefully all be uncontroversial, minimal changes to deal
with progressing the build to completion on OpenBSD or addressing minor
portability issues. This is not the full set of changes to get a
successful build; other portability issues will be addressed in future
commits.

Most of this is just adding the relevant clauses to the ifdefs, but of
note in this commit:

* StdlibUnittest.swift: the default conditional in _getOSVersion assumes
  an Apple platform, therefore the explicit conditional and the relevant
  enums need filling out. The default conditional should be #error, but
  we'll fix this in a different commit.

* tgmath.swift.gyb: inexplicably, OpenBSD is missing just lgammal_r.
  Tests are updated correspondingly.

* ThreadLocalStorage.h: we use the pthread implementation, so it
  seems we should typedef __swift_thread_key_t as pthread_key_t.
  However, that's also a tweak for another commit.
2020-03-01 12:50:06 -05:00
Ravi Kandhadai
7c9ddca1d4 [os log][stdlib/private] Enable precision and alignment values to be dynamic.
The format specifier constructed by the os log implementation uses '*' for
width and precision, and passes those values to the os_log ABIs as additional
arguments of the message. (The precision/alignment arguments have the
type: count).

Update tests to handle this change.
2020-02-25 15:11:48 -08:00
Nate Cook
c6183ee71b Add RangeSet and discontiguous collection operations (#28161)
This adds the RangeSet and DiscontiguousSlice types, as well as collection
operations for working with discontiguous ranges of elements. This also adds
a COWLoggingArray type to the test suite to verify that mutable collection
algorithms don't perform unexpected copy-on-write operations when mutating
slices mid-operation.
2020-02-22 15:33:03 -06:00
Daniel Rodríguez Troitiño
5e05ce5ff9 [android] Enable SwiftPrivateThreadExtras to build in Android.
Disabled by mistake in #29530.
2020-02-13 14:15:49 -08:00
Dmitri Gribenko
3566e6ed7a Merge pull request #29530 from swiftwasm/swiftwasm-ifdefs
[WebAssembly] Add ifdefs for the WASI target
2020-02-13 17:40:45 +01:00
Ravi Kandhadai
3c7f6d88e2 [stdlib/private][OSLog] Add basic support for interpolating floating-point
types without formatting options, add an auto-inferred privacy mode and
make it the default privacy mode, add support for aligning string
arguments.
2020-02-12 18:46:50 -08:00
Max Desiatov
67297904ac [WebAssembly] Add ifdefs for the WASI target 2020-02-08 07:37:10 +00:00
Ravi Kandhadai
4f2a55bdd4 [stdlib/private][OSLog] Support expressive, fprintf-style formatting
options for integers passed to os log string interpolation.
2020-02-07 17:36:06 -08:00
Ravi Kandhadai
e631c66e0d [stdlib/private][os log] Annotate tiny helper functions in the new
os log overlay @_transparent so that they will be inlined in their
callers even annotated as @_optimize(none).

Make the OSLogPrototypeCompileTest.swift test suite check only the
output of the OSLogOptimization pass instead of the output of the
Onone pipeline. This will make the tes more resilient to adding
mandatory optimizations later in the pass pipeline. Also, remove
a duplicate test from the OSLogPrototypeExecTest suite.
2020-02-04 11:03:38 -08:00
Chris Amanse
e13ea48dcd Private method should be for non-Windows only 2020-01-29 14:14:12 -08:00
Chris Amanse
ffa6bf4729 Fix memory leaks in ThreadBarriers.swift (#12212)
* Fix memory leaks in ThreadBarriers.swift

* Fatal error on pthread cond/mutex destroy failure

* Rename pthread to thread

* Fix pthread init function calls

* Fix guard statement
2020-01-29 08:21:52 -08:00
David Zarzycki
8732b15597 [Testing] Fix unused/read-only variable warnings 2020-01-27 06:12:02 -05:00
Ravi Kandhadai
d154f45f01 [stdlib-private][os log] Add new log methods for each specific logging level.
Also, add aliases for the logging levels for source compatibility with swift-server
side logging. Create a new initializer of Logger that can directly accept an
existing os log object of type `OSLog`. This aids in porting uses of existing
os_log API to the new API.
2019-12-11 11:49:02 -08:00
Ravi Kandhadai
f705720f1e [os log][stdlib/private] Add extensions for logging NSObjects.
The extensions for supporting NSObjects are in the file:
OSLogNSObjectType.swift. This creates a new dependency for the
OSLogPrototype overlay on the module: ObjectiveC. However,
ObjectiveC is already a dependency for the os module.

This patch includes tests for the NSObject extensions.
In addition, this patch contains a few other minor changes.
1. It makes the `osLog` function public (so that it can be
used by clients directly). 2. It fixes a lifetime-related
bug in the osLog function implementation. 3. It improves
the OSLogPrototypeExecTest suite by refactoring a few
helper functions.
2019-12-09 20:03:50 -08:00
Ravi Kandhadai
05be088431 [stdlib/private][oslog] Make tiny helper functions of struct OSLogMessage constant_evaluable
instead of transparent.
2019-12-03 11:14:49 -08:00
Ravi Kandhadai
b0de132aad [stdlib-private][oslog] Remove OSLogArguments.serializeAt method
and instead directly access the array stored in OSLogArguments.
This will make constant folding of the array possible when its
contents are inferred at compile time by the OSLogOptimization pass.
2019-11-07 17:11:07 -08:00
Saleem Abdulrasool
5d683d9670 StdlibUnittest: port to android x86, x86_64
Account for the x86 and x86_64 architectures when defining
`RTLD_DEFAULT`.
2019-11-03 20:52:11 -08:00
Ravi Kandhadai
861c0aaca9 [OSLogOptimization][stdlib/private] Make string interpolation methods
of OSLogMessage constant evaluable and remove @_transparent annotation
from the methods. Also, improve diagnostics in the OSLogOptimization
pass as now it rely on seeing the appendInterpolation/Literal calls.
2019-10-29 19:35:37 -07:00
Mike Ash
55f9d2afca Merge pull request #27863 from mikeash/will-throw-callback
[Runtime] Add a function pointer for intercepting swift_willThrow calls.
2019-10-29 16:50:36 -04:00
Saleem Abdulrasool
a41b4a8f14 SwiftReflectionTest: enable builds on non-Apple targets
Ensure that the swift-reflection-test binary is built for Windows by
default.  This is preventing tests from executing on Windows.  There are
dependencies which were already specified for Linux even, the tool just
was disabled due to an invalid check.
2019-10-29 08:37:49 -07:00
Mike Ash
b8f5e841e2 [Runtime] Add a function pointer for intercepting swift_willThrow calls.
rdar://problem/53400364
2019-10-24 14:06:14 -04:00
Ravi Kandhadai
7dabec4db2 [oslog][stdlib-private] Modify the implementation of the new OSLog
library so that the type: OSLogByteBufferBuilder is no longer needed.
This would make backward deployment of code using the new log APIs
easier, besides other minor benefits.
2019-09-25 17:47:27 -07:00
Ravi Kandhadai
61fd4b1431 [OSLog][Test] Update the new oslog overlay implementation to use
@_semantics("constant_evaluable") annotation to denote constant
evaluable functions.

Add a test suite that uses the sil-opt pass ConstantEvaluableSubsetChecker.cpp
to check the constant evaluability of function in the OSLog
overlay.
2019-09-18 10:44:48 -07:00
Ravi Kandhadai
03c6365671 [oslog][stdlib-private] Add support for interpolating strings
in the new os_log APIs.
2019-08-30 17:04:39 -07:00
ravikandhadai
dcd0893efe Merge pull request #26815 from ravikandhadai/oslog-integer-types
[oslog][stdlib-private] Refactor and generalize interpolation of Int type in the new os_log APIs so as to extend to other integer types.
2019-08-30 16:22:18 -07:00
Michael Ilseman
d30ec5ba79 Merge pull request #26884 from milseman/cache_alignment
[test] Disable misaligned indices test prior to 5.1
2019-08-28 14:23:11 -07:00
Michael Ilseman
774788ac18 [test] Disable misaligned indices test prior to 5.1
Misaligned indices were fixed in 5.1, but we should disable the test
when testing back deployment.

Adds a shared helper to StdlibUnittest for the run time check.
2019-08-27 15:13:38 -07:00
Karoy Lorentey
d5ea371eed [test] Add some high-level tests for AutoreleasingUnsafeMutablePointer 2019-08-26 20:09:53 -07:00
Ravi Kandhadai
8641dc7310 [oslog][stdlib-private] Refactor and generalize implementation of
interpolation of Int types in the new os_log APIs so that it is
easier to extend to other integer types. Based on this, add support
for interpolating Int32 types.
2019-08-24 19:08:55 -07:00
swift-ci
e6ae7867bf Merge pull request #26441 from alexshap/linux_compile_flags 2019-08-01 18:46:57 -07:00
swift-ci
d5d4ac672b Merge pull request #26338 from xiaobai/debride-option 2019-08-01 18:42:33 -07:00
Alexander Shaposhnikov
6febe07dec Introduce SWIFT_COMPILE_FLAGS_LINUX 2019-07-31 16:28:04 -07:00
Steve (Numerics) Canon
0fb8510da3 Replace @_fixed_layout with @frozen in private/OSLog
This one slipped through when the main search and replace pass happened,
becausee it's not in public.
2019-07-29 13:48:35 -04:00
Alex Langford
a16c71cc86 [CMake] Remove TARGET_LIBRARY option from add_swift_target_library
If you're calling add_swift_target_library, you already know it's a
target library.
2019-07-24 14:55:08 -07:00
Ravi Kandhadai
7a3c6d58f5 [stdlib][oslog] Create an SPI _globalStringTablePointer that exposes
the builtin.globalStringTablePointer to the new OSLog overlay.

Modify the new OSLog implementation to use this SPI instead of
`withCString` to pass the (compiler-generated) format string to
the C os_log_impl ABI.

Move the OSLogOptimization pass before constant propagation in
the pass pipeline so that the SPI and the builtin it uses can be
folded to a string_literal instruction.

Update OSLogTests to work with the changes in the implementation.
2019-07-03 17:25:37 -07:00
Slava Pestov
7cc4be421f Fix invalid method overrides in StdlibCollectionUnittest 2019-07-02 15:43:02 -04:00
Puyan Lotfi
6691fda8ec Appending SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS to SWIFT_COMPILE_FLAGS.
There are situations where you want to build against a libc that is out
of tree or that is not the system libc (Or for cross build scenarios).
This is a change for passing the -sdk and include paths for things like
this.
2019-07-01 09:43:47 -07:00
Saleem Abdulrasool
2a710f4bba StdlibUnittest: disable FP80 path on android
android x64 does not support FP80
2019-06-23 21:05:46 -07:00
Ravi Kandhadai
27eefd7311 [os_log][SIL Optimization] Make new os log APIs @_transparent and
change OSLogOptimization pass so that inlining is not performed.
2019-06-11 15:47:21 -07:00
Saleem Abdulrasool
1d1c362aba StdlibUnittest: consume the carriage return on stdout
This was already being done for the stderr, but not for stdout.  Doing
this means that we no longer get spurious carriage returns on the stdout
output stream on Windows.  This is needed for supporting the
validation test suite on Windows.
2019-06-05 13:59:22 -07:00
Saleem Abdulrasool
c63114f12c stdlib: enable RuntimeUnittest on Windows
No longer limit this to POSIX platforms.  The threading has been
generalised to support all targets.
2019-06-05 09:04:05 -07:00
Mishal Shah
6c69c8d0bb Merge pull request #25135 from porglezomp-misc/fix/stdlib-unittest-over-release
FIx an overrelease in StdlibUnittest's getSystemVersionPlistProperty
2019-06-03 13:35:04 -07:00
Saleem Abdulrasool
114e812631 stdlib: permit builtin Collections and Unicode tests everywhere
The pthread dependency has been lifted through the Windows port
generalising the SwiftThreadExtras.  Enable building these unit test
binaries which are needed for the validation test suite.
2019-06-02 11:19:25 -07:00
Mishal Shah
d543dd9a61 Merge pull request #25136 from porglezomp-misc/fix/stdlib-unittest-race
Fix a potential race condition in StdlibUnittest
2019-05-31 14:18:30 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Cassie Jones
dc395a1d1d Replace objc version of getSystemVersionPlistProperty with swift version
The comment in the function said:
// This function is implemented in Objective-C because Swift does not support
// failing initializers.
which hasn't been true since swift 1.1.
2019-05-29 18:51:31 -07:00
Cassie Jones
2d21059030 Fix an over-release in StdlibUnittest
Fixes rdar://51245681
2019-05-29 18:01:39 -07:00
Cassie Jones
e84142539c Fix a potential race condition in StdlibUnittest
StdlibUnittest uses an AtomicBool to track whether a failure has ocurred
in a test. Before this, expectFailure could have a false-positive
failure due to a race condition on the _anyExpectFailed.

The following interleaving would trigger the issue:

A: loads false
A: stores false
B: loads false
A: stores true
B: stores false
A: loads false (after body)

This causes A to see a false-positive failure.
2019-05-26 16:17:39 -07:00
Daniel Rodríguez Troitiño
69776aac35 Merge pull request #24521 from drodriguez/android-stop-leaking-fds
[android] Stop leaking FDs in parent test process.
2019-05-20 18:11:13 -07:00
Ravi Kandhadai
9be4fef53a [SIL Optimization] Add a mandatory optimization pass for optimizing
the new os log APIs based on string interpolation.
2019-05-14 18:08:59 -07:00