Commit Graph

430 Commits

Author SHA1 Message Date
Daniel Rodríguez Troitiño
73fd7d6551 [android] Add missing POSIX/Linux headers to Android build.
Reviewed the cases of Glibc where branching occurred and checked the
skipped headers against the Android NDK sysroot, and added the Android
check in the right places. This will give access to a lot more
functions from libc.
2019-04-25 13:46:40 -07:00
Saleem Abdulrasool
5d2be1acc7 Windows: expose ConsoleAPI
This exposes the Windows 10 ConsoleAPI from the module.
2019-04-20 17:02:09 -07:00
Alex Langford
3d9a28925b [CMake] Modify swift_install_in_component to support cmake install components
CMake supports the notion of installation components. Right now we have some
custom code for supporting swift components. I think that for installation
purposes, it would be nice to use the CMake component system.

This should be a non-functional change. We should still only be generating
install rules for targets and files in components we want to install, and we
still use the install ninja target to install everything.
2019-04-19 14:06:11 -07:00
Saleem Abdulrasool
9f96244855 Merge pull request #24074 from gmittert/LetMeKnow
Provide inotify from glibc
2019-04-19 13:00:21 -07:00
Stephen Canon
57a4553832 SE-0246: Protocols and static functions (#23824)
This implements the protocols and static functions proposed in SE-0246, plus some initial test coverage. It also has some rough accompanying cleanup of tgmath. It does not include the globals (on scalars or SIMD types) nor does it deprecate much in tgmath.h.
2019-04-17 23:57:33 +02:00
Gwen Mittertreiner
c79bb5b607 Provide inotify from glibc 2019-04-16 15:54:34 -07:00
Alsey Coleman Miller
32fb4980e8 Compile POSIXError.swift for Windows 2019-04-16 02:06:45 -05:00
Alsey Coleman Miller
371b7ca764 Added POSIXErrorCode for Windows
https://docs.microsoft.com/en-us/cpp/c-runtime-library/errno-doserrno-sy
s-errlist-and-sys-nerr
2019-04-16 01:59:04 -05:00
Saleem Abdulrasool
b6ca2fb786 Merge pull request #24028 from colemancda/posixErrorGlibc
[stdlib] Include POSIXError as part of Glibc
2019-04-15 17:05:12 -07:00
David Smith
7db8cb1ea3 SR-10294: convertBoolToDarwinBool and friends should be inlined 2019-04-15 09:00:29 -07:00
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