1// @configure_input@
2// $Header$
3//
4// Copyright (C) 2000 - 2003, by
5//
6// Carlo Wood, Run on IRC <carlo@alinoe.com>
7// RSA-1024 0x624ACAD5 1997-01-26                    Sign & Encrypt
8// Fingerprint16 = 32 EC A7 B6 AC DB 65 A6  F6 F6 55 DD 1C DC FF 61
9//
10// This file may be distributed under the terms of the Q Public License
11// version 1.0 as appearing in the file LICENSE.QPL included in the
12// packaging of this file.
13//
14
15//
16// NOTE:
17//
18// This header file was generated with the `configure' script of libcwd-@VERSION@
19// If you change your system header files (like glibc or kernel header)
20// it might be needed to regenerate it.
21//
22
23/** \file libcwd/sys.h
24 * Do not include this header file directly, instead include a custom \link preparation "sys.h" \endlink.
25 */
26
27#ifndef LIBCWD_SYS_H
28#define LIBCWD_SYS_H
29
30namespace libcwd {
31  /**
32   * \brief Offset to __builtin_return_address() needed to get the correct line number from location_ct.
33   *
34   * \par Example
35   * \code
36   * libcwd::location_ct loc((char*)__builtin_return_address(0) + libcwd::builtin_return_address_offset);
37   * \endcode
38   */
39  int const builtin_return_address_offset = @CW_CONFIG_BUILTIN_RETURN_ADDRESS_OFFSET@;
40}
41
42//
43// Compilers and preprocessor used.  Put here to cause a recompile when changed.
44// CC    : @CC_FINGER_PRINT@
45// CXX   : @CXX_FINGER_PRINT@
46// CXXCPP: @CXXCPP_FINGER_PRINT@
47//
48
49//
50// Sanity check - if this is defined then _REENTRANT will be defined regardless
51// and that won't work.
52//
53#ifdef __GTHREADS
54#error No, no, no... "sys.h" has to be the VERY first header file you include.  Before ANY other (system) header file.
55#endif
56
57//
58// g++ 3.4 (20030816) defines _REENTRANT regardless when including
59// certain standard libstdc++ header files.  Therefore we can ONLY
60// test on _REENTRANT here, before including any other header file.
61//
62#if defined(_REENTRANT) || defined(_THREAD_SAFE)
63// Some (broken) third party libraries include -D_REENTRANT in the
64// pkg-config --cflags output (for example, several X libraries).
65// Therefore we can't even rely here on it anymore.  Instead use
66// our own define to know if this is a threaded application or not.
67#ifndef LIBCWD_THREAD_SAFE
68// This could be a #warning -- if gcc SHOWED warnings in system headers.
69#error Please use -DLIBCWD_THREAD_SAFE on the command line if you intend to link with libcwd_r! \
70       To fix this error, remove -D_REENTRANT (and/or -D_THREAD_SAFE) from your compile flags \
71       when you are compiling a single threaded application (and link with libcwd), or add \
72       -DLIBCWD_THREAD_SAFE to the compile flags (and link with libcwd_r). Alternatively you \
73       can suppress this warning by adding -DLIBCWD_THREAD_SAFE=0 (and link with libcwd). \
74       You are strongly advised to use pkg-config to determine the correct flags \
75       (see example-project/m4/CW_LIB_LIBCWD.m4)!
76#endif	// LIBCWD_THREAD_SAFE
77
78#else	// !(defined(_REENTRANT) || defined(_THREAD_SAFE))
79
80#ifndef LIBCWD_THREAD_SAFE
81#define LIBCWD_THREAD_SAFE 0
82#elif LIBCWD_THREAD_SAFE
83// This could be a #warning -- if gcc SHOWED warnings in system headers.
84#error LIBCWD_THREAD_SAFE is set, which implies the use of threads. \
85       You should also define _REENTRANT (or _THREAD_SAFE on some OS) for the sake of other libraries in this case! \
86       Add -D_REENTRANT -pthread to your CXXFLAGS for threaded applications.
87#endif
88
89#endif	// defined(_REENTRANT) || defined(_THREAD_SAFE)
90
91#if LIBCWD_THREAD_SAFE && !defined(_GNU_SOURCE)
92#error Sorry, libcwd_r uses GNU extensions, also in the header files.
93#error Therefore you must also define _GNU_SOURCE when you are linking with -lcwd_r.
94#error Please add #define _GNU_SOURCE to your "sys.h", see reference-manual/preparation.html#preparation_step2.
95#endif
96
97#endif /* LIBCWD_SYS_H */
98