Commit Graph

220 Commits

Author SHA1 Message Date
Alsey Coleman Miller
787bc36f6d [stdlib] Include POSIXError as part of Glibc 2019-04-14 17:03:06 -05:00
Stephen Canon
c5e3f85378 Revert SE-0246 (#23800)
* Revert "Merge pull request #23791 from compnerd/you-know-nothing-clang"

This reverts commit 5150981150, reversing
changes made to 8fc305c03e.

* Revert "Merge pull request #23780 from compnerd/math-is-terrible"

This reverts commit 2d7fedd25f, reversing
changes made to 0205150b8f.

* Revert "Merge pull request #23140 from stephentyrone/mafs"

This reverts commit 777750dc51, reversing
changes made to 0c8920e747.
2019-04-04 19:35:25 -04:00
Steve (Numerics) Canon
3fda509805 Implementation of ElementaryFunctions / Real protocols.
This commit implements SE-0246, by adding conformance to Real to the Float, CGFloat, Double, and Float80 types, implemented either in terms of the system's C math library, existing standard library functionality, or LLVM intrinsics. It includes basic test coverage for these new functions, and deprecates and obsoletes *some* existing functionality in the Platform overlay. We still need to make a decision about how to handle the remaining "tgmath" functions, because obsoleting them is technically a source-breaking change (if users have unqualified names like "exp(1)", it's fine, but it would break users who have used qualified names like "Darwin.exp(1)".)
2019-04-02 18:49:31 -04:00
Steve (Numerics) Canon
b8d1481fc6 WOW\! 100% less gratuitous type machinery at runtime\! 2019-04-02 18:48:08 -04:00
Steve (Numerics) Canon
5e5cd76e8d Work in progress towards "Mathsable"
Fundamental decision to be made; should implementation hooks present like `Float.exp(_ x: Float) -> Float` or like `Float.Maths.exp(_ x: Float) -> Float`? Having the intermediate namespace to group them as in the second is definitely nicer, but it requires a little bit of extra machinery, and much more importantly, there doesn't seem to be any way to make access to the static `Maths` associatedtype transparent.
2019-04-02 18:48:08 -04:00
Saleem Abdulrasool
19cd786ca6 platform: correct case for WinSDK module (NFC)
This adjusts the case so that it can build on case sensitive file
systems (e.g. ext4).
2019-03-31 13:07:42 -07:00
Saleem Abdulrasool
fc3014c9d7 platform: add ACLAPI to WinSDK
This is needed to implement chmod-like functionality on Windows.  Ensure
that the ACL APIs are available to swift.
2019-03-30 21:40:10 -07:00
Mike Ash
4fb99998ae [Build] Use magic linker symbols to specify an @rpath-relative install name when targeting pre-stable-ABI OSes.
Magic symbols of the form $ld$install_name$os9.0$@rpath/libswiftCore.dylib tell the linker to use that install name when targeting that OS version. Use these symbols to specify an @rpath install name for all back-deployment libraries when targeting watchOS 2.0-5.1, iOS 7.0-12.1, and macOS 10.9-10.14.

