OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef PLATFORM_GLOBALS_H_ | 5 #ifndef PLATFORM_GLOBALS_H_ |
6 #define PLATFORM_GLOBALS_H_ | 6 #define PLATFORM_GLOBALS_H_ |
7 | 7 |
8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to | 8 // __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to |
9 // enable platform independent printf format specifiers. | 9 // enable platform independent printf format specifiers. |
10 #ifndef __STDC_FORMAT_MACROS | 10 #ifndef __STDC_FORMAT_MACROS |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 | 45 |
46 #if defined(_WIN32) | 46 #if defined(_WIN32) |
47 #include "platform/c99_support_win.h" | 47 #include "platform/c99_support_win.h" |
48 #include "platform/inttypes_support_win.h" | 48 #include "platform/inttypes_support_win.h" |
49 #endif | 49 #endif |
50 | 50 |
51 // Target OS detection. | 51 // Target OS detection. |
52 // for more information on predefined macros: | 52 // for more information on predefined macros: |
53 // - http://msdn.microsoft.com/en-us/library/b0084kay.aspx | 53 // - http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
54 // - with gcc, run: "echo | gcc -E -dM -" | 54 // - with gcc, run: "echo | gcc -E -dM -" |
55 #if defined(__linux__) || defined(__FreeBSD__) | 55 #if defined(__ANDROID__) |
56 #define TARGET_OS_ANDROID | |
57 #elif defined(__linux__) || defined(__FreeBSD__) | |
56 #define TARGET_OS_LINUX 1 | 58 #define TARGET_OS_LINUX 1 |
57 #elif defined(__APPLE__) | 59 #elif defined(__APPLE__) |
58 #define TARGET_OS_MACOS 1 | 60 #define TARGET_OS_MACOS 1 |
59 #elif defined(_WIN32) | 61 #elif defined(_WIN32) |
60 #define TARGET_OS_WINDOWS 1 | 62 #define TARGET_OS_WINDOWS 1 |
61 #else | 63 #else |
62 #error Automatic target os detection failed. | 64 #error Automatic target os detection failed. |
63 #endif | 65 #endif |
64 | 66 |
65 // Processor architecture detection. For more info on what's defined, see: | 67 // Processor architecture detection. For more info on what's defined, see: |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 // A macro to ensure that memcpy cannot be called. memcpy does not handle | 325 // A macro to ensure that memcpy cannot be called. memcpy does not handle |
324 // overlapping memory regions. Even though this is well documented it seems | 326 // overlapping memory regions. Even though this is well documented it seems |
325 // to be used in error quite often. To avoid problems we disallow the direct | 327 // to be used in error quite often. To avoid problems we disallow the direct |
326 // use of memcpy here. | 328 // use of memcpy here. |
327 // | 329 // |
328 // On Windows the basic libraries use memcpy and therefore compilation will | 330 // On Windows the basic libraries use memcpy and therefore compilation will |
329 // fail if memcpy is overwritten even if user code does not use memcpy. | 331 // fail if memcpy is overwritten even if user code does not use memcpy. |
330 #if defined(memcpy) | 332 #if defined(memcpy) |
331 #undef memcpy | 333 #undef memcpy |
332 #endif | 334 #endif |
333 #if !defined(TARGET_OS_WINDOWS) | 335 #if defined(TARGET_OS_ANDROID) |
336 // Need to allow memcpy, it's used by stlport headers | |
cshapiro
2012/08/07 20:56:54
Why not mention android in the comment on line 330
jackpal
2012/08/07 21:43:26
Done.
| |
337 #elif defined(TARGET_OS_WINDOWS) | |
338 // Allow memcpy | |
339 #else | |
334 #define memcpy "Please use memmove instead of memcpy." | 340 #define memcpy "Please use memmove instead of memcpy." |
335 #endif | 341 #endif |
336 | 342 |
337 | 343 |
338 // On Windows the reentrent version of strtok is called | 344 // On Windows the reentrent version of strtok is called |
339 // strtok_s. Unify on the posix name strtok_r. | 345 // strtok_s. Unify on the posix name strtok_r. |
340 #if defined(TARGET_OS_WINDOWS) | 346 #if defined(TARGET_OS_WINDOWS) |
341 #define snprintf _snprintf | 347 #define snprintf _snprintf |
342 #define strtok_r strtok_s | 348 #define strtok_r strtok_s |
343 #endif | 349 #endif |
344 | 350 |
345 #if !defined(TARGET_OS_WINDOWS) && !defined(TEMP_FAILURE_RETRY) | 351 #if !defined(TARGET_OS_WINDOWS) && !defined(TEMP_FAILURE_RETRY) |
346 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. The | 352 // TEMP_FAILURE_RETRY is defined in unistd.h on some platforms. The |
347 // definition below is copied from Linux and adapted to avoid lint | 353 // definition below is copied from Linux and adapted to avoid lint |
348 // errors (type long int changed to int64_t and do/while split on | 354 // errors (type long int changed to int64_t and do/while split on |
349 // separate lines with body in {}s). | 355 // separate lines with body in {}s). |
350 # define TEMP_FAILURE_RETRY(expression) \ | 356 # define TEMP_FAILURE_RETRY(expression) \ |
351 ({ int64_t __result; \ | 357 ({ int64_t __result; \ |
352 do { \ | 358 do { \ |
353 __result = (int64_t) (expression); \ | 359 __result = (int64_t) (expression); \ |
354 } while (__result == -1L && errno == EINTR); \ | 360 } while (__result == -1L && errno == EINTR); \ |
355 __result; }) | 361 __result; }) |
356 #endif | 362 #endif |
357 | 363 |
358 #endif // PLATFORM_GLOBALS_H_ | 364 #endif // PLATFORM_GLOBALS_H_ |
OLD | NEW |