--- /dev/null
+cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
+
+
+# ----------------------------------------------------------------------------
+# package information
+set (PROJECT_NAME "gflags")
+set (PACKAGE_NAME "${PROJECT_NAME}")
+set (PACKAGE_VERSION "2.1.0")
+set (PACKAGE_STRING "${PROJECT_NAME} ${PACKAGE_VERSION}")
+set (PACKAGE_TARNAME "${PROJECT_NAME}-${PACKAGE_VERSION}")
+set (PACKAGE_BUGREPORT "https://code.google.com/p/gflags/issues/")
+
+project (${PROJECT_NAME})
+
+# ----------------------------------------------------------------------------
+# configure options
+option (BUILD_SHARED_LIBS "Request build of shared libraries." OFF)
+
+set (GFLAGS_NAMESPACE "gflags" CACHE STRING "C++ namespace identifier of gflags library.")
+mark_as_advanced (GFLAGS_NAMESPACE)
+
+# ----------------------------------------------------------------------------
+# source files - excluding root subdirectory and/or .in suffix
+set (PUBLIC_HDRS
+ "gflags/gflags.h"
+ "gflags/gflags_declare.h"
+ "gflags/gflags_completions.h"
+)
+
+set (PRIVATE_HDRS
+ "config.h"
+)
+
+set (GFLAGS_SRCS
+ "gflags.cc"
+ "gflags_reporting.cc"
+ "gflags_completions.cc"
+)
+
+# ----------------------------------------------------------------------------
+# system checks
+include (CheckTypeSize)
+foreach (type IN ITEMS uint16_t u_int16_t __int16)
+ CHECK_TYPE_SIZE (${type} SIZE)
+ if (SIZE)
+ set (HAVE_${type} 1)
+ else ()
+ set (HAVE_${type} 0)
+ endif ()
+endforeach ()
+
+include (CheckIncludeFileCXX)
+foreach (fname IN ITEMS fnmatch inttypes unistd sys/stat)
+ string (TOUPPER "${fname}" FNAME)
+ string (REGEX REPLACE "/" "_" FNAME "${FNAME}")
+ CHECK_INCLUDE_FILE_CXX ("${fname}.h" HAVE_${FNAME}_H)
+ if (HAVE_${FNAME}_H)
+ set (HAVE_${FNAME}_H 1)
+ else ()
+ set (HAVE_${FNAME}_H 0)
+ endif ()
+endforeach ()
+
+include (CheckSymbolExists)
+foreach (fname IN ITEMS strtoll strtoq)
+ string (TOUPPER "${fname}" FNAME)
+ CHECK_SYMBOL_EXISTS ("${fname}" stdlib.h HAVE_${FNAME})
+ if (HAVE_${FNAME})
+ set (HAVE_${FNAME} 1)
+ else ()
+ set (HAVE_${FNAME} 0)
+ endif ()
+endforeach ()
+
+find_package (Threads)
+if (Threads_FOUND)
+ if (CMAKE_USE_PTHREADS_INIT)
+ set (HAVE_PTHREAD 1)
+ else ()
+ set (HAVE_PTHREAD 0)
+ endif ()
+endif ()
+
+# ----------------------------------------------------------------------------
+# configure source files
+if (CMAKE_COMPILER_IS_GNUCXX)
+ set (__ATTRIBUTE__UNUSED "__attribute((unused))")
+else ()
+ set (__ATTRIBUTE__UNUSED)
+endif ()
+
+function (configure_sources out subdir)
+ set (tmp)
+ foreach (src IN LISTS ARGN)
+ set (src "${subdir}/${src}")
+ if (EXISTS "${PROJECT_SOURCE_DIR}/${src}.in")
+ configure_file ("${PROJECT_SOURCE_DIR}/${src}.in" "${PROJECT_BINARY_DIR}/${src}" @ONLY)
+ list (APPEND tmp "${PROJECT_BINARY_DIR}/${src}")
+ else ()
+ list (APPEND tmp "${PROJECT_SOURCE_DIR}/${src}")
+ endif ()
+ endforeach ()
+ set (${out} "${tmp}" PARENT_SCOPE)
+endfunction ()
+
+configure_sources (PUBLIC_HDRS include ${PUBLIC_HDRS})
+configure_sources (PRIVATE_HDRS src ${PRIVATE_HDRS})
+configure_sources (GFLAGS_SRCS src ${GFLAGS_SRCS})
+
+# ----------------------------------------------------------------------------
+# output directories
+set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
+set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
+set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "lib")
+
+# ----------------------------------------------------------------------------
+# add library target
+include_directories (
+ "${PROJECT_BINARY_DIR}/include"
+ "${PROJECT_SOURCE_DIR}/include"
+ "${PROJECT_BINARY_DIR}/src"
+ "${PROJECT_SOURCE_DIR}/src"
+)
+
+if (WIN32)
+ add_definitions (-DGFLAGS_DLL_EXPORT)
+endif ()
+
+add_library (gflags ${GFLAGS_SRCS})
+
+# ----------------------------------------------------------------------------
+# installation
+install (TARGETS gflags DESTINATION lib)
+install (FILES ${PUBLIC_HDRS} DESTINATION include/gflags)
#ifndef GFLAGS_GFLAGS_H_
#define GFLAGS_GFLAGS_H_
+
+#if !defined(GFLAGS_DLL_DECL)
+# if defined(_MSC_VER)
+# if defined(GFLAGS_DLL_EXPORT)
+# define GFLAGS_DLL_DECL __declspec(dllexport)
+# else
+# define GFLAGS_DLL_DECL __declspec(dllimport)
+# endif
+# else
+# define GFLAGS_DLL_DECL
+# endif
+#endif
+
+// We always want to export defined variables, dll or no
+#if !defined(GFLAGS_DLL_DEFINE_FLAG)
+# if defined(_MSC_VER)
+# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllimport)
+# else
+# define GFLAGS_DLL_DEFINE_FLAG
+# endif
+#endif
+
+
#include <string>
#include <vector>
#include <gflags/gflags_declare.h> // IWYU pragma: export
-@ac_google_start_namespace@
-//
-// NOTE: all functions below MUST have an explicit 'extern' before
-// them. Our automated opensourcing tools use this as a signal to do
-// appropriate munging for windows, which needs to add GFLAGS_DLL_DECL.
-//
-#define GFLAGS_DLL_DECL /* rewritten to be non-empty in windows dir */
-#define GFLAGS_DLL_DEFINE_FLAG /* rewritten to be non-empty in windows dir */
+namespace @GFLAGS_NAMESPACE@ {
// --------------------------------------------------------------------
// Convenience macro for the registration of a flag validator
#define DEFINE_validator(name, validator) \
static const bool name##_validator_registered = \
- @ac_google_namespace@::RegisterFlagValidator(&FLAGS_##name, validator)
+ @GFLAGS_NAMESPACE@::RegisterFlagValidator(&FLAGS_##name, validator)
// --------------------------------------------------------------------
FlagSaver(const FlagSaver&); // no copying!
void operator=(const FlagSaver&);
}
-@ac_cv___attribute__unused@;
+@__ATTRIBUTE__UNUSED@;
// --------------------------------------------------------------------
// Some deprecated or hopefully-soon-to-be-deprecated functions.
extern const char kStrippedFlagHelp[];
-@ac_google_end_namespace@
+
+} // namespace @GFLAGS_NAMESPACE@
+
#ifndef SWIG // In swig, ignore the main flag declarations
#if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
// Need this construct to avoid the 'defined but not used' warning.
#define MAYBE_STRIPPED_HELP(txt) \
- (false ? (txt) : @ac_google_namespace@::kStrippedFlagHelp)
+ (false ? (txt) : @GFLAGS_NAMESPACE@::kStrippedFlagHelp)
#else
#define MAYBE_STRIPPED_HELP(txt) txt
#endif
/* We always want to export defined variables, dll or no */ \
GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
type FLAGS_no##name = FLAGS_nono##name; \
- static @ac_google_namespace@::FlagRegisterer o_##name( \
+ static @GFLAGS_NAMESPACE@::FlagRegisterer o_##name( \
#name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
&FLAGS_##name, &FLAGS_no##name); \
} \
DEFINE_VARIABLE(bool, B, name, val, txt)
#define DEFINE_int32(name, val, txt) \
- DEFINE_VARIABLE(@ac_google_namespace@::int32, I, \
+ DEFINE_VARIABLE(@GFLAGS_NAMESPACE@::int32, I, \
name, val, txt)
#define DEFINE_int64(name, val, txt) \
- DEFINE_VARIABLE(@ac_google_namespace@::int64, I64, \
+ DEFINE_VARIABLE(@GFLAGS_NAMESPACE@::int64, I64, \
name, val, txt)
#define DEFINE_uint64(name,val, txt) \
- DEFINE_VARIABLE(@ac_google_namespace@::uint64, U64, \
+ DEFINE_VARIABLE(@GFLAGS_NAMESPACE@::uint64, U64, \
name, val, txt)
#define DEFINE_double(name, val, txt) \
clstring* const FLAGS_no##name = ::fLS:: \
dont_pass0toDEFINE_string(s_##name[0].s, \
val); \
- static @ac_google_namespace@::FlagRegisterer o_##name( \
+ static @GFLAGS_NAMESPACE@::FlagRegisterer o_##name( \
#name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
#ifndef GFLAGS_COMPLETIONS_H_
#define GFLAGS_COMPLETIONS_H_
-// Annoying stuff for windows -- makes sure clients can import these functions
-//
-// NOTE: all functions below MUST have an explicit 'extern' before
-// them. Our automated opensourcing tools use this as a signal to do
-// appropriate munging for windows, which needs to add GFLAGS_DLL_DECL.
-//
-#define GFLAGS_DLL_DECL /* rewritten to be non-empty in windows dir */
-
-
-@ac_google_start_namespace@
+namespace @GFLAGS_NAMESPACE@ {
extern void HandleCommandLineCompletions(void);
-@ac_google_end_namespace@
+}
#endif // GFLAGS_COMPLETIONS_H_
#ifndef GFLAGS_DECLARE_H_
#define GFLAGS_DECLARE_H_
+
+#if !defined(GFLAGS_DLL_DECL)
+# if defined(_MSC_VER)
+# if defined(GFLAGS_DLL_EXPORT)
+# define GFLAGS_DLL_DECL __declspec(dllexport)
+# else
+# define GFLAGS_DLL_DECL __declspec(dllimport)
+# endif
+# else
+# define GFLAGS_DLL_DECL
+# endif
+#endif
+
+// We always want to import declared variables, dll or no
+#if !defined(GFLAGS_DLL_DECLARE_FLAG)
+# if defined(_MSC_VER)
+# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
+# else
+# define GFLAGS_DLL_DECLARE_FLAG
+# endif
+#endif
+
+
#include <string>
-#if @ac_cv_have_stdint_h@
+#if @HAVE_STDINT_H@
#include <stdint.h> // the normal place uint16_t is defined
#endif
-#if @ac_cv_have_systypes_h@
+#if @HAVE_SYS_TYPES_H@
#include <sys/types.h> // the normal place u_int16_t is defined
#endif
-#if @ac_cv_have_inttypes_h@
+#if @HAVE_INTTYPES_H@
#include <inttypes.h> // a third place for uint16_t or u_int16_t
#endif
-@ac_google_start_namespace@
-#if @ac_cv_have_uint16_t@ // the C99 format
-typedef int32_t int32;
+
+namespace @GFLAGS_NAMESPACE@ {
+
+#if @HAVE_uint16_t@ // the C99 format
+typedef int32_t int32;
typedef uint32_t uint32;
-typedef int64_t int64;
+typedef int64_t int64;
typedef uint64_t uint64;
-#elif @ac_cv_have_u_int16_t@ // the BSD format
-typedef int32_t int32;
+#elif @HAVE_u_int16_t@ // the BSD format
+typedef int32_t int32;
typedef u_int32_t uint32;
-typedef int64_t int64;
+typedef int64_t int64;
typedef u_int64_t uint64;
-#elif @ac_cv_have___int16@ // the windows (vc7) format
-typedef __int32 int32;
+#elif @HAVE___int16@ // the windows (vc7) format
+typedef __int32 int32;
typedef unsigned __int32 uint32;
-typedef __int64 int64;
+typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
-#error Do not know how to define a 32-bit integer quantity on your system
+# error Do not know how to define a 32-bit integer quantity on your system
#endif
-@ac_google_end_namespace@
+} // namespace @GFLAGS_NAMESPACE@
-#define GFLAGS_DLL_DECLARE_FLAG /* rewritten to be non-empty in windows dir */
namespace fLS {
// included). Save the current meaning now and use it in the macros.
typedef std::string clstring;
-}
+} // namespace fLS
+
#define DECLARE_VARIABLE(type, shorttype, name) \
/* We always want to import declared variables, dll or no */ \
DECLARE_VARIABLE(double, D, name)
#define DECLARE_string(name) \
- namespace fLS { \
- using ::fLS::clstring; \
+ /* We always want to import declared variables, dll or no */ \
+ namespace fLS { \
+ using ::fLS::clstring; \
extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
- } \
+ } \
using fLS::FLAGS_##name
+
#endif // GFLAGS_DECLARE_H_
-/* src/config.h.in. Generated from configure.ac by autoheader. */
+/* Generated from config.h.in during configuration using CMake. */
-/* Always the empty-string on non-windows systems. On windows, should be
- "__declspec(dllexport)". This way, when we compile the dll, we export our
- functions/classes. It's safe to define this here because config.h is only
- used internally, to compile the DLL, and every DLL source file #includes
- "config.h" before anything else. */
-#undef GFLAGS_DLL_DECL
+// ---------------------------------------------------------------------------
+// Meta-information
-/* Namespace for Google classes */
-#undef GOOGLE_NAMESPACE
+// Name of package.
+#define PACKAGE @PROJECT_NAME@
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
+// Define to the full name of this package.
+#define PACKAGE_NAME @PACKAGE_NAME@
-/* Define to 1 if you have the <fnmatch.h> header file. */
-#undef HAVE_FNMATCH_H
+// Define to the full name and version of this package.
+#define PACKAGE_STRING @PACKAGE_STRING@
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
+// Define to the one symbol short name of this package.
+#define PACKAGE_TARNAME @PACKAGE_TARNAME@
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
+// Define to the version of this package.
+#define PACKAGE_VERSION @PACKAGE_VERSION@
-/* define if the compiler implements namespaces */
-#undef HAVE_NAMESPACES
+// Version number of package.
+#define VERSION PACKAGE_VERSION
-/* Define if you have POSIX threads libraries and header files. */
-#undef HAVE_PTHREAD
+// Define to the address where bug reports for this package should be sent.
+#define PACKAGE_BUGREPORT @PACKAGE_BUGREPORT@
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
+// ---------------------------------------------------------------------------
+// Namespace for gflags symbols.
+#define GFLAGS_NAMESPACE @GFLAGS_NAMESPACE@
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
+// ---------------------------------------------------------------------------
+// Available system headers
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
+// Whether sources are compiled on a Windows system
+#define WINDOWS (defined(_WIN32) || defined(WIN32) || defined(_WINDOWS))
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
+// Define to 1 if you have the <fnmatch.h> header file.
+#define HAVE_FNMATCH_H @HAVE_FNMATCH_H@
-/* Define to 1 if you have the `strtoll' function. */
-#undef HAVE_STRTOLL
+// Define to 1 if you have the <inttypes.h> header file.
+#define HAVE_INTTYPES_H @HAVE_INTTYPES_H@
-/* Define to 1 if you have the `strtoq' function. */
-#undef HAVE_STRTOQ
+// Define to 1 if you have the <unistd.h> header file.
+#define HAVE_UNISTD_H @HAVE_UNISTD_H@
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
+// Define to 1 if you have the <sys/stat.h> header file.
+#define HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
+// Define to 1 if you have the strtoll function.
+#define HAVE_STRTOLL @HAVE_STRTOLL@
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
+// Define to 1 if you have the strtoq function.
+#define HAVE_STRTOQ @HAVE_STRTOQ@
-/* define if your compiler has __attribute__ */
-#undef HAVE___ATTRIBUTE__
+// Define to 1 if you have the <pthread.h> header file.
+#define HAVE_PTHREAD @HAVE_PTHREAD@
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#undef LT_OBJDIR
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to necessary symbol if this constant uses a non-standard name on
- your system. */
-#undef PTHREAD_CREATE_JOINABLE
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* the namespace where STL code like vector<> is defined */
-#undef STL_NAMESPACE
-
-/* Version number of package */
-#undef VERSION
-
-/* Stops putting the code inside the Google namespace */
-#undef _END_GOOGLE_NAMESPACE_
-
-/* Puts following code inside the Google namespace */
-#undef _START_GOOGLE_NAMESPACE_
+// ---------------------------------------------------------------------------
+// Path separator
+#ifndef PATH_SEPARATOR
+# define PATH_SEPARATOR '/'
+#endif
+// ---------------------------------------------------------------------------
+// Windows-specific definitions
+#if !defined(GFLAGS_DLL_DECL)
+# if defined(_MSC_VER)
+# if defined(GFLAGS_DLL_EXPORT)
+# define GFLAGS_DLL_DECL __declspec(dllexport)
+# else
+# define GFLAGS_DLL_DECL __declspec(dllimport)
+# endif
+# else
+# define GFLAGS_DLL_DECL
+# endif
+#endif
#if defined( __MINGW32__) || defined(__MINGW64__)
-#include "windows/port.h"
+# include "windows/port.h"
#endif
-
// This comes first to ensure we define __STDC_FORMAT_MACROS in time.
#include <config.h>
-#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
+#if HAVE_INTTYPES_H && !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS 1 // gcc requires this to get PRId64, etc.
#endif
#include <assert.h>
#include <ctype.h>
#include <errno.h>
-#ifdef HAVE_FNMATCH_H
+#if HAVE_FNMATCH_H
# include <fnmatch.h>
#endif
#include <stdarg.h> // For va_list and related operations
#include "util.h"
#ifndef PATH_SEPARATOR
-#define PATH_SEPARATOR '/'
+# define PATH_SEPARATOR '/'
#endif
"with that name. IMPORTANT: flags in this list that have "
"arguments MUST use the flag=value format");
-_START_GOOGLE_NAMESPACE_
+namespace GFLAGS_NAMESPACE {
using std::map;
using std::pair;
private:
friend class CommandLineFlag; // for many things, including Validate()
- friend class GOOGLE_NAMESPACE::FlagSaverImpl; // calls New()
+ friend class GFLAGS_NAMESPACE::FlagSaverImpl; // calls New()
friend class FlagRegistry; // checks value_buffer_ for flags_by_ptr_ map
template <typename T> friend T GetFromEnv(const char*, const char*, T);
friend bool TryParseLocked(const CommandLineFlag*, FlagValue*,
private:
// for SetFlagLocked() and setting flags_by_ptr_
friend class FlagRegistry;
- friend class GOOGLE_NAMESPACE::FlagSaverImpl; // for cloning the values
+ friend class GFLAGS_NAMESPACE::FlagSaverImpl; // for cloning the values
// set validate_fn
friend bool AddFlagValidator(const void*, ValidateFnProto);
static FlagRegistry* GlobalRegistry(); // returns a singleton registry
private:
- friend class GOOGLE_NAMESPACE::FlagSaverImpl; // reads all the flags in order to copy them
+ friend class GFLAGS_NAMESPACE::FlagSaverImpl; // reads all the flags in order to copy them
friend class CommandLineFlagParser; // for ValidateAllFlags
- friend void GOOGLE_NAMESPACE::GetAllFlags(vector<CommandLineFlagInfo>*);
+ friend void GFLAGS_NAMESPACE::GetAllFlags(vector<CommandLineFlagInfo>*);
// The map from name to flag, for FindFlagLocked().
typedef map<const char*, CommandLineFlag*, StringCmp> FlagMap;
// We try matching both against the full argv0 and basename(argv0)
if (glob == ProgramInvocationName() // small optimization
|| glob == ProgramInvocationShortName()
-#ifdef HAVE_FNMATCH_H
+#if HAVE_FNMATCH_H
|| fnmatch(glob.c_str(),
ProgramInvocationName(),
FNM_PATHNAME) == 0
}
const char* ProgramInvocationShortName() { // like the GNU libc fn
const char* slash = strrchr(argv0, '/');
-#ifdef OS_WINDOWS
+#ifdef WINDOWS
if (!slash) slash = strrchr(argv0, '\\');
#endif
return slash ? slash + 1 : argv0;
FlagRegistry::DeleteGlobalRegistry();
}
-_END_GOOGLE_NAMESPACE_
+
+} // namespace GFLAGS_NAMESPACE
using std::string;
using std::vector;
-#ifndef PATH_SEPARATOR
-#define PATH_SEPARATOR '/'
-#endif
DEFINE_string(tab_completion_word, "",
"If non-empty, HandleCommandLineCompletions() will hijack the "
DEFINE_int32(tab_completion_columns, 80,
"Number of columns to use in output for tab completion");
-_START_GOOGLE_NAMESPACE_
+
+namespace GFLAGS_NAMESPACE {
+
namespace {
// Function prototypes and Type forward declarations. Code may be
gflags_exitfunc(0);
}
-_END_GOOGLE_NAMESPACE_
+
+} // namespace GFLAGS_NAMESPACE
#include <gflags/gflags_completions.h>
#include "util.h"
-#ifndef PATH_SEPARATOR
-#define PATH_SEPARATOR '/'
-#endif
// The 'reporting' flags. They all call gflags_exitfunc().
DEFINE_bool(help, false,
DEFINE_bool(version, false,
"show version and build info and exit");
-_START_GOOGLE_NAMESPACE_
+
+namespace GFLAGS_NAMESPACE {
+
using std::string;
using std::vector;
}
}
-_END_GOOGLE_NAMESPACE_
+
+} // namespace GFLAGS_NAMESPACE
// A simple mutex wrapper, supporting locks and read-write locks.
// You should assume the locks are *not* re-entrant.
//
-// To use: you should define the following macros in your configure.ac:
-// ACX_PTHREAD
-// AC_RWLOCK
-// The latter is defined in ../autoconf.
-//
// This class is meant to be internal-only and should be wrapped by an
// internal namespace. Before you use this module, please give the
// name of your internal namespace for this module. Or, if you want
// weird to a Mutex's memory after it is destroyed, but for a
// static global variable, that's pretty safe.
-#ifndef GOOGLE_MUTEX_H_
-#define GOOGLE_MUTEX_H_
+#ifndef GFLAGS_MUTEX_H_
+#define GFLAGS_MUTEX_H_
#include "config.h" // to figure out pthreads support
# endif
# include <pthread.h>
typedef pthread_rwlock_t MutexType;
-#elif defined(HAVE_PTHREAD)
+#elif HAVE_PTHREAD
# include <pthread.h>
typedef pthread_mutex_t MutexType;
#else
#undef MUTEX_NAMESPACE
-#endif /* #define GOOGLE_MUTEX_H__ */
+#endif /* #define GFLAGS_MUTEX_H__ */
#include <assert.h>
#include <config.h>
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
#endif
#include <stdarg.h> // for va_*
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
#endif // for mkdir()
-_START_GOOGLE_NAMESPACE_
+
+namespace GFLAGS_NAMESPACE {
+
// This is used for unittests for death-testing. It is defined in gflags.cc.
extern GFLAGS_DLL_DECL void (*gflags_exitfunc)(int);
// Work properly if either strtoll or strtoq is on this system
-#ifdef HAVE_STRTOLL
-# define strto64 strtoll
-# define strtou64 strtoull
+#if HAVE_STRTOLL
+# define strto64 strtoll
+# define strtou64 strtoull
#elif HAVE_STRTOQ
-# define strto64 strtoq
-# define strtou64 strtouq
+# define strto64 strtoq
+# define strtou64 strtouq
#else
// Neither strtoll nor strtoq are defined. I hope strtol works!
-# define strto64 strtol
-# define strtou64 strtoul
+# define strto64 strtol
+# define strtou64 strtoul
#endif
// If we have inttypes.h, it will have defined PRId32/etc for us. If
// not, take our best guess.
#ifndef PRId32
-# define PRId32 "d"
+# define PRId32 "d"
#endif
#ifndef PRId64
-# define PRId64 "lld"
+# define PRId64 "lld"
#endif
#ifndef PRIu64
-# define PRIu64 "llu"
+# define PRIu64 "llu"
#endif
typedef signed char int8;
return output;
}
-_END_GOOGLE_NAMESPACE_
+
+} // namespace GFLAGS_NAMESPACE
+
#endif // GFLAGS_UTIL_H_