-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[FreeBSD] Adding FreeBSD support #77836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
0c47c45
7f0f2ac
03463ea
26dd5c3
617a701
ec41711
9a948a9
8738e72
7bbafc5
84ee0af
d681126
cf041b1
aaf2832
bc870ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -422,7 +422,14 @@ class DerivativeFunctionTypeError | |
Kind kind; | ||
|
||
/// The type and index of a differentiability parameter or result. | ||
using TypeAndIndex = std::pair<Type, unsigned>; | ||
/// std::pair does not have a trivial copy constructor on FreeBSD <= 14 for | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you just change the call sites that are using the constructor? That would simplify the diff.
michael-yuji marked this conversation as resolved.
Show resolved
Hide resolved
michael-yuji marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// ABI reasons, so we have to define our own type here instead | ||
struct TypeAndIndex { | ||
Type first; | ||
unsigned second; | ||
|
||
TypeAndIndex(Type type, unsigned index) : first(type), second(index) {} | ||
}; | ||
|
||
private: | ||
union Value { | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -338,12 +338,12 @@ public var SIG_DFL: sig_t? { return nil } | |||||||||
public var SIG_IGN: sig_t { return unsafeBitCast(1, to: sig_t.self) } | ||||||||||
public var SIG_ERR: sig_t { return unsafeBitCast(-1, to: sig_t.self) } | ||||||||||
public var SIG_HOLD: sig_t { return unsafeBitCast(5, to: sig_t.self) } | ||||||||||
#elseif os(OpenBSD) | ||||||||||
#elseif os(OpenBSD) || os(FreeBSD) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: platform order |
||||||||||
public var SIG_DFL: sig_t? { return nil } | ||||||||||
public var SIG_IGN: sig_t { return unsafeBitCast(1, to: sig_t.self) } | ||||||||||
public var SIG_ERR: sig_t { return unsafeBitCast(-1, to: sig_t.self) } | ||||||||||
public var SIG_HOLD: sig_t { return unsafeBitCast(3, to: sig_t.self) } | ||||||||||
#elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Haiku) | ||||||||||
#elseif os(Linux) || os(PS4) || os(Android) || os(Haiku) | ||||||||||
#if !canImport(SwiftMusl) | ||||||||||
public typealias sighandler_t = __sighandler_t | ||||||||||
#endif | ||||||||||
|
@@ -495,3 +495,7 @@ public var environ: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?> { | |||||||||
} | ||||||||||
#endif | ||||||||||
#endif // SWIFT_STDLIB_HAS_ENVIRON | ||||||||||
|
||||||||||
#if os(FreeBSD) | ||||||||||
public let inet_pton = __inet_pton | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
/// It's not named just Glibc so that it doesn't conflict in the event of a | ||
/// future official glibc modulemap. | ||
module SwiftGlibc [system] { | ||
% if CMAKE_SDK in ["LINUX", "OPENBSD"]: | ||
% if CMAKE_SDK in ["LINUX", "OPENBSD", "FREEBSD"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: platform order |
||
link "m" | ||
% end | ||
% if CMAKE_SDK in ["LINUX", "FREEBSD", "OPENBSD", "CYGWIN"]: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
|
||
// Clang has been defining __INTxx_TYPE__ macros for a long time. | ||
// __UINTxx_TYPE__ are defined only since Clang 3.5. | ||
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__wasi__) | ||
#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__wasi__) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: platf—okay you get the idea |
||
#include <stdint.h> | ||
typedef int64_t __swift_int64_t; | ||
typedef uint64_t __swift_uint64_t; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift Atomics open source project | ||
// | ||
// Copyright (c) 2024 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Glibc | ||
|
||
@available(SwiftStdlib 6.0, *) | ||
@frozen | ||
@_staticExclusiveOnly | ||
public struct _MutexHandle: ~Copyable { | ||
michael-yuji marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@usableFromInline | ||
let value: _Cell<umutex> | ||
|
||
@available(SwiftStdlib 6.0, *) | ||
@_alwaysEmitIntoClient | ||
@_transparent | ||
public init() { | ||
value = _Cell(umutex()) | ||
} | ||
|
||
@available(SwiftStdlib 6.0, *) | ||
@_alwaysEmitIntoClient | ||
@_transparent | ||
internal borrowing func _lock() { | ||
_umtx_op(value._address, UMTX_OP_MUTEX_LOCK, 0, nil, nil) | ||
} | ||
|
||
@available(SwiftStdlib 6.0, *) | ||
@_alwaysEmitIntoClient | ||
@_transparent | ||
internal borrowing func _tryLock() -> Bool { | ||
_umtx_op(value._address, UMTX_OP_MUTEX_TRYLOCK, 0, nil, nil) != -1 | ||
} | ||
|
||
@available(SwiftStdlib 6.0, *) | ||
@_alwaysEmitIntoClient | ||
@_transparent | ||
internal borrowing func _unlock() { | ||
_umtx_op(value._address, UMTX_OP_MUTEX_UNLOCK, 0, nil, nil) | ||
} | ||
} |
michael-yuji marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.