Commit Graph

5 Commits

Author SHA1 Message Date
Saleem Abdulrasool 1595c42b9a
CNIOAtomics: define types for `uintptr_t` and `intptr_t` (#1401)
On LLP64 hosts, `Int` is mapped to `intptr_t` and `UInt` to `uintptr_t`.
As a result, we need to ensure that we map the atomic extensions to
those types for type conversions.

Add the types for `uintptr_t` and `intptr_t` so that they can be used to
implement `CNIOConcurrencyHelpers` on Windows.

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2020-02-26 17:07:39 +00:00
Saleem Abdulrasool 1832cff669
CNIOAtomics: declare atomic operations using a macro (#1400)
Use a macro to define the interface for the typed atomics.  This reduces
the boiler plate that is expanded by hand.  More importantly, it makes
it easier to add new types in the future.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2020-02-18 10:24:20 +00:00
Jake 3c879ebbaf Fast atomics (#1263)
Motivation:

The existing Atomic class holds an UnsafeEmbeddedAtomic which holds an OpaquePointer to raw memory for the C atomic. This results in multiple allocations on init. The new NIOAtomic class uses ManagedBufferPointer which tail allocates memory for the C atomic as part of the NIOAtomic class allocation.

Modifications:

Created NIOAtomic class that uses ManagedBufferPointer to allocate memory for the C atomic. Created version of catmc_atomic_* C functions that expect memory to be allocated/deallocated by caller. Created NIOAtomicPrimitive protocol for the new version of catmc_atomic_* functions.

Result:

Purely additive. NIOAtomic is available as a replacement for Atomic which results in fewer memory allocations.
2019-11-28 07:45:05 +00:00
Gwynne Raskind 790827800d Remove `cpp_magic.h` import and ancient Clang compatibility hack from `CNIOAtomics.h` (#1111)
The inclusion of `cpp_magic.h` in `CNIOAtomics.h` is unnecessary and pollutes the namespace of anyone else importing the header. NIO now also requires Swift 5, which itself will not be built with a Clang too old to understand `_Nonnull`. Note: Removing the extra import of cpp-magic.h required moving it to the src/ directory to avoid complaints about its inclusion (or lack thereof) in the module's umbrella header.
2019-08-15 10:54:43 +01:00
Johannes Weiss 9bae007a15 use umbrella headers for C modules (#636)
Motivation:

SwiftPM only generates fully usable clang modules for C modules if they
have umbrella headers. Therefore, adding a generated NIO.xcodeproj to
another Xcode project as a sub-project never worked.
To make a header an umbrella header you need to name them _exactly_ like
the module.

Modifications:

give each C module an umbrella header

Result:

generated NIO Xcode projects can be used as sub-projects.
2018-10-19 14:49:43 +01:00