rdar://problem/45027809
2019-03-22 10:04:39 -04:00
Saleem Abdulrasool
8ed5c1a4bc build: introduce and switch to GYB_SOURCES
This avoids us having to pattern match every source file which should
help speed up the CMake generation.  A secondary optimization is
possible with CMake 3.14 which has the ability to remove the last
extension component without having to resort to regular expressions.  It
also helps easily identify the GYB'ed sources.
2019-03-11 13:48:54 -07:00
Saleem Abdulrasool
14d771436c WinSDK: add some constants from CommCtrl
This exposes the common control window class name constants to the Swift
side enabling the use of these constants to create Windows.
2019-03-10 21:23:59 -07:00
Saleem Abdulrasool
c826deadb4 stdlib: link against legacy_stdio_definitions on Windows
Because Microsoft inlines the definitions of the printf family of
functions, we end up with undefined references to them.  Add an explicit
request to link against the `legacy_stdio_definitions` library when
`ucrt.C.stdio` is used which provides out-of-line definitions for them.
This fixes the building of the `stdlib/VarArgs' test.
2019-03-01 14:50:46 -08:00
Saleem Abdulrasool
bba46b9a14 WinSDK: improve module map further
Split out the User32 interfaces from the previously owning module
(WinSock2).  This improves the debugging experience and more accurately
reflects the module structure but should not impact the ability to build
the swift runtime.
2019-02-16 14:21:34 -08:00
Saleem Abdulrasool
d4660ef8c2 Windows: extend WinSDK module further
This extends the WinSDK modulemap to cover Winsock2 and IPHelp API Set.
These are used in Foundation.
2019-02-02 18:50:20 -08:00
Saleem Abdulrasool
c1da7a206a WinSDK: extend the module definition for Foundation
Update the module definition to extend it to support stack symbolication
for use in Foundation.
2019-01-26 10:52:10 -08:00
Saleem Abdulrasool
7efd6df09d build: remove some unused variables in CMake (NFC)
`swift_platform_flags` and `swift_platform_name` are no longer used.  Remove
them.
2019-01-24 08:25:36 -08:00
Jordan Rose
aea1ef8175 Move API notes out of the arch-specific subdirectories in lib/swift/ (#21690)
They're all the same anyway, and no longer even need to be compiled,
just copied in as text.

And drastically simplify how we "generate" them. Instead of attaching
their build jobs to the appropriate overlays, if present, "just" have
one job to copy them all and attach it to the Darwin overlay. That's
what we do for the overlay shim headers, and it's good enough.
(Eventually we want to get out of the business of shipping them
altogether.)

This does have the same flaw as the shim headers: if you /just/ change
API notes, the corresponding overlay does not get rebuilt. You have to
touch that too. But in practice that'll happen most of the time
anyway.

Part of rdar://problem/43545560
2019-01-09 14:06:21 -08:00
Saleem Abdulrasool
fe37d7752a Platform: extend WinSDK module
Update the module definitions to include ShellAPI and Path API Set.
These are used by Foundation for FileManager.
2019-01-06 20:26:56 -08:00
Saleem Abdulrasool
a3814052f2 winsdk: add the Heap API set 2019-01-03 17:43:01 -08:00
Saleem Abdulrasool
58429e7d06 Platform: add legacy compatibility macros to MSVCRT
Although technically these shouldn't be needed on Windows since there is
no compatibility to maintain since there is no version that exists
previously.  However, this will ease porting of sources to the platform.
It also ensures that future tests added cover windows as well.
2018-12-23 09:58:01 -08:00
swift-ci
93d6eb9478 Merge pull request #21442 from compnerd/module-map 2018-12-19 14:57:52 -08:00
Saleem Abdulrasool
0bdf536c8a Platform: improve WinSDK coverage further
Additional APISets are required to implement the Foundation API surface.
Expand the module to include that.  Unfortunately, I have not been able
to get the ImageHelp or the DebugHelp APIs or the RTLSupport APISet
covered under the module.  Those are required to get stack captures to
work.
2018-12-19 13:53:15 -08:00
Saleem Abdulrasool
e86c1714a2 stdlib: extend WinSDK module for Foundation
When building foundation, we end up including the interlocked module
through CoreFoundation.  Extend the modulemap for this.
2018-12-18 15:17:17 -08:00
Saleem Abdulrasool
df5712d1fd platform: widen winsdk modulemap
Add NamedPipe API Set for LibcExtras.
2018-12-16 22:11:07 -08:00
Saleem Abdulrasool
df1bcb76e4 test: add ClangImporter test for _setjmp APINote
This ensures that we do not allow someone to import `_setjmp` on Windows
which is not annotated with `__attribute__((__returns_twice__))` and
cannot be adjusted without assistance from Microsoft.
2018-12-15 09:24:01 -08:00
Saleem Abdulrasool
04a5d84575 Platform: make MSVCRT more Unix-libc like
Since `stdin`, `stdout`, and `stderr` are defined via macros, we cannot see them
on the swift side.  Replicate these by hand.  Expose `STDIN_FILENO`,
`STDOUT_FILENO`, and `STDERR_FILENO` for compatibility with other libc
implementations.  This reduces the need for changing the codebase unnecessarily
for MSVCRT.
2018-12-13 16:01:42 -08:00
Saleem Abdulrasool
16e9bab7f0 Platform: add setjmp module for VisualC
Add the setjmp module which was missing.  The roughly equivalent
function is `_setjmp`.  Unfortunately, it is not marked as
`__attribute__((__returns_twice__))`.
2018-12-04 09:55:33 -08:00
Xiaodi Wu
9fe28c6e55 [gardening] Fix header comments [NFC] 2018-12-02 15:38:41 -05:00
Saleem Abdulrasool
8b8198aaae stdlib: add modulemap for WinSDK
This is needed to build the threading extras.
2018-11-26 13:10:00 -08:00
Jordan Rose
6afe77ae98 [CMake] Clean up (somewhat) the generated Xcode project (#20586)
Still to do: have command-only targets that present sources, for things
like copy_shim_headers.
2018-11-26 11:31:41 -08:00
Saleem Abdulrasool
29dc89bd9b stdlib: broaden ucrt module
Add `process` to the ucrt module as this is used in the Foundation port
for Windows.
2018-11-24 20:57:46 -08:00
Alex Blewitt
0ee1d78beb Add -lm to Glibc.modulemap on Linux
Unlike Darwin, on Linux when using functions from math.h the m library
needs to be added to the compilation. This should be explicit in the
module map, rather than being implicit in the driver.

Fixes SR-9198
2018-11-08 16:53:18 +00:00
Michael Gottesman
3f17bb6ddf Carefully split the build's invocation of add_swift_library into host/target variants.
The key thing here is that all of the underlying code is exactly the same. I
purposely did not debride anything. This is to ensure that I am not touching too
much and increasing the probability of weird errors from occurring. Thus the
exact same code should be executed... just the routing changed.
2018-10-27 12:58:51 -07:00
Daniel Rodríguez Troitiño
60e2205663 [stdlib] Enable lgamma for Android.
Android Bionic offers lgammaf_r and lgamma_r only if _GNU_SOURCE is
provided. It also offers lgammal_r in API levels 23 and above, but
that one will not be available until 128 bit floats are supported.

The patch modifies the importer to use _GNU_SOURCE while importing
Android headers and slighly modify a check that was avoding the
function from being created for Android.

This fixes the compilation of the tgmath test in Android.
2018-10-12 14:42:52 -07:00
Mike Ash
5f17b450c3 [Stdlib] Make all the functions in LibcShims.h either INTERNAL or inline. Move LibcShimsInline.h to LibcOverlayShims.h for more consistent naming. Fix up several tests that needed the mock Darwin overlay built. Fix one SourceKit test that no longer produces is_system: 1 on an import Darwin line. 2018-10-03 09:55:34 -04:00
Mike Ash
b2675280c7 [Stdlib] Move the shims used by Platform.swift into a separate header and make them static inline. This avoids exposing them as exported symbols in libswiftCore. 2018-10-03 09:55:34 -04:00
Mike Ash
e18e03171f [Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
The functions in LibcShims are used externally, some directly and some through @inlineable functions. These are changed to SWIFT_RUNTIME_STDLIB_SPI to better match their actual usage. Their names are also changed to add "_swift" to the front to match our naming conventions.

Three functions from SwiftObject.mm are changed to SPI and get a _swift prefix.

A few other support functions are also changed to SPI. They already had a prefix and look like they were meant to be SPI anyway. It was just hard to notice any mixup when they were #defined to the same thing.

rdar://problem/35863717
2018-10-03 09:55:33 -04:00
Ding Ye
033f6aca92 Fix warnings in stdlib 2018-08-31 08:42:01 +10:00
Stephen Canon
ff89fce7df Make FloatingPoint require that Self.Magnitude == Self (#17323)
* Make FloatingPoint require that Self.Magnitude == Self

We didn't have the where clause to express this constraint at the time that the FloatingPoint protocol was implemented, but we do now. This is not a semantic change to FloatingPoint, which has always bound IEEE-754 arithmetic types, for which this constraint would necessarily hold, but it does effect the type system.

For example, currently the following function does not type check:
~~~~
func foo<T>(x: T) -> T where T: FloatingPoint {
  var r = x.remainder(dividingBy: 1)
  return r.magnitude
}
~~~~
with this change, it compiles correctly.

Having done this, we no longer need to have a separate `abs` defined on FloatingPoint; we can use the existing function defined on `SignedNumeric` instead. Additionally mark the global `fabs` defined in the platform C module deprecated in favor of the Swift `abs`; we don't need to carry two names for this function going forward.
2018-06-20 19:56:22 -04:00
Saleem Abdulrasool
a990013847 Platform: MSVCRT provides POSIX.fcntl
Add the missing module declaration for the POSIX interfaces.  This is
needed to access the permission mode macros.
2018-06-05 13:20:44 -07:00
swift-ci
8beed90e0d Merge pull request #15833 from lanza/android 2018-05-04 17:54:02 -07:00
Nathan Lanza
7429856034 Change various search and linker paths to account for changes in NDK16
ndk14 introduced "unified headers" which merged the headers for all
different API versions into one directory which effectively split the
"SWIFT_SDK_ANDROID_ARCH_${ARCH}_PATH" into two different directories.

Add include and library specific paths to various compilation and link
invocations across the Swift project to account for this change. Remove
some broken sysroot/sdk specific settings.
2018-05-02 14:18:11 -07:00
Saleem Abdulrasool
a0fea45957 Windows: further improve module maps
Further enhance the modulemaps.  This is needed to support the use of
the ucrt for the builtins as used in the ClangImporter unit tests.
2018-04-30 12:08:36 -07:00
Nathan Lanza
8649b2137e Remove lgamma from Android in tgmath
Remove lgamma from Android in tgmath.swift.gyb.
2018-04-23 13:47:16 -07:00
Saleem Abdulrasool
f6dcc22598 platform: enhance the VisualC modulemap
Add the `vadefs` and `stdint` submodules.  These are required to get the
importing of the standard types (`intmax_t` and `uintptr_t`) correct
with the Visual C runtime.  This allows building the libdispatch Swift
overlay.
2018-04-04 14:27:54 -07:00
Nathan Lanza
e06c52584f Change various uses of SWIFT_SDK_${SDK}_PATH to its architecture specific vairant
Cross-compilation for multiple architectures & sdks require various
variables to be split to specify the arch/adk variant being focused on.
This change modifies various uses of the `SWIFT_SDK_${SDK}_PATH` to
`SWIFT_SDK_${SDK}_ARCH_${ARCH}`
2018-03-30 17:50:59 +00:00
Jordan Rose
05293f26b6 [stdlib] Remove '@_frozen' from enums that shouldn't be frozen
Error codes, FloatingPointRoundingRule, Mirror.AncestorRepresentation,
Mirror.DisplayStyle, and PlaygroundQuickLook.
2018-03-20 14:50:40 -07:00
Jordan Rose
9034ba617b Ban @_fixed_layout on enums in favor of @_frozen
In theory there could be a "fixed-layout" enum that's not exhaustive
but promises not to add any more cases with payloads, but we don't
need that distinction today.

(Note that @objc enums are still "fixed-layout" in the actual sense of
"having a compile-time known layout". There's just no special way to
spell that.)
2018-03-20 14:49:10 -07:00
Stephen Canon
d3cb915abb Updates to tgmath functions for CGFloat (#15360)
* Updates to tgmath functions for CGFloat

These changes bring CGFloat in line with the other FloatingPoint types.  Some of this stuff is now defined at the protocol level, so we can get rid of it at the concrete type level.  A couple other functions have been deprecated for all types, with protocol or tgmath replacements.
2018-03-20 11:14:57 -04:00
Stephen Canon
ddf70fa199 Cleanup tgmath wrappers. (#15304)
* Cleanup tgmath wrappers.

- Remove special-case gyb logic for lgamma on Darwin; the symbols we need are always present, even if not visible in the headers, so we only need a prototype.
- Add some deprecations for symbols that have direct stdlib analogues.
- Make some operations generic on [Binary]FloatingPoint, where they can map to the protocols instead of calling libm.
- Mark ldexp(Float/Double) renamed to scalbn; for binary formats these are identical functions, and we don't really want to use these names for hypothetical future Decimal support, as they're not Swifty.
2018-03-17 10:32:13 -04:00
Sho Ikeda
a3f9a4c408 Fix a comment in MachError.swift 2018-03-14 13:57:00 +09:00