40 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
41 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
202 # include <sys/types.h>
203 # include <sys/stat.h>
204 #endif // !_WIN32_WCE
206 #if defined __APPLE__
207 # include <AvailabilityMacros.h>
208 # include <TargetConditionals.h>
215 #define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
216 #define GTEST_FLAG_PREFIX_ "gtest_"
217 #define GTEST_FLAG_PREFIX_DASH_ "gtest-"
218 #define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
219 #define GTEST_NAME_ "Google Test"
220 #define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/"
225 # define GTEST_GCC_VER_ \
226 (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
231 # define GTEST_OS_CYGWIN 1
232 #elif defined __SYMBIAN32__
233 # define GTEST_OS_SYMBIAN 1
235 # define GTEST_OS_WINDOWS 1
237 # define GTEST_OS_WINDOWS_MOBILE 1
238 # elif defined(__MINGW__) || defined(__MINGW32__)
239 # define GTEST_OS_WINDOWS_MINGW 1
241 # define GTEST_OS_WINDOWS_DESKTOP 1
242 # endif // _WIN32_WCE
243 #elif defined __APPLE__
244 # define GTEST_OS_MAC 1
245 # if TARGET_OS_IPHONE
246 # define GTEST_OS_IOS 1
247 # if TARGET_IPHONE_SIMULATOR
248 # define GTEST_OS_IOS_SIMULATOR 1
251 #elif defined __linux__
252 # define GTEST_OS_LINUX 1
253 # if defined __ANDROID__
254 # define GTEST_OS_LINUX_ANDROID 1
256 #elif defined __MVS__
257 # define GTEST_OS_ZOS 1
258 #elif defined(__sun) && defined(__SVR4)
259 # define GTEST_OS_SOLARIS 1
261 # define GTEST_OS_AIX 1
262 #elif defined(__hpux)
263 # define GTEST_OS_HPUX 1
264 #elif defined __native_client__
265 # define GTEST_OS_NACL 1
266 #elif defined __OpenBSD__
267 # define GTEST_OS_OPENBSD 1
268 #elif defined __QNX__
269 # define GTEST_OS_QNX 1
272 #ifndef GTEST_LANG_CXX11
277 # if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L
279 # define GTEST_LANG_CXX11 1
281 # define GTEST_LANG_CXX11 0
288 #if !GTEST_OS_WINDOWS
293 # include <strings.h>
294 #elif !GTEST_OS_WINDOWS_MOBILE
299 #if GTEST_OS_LINUX_ANDROID
301 # include <android/api-level.h>
305 #ifndef GTEST_HAS_POSIX_RE
306 # if GTEST_OS_LINUX_ANDROID
308 # define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)
310 # define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)
314 #if GTEST_HAS_POSIX_RE
322 # define GTEST_USES_POSIX_RE 1
324 #elif GTEST_OS_WINDOWS
328 # define GTEST_USES_SIMPLE_RE 1
334 # define GTEST_USES_SIMPLE_RE 1
336 #endif // GTEST_HAS_POSIX_RE
338 #ifndef GTEST_HAS_EXCEPTIONS
341 # if defined(_MSC_VER) || defined(__BORLANDC__)
345 # ifndef _HAS_EXCEPTIONS
346 # define _HAS_EXCEPTIONS 1
347 # endif // _HAS_EXCEPTIONS
348 # define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
349 # elif defined(__GNUC__) && __EXCEPTIONS
351 # define GTEST_HAS_EXCEPTIONS 1
352 # elif defined(__SUNPRO_CC)
356 # define GTEST_HAS_EXCEPTIONS 1
357 # elif defined(__IBMCPP__) && __EXCEPTIONS
359 # define GTEST_HAS_EXCEPTIONS 1
360 # elif defined(__HP_aCC)
363 # define GTEST_HAS_EXCEPTIONS 1
367 # define GTEST_HAS_EXCEPTIONS 0
368 # endif // defined(_MSC_VER) || defined(__BORLANDC__)
369 #endif // GTEST_HAS_EXCEPTIONS
371 #if !defined(GTEST_HAS_STD_STRING)
374 # define GTEST_HAS_STD_STRING 1
375 #elif !GTEST_HAS_STD_STRING
377 # error "Google Test cannot be used where ::std::string isn't available."
378 #endif // !defined(GTEST_HAS_STD_STRING)
380 #ifndef GTEST_HAS_GLOBAL_STRING
384 # define GTEST_HAS_GLOBAL_STRING 0
386 #endif // GTEST_HAS_GLOBAL_STRING
388 #ifndef GTEST_HAS_STD_WSTRING
397 # define GTEST_HAS_STD_WSTRING \
398 (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
400 #endif // GTEST_HAS_STD_WSTRING
402 #ifndef GTEST_HAS_GLOBAL_WSTRING
405 # define GTEST_HAS_GLOBAL_WSTRING \
406 (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
407 #endif // GTEST_HAS_GLOBAL_WSTRING
410 #ifndef GTEST_HAS_RTTI
416 # ifdef _CPPRTTI // MSVC defines this macro iff RTTI is enabled.
417 # define GTEST_HAS_RTTI 1
419 # define GTEST_HAS_RTTI 0
423 # elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40302)
430 # if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \
431 !defined(__EXCEPTIONS)
432 # define GTEST_HAS_RTTI 0
434 # define GTEST_HAS_RTTI 1
435 # endif // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS
437 # define GTEST_HAS_RTTI 0
438 # endif // __GXX_RTTI
443 # elif defined(__clang__)
445 # define GTEST_HAS_RTTI __has_feature(cxx_rtti)
449 # elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
452 # define GTEST_HAS_RTTI 1
454 # define GTEST_HAS_RTTI 0
460 # define GTEST_HAS_RTTI 1
464 #endif // GTEST_HAS_RTTI
473 #ifndef GTEST_HAS_PTHREAD
479 # define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \
481 #endif // GTEST_HAS_PTHREAD
483 #if GTEST_HAS_PTHREAD
486 # include <pthread.h>
495 #ifndef GTEST_HAS_TR1_TUPLE
496 # if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR)
498 # define GTEST_HAS_TR1_TUPLE 0
501 # define GTEST_HAS_TR1_TUPLE 1
503 #endif // GTEST_HAS_TR1_TUPLE
507 #ifndef GTEST_USE_OWN_TR1_TUPLE
520 # if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
521 && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600
522 # define GTEST_ENV_HAS_TR1_TUPLE_ 1
528 # if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)
529 # define GTEST_ENV_HAS_STD_TUPLE_ 1
532 # if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_
533 # define GTEST_USE_OWN_TR1_TUPLE 0
535 # define GTEST_USE_OWN_TR1_TUPLE 1
538 #endif // GTEST_USE_OWN_TR1_TUPLE
543 #if GTEST_HAS_TR1_TUPLE
545 # if GTEST_USE_OWN_TR1_TUPLE
547 # elif GTEST_ENV_HAS_STD_TUPLE_
558 using ::std::tuple_element;
559 using ::std::tuple_size;
563 # elif GTEST_OS_SYMBIAN
570 # ifdef BOOST_HAS_TR1_TUPLE
571 # undef BOOST_HAS_TR1_TUPLE
572 # endif // BOOST_HAS_TR1_TUPLE
576 # define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED
579 # elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)
583 # if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
589 # define _TR1_FUNCTIONAL 1
590 # include <tr1/tuple>
591 # undef _TR1_FUNCTIONAL // Allows the user to #include
594 # include <tr1/tuple>
595 # endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
601 # endif // GTEST_USE_OWN_TR1_TUPLE
603 #endif // GTEST_HAS_TR1_TUPLE
609 #ifndef GTEST_HAS_CLONE
612 # if GTEST_OS_LINUX && !defined(__ia64__)
613 # if GTEST_OS_LINUX_ANDROID
615 # if defined(__arm__) && __ANDROID_API__ >= 9
616 # define GTEST_HAS_CLONE 1
618 # define GTEST_HAS_CLONE 0
621 # define GTEST_HAS_CLONE 1
624 # define GTEST_HAS_CLONE 0
625 # endif // GTEST_OS_LINUX && !defined(__ia64__)
627 #endif // GTEST_HAS_CLONE
631 #ifndef GTEST_HAS_STREAM_REDIRECTION
634 # if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN
635 # define GTEST_HAS_STREAM_REDIRECTION 0
637 # define GTEST_HAS_STREAM_REDIRECTION 1
638 # endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_SYMBIAN
639 #endif // GTEST_HAS_STREAM_REDIRECTION
645 #if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
646 (GTEST_OS_MAC && !GTEST_OS_IOS) || GTEST_OS_IOS_SIMULATOR || \
647 (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
648 GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
649 GTEST_OS_OPENBSD || GTEST_OS_QNX)
650 # define GTEST_HAS_DEATH_TEST 1
657 #define GTEST_HAS_PARAM_TEST 1
663 #if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \
664 defined(__IBMCPP__) || defined(__HP_aCC)
665 # define GTEST_HAS_TYPED_TEST 1
666 # define GTEST_HAS_TYPED_TEST_P 1
673 #if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC)
674 # define GTEST_HAS_COMBINE 1
678 #define GTEST_WIDE_STRING_USES_UTF16_ \
679 (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
683 # define GTEST_CAN_STREAM_RESULTS_ 1
696 #ifdef __INTEL_COMPILER
697 # define GTEST_AMBIGUOUS_ELSE_BLOCKER_
699 # define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default: // NOLINT
713 #if defined(__GNUC__) && !defined(COMPILER_ICC)
714 # define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
716 # define GTEST_ATTRIBUTE_UNUSED_
721 #define GTEST_DISALLOW_ASSIGN_(type)\
722 void operator=(type const &)
726 #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\
728 GTEST_DISALLOW_ASSIGN_(type)
735 #if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC)
736 # define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
738 # define GTEST_MUST_USE_RESULT_
739 #endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
744 #ifndef GTEST_HAS_SEH
747 # if defined(_MSC_VER) || defined(__BORLANDC__)
749 # define GTEST_HAS_SEH 1
752 # define GTEST_HAS_SEH 0
755 #endif // GTEST_HAS_SEH
759 # if GTEST_LINKED_AS_SHARED_LIBRARY
760 # define GTEST_API_ __declspec(dllimport)
761 # elif GTEST_CREATE_SHARED_LIBRARY
762 # define GTEST_API_ __declspec(dllexport)
773 # define GTEST_NO_INLINE_ __attribute__((noinline))
775 # define GTEST_NO_INLINE_
779 #if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)
780 # define GTEST_HAS_CXXABI_H_ 1
782 # define GTEST_HAS_CXXABI_H_ 0
815 #define GTEST_COMPILE_ASSERT_(expr, msg) \
816 typedef ::testing::internal::CompileAssert<(static_cast<bool>(expr))> \
817 msg[static_cast<bool>(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_
863 template <
typename T1,
typename T2>
866 template <
typename T>
869 #if GTEST_HAS_GLOBAL_STRING
873 #endif // GTEST_HAS_GLOBAL_STRING
875 #if GTEST_HAS_GLOBAL_WSTRING
877 #elif GTEST_HAS_STD_WSTRING
879 #endif // GTEST_HAS_GLOBAL_WSTRING
889 template <
typename T>
899 T*
get()
const {
return ptr_; }
935 #if GTEST_HAS_GLOBAL_STRING
939 #endif // GTEST_HAS_GLOBAL_STRING
945 const char*
pattern()
const {
return pattern_; }
955 return FullMatch(str.c_str(), re);
958 return PartialMatch(str.c_str(), re);
961 #if GTEST_HAS_GLOBAL_STRING
964 return FullMatch(str.c_str(), re);
967 return PartialMatch(str.c_str(), re);
970 #endif // GTEST_HAS_GLOBAL_STRING
972 static bool FullMatch(
const char* str,
const RE& re);
973 static bool PartialMatch(
const char* str,
const RE& re);
976 void Init(
const char* regex);
981 const char* pattern_;
984 #if GTEST_USES_POSIX_RE
987 regex_t partial_regex_;
989 #else // GTEST_USES_SIMPLE_RE
991 const char* full_pattern_;
1039 #define GTEST_LOG_(severity) \
1040 ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
1041 __FILE__, __LINE__).GetStream()
1060 #define GTEST_CHECK_(condition) \
1061 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1062 if (::testing::internal::IsTrue(condition)) \
1065 GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
1072 #define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
1073 if (const int gtest_error = (posix_call)) \
1074 GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
1097 template<
typename To>
1121 template<
typename To,
typename From>
1129 ::testing::internal::ImplicitCast_<From*>(to);
1134 GTEST_CHECK_(f == NULL || dynamic_cast<To>(f) != NULL);
1136 return static_cast<To
>(
f);
1144 template <
class Derived,
class Base>
1148 return dynamic_cast<Derived*
>(base);
1150 return static_cast<Derived*
>(base);
1154 #if GTEST_HAS_STREAM_REDIRECTION
1167 #endif // GTEST_HAS_STREAM_REDIRECTION
1170 #if GTEST_HAS_DEATH_TEST
1172 const ::std::vector<testing::internal::string>& GetInjectableArgvs();
1173 void SetInjectableArgvs(const ::std::vector<testing::internal::string>*
1177 extern ::std::vector<testing::internal::string> g_argvs;
1179 #endif // GTEST_HAS_DEATH_TEST
1183 #if GTEST_HAS_PTHREAD
1188 inline void SleepMilliseconds(
int n) {
1189 const timespec time = {
1193 nanosleep(&time, NULL);
1202 class Notification {
1204 Notification() : notified_(false) {
1208 pthread_mutex_destroy(&mutex_);
1214 pthread_mutex_lock(&mutex_);
1216 pthread_mutex_unlock(&mutex_);
1221 void WaitForNotification() {
1223 pthread_mutex_lock(&mutex_);
1224 const bool notified = notified_;
1225 pthread_mutex_unlock(&mutex_);
1228 SleepMilliseconds(10);
1233 pthread_mutex_t mutex_;
1244 class ThreadWithParamBase {
1246 virtual ~ThreadWithParamBase() {}
1247 virtual void Run() = 0;
1256 extern "C" inline void* ThreadFuncWithCLinkage(
void* thread) {
1257 static_cast<ThreadWithParamBase*
>(thread)->Run();
1273 template <
typename T>
1274 class ThreadWithParam :
public ThreadWithParamBase {
1276 typedef void (*UserThreadFunc)(
T);
1279 UserThreadFunc
func,
T param, Notification* thread_can_start)
1282 thread_can_start_(thread_can_start),
1284 ThreadWithParamBase*
const base =
this;
1288 pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base));
1290 ~ThreadWithParam() { Join(); }
1299 virtual void Run() {
1300 if (thread_can_start_ != NULL)
1301 thread_can_start_->WaitForNotification();
1306 const UserThreadFunc func_;
1310 Notification*
const thread_can_start_;
1341 owner_ = pthread_self();
1357 void AssertHeld()
const {
1358 GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))
1359 <<
"The current thread is not holding the mutex @" <<
this;
1368 pthread_mutex_t mutex_;
1380 # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
1381 extern ::testing::internal::MutexBase mutex
1389 # define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
1390 ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false }
1394 class Mutex :
public MutexBase {
1411 class GTestMutexLock {
1414 : mutex_(mutex) { mutex_->Lock(); }
1419 MutexBase*
const mutex_;
1432 class ThreadLocalValueHolderBase {
1434 virtual ~ThreadLocalValueHolderBase() {}
1439 extern "C" inline void DeleteThreadLocalValue(
void* value_holder) {
1440 delete static_cast<ThreadLocalValueHolderBase*
>(value_holder);
1472 template <
typename T>
1477 explicit ThreadLocal(
const T& value) : key_(CreateKey()),
1482 DeleteThreadLocalValue(pthread_getspecific(key_));
1489 T*
pointer() {
return GetOrCreateValue(); }
1490 const T*
pointer()
const {
return GetOrCreateValue(); }
1491 const T&
get()
const {
return *
pointer(); }
1496 class ValueHolder :
public ThreadLocalValueHolderBase {
1498 explicit ValueHolder(
const T& value) : value_(value) {}
1507 static pthread_key_t CreateKey() {
1512 pthread_key_create(&key, &DeleteThreadLocalValue));
1516 T* GetOrCreateValue()
const {
1517 ThreadLocalValueHolderBase*
const holder =
1518 static_cast<ThreadLocalValueHolderBase*
>(pthread_getspecific(key_));
1519 if (holder != NULL) {
1520 return CheckedDowncastToActualType<ValueHolder>(holder)->
pointer();
1523 ValueHolder*
const new_holder =
new ValueHolder(default_);
1524 ThreadLocalValueHolderBase*
const holder_base = new_holder;
1526 return new_holder->pointer();
1530 const pthread_key_t key_;
1536 # define GTEST_IS_THREADSAFE 1
1538 #else // GTEST_HAS_PTHREAD
1553 # define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
1554 extern ::testing::internal::Mutex mutex
1556 # define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
1565 template <
typename T>
1572 const T&
get()
const {
return value_; }
1573 void set(
const T& value) { value_ = value; }
1580 # define GTEST_IS_THREADSAFE 0
1582 #endif // GTEST_HAS_PTHREAD
1594 #if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)
1597 # define GTEST_ELLIPSIS_NEEDS_POD_ 1
1599 # define GTEST_CAN_COMPARE_NULL 1
1606 #if defined(__SYMBIAN32__) || defined(__IBMCPP__)
1607 # define GTEST_NEEDS_IS_POINTER_ 1
1610 template <
bool bool_value>
1620 template <
typename T>
1623 template <
typename T>
1626 template <
typename Iterator>
1631 template <
typename T>
1636 template <
typename T>
1641 #if GTEST_OS_WINDOWS
1642 # define GTEST_PATH_SEP_ "\\"
1643 # define GTEST_HAS_ALT_PATH_SEP_ 1
1647 # define GTEST_PATH_SEP_ "/"
1648 # define GTEST_HAS_ALT_PATH_SEP_ 0
1650 #endif // GTEST_OS_WINDOWS
1660 return isalpha(static_cast<unsigned char>(ch)) != 0;
1663 return isalnum(static_cast<unsigned char>(ch)) != 0;
1666 return isdigit(static_cast<unsigned char>(ch)) != 0;
1669 return islower(static_cast<unsigned char>(ch)) != 0;
1672 return isspace(static_cast<unsigned char>(ch)) != 0;
1675 return isupper(static_cast<unsigned char>(ch)) != 0;
1678 return isxdigit(static_cast<unsigned char>(ch)) != 0;
1681 const unsigned char low_byte =
static_cast<unsigned char>(ch);
1682 return ch == low_byte && isxdigit(low_byte) != 0;
1686 return static_cast<char>(tolower(static_cast<unsigned char>(ch)));
1689 return static_cast<char>(toupper(static_cast<unsigned char>(ch)));
1702 #if GTEST_OS_WINDOWS
1704 typedef struct _stat StatStruct;
1706 # ifdef __BORLANDC__
1707 inline int IsATTY(
int fd) {
return isatty(fd); }
1708 inline int StrCaseCmp(
const char* s1,
const char* s2) {
1709 return stricmp(s1, s2);
1711 inline char*
StrDup(
const char* src) {
return strdup(src); }
1712 # else // !__BORLANDC__
1713 # if GTEST_OS_WINDOWS_MOBILE
1714 inline int IsATTY(
int ) {
return 0; }
1716 inline int IsATTY(
int fd) {
return _isatty(fd); }
1717 # endif // GTEST_OS_WINDOWS_MOBILE
1718 inline int StrCaseCmp(
const char* s1,
const char* s2) {
1719 return _stricmp(s1, s2);
1721 inline char*
StrDup(
const char* src) {
return _strdup(src); }
1722 # endif // __BORLANDC__
1724 # if GTEST_OS_WINDOWS_MOBILE
1725 inline int FileNo(FILE* file) {
return reinterpret_cast<int>(_fileno(file)); }
1729 inline int FileNo(FILE* file) {
return _fileno(file); }
1730 inline int Stat(
const char* path, StatStruct* buf) {
return _stat(path, buf); }
1731 inline int RmDir(
const char* dir) {
return _rmdir(dir); }
1732 inline bool IsDir(
const StatStruct& st) {
1733 return (_S_IFDIR & st.st_mode) != 0;
1735 # endif // GTEST_OS_WINDOWS_MOBILE
1739 typedef struct stat StatStruct;
1741 inline int FileNo(FILE* file) {
return fileno(file); }
1742 inline int IsATTY(
int fd) {
return isatty(fd); }
1743 inline int Stat(
const char* path, StatStruct* buf) {
return stat(path, buf); }
1745 return strcasecmp(s1, s2);
1747 inline char*
StrDup(
const char* src) {
return strdup(src); }
1748 inline int RmDir(
const char* dir) {
return rmdir(dir); }
1749 inline bool IsDir(
const StatStruct& st) {
return S_ISDIR(st.st_mode); }
1751 #endif // GTEST_OS_WINDOWS
1757 # pragma warning(push)
1758 # pragma warning(disable:4996)
1761 inline const char*
StrNCpy(
char* dest,
const char* src,
size_t n) {
1769 #if !GTEST_OS_WINDOWS_MOBILE
1770 inline int ChDir(
const char* dir) {
return chdir(dir); }
1772 inline FILE*
FOpen(
const char* path,
const char* mode) {
1773 return fopen(path, mode);
1775 #if !GTEST_OS_WINDOWS_MOBILE
1776 inline FILE *
FReopen(
const char* path,
const char* mode, FILE* stream) {
1777 return freopen(path, mode, stream);
1779 inline FILE*
FDOpen(
int fd,
const char* mode) {
return fdopen(fd, mode); }
1781 inline int FClose(FILE* fp) {
return fclose(fp); }
1782 #if !GTEST_OS_WINDOWS_MOBILE
1783 inline int Read(
int fd,
void* buf,
unsigned int count) {
1784 return static_cast<int>(read(fd, buf, count));
1786 inline int Write(
int fd,
const void* buf,
unsigned int count) {
1787 return static_cast<int>(write(fd, buf, count));
1789 inline int Close(
int fd) {
return close(fd); }
1790 inline const char*
StrError(
int errnum) {
return strerror(errnum); }
1792 inline const char*
GetEnv(
const char* name) {
1793 #if GTEST_OS_WINDOWS_MOBILE
1796 #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
1799 const char*
const env = getenv(name);
1800 return (env != NULL && env[0] !=
'\0') ? env : NULL;
1802 return getenv(name);
1807 # pragma warning(pop) // Restores the warning state.
1810 #if GTEST_OS_WINDOWS_MOBILE
1817 #endif // GTEST_OS_WINDOWS_MOBILE
1826 #if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
1828 # define GTEST_SNPRINTF_(buffer, size, format, ...) \
1829 _snprintf_s(buffer, size, size, format, __VA_ARGS__)
1830 #elif defined(_MSC_VER)
1833 # define GTEST_SNPRINTF_ _snprintf
1835 # define GTEST_SNPRINTF_ snprintf
1846 ~(
static_cast<BiggestInt
>(1) << (8*
sizeof(BiggestInt) - 1));
1866 template <
size_t size>
1890 #if GTEST_OS_WINDOWS
1891 typedef __int64
Int;
1892 typedef unsigned __int64
UInt;
1896 #endif // GTEST_OS_WINDOWS
1909 #define GTEST_FLAG(name) FLAGS_gtest_##name
1912 #define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
1913 #define GTEST_DECLARE_int32_(name) \
1914 GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
1915 #define GTEST_DECLARE_string_(name) \
1916 GTEST_API_ extern ::std::string GTEST_FLAG(name)
1919 #define GTEST_DEFINE_bool_(name, default_val, doc) \
1920 GTEST_API_ bool GTEST_FLAG(name) = (default_val)
1921 #define GTEST_DEFINE_int32_(name, default_val, doc) \
1922 GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
1923 #define GTEST_DEFINE_string_(name, default_val, doc) \
1924 GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
1927 #define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
1928 #define GTEST_LOCK_EXCLUDED_(locks)
1936 bool ParseInt32(
const Message& src_text,
const char* str, Int32* value);
1947 #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
bool IsXDigit(char ch)
Definition: gtest-port.h:1677
FILE * FReopen(const char *path, const char *mode, FILE *stream)
Definition: gtest-port.h:1776
scoped_ptr(T *p=NULL)
Definition: gtest-port.h:894
GTEST_API_ Int32 Int32FromGTestEnv(const char *flag, Int32 default_val)
Definition: gtest-port.cc:776
GTEST_API_ bool IsTrue(bool condition)
Definition: gtest.cc:4648
void set(const T &value)
Definition: gtest-port.h:1573
GTEST_API_ std::string GetCapturedStdout()
GTEST_API_ std::string GetCapturedStderr()
To ImplicitCast_(To x)
Definition: gtest-port.h:1098
static bool FullMatch(const ::std::string &str, const RE &re)
Definition: gtest-port.h:954
Definition: gtest-death-test.h:43
std::complex< double > func(int n, int t1, int t2, int t3, double xx, double yy, double zz)
Definition: wannier.cc:98
Definition: gtest-port.h:812
void reset(T *p=NULL)
Definition: gtest-port.h:907
Iterator::value_type value_type
Definition: gtest-port.h:1628
int FClose(FILE *fp)
Definition: gtest-port.h:1781
static const bool value
Definition: gtest-port.h:1613
Definition: gtest-port.h:1566
const T * pointer() const
Definition: gtest-port.h:1571
GTestMutexLock(Mutex *)
Definition: gtest-port.h:1560
RE(const RE &other)
Definition: gtest-port.h:930
Definition: gtest-port.h:1016
const char * StringFromGTestEnv(const char *flag, const char *default_val)
Definition: gtest-port.cc:798
void UInt
Definition: gtest-port.h:1871
GTEST_API_::std::string FormatFileLocation(const char *file, int line)
Definition: gtest-port.cc:456
const double L
Definition: 3dharmonic.cc:123
int IsATTY(int fd)
Definition: gtest-port.h:1742
::std::string string
Definition: gtest-port.h:872
bool_constant< bool_value > type
Definition: gtest-port.h:1612
ThreadLocal()
Definition: gtest-port.h:1568
Definition: gtest-port.h:1621
bool ParseInt32(const Message &src_text, const char *str, Int32 *value)
Definition: gtest-port.cc:724
RE(const ::std::string ®ex)
Definition: gtest-port.h:933
::std::wstring wstring
Definition: gtest-port.h:878
GTEST_API_ size_t GetThreadCount()
Definition: gtest-port.cc:128
bool IsDigit(char ch)
Definition: gtest-port.h:1665
Definition: gtest-port.h:1018
Definition: mpreal.h:3066
int Stat(const char *path, StatStruct *buf)
Definition: gtest-port.h:1743
T * release()
Definition: gtest-port.h:901
int ChDir(const char *dir)
Definition: gtest-port.h:1770
Definition: gtest-port.h:1867
const char * GetEnv(const char *name)
Definition: gtest-port.h:1792
unsigned long long UInt
Definition: gtest-port.h:1895
#define GTEST_API_
Definition: gtest-port.h:768
NDIM & f
Definition: mra.h:2179
GTEST_API_ void CaptureStdout()
TypeWithSize< 8 >::Int TimeInMillis
Definition: gtest-port.h:1904
~scoped_ptr()
Definition: gtest-port.h:895
GTestLogSeverity
Definition: gtest-port.h:1014
bool_constant< true > true_type
Definition: gtest-port.h:1618
static bool PartialMatch(const ::std::string &str, const RE &re)
Definition: gtest-port.h:957
To DownCast_(From *f)
Definition: gtest-port.h:1122
tuple make_tuple()
Definition: gtest-tuple.h:667
long long Int
Definition: gtest-port.h:1894
Definition: gtest-port.h:1024
#define GTEST_DISALLOW_ASSIGN_(type)
Definition: gtest-port.h:721
bool_constant< false > false_type
Definition: gtest-port.h:1617
TypeWithSize< 4 >::UInt UInt32
Definition: gtest-port.h:1901
int Write(int fd, const void *buf, unsigned int count)
Definition: gtest-port.h:1786
char ToLower(char ch)
Definition: gtest-port.h:1685
::std::ostream & GetStream()
Definition: gtest-port.h:1031
TypeWithSize< 4 >::Int Int32
Definition: gtest-port.h:1900
bool IsSpace(char ch)
Definition: gtest-port.h:1671
void AssertHeld() const
Definition: gtest-port.h:1550
int RmDir(const char *dir)
Definition: gtest-port.h:1748
T * operator->() const
Definition: gtest-port.h:898
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
#define GTEST_CHECK_(condition)
Definition: gtest-port.h:1060
RE(const char *regex)
Definition: gtest-port.h:941
void LogToStderr()
Definition: gtest-port.h:1043
Definition: gtest-port.h:1545
Definition: gtest-port.h:1558
int Read(int fd, void *buf, unsigned int count)
Definition: gtest-port.h:1783
GTestMutexLock MutexLock
Definition: gtest-port.h:1563
Definition: gtest-port.h:1017
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:222
ThreadLocal(const T &value)
Definition: gtest-port.h:1569
Definition: gtest-port.h:864
int StrCaseCmp(const char *s1, const char *s2)
Definition: gtest-port.h:1744
long long BiggestInt
Definition: gtest-port.h:1649
bool IsDir(const StatStruct &st)
Definition: gtest-port.h:1749
bool IsAlpha(char ch)
Definition: gtest-port.h:1659
#define GTEST_CHECK_POSIX_SUCCESS_(posix_call)
Definition: gtest-port.h:1072
void Init(int &argc, char **&argv)
Analogous to MPI_Init.
Definition: safempi.h:730
void Lock()
Definition: gtest-port.h:1548
Definition: gtest-port.h:1611
int FileNo(FILE *file)
Definition: gtest-port.h:1741
GTEST_API_::std::string FormatCompilerIndependentFileLocation(const char *file, int line)
Definition: gtest-port.cc:474
const char * pattern() const
Definition: gtest-port.h:945
Definition: gtest-port.h:1015
bool BoolFromGTestEnv(const char *flag, bool default_val)
Definition: gtest-port.cc:766
FILE * FOpen(const char *path, const char *mode)
Definition: gtest-port.h:1772
bool IsLower(char ch)
Definition: gtest-port.h:1668
int Close(int fd)
Definition: gtest-port.h:1789
unsigned int UInt
Definition: gtest-port.h:1883
char ToUpper(char ch)
Definition: gtest-port.h:1688
Mutex()
Definition: gtest-port.h:1547
GTEST_API_ void CaptureStderr()
void Abort()
Definition: gtest-port.h:1816
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition: gtest-port.h:726
void FlushInfoLog()
Definition: gtest-port.h:1044
const char * StrNCpy(char *dest, const char *src, size_t n)
Definition: gtest-port.h:1761
TypeWithSize< 8 >::UInt UInt64
Definition: gtest-port.h:1903
T value_type
Definition: gtest-port.h:1633
bool IsUpper(char ch)
Definition: gtest-port.h:1674
Definition: gtest-port.h:926
TypeWithSize< 8 >::Int Int64
Definition: gtest-port.h:1902
void Unlock()
Definition: gtest-port.h:1549
int Int
Definition: gtest-port.h:1882
Definition: gtest-port.h:890
FILE * FDOpen(int fd, const char *mode)
Definition: gtest-port.h:1779
const BiggestInt kMaxBiggestInt
Definition: gtest-port.h:1845
char * StrDup(const char *src)
Definition: gtest-port.h:1747
const char * StrError(int errnum)
Definition: gtest-port.h:1790
Derived * CheckedDowncastToActualType(Base *base)
Definition: gtest-port.h:1145
T * pointer()
Definition: gtest-port.h:1570
T & operator*() const
Definition: gtest-port.h:897
Definition: gtest-port.h:1627
T value_type
Definition: gtest-port.h:1638
T element_type
Definition: gtest-port.h:892
bool IsAlNum(char ch)
Definition: gtest-port.h:1662