Commit 0baf4ab4 authored by Craig Silverstein's avatar Craig Silverstein

* Remove reference to InitGoogle (csilvers)

	* Remove superfluous friend declaration (mec)
	* Better reporting of current vs default value (handler)
	* Allow cleaning up of memory at program-exit (jmarantz)
	* Put CompileAssert in correct namespace (csilvers)


git-svn-id: https://gflags.googlecode.com/svn/trunk@43 6586e3c6-dcc4-952a-343f-ff74eb82781d
parent 84b18ac0
#! /bin/sh #! /bin/sh
# Attempt to guess a canonical system name. # Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Inc. # Free Software Foundation, Inc.
timestamp='2007-07-22' timestamp='2009-06-10'
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by # under the terms of the GNU General Public License as published by
...@@ -56,8 +56,8 @@ version="\ ...@@ -56,8 +56,8 @@ version="\
GNU config.guess ($timestamp) GNU config.guess ($timestamp)
Originally written by Per Bothner. Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
Free Software Foundation, Inc. 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
...@@ -170,7 +170,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ...@@ -170,7 +170,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax) arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ELF__ >/dev/null | grep -q __ELF__
then then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX? # Return netbsd for either. FIX?
...@@ -324,6 +324,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ...@@ -324,6 +324,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
case `/usr/bin/uname -p` in case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7; exit ;; sparc) echo sparc-icl-nx7; exit ;;
esac ;; esac ;;
s390x:SunOS:*:*)
echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4H:SunOS:5.*:*) sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;; exit ;;
...@@ -331,7 +334,20 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ...@@ -331,7 +334,20 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;; exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` eval $set_cc_for_build
SUN_ARCH="i386"
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH="x86_64"
fi
fi
echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;; exit ;;
sun4*:SunOS:6*:*) sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize # According to config.sub, this is the proper way to canonicalize
...@@ -532,7 +548,7 @@ EOF ...@@ -532,7 +548,7 @@ EOF
echo rs6000-ibm-aix3.2 echo rs6000-ibm-aix3.2
fi fi
exit ;; exit ;;
*:AIX:*:[45]) *:AIX:*:[456])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000 IBM_ARCH=rs6000
...@@ -640,7 +656,7 @@ EOF ...@@ -640,7 +656,7 @@ EOF
# => hppa64-hp-hpux11.23 # => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
grep __LP64__ >/dev/null grep -q __LP64__
then then
HP_ARCH="hppa2.0w" HP_ARCH="hppa2.0w"
else else
...@@ -796,13 +812,19 @@ EOF ...@@ -796,13 +812,19 @@ EOF
x86) x86)
echo i586-pc-interix${UNAME_RELEASE} echo i586-pc-interix${UNAME_RELEASE}
exit ;; exit ;;
EM64T | authenticamd) EM64T | authenticamd | genuineintel)
echo x86_64-unknown-interix${UNAME_RELEASE} echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;; exit ;;
IA64)
echo ia64-unknown-interix${UNAME_RELEASE}
exit ;;
esac ;; esac ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks echo i${UNAME_MACHINE}-pc-mks
exit ;; exit ;;
8664:Windows_NT:*)
echo x86_64-pc-mks
exit ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*) i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem? # How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
...@@ -833,7 +855,14 @@ EOF ...@@ -833,7 +855,14 @@ EOF
echo ${UNAME_MACHINE}-pc-minix echo ${UNAME_MACHINE}-pc-minix
exit ;; exit ;;
arm*:Linux:*:*) arm*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
fi
exit ;; exit ;;
avr32*:Linux:*:*) avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-gnu
...@@ -856,40 +885,17 @@ EOF ...@@ -856,40 +885,17 @@ EOF
m68*:Linux:*:*) m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;; exit ;;
mips:Linux:*:*) mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips
#undef mipsel
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mipsel
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips
#else
CPU=
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^CPU/{
s: ::g
p
}'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
mips64:Linux:*:*)
eval $set_cc_for_build eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c sed 's/^ //' << EOF >$dummy.c
#undef CPU #undef CPU
#undef mips64 #undef ${UNAME_MACHINE}
#undef mips64el #undef ${UNAME_MACHINE}el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mips64el CPU=${UNAME_MACHINE}el
#else #else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips64 CPU=${UNAME_MACHINE}
#else #else
CPU= CPU=
#endif #endif
...@@ -921,10 +927,13 @@ EOF ...@@ -921,10 +927,13 @@ EOF
EV67) UNAME_MACHINE=alphaev67 ;; EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;; EV68*) UNAME_MACHINE=alphaev68 ;;
esac esac
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit ;; exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*) parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level # Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
...@@ -954,8 +963,8 @@ EOF ...@@ -954,8 +963,8 @@ EOF
x86_64:Linux:*:*) x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu echo x86_64-unknown-linux-gnu
exit ;; exit ;;
xtensa:Linux:*:*) xtensa*:Linux:*:*)
echo xtensa-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;; exit ;;
i*86:Linux:*:*) i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so # The BFD linker knows what the default object file format is, so
...@@ -972,17 +981,6 @@ EOF ...@@ -972,17 +981,6 @@ EOF
elf32-i386) elf32-i386)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;; ;;
a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit ;;
coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit ;;
"")
# Either a pre-BFD a.out linker (linux-gnuoldld) or
# one that does not give us useful --help.
echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
exit ;;
esac esac
# Determine whether the default compiler is a.out or elf # Determine whether the default compiler is a.out or elf
eval $set_cc_for_build eval $set_cc_for_build
...@@ -1048,7 +1046,7 @@ EOF ...@@ -1048,7 +1046,7 @@ EOF
i*86:syllable:*:*) i*86:syllable:*:*)
echo ${UNAME_MACHINE}-pc-syllable echo ${UNAME_MACHINE}-pc-syllable
exit ;; exit ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
echo i386-unknown-lynxos${UNAME_RELEASE} echo i386-unknown-lynxos${UNAME_RELEASE}
exit ;; exit ;;
i*86:*DOS:*:*) i*86:*DOS:*:*)
...@@ -1092,8 +1090,11 @@ EOF ...@@ -1092,8 +1090,11 @@ EOF
pc:*:*:*) pc:*:*:*)
# Left here for compatibility: # Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about # uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i386. # the processor, so we play safe by assuming i586.
echo i386-pc-msdosdjgpp # Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configury will decide that
# this is a cross-build.
echo i586-pc-msdosdjgpp
exit ;; exit ;;
Intel:Mach:3*:*) Intel:Mach:3*:*)
echo i386-pc-mach3 echo i386-pc-mach3
...@@ -1131,6 +1132,16 @@ EOF ...@@ -1131,6 +1132,16 @@ EOF
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;; && { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE} echo m68k-unknown-lynxos${UNAME_RELEASE}
exit ;; exit ;;
...@@ -1143,7 +1154,7 @@ EOF ...@@ -1143,7 +1154,7 @@ EOF
rs6000:LynxOS:2.*:*) rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE} echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit ;; exit ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE} echo powerpc-unknown-lynxos${UNAME_RELEASE}
exit ;; exit ;;
SM[BE]S:UNIX_SV:*:*) SM[BE]S:UNIX_SV:*:*)
...@@ -1206,6 +1217,9 @@ EOF ...@@ -1206,6 +1217,9 @@ EOF
BePC:BeOS:*:*) # BeOS running on Intel PC compatible. BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos echo i586-pc-beos
exit ;; exit ;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
SX-4:SUPER-UX:*:*) SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE} echo sx4-nec-superux${UNAME_RELEASE}
exit ;; exit ;;
...@@ -1314,6 +1328,9 @@ EOF ...@@ -1314,6 +1328,9 @@ EOF
i*86:rdos:*:*) i*86:rdos:*:*)
echo ${UNAME_MACHINE}-pc-rdos echo ${UNAME_MACHINE}-pc-rdos
exit ;; exit ;;
i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros
exit ;;
esac esac
#echo '(No uname command or uname output not recognized.)' 1>&2 #echo '(No uname command or uname output not recognized.)' 1>&2
...@@ -1474,9 +1491,9 @@ This script, last modified $timestamp, has failed to recognize ...@@ -1474,9 +1491,9 @@ This script, last modified $timestamp, has failed to recognize
the operating system you are using. It is advised that you the operating system you are using. It is advised that you
download the most up to date version of the config scripts from download the most up to date version of the config scripts from
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
and and
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
If the version you run ($0) is already up to date, please If the version you run ($0) is already up to date, please
send the following data and any information you think might be send the following data and any information you think might be
......
#! /bin/sh #! /bin/sh
# Configuration validation subroutine script. # Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Inc. # Free Software Foundation, Inc.
timestamp='2007-06-28' timestamp='2009-06-11'
# This file is (in principle) common to ALL GNU software. # This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software # The presence of a machine in this file suggests that SOME GNU software
...@@ -72,8 +72,8 @@ Report bugs and patches to <config-patches@gnu.org>." ...@@ -72,8 +72,8 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\ version="\
GNU config.sub ($timestamp) GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
Free Software Foundation, Inc. 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
...@@ -122,6 +122,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` ...@@ -122,6 +122,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*) storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
...@@ -152,6 +153,9 @@ case $os in ...@@ -152,6 +153,9 @@ case $os in
os= os=
basic_machine=$1 basic_machine=$1
;; ;;
-bluegene*)
os=-cnk
;;
-sim | -cisco | -oki | -wec | -winbond) -sim | -cisco | -oki | -wec | -winbond)
os= os=
basic_machine=$1 basic_machine=$1
...@@ -249,13 +253,16 @@ case $basic_machine in ...@@ -249,13 +253,16 @@ case $basic_machine in
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \ | i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \ | ip2k | iq2000 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \ | m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep \ | maxq | mb | microblaze | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \ | mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \ | mips16 \
| mips64 | mips64el \ | mips64 | mips64el \
| mips64vr | mips64vrel \ | mips64octeon | mips64octeonel \
| mips64orion | mips64orionel \ | mips64orion | mips64orionel \
| mips64r5900 | mips64r5900el \
| mips64vr | mips64vrel \
| mips64vr4100 | mips64vr4100el \ | mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \ | mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \ | mips64vr5000 | mips64vr5000el \
...@@ -268,6 +275,7 @@ case $basic_machine in ...@@ -268,6 +275,7 @@ case $basic_machine in
| mipsisa64sr71k | mipsisa64sr71kel \ | mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \ | mipstx39 | mipstx39el \
| mn10200 | mn10300 \ | mn10200 | mn10300 \
| moxie \
| mt \ | mt \
| msp430 \ | msp430 \
| nios | nios2 \ | nios | nios2 \
...@@ -277,7 +285,7 @@ case $basic_machine in ...@@ -277,7 +285,7 @@ case $basic_machine in
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \ | pyramid \
| score \ | score \
| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \ | sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
...@@ -286,7 +294,7 @@ case $basic_machine in ...@@ -286,7 +294,7 @@ case $basic_machine in
| v850 | v850e \ | v850 | v850e \
| we32k \ | we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k) | z8k | z80)
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
;; ;;
m6811 | m68hc11 | m6812 | m68hc12) m6811 | m68hc11 | m6812 | m68hc12)
...@@ -329,14 +337,17 @@ case $basic_machine in ...@@ -329,14 +337,17 @@ case $basic_machine in
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \ | i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \ | ip2k-* | iq2000-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \ | m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \ | mips16-* \
| mips64-* | mips64el-* \ | mips64-* | mips64el-* \
| mips64vr-* | mips64vrel-* \ | mips64octeon-* | mips64octeonel-* \
| mips64orion-* | mips64orionel-* \ | mips64orion-* | mips64orionel-* \
| mips64r5900-* | mips64r5900el-* \
| mips64vr-* | mips64vrel-* \
| mips64vr4100-* | mips64vr4100el-* \ | mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \ | mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \ | mips64vr5000-* | mips64vr5000el-* \
...@@ -358,20 +369,24 @@ case $basic_machine in ...@@ -358,20 +369,24 @@ case $basic_machine in
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \ | pyramid-* \
| romp-* | rs6000-* \ | romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \ | sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \ | tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
| tron-* \ | tron-* \
| v850-* | v850e-* | vax-* \ | v850-* | v850e-* | vax-* \
| we32k-* \ | we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa-* \ | xstormy16-* | xtensa*-* \
| ymp-* \ | ymp-* \
| z8k-*) | z8k-* | z80-*)
;;
# Recognize the basic CPU types without company name, with glob match.
xtensa*)
basic_machine=$basic_machine-unknown
;; ;;
# Recognize the various machine names and aliases which stand # Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS. # for a CPU type and a company and sometimes even an OS.
...@@ -435,6 +450,10 @@ case $basic_machine in ...@@ -435,6 +450,10 @@ case $basic_machine in
basic_machine=m68k-apollo basic_machine=m68k-apollo
os=-bsd os=-bsd
;; ;;
aros)
basic_machine=i386-pc
os=-aros
;;
aux) aux)
basic_machine=m68k-apple basic_machine=m68k-apple
os=-aux os=-aux
...@@ -443,10 +462,26 @@ case $basic_machine in ...@@ -443,10 +462,26 @@ case $basic_machine in
basic_machine=ns32k-sequent basic_machine=ns32k-sequent
os=-dynix os=-dynix
;; ;;
blackfin)
basic_machine=bfin-unknown
os=-linux
;;
blackfin-*)
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
bluegene*)
basic_machine=powerpc-ibm
os=-cnk
;;
c90) c90)
basic_machine=c90-cray basic_machine=c90-cray
os=-unicos os=-unicos
;; ;;
cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
convex-c1) convex-c1)
basic_machine=c1-convex basic_machine=c1-convex
os=-bsd os=-bsd
...@@ -514,6 +549,10 @@ case $basic_machine in ...@@ -514,6 +549,10 @@ case $basic_machine in
basic_machine=m88k-motorola basic_machine=m88k-motorola
os=-sysv3 os=-sysv3
;; ;;
dicos)
basic_machine=i686-pc
os=-dicos
;;
djgpp) djgpp)
basic_machine=i586-pc basic_machine=i586-pc
os=-msdosdjgpp os=-msdosdjgpp
...@@ -668,6 +707,14 @@ case $basic_machine in ...@@ -668,6 +707,14 @@ case $basic_machine in
basic_machine=m68k-isi basic_machine=m68k-isi
os=-sysv os=-sysv
;; ;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
m88k-omron*) m88k-omron*)
basic_machine=m88k-omron basic_machine=m88k-omron
;; ;;
...@@ -813,6 +860,14 @@ case $basic_machine in ...@@ -813,6 +860,14 @@ case $basic_machine in
basic_machine=i860-intel basic_machine=i860-intel
os=-osf os=-osf
;; ;;
parisc)
basic_machine=hppa-unknown
os=-linux
;;
parisc-*)
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
pbd) pbd)
basic_machine=sparc-tti basic_machine=sparc-tti
;; ;;
...@@ -1021,6 +1076,10 @@ case $basic_machine in ...@@ -1021,6 +1076,10 @@ case $basic_machine in
basic_machine=tic6x-unknown basic_machine=tic6x-unknown
os=-coff os=-coff
;; ;;
tile*)
basic_machine=tile-unknown
os=-linux-gnu
;;
tx39) tx39)
basic_machine=mipstx39-unknown basic_machine=mipstx39-unknown
;; ;;
...@@ -1096,6 +1155,10 @@ case $basic_machine in ...@@ -1096,6 +1155,10 @@ case $basic_machine in
basic_machine=z8k-unknown basic_machine=z8k-unknown
os=-sim os=-sim
;; ;;
z80-*-coff)
basic_machine=z80-unknown
os=-sim
;;
none) none)
basic_machine=none-none basic_machine=none-none
os=-none os=-none
...@@ -1134,7 +1197,7 @@ case $basic_machine in ...@@ -1134,7 +1197,7 @@ case $basic_machine in
we32k) we32k)
basic_machine=we32k-att basic_machine=we32k-att
;; ;;
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown basic_machine=sh-unknown
;; ;;
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
...@@ -1204,10 +1267,11 @@ case $os in ...@@ -1204,10 +1267,11 @@ case $os in
# Each alternative MUST END IN A *, to match a version number. # Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4. # -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -kopensolaris* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* \ | -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
...@@ -1216,7 +1280,7 @@ case $os in ...@@ -1216,7 +1280,7 @@ case $os in
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \ | -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \ | -uxpv* | -beos* | -mpeix* | -udk* \
...@@ -1356,6 +1420,9 @@ case $os in ...@@ -1356,6 +1420,9 @@ case $os in
-zvmoe) -zvmoe)
os=-zvmoe os=-zvmoe
;; ;;
-dicos*)
os=-dicos
;;
-none) -none)
;; ;;
*) *)
...@@ -1553,7 +1620,7 @@ case $basic_machine in ...@@ -1553,7 +1620,7 @@ case $basic_machine in
-sunos*) -sunos*)
vendor=sun vendor=sun
;; ;;
-aix*) -cnk*|-aix*)
vendor=ibm vendor=ibm
;; ;;
-beos*) -beos*)
......
...@@ -143,6 +143,7 @@ ...@@ -143,6 +143,7 @@
# define PRIu64 "llu" # define PRIu64 "llu"
#endif #endif
typedef signed char int8;
typedef unsigned char uint8; typedef unsigned char uint8;
// Special flags, type 1: the 'recursive' flags. They set another flag's val. // Special flags, type 1: the 'recursive' flags. They set another flag's val.
...@@ -223,7 +224,7 @@ static void ReportError(DieWhenReporting should_die, const char* format, ...) { ...@@ -223,7 +224,7 @@ static void ReportError(DieWhenReporting should_die, const char* format, ...) {
class CommandLineFlag; class CommandLineFlag;
class FlagValue { class FlagValue {
public: public:
FlagValue(void* valbuf, const char* type); FlagValue(void* valbuf, const char* type, bool transfer_ownership_of_value);
~FlagValue(); ~FlagValue();
bool ParseFrom(const char* spec); bool ParseFrom(const char* spec);
...@@ -259,7 +260,8 @@ class FlagValue { ...@@ -259,7 +260,8 @@ class FlagValue {
bool Validate(const char* flagname, ValidateFnProto validate_fn_proto) const; bool Validate(const char* flagname, ValidateFnProto validate_fn_proto) const;
void* value_buffer_; // points to the buffer holding our data void* value_buffer_; // points to the buffer holding our data
uint32 type_; // how to interpret value_ int8 type_; // how to interpret value_
bool owns_value_; // whether to free value on destruct
FlagValue(const FlagValue&); // no copying! FlagValue(const FlagValue&); // no copying!
void operator=(const FlagValue&); void operator=(const FlagValue&);
...@@ -272,7 +274,10 @@ class FlagValue { ...@@ -272,7 +274,10 @@ class FlagValue {
#define OTHER_VALUE_AS(fv, type) *reinterpret_cast<type*>(fv.value_buffer_) #define OTHER_VALUE_AS(fv, type) *reinterpret_cast<type*>(fv.value_buffer_)
#define SET_VALUE_AS(type, value) VALUE_AS(type) = (value) #define SET_VALUE_AS(type, value) VALUE_AS(type) = (value)
FlagValue::FlagValue(void* valbuf, const char* type) : value_buffer_(valbuf) { FlagValue::FlagValue(void* valbuf, const char* type,
bool transfer_ownership_of_value)
: value_buffer_(valbuf),
owns_value_(transfer_ownership_of_value) {
for (type_ = 0; type_ <= FV_MAX_INDEX; ++type_) { for (type_ = 0; type_ <= FV_MAX_INDEX; ++type_) {
if (!strcmp(type, TypeName())) { if (!strcmp(type, TypeName())) {
break; break;
...@@ -282,6 +287,9 @@ FlagValue::FlagValue(void* valbuf, const char* type) : value_buffer_(valbuf) { ...@@ -282,6 +287,9 @@ FlagValue::FlagValue(void* valbuf, const char* type) : value_buffer_(valbuf) {
} }
FlagValue::~FlagValue() { FlagValue::~FlagValue() {
if (!owns_value_) {
return;
}
switch (type_) { switch (type_) {
case FV_BOOL: delete reinterpret_cast<bool*>(value_buffer_); break; case FV_BOOL: delete reinterpret_cast<bool*>(value_buffer_); break;
case FV_INT32: delete reinterpret_cast<int32*>(value_buffer_); break; case FV_INT32: delete reinterpret_cast<int32*>(value_buffer_); break;
...@@ -445,12 +453,12 @@ bool FlagValue::Equal(const FlagValue& x) const { ...@@ -445,12 +453,12 @@ bool FlagValue::Equal(const FlagValue& x) const {
FlagValue* FlagValue::New() const { FlagValue* FlagValue::New() const {
const char *type = TypeName(); const char *type = TypeName();
switch (type_) { switch (type_) {
case FV_BOOL: return new FlagValue(new bool(false), type); case FV_BOOL: return new FlagValue(new bool(false), type, true);
case FV_INT32: return new FlagValue(new int32(0), type); case FV_INT32: return new FlagValue(new int32(0), type, true);
case FV_INT64: return new FlagValue(new int64(0), type); case FV_INT64: return new FlagValue(new int64(0), type, true);
case FV_UINT64: return new FlagValue(new uint64(0), type); case FV_UINT64: return new FlagValue(new uint64(0), type, true);
case FV_DOUBLE: return new FlagValue(new double(0.0), type); case FV_DOUBLE: return new FlagValue(new double(0.0), type, true);
case FV_STRING: return new FlagValue(new string, type); case FV_STRING: return new FlagValue(new string, type, true);
default: assert(false); return NULL; // unknown type default: assert(false); return NULL; // unknown type
} }
} }
...@@ -521,7 +529,6 @@ class CommandLineFlag { ...@@ -521,7 +529,6 @@ class CommandLineFlag {
// for SetFlagLocked() and setting flags_by_ptr_ // for SetFlagLocked() and setting flags_by_ptr_
friend class FlagRegistry; friend class FlagRegistry;
friend class GOOGLE_NAMESPACE::FlagSaverImpl; // for cloning the values friend class GOOGLE_NAMESPACE::FlagSaverImpl; // for cloning the values
friend bool GetCommandLineOption(const char*, string*, bool*);
// set validate_fn // set validate_fn
friend bool AddFlagValidator(const void*, ValidateFnProto); friend bool AddFlagValidator(const void*, ValidateFnProto);
...@@ -640,6 +647,17 @@ struct StringCmp { // Used by the FlagRegistry map class to compare char*'s ...@@ -640,6 +647,17 @@ struct StringCmp { // Used by the FlagRegistry map class to compare char*'s
class FlagRegistry { class FlagRegistry {
public: public:
FlagRegistry() { } FlagRegistry() { }
~FlagRegistry() {
for (FlagMap::iterator p = flags_.begin(), e = flags_.end(); p != e; ++p) {
CommandLineFlag* flag = p->second;
delete flag;
}
}
static void DeleteGlobalRegistry() {
delete global_registry_;
global_registry_ = NULL;
}
void Lock() { lock_.Lock(); } void Lock() { lock_.Lock(); }
void Unlock() { lock_.Unlock(); } void Unlock() { lock_.Unlock(); }
...@@ -1342,7 +1360,7 @@ T GetFromEnv(const char *varname, const char* type, T dflt) { ...@@ -1342,7 +1360,7 @@ T GetFromEnv(const char *varname, const char* type, T dflt) {
const char* const valstr = getenv(varname); const char* const valstr = getenv(varname);
if (!valstr) if (!valstr)
return dflt; return dflt;
FlagValue ifv(new T, type); FlagValue ifv(new T, type, true);
if (!ifv.ParseFrom(valstr)) if (!ifv.ParseFrom(valstr))
ReportError(DIE, "ERROR: error parsing env variable '%s' with value '%s'\n", ReportError(DIE, "ERROR: error parsing env variable '%s' with value '%s'\n",
varname, valstr); varname, valstr);
...@@ -1400,8 +1418,8 @@ FlagRegisterer::FlagRegisterer(const char* name, const char* type, ...@@ -1400,8 +1418,8 @@ FlagRegisterer::FlagRegisterer(const char* name, const char* type,
// components, so we get rid of those, if any. // components, so we get rid of those, if any.
if (strchr(type, ':')) if (strchr(type, ':'))
type = strrchr(type, ':') + 1; type = strrchr(type, ':') + 1;
FlagValue* current = new FlagValue(current_storage, type); FlagValue* current = new FlagValue(current_storage, type, false);
FlagValue* defvalue = new FlagValue(defvalue_storage, type); FlagValue* defvalue = new FlagValue(defvalue_storage, type, false);
// Importantly, flag_ will never be deleted, so storage is always good. // Importantly, flag_ will never be deleted, so storage is always good.
CommandLineFlag* flag = new CommandLineFlag(name, help, filename, CommandLineFlag* flag = new CommandLineFlag(name, help, filename,
current, defvalue); current, defvalue);
...@@ -1933,4 +1951,8 @@ uint32 ReparseCommandLineNonHelpFlags() { ...@@ -1933,4 +1951,8 @@ uint32 ReparseCommandLineNonHelpFlags() {
return retval; return retval;
} }
void ShutDownCommandLineFlags() {
FlagRegistry::DeleteGlobalRegistry();
}
_END_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_
...@@ -130,7 +130,7 @@ typedef unsigned __int64 uint64; ...@@ -130,7 +130,7 @@ typedef unsigned __int64 uint64;
// The validation function should return true if the flag value is valid, and // The validation function should return true if the flag value is valid, and
// false otherwise. If the function returns false for the new setting of the // false otherwise. If the function returns false for the new setting of the
// flag, the flag will retain its current value. If it returns false for the // flag, the flag will retain its current value. If it returns false for the
// default value, InitGoogle will die. // default value, ParseCommandLineFlags() will die.
// //
// This function is safe to call at global construct time (as in the // This function is safe to call at global construct time (as in the
// example below). // example below).
...@@ -385,6 +385,16 @@ extern void AllowCommandLineReparsing(); ...@@ -385,6 +385,16 @@ extern void AllowCommandLineReparsing();
// since their flags are not registered until they are loaded. // since their flags are not registered until they are loaded.
extern uint32 ReparseCommandLineNonHelpFlags(); extern uint32 ReparseCommandLineNonHelpFlags();
// Clean up memory allocated by flags. This is only needed to reduce
// the quantity of "potentially leaked" reports emitted by memory
// debugging tools such as valgrind. It is not required for normal
// operation, or for the perftools heap-checker. It must only be called
// when the process is about to exit, and all threads that might
// access flags are quiescent. Referencing flags after this is called
// will have unexpected consequences. This is not safe to run when
// multiple threads might be running: the function is thread-hostile.
extern void ShutDownCommandLineFlags();
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Now come the command line flag declaration/definition macros that // Now come the command line flag declaration/definition macros that
...@@ -497,7 +507,7 @@ bool IsBoolFlag(bool from); ...@@ -497,7 +507,7 @@ bool IsBoolFlag(bool from);
#define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name) #define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name)
#define DEFINE_bool(name, val, txt) \ #define DEFINE_bool(name, val, txt) \
namespace fLB { \ namespace fLB { \
typedef CompileAssert FLAG_##name##_value_is_not_a_bool[ \ typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \
(sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \ (sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \
} \ } \
DEFINE_VARIABLE(bool, B, name, val, txt) DEFINE_VARIABLE(bool, B, name, val, txt)
......
...@@ -109,6 +109,17 @@ static void AddString(const string& s, ...@@ -109,6 +109,17 @@ static void AddString(const string& s,
*chars_in_line += slen; *chars_in_line += slen;
} }
static string PrintStringFlagsWithQuotes(const CommandLineFlagInfo& flag,
const string& text, bool current) {
const char* c_string = (current ? flag.current_value.c_str() :
flag.default_value.c_str());
if (strcmp(flag.type.c_str(), "string") == 0) { // add quotes for strings
return text + ": \"" + c_string + "\"";
} else {
return text + ": " + c_string;
}
}
// Create a descriptive string for a flag. // Create a descriptive string for a flag.
// Goes to some trouble to make pretty line breaks. // Goes to some trouble to make pretty line breaks.
string DescribeOneFlag(const CommandLineFlagInfo& flag) { string DescribeOneFlag(const CommandLineFlagInfo& flag) {
...@@ -159,22 +170,14 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) { ...@@ -159,22 +170,14 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) {
// Append data type // Append data type
AddString(string("type: ") + flag.type, &final_string, &chars_in_line); AddString(string("type: ") + flag.type, &final_string, &chars_in_line);
// Append the effective default value (i.e., the value that the flag // The listed default value will be the actual default from the flag
// will have after the command line is parsed if the flag is not // definition in the originating source file, unless the value has
// specified on the command line), which may be different from the // subsequently been modified using SetCommandLineOptionWithMode() with mode
// stored default value. This would happen if the value of the flag // SET_FLAGS_DEFAULT, or by setting FLAGS_foo = bar before initializing.
// was modified before the command line was parsed. (Unless the AddString(PrintStringFlagsWithQuotes(flag, "default", false), &final_string,
// value was modified using SetCommandLineOptionWithMode() with mode &chars_in_line);
// SET_FLAGS_DEFAULT.) if (!flag.is_default) {
// Note that we are assuming this code is being executed because a help AddString(PrintStringFlagsWithQuotes(flag, "currently", true),
// request was just parsed from the command line, in which case the
// printed value is indeed the effective default, as long as no value
// for the flag was parsed from the command line before "--help".
if (strcmp(flag.type.c_str(), "string") == 0) { // add quotes for strings
AddString(string("default: \"") + flag.current_value + string("\""),
&final_string, &chars_in_line);
} else {
AddString(string("default: ") + flag.current_value,
&final_string, &chars_in_line); &final_string, &chars_in_line);
} }
......
...@@ -948,7 +948,7 @@ TEST(ShowUsageWithFlagsRestrictTest, BaseTest) { ...@@ -948,7 +948,7 @@ TEST(ShowUsageWithFlagsRestrictTest, BaseTest) {
} }
// Note: all these argv-based tests depend on SetArgv being called // Note: all these argv-based tests depend on SetArgv being called
// before InitGoogle() in main(), below. // before ParseCommandLineFlags() in Main(), below.
TEST(GetArgvsTest, BaseTest) { TEST(GetArgvsTest, BaseTest) {
vector<string> argvs = GetArgvs(); vector<string> argvs = GetArgvs();
EXPECT_EQ(4, argvs.size()); EXPECT_EQ(4, argvs.size());
...@@ -982,7 +982,7 @@ TEST(ProgramInvocationShortNameTest, BaseTest) { ...@@ -982,7 +982,7 @@ TEST(ProgramInvocationShortNameTest, BaseTest) {
EXPECT_STREQ("gflags_unittest", ProgramInvocationShortName()); EXPECT_STREQ("gflags_unittest", ProgramInvocationShortName());
} }
TEST(ProgramUsageTest, BaseTest) { // Depends on 1st arg to InitGoogle in main TEST(ProgramUsageTest, BaseTest) { // Depends on arg to SetUsageMessage()
EXPECT_STREQ("/test/argv/for/gflags_unittest: " EXPECT_STREQ("/test/argv/for/gflags_unittest: "
"<useless flag> [...]\nDoes something useless.\n", "<useless flag> [...]\nDoes something useless.\n",
ProgramUsage()); ProgramUsage());
...@@ -1206,7 +1206,7 @@ TEST(DeprecatedFunctionsTest, ReadFromFlagsFileFailure) { ...@@ -1206,7 +1206,7 @@ TEST(DeprecatedFunctionsTest, ReadFromFlagsFileFailure) {
EXPECT_EQ(-22, FLAGS_test_int32); // the -21 from the flagsfile didn't take EXPECT_EQ(-22, FLAGS_test_int32); // the -21 from the flagsfile didn't take
} }
TEST(FlagsSetBeforeInitGoogleTest, TryFromEnv) { TEST(FlagsSetBeforeInitTest, TryFromEnv) {
EXPECT_EQ("pre-set", FLAGS_test_tryfromenv); EXPECT_EQ("pre-set", FLAGS_test_tryfromenv);
} }
...@@ -1538,7 +1538,7 @@ TEST(FlagsValidator, FlagSaver) { ...@@ -1538,7 +1538,7 @@ TEST(FlagsValidator, FlagSaver) {
static int Main(int argc, char **argv) { static int Main(int argc, char **argv) {
// We need to call SetArgv before InitGoogle, so our "test" argv will // We need to call SetArgv before SetUsage, so our "test" argv will
// win out over this executable's real argv. That makes running this // win out over this executable's real argv. That makes running this
// test with a real --help flag kinda annoying, unfortunately. // test with a real --help flag kinda annoying, unfortunately.
const char* test_argv[] = { "/test/argv/for/gflags_unittest", const char* test_argv[] = { "/test/argv/for/gflags_unittest",
...@@ -1549,8 +1549,8 @@ static int Main(int argc, char **argv) { ...@@ -1549,8 +1549,8 @@ static int Main(int argc, char **argv) {
string usage_message = (string(GetArgv0()) + string usage_message = (string(GetArgv0()) +
": <useless flag> [...]\nDoes something useless.\n"); ": <useless flag> [...]\nDoes something useless.\n");
// We test setting tryfromenv manually, and making sure initgoogle still // We test setting tryfromenv manually, and making sure
// evaluates it. // ParseCommandLineFlags still evaluates it.
FLAGS_tryfromenv = "test_tryfromenv"; FLAGS_tryfromenv = "test_tryfromenv";
setenv("FLAGS_test_tryfromenv", "pre-set", 1); setenv("FLAGS_test_tryfromenv", "pre-set", 1);
...@@ -1584,5 +1584,7 @@ static int Main(int argc, char **argv) { ...@@ -1584,5 +1584,7 @@ static int Main(int argc, char **argv) {
_END_GOOGLE_NAMESPACE_ _END_GOOGLE_NAMESPACE_
int main(int argc, char** argv) { int main(int argc, char** argv) {
return GOOGLE_NAMESPACE::Main(argc, argv); const int exit_status = GOOGLE_NAMESPACE::Main(argc, argv);
GOOGLE_NAMESPACE::ShutDownCommandLineFlags();
return exit_status;
} }
...@@ -118,7 +118,12 @@ Expect $LINENO 1 "/gflags_reporting.cc" "" --help ...@@ -118,7 +118,12 @@ Expect $LINENO 1 "/gflags_reporting.cc" "" --help
Expect $LINENO 1 \ Expect $LINENO 1 \
"-changed_bool1 (changed) type: bool default: true" "" --help "-changed_bool1 (changed) type: bool default: true" "" --help
Expect $LINENO 1 \ Expect $LINENO 1 \
"-changed_bool2 (changed) type: bool default: true" "" --help "-changed_bool2 (changed) type: bool default: false currently: true" "" \
--help
# And on the command-line, too
Expect $LINENO 1 \
"-changeable_string_var () type: string default: \"1\" currently: \"2\"" \
"" --changeable_string_var 2 --help
# --nohelp and --help=false should be as if we didn't say anything # --nohelp and --help=false should be as if we didn't say anything
Expect $LINENO 0 "PASS" "" --nohelp Expect $LINENO 0 "PASS" "" --nohelp
......
...@@ -80,6 +80,10 @@ ...@@ -80,6 +80,10 @@
/* define if your compiler has __attribute__ */ /* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__ #undef HAVE___ATTRIBUTE__
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */ /* Name of package */
#undef PACKAGE #undef PACKAGE
......
...@@ -153,7 +153,7 @@ typedef unsigned __int64 uint64; ...@@ -153,7 +153,7 @@ typedef unsigned __int64 uint64;
// The validation function should return true if the flag value is valid, and // The validation function should return true if the flag value is valid, and
// false otherwise. If the function returns false for the new setting of the // false otherwise. If the function returns false for the new setting of the
// flag, the flag will retain its current value. If it returns false for the // flag, the flag will retain its current value. If it returns false for the
// default value, InitGoogle will die. // default value, ParseCommandLineFlags() will die.
// //
// This function is safe to call at global construct time (as in the // This function is safe to call at global construct time (as in the
// example below). // example below).
...@@ -408,6 +408,16 @@ extern GFLAGS_DLL_DECL void AllowCommandLineReparsing(); ...@@ -408,6 +408,16 @@ extern GFLAGS_DLL_DECL void AllowCommandLineReparsing();
// since their flags are not registered until they are loaded. // since their flags are not registered until they are loaded.
extern GFLAGS_DLL_DECL uint32 ReparseCommandLineNonHelpFlags(); extern GFLAGS_DLL_DECL uint32 ReparseCommandLineNonHelpFlags();
// Clean up memory allocated by flags. This is only needed to reduce
// the quantity of "potentially leaked" reports emitted by memory
// debugging tools such as valgrind. It is not required for normal
// operation, or for the perftools heap-checker. It must only be called
// when the process is about to exit, and all threads that might
// access flags are quiescent. Referencing flags after this is called
// will have unexpected consequences. This is not safe to run when
// multiple threads might be running: the function is thread-hostile.
extern void ShutDownCommandLineFlags();
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// Now come the command line flag declaration/definition macros that // Now come the command line flag declaration/definition macros that
...@@ -522,7 +532,7 @@ GFLAGS_DLL_DECL bool IsBoolFlag(bool from); ...@@ -522,7 +532,7 @@ GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
#define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name) #define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name)
#define DEFINE_bool(name, val, txt) \ #define DEFINE_bool(name, val, txt) \
namespace fLB { \ namespace fLB { \
typedef CompileAssert FLAG_##name##_value_is_not_a_bool[ \ typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \
(sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \ (sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \
} \ } \
DEFINE_VARIABLE(bool, B, name, val, txt) DEFINE_VARIABLE(bool, B, name, val, txt)
...@@ -545,22 +555,29 @@ GFLAGS_DLL_DECL bool IsBoolFlag(bool from); ...@@ -545,22 +555,29 @@ GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
// try to avoid crashes in that case, we use a char buffer to store // try to avoid crashes in that case, we use a char buffer to store
// the string, which we can static-initialize, and then placement-new // the string, which we can static-initialize, and then placement-new
// into it later. It's not perfect, but the best we can do. // into it later. It's not perfect, but the best we can do.
#define DECLARE_string(name) namespace fLS { extern GFLAGS_DLL_DECLARE_FLAG std::string& FLAGS_##name; } \
using fLS::FLAGS_##name
namespace fLS { namespace fLS {
inline std::string* dont_pass0toDEFINE_string(char *stringspot, // The meaning of "string" might be different between now and when the
const char *value) { // macros below get invoked (e.g., if someone is experimenting with
return new(stringspot) std::string(value); // other string implementations that get defined after this file is
// included). Save the current meaning now and use it in the macros.
typedef std::string clstring;
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
const char *value) {
return new(stringspot) clstring(value);
} }
inline std::string* dont_pass0toDEFINE_string(char *stringspot, inline clstring* dont_pass0toDEFINE_string(char *stringspot,
const std::string &value) { const clstring &value) {
return new(stringspot) std::string(value); return new(stringspot) clstring(value);
} }
inline std::string* dont_pass0toDEFINE_string(char *stringspot, inline clstring* dont_pass0toDEFINE_string(char *stringspot,
int value); int value);
} // namespace fLS } // namespace fLS
#define DECLARE_string(name) namespace fLS { extern ::fLS::clstring& FLAGS_##name; } \
using fLS::FLAGS_##name
// We need to define a var named FLAGS_no##name so people don't define // We need to define a var named FLAGS_no##name so people don't define
// --string and --nostring. And we need a temporary place to put val // --string and --nostring. And we need a temporary place to put val
// so we don't have to evaluate it twice. Two great needs that go // so we don't have to evaluate it twice. Two great needs that go
...@@ -568,19 +585,20 @@ inline std::string* dont_pass0toDEFINE_string(char *stringspot, ...@@ -568,19 +585,20 @@ inline std::string* dont_pass0toDEFINE_string(char *stringspot,
// The weird 'using' + 'extern' inside the fLS namespace is to work around // The weird 'using' + 'extern' inside the fLS namespace is to work around
// an unknown compiler bug/issue with the gcc 4.2.1 on SUSE 10. See // an unknown compiler bug/issue with the gcc 4.2.1 on SUSE 10. See
// http://code.google.com/p/google-gflags/issues/detail?id=20 // http://code.google.com/p/google-gflags/issues/detail?id=20
#define DEFINE_string(name, val, txt) \ #define DEFINE_string(name, val, txt) \
namespace fLS { \ namespace fLS { \
static union { void* align; char s[sizeof(std::string)]; } s_##name[2]; \ using ::fLS::clstring; \
std::string* const FLAGS_no##name = ::fLS:: \ static union { void* align; char s[sizeof(clstring)]; } s_##name[2]; \
dont_pass0toDEFINE_string(s_##name[0].s, \ clstring* const FLAGS_no##name = ::fLS:: \
val); \ dont_pass0toDEFINE_string(s_##name[0].s, \
static ::google::FlagRegisterer o_##name( \ val); \
#name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \ static ::google::FlagRegisterer o_##name( \
s_##name[0].s, new (s_##name[1].s) std::string(*FLAGS_no##name)); \ #name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
extern GFLAGS_DLL_DEFINE_FLAG std::string& FLAGS_##name; \ s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
using fLS::FLAGS_##name; \ extern clstring& FLAGS_##name; \
std::string& FLAGS_##name = *FLAGS_no##name; \ using fLS::FLAGS_##name; \
} \ clstring& FLAGS_##name = *FLAGS_no##name; \
} \
using fLS::FLAGS_##name using fLS::FLAGS_##name
#endif // SWIG #endif // SWIG
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment