OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrAutoLocaleSetter_DEFINED | 8 #ifndef GrAutoLocaleSetter_DEFINED |
9 #define GrAutoLocaleSetter_DEFINED | 9 #define GrAutoLocaleSetter_DEFINED |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 /** | 21 /** |
22 * Helper class for ensuring that we don't use the wrong locale when building sh
aders. Android | 22 * Helper class for ensuring that we don't use the wrong locale when building sh
aders. Android |
23 * doesn't support locale in the NDK, so this is a no-op there. | 23 * doesn't support locale in the NDK, so this is a no-op there. |
24 */ | 24 */ |
25 class GrAutoLocaleSetter { | 25 class GrAutoLocaleSetter { |
26 public: | 26 public: |
27 GrAutoLocaleSetter (const char* name) { | 27 GrAutoLocaleSetter (const char* name) { |
28 #if defined(SK_BUILD_FOR_WIN) | 28 #if defined(SK_BUILD_FOR_WIN) |
29 fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); | 29 fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); |
30 fOldLocale = setlocale(LC_ALL, name); | 30 fOldLocale = setlocale(LC_ALL, name); |
31 #elif !defined(SK_BUILD_FOR_ANDROID) | 31 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) |
32 fLocale = newlocale(LC_ALL, name, 0); | 32 fLocale = newlocale(LC_ALL, name, 0); |
33 if (fLocale) { | 33 if (fLocale) { |
34 fOldLocale = uselocale(fLocale); | 34 fOldLocale = uselocale(fLocale); |
35 } | 35 } |
36 #else | 36 #else |
37 (void) name; // suppress unused param warning. | 37 (void) name; // suppress unused param warning. |
38 #endif | 38 #endif |
39 } | 39 } |
40 | 40 |
41 ~GrAutoLocaleSetter () { | 41 ~GrAutoLocaleSetter () { |
42 #if defined(SK_BUILD_FOR_WIN) | 42 #if defined(SK_BUILD_FOR_WIN) |
43 setlocale(LC_ALL, fOldLocale); | 43 setlocale(LC_ALL, fOldLocale); |
44 _configthreadlocale(fOldPerThreadLocale); | 44 _configthreadlocale(fOldPerThreadLocale); |
45 #elif !defined(SK_BUILD_FOR_ANDROID) | 45 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) |
46 if (fLocale) { | 46 if (fLocale) { |
47 uselocale(fOldLocale); | 47 uselocale(fOldLocale); |
48 freelocale(fLocale); | 48 freelocale(fLocale); |
49 } | 49 } |
50 #endif | 50 #endif |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 #if defined(SK_BUILD_FOR_WIN) | 54 #if defined(SK_BUILD_FOR_WIN) |
55 int fOldPerThreadLocale; | 55 int fOldPerThreadLocale; |
56 const char* fOldLocale; | 56 const char* fOldLocale; |
57 #elif !defined(SK_BUILD_FOR_ANDROID) | 57 #elif !defined(SK_BUILD_FOR_ANDROID) && !defined(__UCLIBC__) |
58 locale_t fOldLocale; | 58 locale_t fOldLocale; |
59 locale_t fLocale; | 59 locale_t fLocale; |
60 #endif | 60 #endif |
61 }; | 61 }; |
62 | 62 |
63 #endif | 63 #endif |
64 | 64 |
OLD | NEW |