Fix PAL_GetLogicalProcessorCacheSizeFromOS on mac (#24777)
[platform/upstream/coreclr.git] / src / pal / inc / pal_char16.h
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 /*++
6
7
8
9 Module Name:
10
11     pal_char16.h
12
13 Abstract:
14
15 This file is used to define the wchar_t type as a 16-bit type on Unix.
16
17
18
19 --*/
20
21 // The unix compilers use a 32-bit wchar_t, so we must make a 16 bit wchar_t.
22 // The windows compilers, gcc and MSVC, both define a 16 bit wchar_t.
23
24 // Note : wchar_t is a built-in type in C++, gcc/llvm ignores any attempts to
25 // typedef it. Using the preprocessor here, we make sure gcc sees
26 // __wchar_16_cpp__ instead of wchar_t. This is apparently not necessary under
27 // vc++, for whom wchar_t is already a typedef instead of a built-in.
28
29 #ifndef PAL_STDCPP_COMPAT
30 #undef wchar_t
31 #undef __WCHAR_TYPE__
32 #define __WCHAR_TYPE__ __wchar_16_cpp__
33 #define wchar_t __wchar_16_cpp__
34
35 // Set up the wchar_t type (which got preprocessed to __wchar_16_cpp__).
36 // In C++11, the standard gives us char16_t, which is what we want (and matches types with u"")
37 // In C, this doesn't exist, so use unsigned short.
38 // **** WARNING: Linking C and C++ objects will break with -fstrict-aliasing with GCC/Clang
39 //               due to conditional typedef
40 #if !defined(_WCHAR_T_DEFINED) || !defined(_MSC_VER)
41 #if defined(__cplusplus)
42 #undef __WCHAR_TYPE__
43 #define __WCHAR_TYPE__ char16_t
44 typedef char16_t wchar_t;
45 #else
46 #undef __WCHAR_TYPE__
47 #define __WCHAR_TYPE__ unsigned short
48 typedef unsigned short wchar_t;
49 #endif // __cplusplus
50
51 #ifndef _WCHAR_T_DEFINED
52 #define _WCHAR_T_DEFINED
53 #endif // !_WCHAR_T_DEFINED
54 #endif // !_WCHAR_T_DEFINED || !_MSC_VER
55 #endif // !PAL_STDCPP_COMPAT