Skip to content

Commit

Permalink
[clang][Emscripten] Define __unix family of macros
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Aug 25, 2021
1 parent 1bdeafe commit c05d30e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/OSTargets.h
Expand Up @@ -944,6 +944,7 @@ class LLVM_LIBRARY_VISIBILITY EmscriptenTargetInfo
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const final {
WebAssemblyOSTargetInfo<Target>::getOSDefines(Opts, Triple, Builder);
DefineStd(Builder, "unix", Opts);
Builder.defineMacro("__EMSCRIPTEN__");
if (Opts.POSIXThreads)
Builder.defineMacro("__EMSCRIPTEN_PTHREADS__");
Expand Down
8 changes: 6 additions & 2 deletions clang/test/Preprocessor/init.c
Expand Up @@ -1847,8 +1847,10 @@
// WEBASSEMBLY-NEXT:#define __clang_version__ "{{.*}}"
// WEBASSEMBLY-NEXT:#define __clang_wide_literal_encoding__ {{.*}}
// WEBASSEMBLY-NEXT:#define __llvm__ 1
// WEBASSEMBLY-NOT:#define __unix
// WEBASSEMBLY-NOT:#define __unix__
// WEBASSEMBLY-WASI-NOT:#define __unix
// WEBASSEMBLY-WASI-NOT:#define __unix__
// EMSCRIPTEN-NEXT:#define __unix 1
// EMSCRIPTEN-NEXT:#define __unix__ 1
// WEBASSEMBLY-WASI-NEXT:#define __wasi__ 1
// WEBASSEMBLY-NOT:#define __wasm_simd128__
// WEBASSEMBLY-NOT:#define __wasm_simd256__
Expand All @@ -1863,6 +1865,8 @@
// WEBASSEMBLY64-NEXT:#define __wasm64 1
// WEBASSEMBLY64-NEXT:#define __wasm64__ 1
// WEBASSEMBLY-NEXT:#define __wasm__ 1
// EMSCRIPTEN:#define unix 1
// WEBASSEMBLY-WASI-NOT:#define unix 1
// WEBASSEMBLY-CXX-NOT:_REENTRANT
// WEBASSEMBLY-CXX-NOT:__STDCPP_THREADS__
// WEBASSEMBLY-CXX-ATOMICS:#define _REENTRANT 1
Expand Down

0 comments on commit c05d30e

Please sign in to comment.