Google

The UDS Collection

Configuring UDS


back to main page

UDS Flags

To use some of the features UDS provides, you have to configure the library in your program. This should to be done at compile time. You do this by defining the variable uds::flags.
That might look like the following:

#include <uds/uds.hh>

// configure UDS
uds::uds_flags_t uds::flags = uds::leak_check | uds::summon_zombies;

The flags will be 0 if you do not override them.

The available flags are:
force_core_dumps
force core dumps when an UDS exception is thrown
leak_check
check for memory leaks
summon_zombies
create zombie objects
log_allocs
log all memory [de]allocations to stderr
rename_cores
rename cores that are dumped by UDS exceptions
std_backtraces
generate always a backtrace when a UDS exception is thrown

Note that starting with version 0.9.5 uds::flags is not constant anymore. You can now change flags at runtime. This is especially useful for the force_core_dumps and log_allocs flags. I recommend you use a VRemember object to make sure the value gets restored in case of an exception. Don't change the leak_check flag though or you will get funny results.

If you don't want to set any flags, you don't have to provide uds::flags. However, UDS defines global new and delete operators (as weak symbols). If you don't set any flags, there is still a small performance overhead. Fortunately, there is a workaround.
UDS comes with a source file ([prefix]/share/uds/udsdeff.cc) that, when added to your program, will #include config.h if present and set the uds flags according to present #defines. Additionally, when it is not necessary to use UDS new / delete operators, the original new and delete operators are restored.
Note that if the standard operators are restored, you won't be able to switch on leak_check, summon_zombies, or log_allocs at runtime.

If you want to use the debugging facilities during development, and run your releases at full speed, add udsdeff.cc to your project and add at least the following line to your configure.in:

UDS_CHECK_FLAGS

This is a m4 macro which adds a configure check for each flag. The default options depend on whether debugging is enabled. This check is done by UDS_DEBUG, a prerequisite macro for UDS_CHECK_FLAGS.
If you use your own --enable-debug option, you might want to use the UDS_CHECK_FLAGS_NB macro instead, which does not depend on other macros. All flag switches default to 'no'.


M4 macros

There are a some other useful m4 macros provided my UDS. Have a look at the UDS configure.in for a few examples.

UDS_CHECK_LIBUDS
Checks that libuds is installed on your system. If not, a short message and a link to the download page are printed.
UDS_CHECK_LIBUDSTHREAD
Same as above, but it is also checked for libudsthread.
UDS_CHECK_VERSION
Checks for specific versions of UDS.
Examples: UDS_CHECK_VERSION(0.9.5) checks for a version >= 0.9.5, and UDS_CHECK_VERSION(0.9.5,1.0.0) checks for a version >= 0.9.5 <= 1.0.0
UDS_CHECK_EXTRA_LI
Adds the configure options --with-extra-libs and --with-extra-includes. You can pass space separated lists of paths to the options to specify extra library and include paths.
You have to use the UDS_FL_GEN macro at the end of your configure.in file to make this work.
UDS_CHECK_DEBUG (updated)
Adds the --enable-debug option which is used to enable generation of debugging information. If you want to use a different debug option than -g, pass it as argument to the macro. Default settings of several other switches (generated by UDS macros) depend on this option.
UDS_CHECK_STATIC_LINK (updated)
Adds the --enable-static option. If enabled, the -static option is used, and STATIC is defined in config.h. Default is 'no'.
UDS_CHECK_OPTIMIZATION
Adds two options, --enable-optimization and --enable-arch. The --enable-optimization is used to toggle optimization options. It is possible to optimize explicitly for speed or size by using --enable-optimization=speed|size. Additional compiler options for standard, speed, and size optimization can be passed as first, second, and third argument to the macro. I use usually something like UDS_CHECK_OPTIMIZATION(, -fstrict-aliasing, -fstrict-aliasing -s). Default is 'yes'.
The --enable-arch option can be used to enable optimization for specific architectures. If the option is set to 'yes' (the default if it is optimized for speed or size), -march=$(uname -m) is used. The architecture can be set explicitly by using --enable-arch=i686.
UDS_CHECK_PROFILE
Adds the --enable-profile option which controls whether to emit profiling info. Default is 'no'. Other valid arguments are 'flat' for flat a profile, 'lcov' for line coverage, and 'both' for both.
UDS_FL_GEN
Put this macro at the end of your configure.in if you use UDS m4 macros which affect compiler options. It sets CFLAGS and CXXFLAGS unless one of those variables is neither empty nor "-g -O2".
UDS_CHECK_PROG
Checks for the presence / absolute path of a program. The full program path is stored in config.h. The macro takes four arguments:
  • the program name
  • --with-[x] option name
  • brief program description
  • config.h macro name
UDS_PATHS
Defines PREFIX, EXEC_PREFIX, BINDIR, SBINDIR, LIBEXECDIR, DATADIR, SYSCONFDIR, SHAREDSTATEDIR, LOCALSTATEDIR, LIBDIR, INFODIR, MANDIR, and INCLUDEDIR in config.h
UDS_CHECK_FLAGS
Described above. Adds the following options:
  • --enable-core-dumps
  • --enable-leak-check
  • --enable-zombies
  • --enable-log-allocs
  • --enable-rename-cores
  • --enable-std-backtraces
UDS_CHECK_FLAGS_ND
Likewise. All options default to 'no' and UDS_CHECK_DEBUG is not a prerequisite macro.
UDS_CHECK_DEFUSER
Adds the option --with-default-user to the configure script. The macro takes the default user name as first argument. The result is stored as DEFAULT_USER in config.h, and made available to Makefiles as the variable uds_defuser. This macro is intended for daemon / server programs. If --without-default-user is given, the value is set to an empty string.
UDS_CHECK_DEFGROUP
Adds the option --with-default-group to the configure script. The macro takes the default group name as first argument. The result is stored as DEFAULT_GROUP in config.h, and made available to Makefiles as the variable uds_defgroup. This macro is intended for daemon / server programs. If --without-default-group is given, the value is set to an empty string.
UDS_CHECK_VARRUNDIR
Adds the --with-var-run-dir option to configure. The default is {localstatedir}/var/run/$1 where $1 is the optional argument to UDS_CHECK_VARRUNDIR. The result is stored in config.h as VARRUNDIR. A trailing slash is removed.
Note that if --with-var-run-dir is actually used, the argument to UDS_CHECK_VARRUNDIR is ignored.