c++-gtk-utils

cgu_config.h

Go to the documentation of this file.
00001 /* Copyright (C) 2010 and 2011 Chris Vine
00002 
00003 The library comprised in this file or of which this file is part is
00004 distributed by Chris Vine under the GNU Lesser General Public
00005 License as follows:
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public License
00009    as published by the Free Software Foundation; either version 2.1 of
00010    the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful, but
00013    WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License, version 2.1, for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License, version 2.1, along with this library (see the file LGPL.TXT
00019    which came with this source code package in the c++-gtk-utils
00020    sub-directory); if not, write to the Free Software Foundation, Inc.,
00021    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00022 
00023 However, it is not intended that the object code of a program whose
00024 source code instantiates a template from this file or uses macros or
00025 inline functions (of any length) should by reason only of that
00026 instantiation or use be subject to the restrictions of use in the GNU
00027 Lesser General Public License.  With that in mind, the words "and
00028 macros, inline functions and instantiations of templates (of any
00029 length)" shall be treated as substituted for the words "and small
00030 macros and small inline functions (ten lines or less in length)" in
00031 the fourth paragraph of section 5 of that licence.  This does not
00032 affect any other reason why object code may be subject to the
00033 restrictions in that licence (nor for the avoidance of doubt does it
00034 affect the application of section 2 of that licence to modifications
00035 of the source code in this file).
00036 
00037 */
00038 
00039 #ifndef CGU_CONFIG_H
00040 #define CGU_CONFIG_H
00041 
00042 /* 
00043  * This file is produced from cgu_config.h.in by the ./configure
00044  * script.
00045  */
00046 
00047 #undef CGU_USE_GLIB_MEMORY_SLICES_COMPAT
00048 #undef CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT
00049 
00050 /* 
00051  * None of these new operators throw std::bad_alloc as glib terminates
00052  * the whole application if it cannot allocate memory.
00053  *
00054  * These functions are only suitable as class member functions,
00055  * because they do not check whether the passed size request value is
00056  * 0, and g_slice_alloc() will not allocate any memory if passed a
00057  * size of 0.  (A class allocator will not be passed a size value less
00058  * than 1 as an empty class/struct object has sizeof 1 in C++, so
00059  * these will always be safe as member functions.)
00060  *
00061  * For anyone porting this library to windows, operator new[]() and
00062  * operator delete[]() for arrays should not be included, because
00063  * Visual Studio does not correctly comply with the C++ standard with
00064  * respect to the two argument version of operator delete[]().
00065  */
00066 #if defined(CGU_USE_GLIB_MEMORY_SLICES_COMPAT) || defined(CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT)
00067 #include <new>
00068 #include <cstdlib>
00069 #include <glib.h>
00070 #define CGU_GLIB_MEMORY_SLICES_FUNCS \
00071 static void* operator new(std::size_t s) {return g_slice_alloc(s);} \
00072 static void* operator new(std::size_t s, const std::nothrow_t&) {return g_slice_alloc(s);} \
00073 static void* operator new(std::size_t s, void* p) {return ::operator new(s, p);} \
00074 static void operator delete(void* p, std::size_t s) {if (p) g_slice_free1(s, p);} \
00075 static void operator delete(void* p, std::size_t s, const std::nothrow_t&) {if (p) g_slice_free1(s, p);} \
00076 static void operator delete(void* p, void* q) {::operator delete(p, q);} \
00077 static void* operator new[](std::size_t s) {return g_slice_alloc(s);} \
00078 static void* operator new[](std::size_t s, const std::nothrow_t&) {return g_slice_alloc(s);} \
00079 static void* operator new[](std::size_t s, void* p) {return ::operator new[](s, p);} \
00080 static void operator delete[](void* p, std::size_t s) {if (p) g_slice_free1(s, p);} \
00081 static void operator delete[](void* p, std::size_t s, const std::nothrow_t&) {if (p) g_slice_free1(s, p);} \
00082 static void operator delete[](void* p, void* q) {return ::operator delete[](p, q);}
00083 #else
00084 #define CGU_GLIB_MEMORY_SLICES_FUNCS // Using global operator new, new[], delete and delete[]
00085 #endif
00086 
00087 /* This determines whether each of the library headers will contain a
00088    'using namespace Cgu' directive. It will include such a using
00089    directive if configure is passed the --with-cgu-using-directive
00090    option.  (It can also be edited by hand.)
00091 */
00092 namespace Cgu {}
00093 // do not include using directive
00094 
00095 /* whether the system provides sched_yield */
00096 #define CGU_USE_SCHED_YIELD 1
00097 
00098 /* whether the system was found to provide working recursive mutexes
00099    when the library was compiled
00100 */
00101 #define CGU_HAVE_RECURSIVE_MUTEX 1
00102 
00103 /* whether to use std::auto_ptr instead of std::unique_ptr in relevant
00104    public interfaces to maintain source compatibility with earlier
00105    versions
00106 */
00107 #undef CGU_USE_AUTO_PTR
00108 
00109 /* whether ==, != and < operators to be available for smart pointers */
00110 #define CGU_USE_SMART_PTR_COMPARISON 1
00111 
00112 /* indicates that the series of the library being compiled against
00113    is series 2.0
00114 */
00115 #define CGU_API_VERSION 20
00116 
00117 #endif // CGU_CONFIG_H