Skip to content

[cxx-interop] [nfc] Remove swift namespace from SwiftShims in C++ mode. #32715

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

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/AssertionReporting.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#endif

#ifdef __cplusplus
namespace swift { extern "C" {
extern "C" {
#endif

/// Report a fatal error to system console, stderr, and crash logs.
Expand Down Expand Up @@ -69,7 +69,7 @@ void _swift_stdlib_reportUnimplementedInitializer(
__swift_uint32_t flags);

#ifdef __cplusplus
}} // extern "C", namespace swift
} // extern "C"
#endif

#if __has_feature(nullability)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/CoreFoundationShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "Visibility.h"

#ifdef __cplusplus
namespace swift { extern "C" {
extern "C" {
#endif

#ifdef __OBJC2__
Expand Down Expand Up @@ -78,7 +78,7 @@ _swift_stdlib_dyld_is_objc_constant_string(const void * _Nonnull addr);
#endif // __OBJC2__

#ifdef __cplusplus
}} // extern "C", namespace swift
} // extern "C"
#endif

#endif // SWIFT_STDLIB_SHIMS_COREFOUNDATIONSHIMS_H
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/DispatchOverlayShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#pragma clang assume_nonnull begin

#ifdef __cplusplus
namespace swift { extern "C" {
extern "C" {
#endif

typedef void (^__swift_shims_dispatch_block_t)(void);
Expand Down Expand Up @@ -251,7 +251,7 @@ static inline void _swift_dispatch_release(dispatch_object_t object) {
}

#ifdef __cplusplus
}} // extern "C", namespace swift
} // extern "C"
#endif

#pragma clang assume_nonnull end
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/FoundationShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "SwiftStdint.h"

