OLD | NEW |
1 /* Copyright (c) 2007, Google Inc. | 1 /* Copyright (c) 2007, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #include <process.h> /* for _getpid */ | 58 #include <process.h> /* for _getpid */ |
59 #include <limits.h> /* for PATH_MAX */ | 59 #include <limits.h> /* for PATH_MAX */ |
60 #include <stdarg.h> /* for va_list */ | 60 #include <stdarg.h> /* for va_list */ |
61 #include <stdio.h> /* need this to override stdio's (v)snprintf */ | 61 #include <stdio.h> /* need this to override stdio's (v)snprintf */ |
62 #include <sys/types.h> /* for _off_t */ | 62 #include <sys/types.h> /* for _off_t */ |
63 #include <assert.h> | 63 #include <assert.h> |
64 #include <stdlib.h> /* for rand, srand, _strtoxxx */ | 64 #include <stdlib.h> /* for rand, srand, _strtoxxx */ |
65 | 65 |
66 /* | 66 /* |
67 * 4018: signed/unsigned mismatch is common (and ok for signed_i < unsigned_i) | 67 * 4018: signed/unsigned mismatch is common (and ok for signed_i < unsigned_i) |
68 * 4244: otherwise we get problems when subtracting two size_t's to an int | 68 * 4244: otherwise we get problems when substracting two size_t's to an int |
69 * 4288: VC++7 gets confused when a var is defined in a loop and then after it | 69 * 4288: VC++7 gets confused when a var is defined in a loop and then after it |
70 * 4267: too many false positives for "conversion gives possible data loss" | 70 * 4267: too many false positives for "conversion gives possible data loss" |
71 * 4290: it's ok windows ignores the "throw" directive | 71 * 4290: it's ok windows ignores the "throw" directive |
72 * 4996: Yes, we're ok using "unsafe" functions like vsnprintf and getenv() | 72 * 4996: Yes, we're ok using "unsafe" functions like vsnprintf and getenv() |
73 * 4146: internal_logging.cc intentionally negates an unsigned value | |
74 */ | 73 */ |
75 #ifdef _MSC_VER | 74 #ifdef _MSC_VER |
76 #pragma warning(disable:4018 4244 4288 4267 4290 4996 4146) | 75 #pragma warning(disable:4018 4244 4288 4267 4290 4996) |
77 #endif | 76 #endif |
78 | 77 |
79 #ifndef __cplusplus | 78 #ifndef __cplusplus |
80 /* MSVC does not support C99 */ | 79 /* MSVC does not support C99 */ |
81 # if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L | 80 # if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L |
82 # ifdef _MSC_VER | 81 # ifdef _MSC_VER |
83 # define inline __inline | 82 # define inline __inline |
84 # else | 83 # else |
85 # define inline static | 84 # define inline static |
86 # endif | 85 # endif |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 407 |
409 /* ----------------------------------- OTHER */ | 408 /* ----------------------------------- OTHER */ |
410 | 409 |
411 inline void srandom(unsigned int seed) { srand(seed); } | 410 inline void srandom(unsigned int seed) { srand(seed); } |
412 inline long random(void) { return rand(); } | 411 inline long random(void) { return rand(); } |
413 inline unsigned int sleep(unsigned int seconds) { | 412 inline unsigned int sleep(unsigned int seconds) { |
414 Sleep(seconds * 1000); | 413 Sleep(seconds * 1000); |
415 return 0; | 414 return 0; |
416 } | 415 } |
417 | 416 |
418 // mingw64 seems to define timespec (though mingw.org mingw doesn't), | |
419 // protected by the _TIMESPEC_DEFINED macro. | |
420 #ifndef _TIMESPEC_DEFINED | |
421 struct timespec { | 417 struct timespec { |
422 int tv_sec; | 418 int tv_sec; |
423 int tv_nsec; | 419 int tv_nsec; |
424 }; | 420 }; |
425 #endif | |
426 | 421 |
427 inline int nanosleep(const struct timespec *req, struct timespec *rem) { | 422 inline int nanosleep(const struct timespec *req, struct timespec *rem) { |
428 Sleep(req->tv_sec * 1000 + req->tv_nsec / 1000000); | 423 Sleep(req->tv_sec * 1000 + req->tv_nsec / 1000000); |
429 return 0; | 424 return 0; |
430 } | 425 } |
431 | 426 |
432 #ifndef __MINGW32__ | 427 #ifndef __MINGW32__ |
433 inline long long int strtoll(const char *nptr, char **endptr, int base) { | 428 inline long long int strtoll(const char *nptr, char **endptr, int base) { |
434 return _strtoi64(nptr, endptr, base); | 429 return _strtoi64(nptr, endptr, base); |
435 } | 430 } |
(...skipping 29 matching lines...) Expand all Loading... |
465 */ | 460 */ |
466 #define GOOGLE_MAYBE_THREADS_H_ 1 | 461 #define GOOGLE_MAYBE_THREADS_H_ 1 |
467 | 462 |
468 | 463 |
469 #endif /* _WIN32 */ | 464 #endif /* _WIN32 */ |
470 | 465 |
471 #undef inline | 466 #undef inline |
472 #undef EXTERN_C | 467 #undef EXTERN_C |
473 | 468 |
474 #endif /* GOOGLE_BASE_WINDOWS_H_ */ | 469 #endif /* GOOGLE_BASE_WINDOWS_H_ */ |
OLD | NEW |