1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Define a bunch of macros that can be used in the tests instead of
10 // implementation defined assumptions:
12 // - floating point number string output
14 #ifndef PLATFORM_SUPPORT_H
15 #define PLATFORM_SUPPORT_H
17 #include "test_macros.h"
20 #define LOCALE_en_US_UTF_8 "en_US.UTF-8"
21 #define LOCALE_fr_FR_UTF_8 "fr_FR.UTF-8"
23 # define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO-8859-1"
24 # define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO-8859-2"
26 # define LOCALE_fr_CA_ISO8859_1 "fr-CA"
27 # define LOCALE_cs_CZ_ISO8859_2 "cs-CZ"
29 # define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO8859-1"
30 # define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO8859-2"
32 #define LOCALE_ja_JP_UTF_8 "ja_JP.UTF-8"
33 #define LOCALE_ru_RU_UTF_8 "ru_RU.UTF-8"
34 #define LOCALE_zh_CN_UTF_8 "zh_CN.UTF-8"
40 # include <io.h> // _mktemp_s
41 # include <fcntl.h> // _O_EXCL, ...
42 # include <sys/stat.h> // _S_IREAD, ...
44 # include <unistd.h> // close
47 #if defined(_CS_GNU_LIBC_VERSION)
48 # include <string.h> // strverscmp
51 #if defined(_NEWLIB_VERSION) && defined(__STRICT_ANSI__)
52 // Newlib provides this, but in the header it's under __STRICT_ANSI__
59 std::string
get_temp_file_name()
63 char Name
[] = "libcxx.XXXXXX";
64 if (_mktemp_s(Name
, sizeof(Name
)) != 0) abort();
65 int fd
= _open(Name
, _O_RDWR
| _O_CREAT
| _O_EXCL
, _S_IREAD
| _S_IWRITE
);
75 std::string Name
= "libcxx.XXXXXX";
76 int FD
= mkstemp(&Name
[0]);
86 #if defined(_CS_GNU_LIBC_VERSION)
87 inline bool glibc_version_less_than(char const* version
) {
88 std::string test_version
= std::string("glibc ") + version
;
90 std::size_t n
= confstr(_CS_GNU_LIBC_VERSION
, nullptr, (size_t)0);
91 char *current_version
= new char[n
];
92 confstr(_CS_GNU_LIBC_VERSION
, current_version
, n
);
94 bool result
= strverscmp(current_version
, test_version
.c_str()) < 0;
95 delete[] current_version
;
98 #endif // _CS_GNU_LIBC_VERSION
100 #endif // PLATFORM_SUPPORT_H