#ifdef __cplusplus
namespace swift { extern "C" {
extern "C" {
#endif

typedef struct {
Expand Down Expand Up @@ -58,7 +58,7 @@ SWIFT_RUNTIME_STDLIB_API
_SwiftNSOperatingSystemVersion _swift_stdlib_operatingSystemVersion() __attribute__((const));

#ifdef __cplusplus
}} // extern "C", namespace swift
} // extern "C"
#endif

#endif // SWIFT_STDLIB_SHIMS_FOUNDATIONSHIMS_H
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/LibcShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#endif

#ifdef __cplusplus
namespace swift { extern "C" {
extern "C" {
#endif

// This declaration might not be universally correct.
Expand Down Expand Up @@ -184,7 +184,7 @@ long double lgammal_r(long double x, int *psigngam);
#endif // defined(__APPLE__)

#ifdef __cplusplus
}} // extern "C", namespace swift
} // extern "C"
#endif

#if __has_feature(nullability)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/Random.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
#endif

#ifdef __cplusplus
namespace swift { extern "C" {
extern "C" {
#endif

SWIFT_RUNTIME_STDLIB_API
void swift_stdlib_random(void *buf, __swift_size_t nbytes);

#ifdef __cplusplus
}} // extern "C", namespace swift
} // extern "C"
#endif

#if __has_feature(nullability)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/RuntimeShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "Visibility.h"

#ifdef __cplusplus
namespace swift { extern "C" {
extern "C" {
#endif

/// Return an NSString to be used as the Mirror summary of the object
Expand Down Expand Up @@ -85,7 +85,7 @@ __swift_size_t _swift_stdlib_getHardwareConcurrency(void);
#define _swift_MinAllocationAlignment (__swift_size_t) 16

#ifdef __cplusplus
}} // extern "C", namespace swift
} // extern "C"
#endif

#endif // SWIFT_STDLIB_SHIMS_RUNTIMESHIMS_H
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/RuntimeStubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "LibcShims.h"

#ifdef __cplusplus
namespace swift { extern "C" {
extern "C" {
#endif

SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
Expand All @@ -42,7 +42,7 @@ _swift_stdlib_overrideUnsafeArgvArgc(char * _Nullable * _Nonnull argv, int argc)
SWIFT_END_NULLABILITY_ANNOTATIONS

#ifdef __cplusplus
}} // extern "C", namespace swift
} // extern "C"
#endif

#endif // SWIFT_STDLIB_SHIMS_RUNTIMESTUBS_H_
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/UnicodeShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#endif

#ifdef __cplusplus
namespace swift { extern "C" {
extern "C" {
#endif

SWIFT_RUNTIME_STDLIB_API
Expand Down Expand Up @@ -554,7 +554,7 @@ double __swift_stdlib_u_getNumericValue(__swift_stdlib_UChar32 c);


#ifdef __cplusplus
}} // extern "C", namespace swift
} // extern "C"
#endif

#if __has_feature(nullability)
Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/runtime/BackDeployment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _swift_classIsSwiftMask = computeIsSwiftMask();
SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_END
#endif // SWIFT_CLASS_IS_SWIFT_MASK_GLOBAL_VARIABLE

static swift::_SwiftNSOperatingSystemVersion swiftInOSVersion = {
static _SwiftNSOperatingSystemVersion swiftInOSVersion = {
#if __MAC_OS_X_VERSION_MIN_REQUIRED
10, 14, 4
// WatchOS also pretends to be iOS, so check it first.
Expand All @@ -43,8 +43,8 @@ static swift::_SwiftNSOperatingSystemVersion swiftInOSVersion = {
#endif
};

static bool versionLessThan(swift::_SwiftNSOperatingSystemVersion lhs,
swift::_SwiftNSOperatingSystemVersion rhs) {
static bool versionLessThan(_SwiftNSOperatingSystemVersion lhs,
_SwiftNSOperatingSystemVersion rhs) {
if (lhs.majorVersion < rhs.majorVersion) return true;
if (lhs.majorVersion > rhs.majorVersion) return false;

Expand All @@ -58,7 +58,7 @@ static bool versionLessThan(swift::_SwiftNSOperatingSystemVersion lhs,

SWIFT_RUNTIME_STDLIB_INTERNAL
int _swift_isBackDeploying() {
auto version = swift::_swift_stdlib_operatingSystemVersion();
auto version = _swift_stdlib_operatingSystemVersion();
return versionLessThan(version, swiftInOSVersion);
}
#endif
8 changes: 4 additions & 4 deletions stdlib/public/stubs/Assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void logPrefixAndMessageToDebugger(
free(debuggerMessage);
}

void swift::_swift_stdlib_reportFatalErrorInFile(
void _swift_stdlib_reportFatalErrorInFile(
const unsigned char *prefix, int prefixLength,
const unsigned char *message, int messageLength,
const unsigned char *file, int fileLength,
Expand All @@ -61,7 +61,7 @@ void swift::_swift_stdlib_reportFatalErrorInFile(
logPrefixAndMessageToDebugger(prefix, prefixLength, message, messageLength);
}

void swift::_swift_stdlib_reportFatalError(
void _swift_stdlib_reportFatalError(
const unsigned char *prefix, int prefixLength,
const unsigned char *message, int messageLength,
uint32_t flags
Expand All @@ -78,7 +78,7 @@ void swift::_swift_stdlib_reportFatalError(
logPrefixAndMessageToDebugger(prefix, prefixLength, message, messageLength);
}

void swift::_swift_stdlib_reportUnimplementedInitializerInFile(
void _swift_stdlib_reportUnimplementedInitializerInFile(
const unsigned char *className, int classNameLength,
const unsigned char *initName, int initNameLength,
const unsigned char *file, int fileLength,
Expand All @@ -99,7 +99,7 @@ void swift::_swift_stdlib_reportUnimplementedInitializerInFile(
free(log);
}

void swift::_swift_stdlib_reportUnimplementedInitializer(
void _swift_stdlib_reportUnimplementedInitializer(
const unsigned char *className, int classNameLength,
const unsigned char *initName, int initNameLength,
uint32_t flags
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/stubs/Availability.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static os_system_version_s getOSVersion() {
/// This is ABI and cannot be removed. Even though _stdlib_isOSVersionAtLeast()
/// is no longer inlinable, is previously was and so calls to this method
/// have been inlined into shipped apps.
_SwiftNSOperatingSystemVersion swift::_swift_stdlib_operatingSystemVersion() {
_SwiftNSOperatingSystemVersion _swift_stdlib_operatingSystemVersion() {
os_system_version_s version = SWIFT_LAZY_CONSTANT(getOSVersion());

return { (int)version.major, (int)version.minor, (int)version.patch };
Expand Down
12 changes: 6 additions & 6 deletions stdlib/public/stubs/FoundationHelpers.mm
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,26 @@ static inline void initializeBridgingFunctions() {
}

__swift_uint8_t
swift::_swift_stdlib_isNSString(id obj) {
_swift_stdlib_isNSString(id obj) {
initializeBridgingFunctions();
return _CFGetTypeID((CFTypeRef)obj) == _CFStringTypeID ? 1 : 0;
}

_swift_shims_CFHashCode
swift::_swift_stdlib_CFStringHashNSString(id _Nonnull obj) {
_swift_stdlib_CFStringHashNSString(id _Nonnull obj) {
initializeBridgingFunctions();
return _CFStringHashNSString(obj);
}

_swift_shims_CFHashCode
swift::_swift_stdlib_CFStringHashCString(const _swift_shims_UInt8 * _Nonnull bytes,
_swift_stdlib_CFStringHashCString(const _swift_shims_UInt8 * _Nonnull bytes,
_swift_shims_CFIndex length) {
initializeBridgingFunctions();
return _CFStringHashCString(bytes, length);
}

const __swift_uint8_t *
swift::_swift_stdlib_NSStringCStringUsingEncodingTrampoline(id _Nonnull obj,
_swift_stdlib_NSStringCStringUsingEncodingTrampoline(id _Nonnull obj,
unsigned long encoding) {
typedef __swift_uint8_t * _Nullable (*cStrImplPtr)(id, SEL, unsigned long);
cStrImplPtr imp = (cStrImplPtr)class_getMethodImplementation([obj superclass],
Expand All @@ -94,7 +94,7 @@ static inline void initializeBridgingFunctions() {
}

__swift_uint8_t
swift::_swift_stdlib_NSStringGetCStringTrampoline(id _Nonnull obj,
_swift_stdlib_NSStringGetCStringTrampoline(id _Nonnull obj,
_swift_shims_UInt8 *buffer,
_swift_shims_CFIndex maxLength,
unsigned long encoding) {
Expand All @@ -111,7 +111,7 @@ typedef __swift_uint8_t (*getCStringImplPtr)(id,
}

__swift_uint8_t
swift::_swift_stdlib_dyld_is_objc_constant_string(const void *addr) {
_swift_stdlib_dyld_is_objc_constant_string(const void *addr) {
initializeBridgingFunctions();
if (!dyld_is_objc_constant) return false;
return dyld_is_objc_constant(dyld_objc_string_kind, addr) ? 1 : 0;
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/stubs/GlobalObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ static swift::_SwiftHashingParameters initializeHashingParameters() {
return { 0, 0, true };
}
__swift_uint64_t seed0 = 0, seed1 = 0;
swift::swift_stdlib_random(&seed0, sizeof(seed0));
swift::swift_stdlib_random(&seed1, sizeof(seed1));
swift_stdlib_random(&seed0, sizeof(seed0));
swift_stdlib_random(&seed1, sizeof(seed1));
return { seed0, seed1, false };
}

Expand Down
14 changes: 6 additions & 8 deletions stdlib/public/stubs/LibcShims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@

#include "../SwiftShims/LibcShims.h"

using namespace swift;

#if !defined(_WIN32) || defined(__CYGWIN__)
static_assert(std::is_same<mode_t, swift::__swift_mode_t>::value,
static_assert(std::is_same<mode_t, __swift_mode_t>::value,
"__swift_mode_t must be defined as equivalent to mode_t in LibcShims.h");
#endif

SWIFT_RUNTIME_STDLIB_INTERNAL
int swift::_swift_stdlib_putchar_unlocked(int c) {
int _swift_stdlib_putchar_unlocked(int c) {
#if defined(_WIN32)
return _putc_nolock(c, stdout);
#else
Expand All @@ -48,15 +46,15 @@ int swift::_swift_stdlib_putchar_unlocked(int c) {
}

SWIFT_RUNTIME_STDLIB_INTERNAL
__swift_size_t swift::_swift_stdlib_fwrite_stdout(const void *ptr,
__swift_size_t _swift_stdlib_fwrite_stdout(const void *ptr,
__swift_size_t size,
__swift_size_t nitems) {
return fwrite(ptr, size, nitems, stdout);
}

SWIFT_RUNTIME_STDLIB_SPI
__swift_ssize_t
swift::_swift_stdlib_read(int fd, void *buf, __swift_size_t nbyte) {
_swift_stdlib_read(int fd, void *buf, __swift_size_t nbyte) {
#if defined(_WIN32)
return _read(fd, buf, nbyte);
#else
Expand All @@ -66,7 +64,7 @@ swift::_swift_stdlib_read(int fd, void *buf, __swift_size_t nbyte) {

SWIFT_RUNTIME_STDLIB_SPI
__swift_ssize_t
swift::_swift_stdlib_write(int fd, const void *buf, __swift_size_t nbyte) {
_swift_stdlib_write(int fd, const void *buf, __swift_size_t nbyte) {
#if defined(_WIN32)
return _write(fd, buf, nbyte);
#else
Expand All @@ -75,7 +73,7 @@ swift::_swift_stdlib_write(int fd, const void *buf, __swift_size_t nbyte) {
}

SWIFT_RUNTIME_STDLIB_SPI
int swift::_swift_stdlib_close(int fd) {
int _swift_stdlib_close(int fd) {
#if defined(_WIN32)
return _close(fd);
#else
Expand Down
8 changes: 5 additions & 3 deletions stdlib/public/stubs/Random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,20 @@

#include <algorithm> // required for std::min

using namespace swift;

#if defined(__APPLE__)

SWIFT_RUNTIME_STDLIB_API
void swift::swift_stdlib_random(void *buf, __swift_size_t nbytes) {
void swift_stdlib_random(void *buf, __swift_size_t nbytes) {
arc4random_buf(buf, nbytes);
}

#elif defined(_WIN32) && !defined(__CYGWIN__)
#warning TODO: Test swift_stdlib_random on Windows

SWIFT_RUNTIME_STDLIB_API
void swift::swift_stdlib_random(void *buf, __swift_size_t nbytes) {
void swift_stdlib_random(void *buf, __swift_size_t nbytes) {
if (nbytes > ULONG_MAX) {
fatalError(0, "Fatal error: %zd exceeds ULONG_MAX\n", nbytes);
}
Expand All @@ -79,7 +81,7 @@ void swift::swift_stdlib_random(void *buf, __swift_size_t nbytes) {
}())

SWIFT_RUNTIME_STDLIB_API
void swift::swift_stdlib_random(void *buf, __swift_size_t nbytes) {
void swift_stdlib_random(void *buf, __swift_size_t nbytes) {
while (nbytes > 0) {
__swift_ssize_t actual_nbytes = -1;

Expand Down
Loading