mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This replaces a number of `#include`-s like this:
```
#include "../../../stdlib/public/SwiftShims/Visibility.h"
```
with this:
```
#include "swift/shims/Visibility.h"
```
This is needed to allow SwiftCompilerSources to use C++ headers which include SwiftShims headers. Currently trying to do that results in errors:
```
swift/swift/include/swift/Demangling/../../../stdlib/public/SwiftShims/module.modulemap:1:8: error: redefinition of module 'SwiftShims'
module SwiftShims {
^
Builds.noindex/swift/swift/bootstrapping0/lib/swift/shims/module.modulemap:1:8: note: previously defined here
module SwiftShims {
^
```
This happens because the headers in both the source dir and the build dir refer to SwiftShims headers by relative path, and both the source root and the build root contain SwiftShims headers (which are equivalent, but since they are located in different dirs, Clang treats them as different modules).
43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
//===--- LibcShims.cpp ----------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2018 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#if defined(__APPLE__)
|
|
#define _REENTRANT
|
|
#include <math.h>
|
|
#endif
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
#include <io.h>
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include <Windows.h>
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "swift/shims/LibcShims.h"
|
|
|
|
#if defined(_WIN32)
|
|
static void __attribute__((__constructor__))
|
|
_swift_stdlib_configure_console_mode(void) {
|
|
static UINT uiPrevConsoleCP = GetConsoleOutputCP();
|
|
atexit([]() { SetConsoleOutputCP(uiPrevConsoleCP); });
|
|
SetConsoleOutputCP(CP_UTF8);
|
|
}
|
|
#endif
|
|
|
|
SWIFT_RUNTIME_STDLIB_INTERNAL
|
|
__swift_size_t _swift_stdlib_fwrite_stdout(const void *ptr,
|
|
__swift_size_t size,
|
|
__swift_size_t nitems) {
|
|
return fwrite(ptr, size, nitems, stdout);
|
|
}
|