blob: 7900bbf84a5538aeb70b58277c8d8df575be9185 [file] [log] [blame]
Howard Hinnantc0d0cba2011-10-03 15:23:59 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// Define a bunch of macros that can be used in the tests instead of
11// implementation defined assumptions:
12// - locale names
13// - floating point number string output
14
15#ifndef PLATFORM_SUPPORT_H
16#define PLATFORM_SUPPORT_H
17
18// locale names
Marshall Clowa22d2ad2013-03-18 17:04:29 +000019#ifdef _WIN32
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000020// WARNING: Windows does not support UTF-8 codepages.
21// Locales are "converted" using http://docs.moodle.org/dev/Table_of_locales
22#define LOCALE_en_US_UTF_8 "English_United States.1252"
23#define LOCALE_cs_CZ_ISO8859_2 "Czech_Czech Republic.1250"
24#define LOCALE_fr_FR_UTF_8 "French_France.1252"
25#define LOCALE_fr_CA_ISO8859_1 "French_Canada.1252"
26#define LOCALE_ru_RU_UTF_8 "Russian_Russia.1251"
27#define LOCALE_zh_CN_UTF_8 "Chinese_China.936"
28#else
29#define LOCALE_en_US_UTF_8 "en_US.UTF-8"
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000030#define LOCALE_fr_FR_UTF_8 "fr_FR.UTF-8"
Howard Hinnantb4ebb0e2013-01-14 17:12:54 +000031#ifdef __linux__
32#define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO-8859-1"
33#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO-8859-2"
34#else
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000035#define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO8859-1"
Howard Hinnantb4ebb0e2013-01-14 17:12:54 +000036#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO8859-2"
37#endif
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000038#define LOCALE_ru_RU_UTF_8 "ru_RU.UTF-8"
39#define LOCALE_zh_CN_UTF_8 "zh_CN.UTF-8"
40#endif
41
Howard Hinnant06d8bf62013-03-22 20:05:40 +000042#include <stdio.h>
43#include <stdlib.h>
44#include <string>
45
46inline
47std::string
48get_temp_file_name()
49{
Howard Hinnante9df0a52013-08-01 18:17:34 +000050#ifdef _LIBCPP_MSVCRT
Howard Hinnant06d8bf62013-03-22 20:05:40 +000051 char* p = _tempnam( NULL, NULL );
52 if (p == nullptr)
53 abort();
54 std::string s(p);
55 free( p );
56#else
Howard Hinnanta5f0e6c2013-04-25 16:08:55 +000057 std::string s("temp.XXXXXX");
Howard Hinnant06d8bf62013-03-22 20:05:40 +000058 mktemp(&s[0]);
59#endif
60 return s;
61}
62
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000063#endif // PLATFORM_SUPPORT_H