diff options
51 files changed, 78 insertions, 55 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 10d7b85495e..e0d9dfaaffb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -170,6 +170,7 @@ libcommon_a_SOURCES = \ common/Timer.cc \ common/Finisher.cc \ common/sctp_crc32.c\ + common/assert.cc \ mon/MonMap.cc \ mon/MonClient.cc \ osd/OSDMap.cc \ @@ -243,7 +244,8 @@ libclient_a_SOURCES = \ client/SyntheticClient.cc \ client/Trace.cc -# headers... yuck +# headers... and everything else we want to include in a 'make dist' +# that autotools doesn't magically identify. noinst_HEADERS = \ client/Client.h\ client/SyntheticClient.h\ @@ -285,6 +287,7 @@ noinst_HEADERS = \ ebofs/types.h\ include/Context.h\ include/Distribution.h\ + include/assert.h\ include/atomic.h\ include/bitmapper.h\ include/blobhash.h\ @@ -394,7 +397,6 @@ noinst_HEADERS = \ mds/events/EUpdate.h\ mds/mds_table_types.h\ mds/mdstypes.h\ - mds/snap.cc\ mds/snap.h\ messages/MCacheExpire.h\ messages/MClientCaps.h\ diff --git a/src/client/Trace.cc b/src/client/Trace.cc index 31bb1c4cf5c..67f86eeb18c 100644 --- a/src/client/Trace.cc +++ b/src/client/Trace.cc @@ -17,7 +17,6 @@ #include "Trace.h" #include <iostream> -#include <cassert> #include <map> #include <ext/rope> using namespace __gnu_cxx; diff --git a/src/client/Trace.h b/src/client/Trace.h index 56c494d2af6..39aba621ee3 100644 --- a/src/client/Trace.h +++ b/src/client/Trace.h @@ -18,7 +18,6 @@ #include <stdlib.h> -#include <cassert> #include <list> #include <string> #include <fstream> diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 3f59431e535..40e97fb2c46 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -21,7 +21,6 @@ #include <errno.h> #include <fcntl.h> #include <unistd.h> -#include <assert.h> // ceph #include "include/types.h" diff --git a/src/common/Cond.h b/src/common/Cond.h index 4cb3d721b42..59ea9350187 100644 --- a/src/common/Cond.h +++ b/src/common/Cond.h @@ -24,7 +24,6 @@ #include "include/Context.h" #include <pthread.h> -#include <cassert> class Cond { // my bits diff --git a/src/common/Mutex.h b/src/common/Mutex.h index 64e98371ab0..855a692d9e9 100755 --- a/src/common/Mutex.h +++ b/src/common/Mutex.h @@ -16,7 +16,7 @@ #define __MUTEX_H #include <pthread.h> -#include <cassert> +#include "include/assert.h" class Mutex { private: @@ -49,6 +49,15 @@ public: return (nlock > 0); } + bool TryLock() { + int r = pthread_mutex_trylock(&_m); + if (r == 0) { + nlock++; + assert(nlock == 1 || recursive); + } + return r == 0; + } + void Lock() { int r = pthread_mutex_lock(&_m); assert(r == 0); diff --git a/src/common/Semaphore.h b/src/common/Semaphore.h index bc0a9e60d7f..4574b7e33cc 100644 --- a/src/common/Semaphore.h +++ b/src/common/Semaphore.h @@ -16,8 +16,6 @@ #ifndef _Sem_Posix_ #define _Sem_Posix_ -#include <cassert> - class Semaphore { Mutex m; diff --git a/src/common/assert.cc b/src/common/assert.cc new file mode 100644 index 00000000000..71fd43b4e7e --- /dev/null +++ b/src/common/assert.cc @@ -0,0 +1,16 @@ + +#include "include/assert.h" +#include "config.h" + +void __ceph_assert_fail(const char *assertion, const char *file, int line, const char *func) +{ + _dout_lock.TryLock(); + *_dout << file << ":" << line << ": FAILED assert in \'" << func << "\': " << assertion << std::endl; + cerr << file << ":" << line << ": FAILED assert in \'" << func << "\': " << assertion << std::endl; + _dout->flush(); + cerr.flush(); + + char *p = 0; + while (1) + *p-- = 0; // make myself core dump. +} diff --git a/src/config.h b/src/config.h index 4af715bcd0b..244fa3945f1 100644 --- a/src/config.h +++ b/src/config.h @@ -26,6 +26,8 @@ extern const char *get_pool_name(int pool); #include <vector> #include <map> +#include "include/assert.h" + #include "common/Mutex.h" extern std::map<int,float> g_fake_osd_down; diff --git a/src/crush/builder.c b/src/crush/builder.c index 5f6985570e9..b8ca2101217 100644 --- a/src/crush/builder.c +++ b/src/crush/builder.c @@ -3,6 +3,7 @@ #include <math.h> #include <stdlib.h> #include <stdio.h> +#include <assert.h> #include "builder.h" #include "hash.h" diff --git a/src/crush/crush.c b/src/crush/crush.c index 26ec8530f2a..4e630b0c80d 100644 --- a/src/crush/crush.c +++ b/src/crush/crush.c @@ -4,6 +4,7 @@ # define free(x) kfree(x) #else # include <stdlib.h> +# include <assert.h> #endif #include "crush.h" diff --git a/src/crush/crush.h b/src/crush/crush.h index 8fd5f61839b..4eeada9d927 100644 --- a/src/crush/crush.h +++ b/src/crush/crush.h @@ -7,7 +7,6 @@ extern "C" { #ifndef __KERNEL__ -# include <assert.h> # define BUG_ON(x) assert(!(x)) # include "include/inttypes.h" /* just for int types */ #else diff --git a/src/crush/mapper.c b/src/crush/mapper.c index f0de32a3a87..8af4276ac2f 100644 --- a/src/crush/mapper.c +++ b/src/crush/mapper.c @@ -1,7 +1,4 @@ -#include "crush.h" -#include "hash.h" - #ifdef __KERNEL__ # include <linux/string.h> # include <linux/slab.h> @@ -9,8 +6,13 @@ #else # include <string.h> # include <stdio.h> +# include <assert.h> #endif +#include "crush.h" +#include "hash.h" + + int crush_find_rule(struct crush_map *map, int pool, int type, int size) { diff --git a/src/crush/types.h b/src/crush/types.h index ffb208b2fec..319728e526d 100644 --- a/src/crush/types.h +++ b/src/crush/types.h @@ -11,7 +11,6 @@ #include <linux/types.h> /* just for int types */ #ifndef BUG_ON -# include <assert.h> # define BUG_ON(x) assert(!(x)) #endif diff --git a/src/crushtool.cc b/src/crushtool.cc index 49c76ebfefe..a83ba5c53bc 100644 --- a/src/crushtool.cc +++ b/src/crushtool.cc @@ -30,7 +30,6 @@ #include <stack> #include <functional> #include <string> -#include <cassert> #include <map> #include <typeinfo> diff --git a/src/ebofs/BlockDevice.cc b/src/ebofs/BlockDevice.cc index 7e6f250a03e..f54bb929a9c 100644 --- a/src/ebofs/BlockDevice.cc +++ b/src/ebofs/BlockDevice.cc @@ -23,7 +23,6 @@ #include <fcntl.h> #include <sys/file.h> #include <iostream> -#include <cassert> #include <errno.h> #include <sys/uio.h> diff --git a/src/ebofs/types.h b/src/ebofs/types.h index bb09ea6e5e6..5af39f23da8 100644 --- a/src/ebofs/types.h +++ b/src/ebofs/types.h @@ -21,7 +21,6 @@ #include "include/pobject.h" #include "common/Cond.h" -#include <cassert> #include <ext/hash_map> #include <set> #include <list> diff --git a/src/include/Context.h b/src/include/Context.h index 47bf0fea32b..ddacd3bc8c4 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -18,7 +18,7 @@ #include "config.h" -#include <assert.h> +#include "assert.h" #include <list> #include <set> diff --git a/src/include/Distribution.h b/src/include/Distribution.h index efc0795a72f..4f78009276f 100644 --- a/src/include/Distribution.h +++ b/src/include/Distribution.h @@ -16,7 +16,6 @@ #ifndef __DISTRIBUTION_H #define __DISTRIBUTION_H -#include <cassert> #include <vector> using namespace std; diff --git a/src/include/assert.h b/src/include/assert.h new file mode 100644 index 00000000000..2cfa38e42b5 --- /dev/null +++ b/src/include/assert.h @@ -0,0 +1,35 @@ +#ifndef __CEPH_ASSERT_H +#define __CEPH_ASSERT_H + +#include <features.h> + +#if defined __cplusplus && __GNUC_PREREQ (2,95) +# define __CEPH_ASSERT_VOID_CAST static_cast<void> +#else +# define __CEPH_ASSERT_VOID_CAST (void) +#endif + +/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' + which contains the name of the function currently being defined. + This is broken in G++ before version 2.6. + C9x has a similar variable called __func__, but prefer the GCC one since + it demangles C++ function names. */ +# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4) +# define __ASSERT_FUNCTION __PRETTY_FUNCTION__ +# else +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __ASSERT_FUNCTION __func__ +# else +# define __ASSERT_FUNCTION ((__const char *) 0) +# endif +# endif + +extern void __ceph_assert_fail(const char *assertion, const char *file, int line, const char *function) + __attribute__ ((__noreturn__)); + +#define assert(expr) \ + ((expr) \ + ? __CEPH_ASSERT_VOID_CAST (0) \ + : __ceph_assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION)) + +#endif diff --git a/src/include/buffer.h b/src/include/buffer.h index a29913523f4..65ddbd98310 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -34,7 +34,6 @@ void *valloc(size_t); #include <malloc.h> #endif #include <stdint.h> -#include <assert.h> #include <string.h> #ifndef __CYGWIN__ @@ -48,6 +47,7 @@ void *valloc(size_t); #include "atomic.h" #include "page.h" #include "crc32c.h" +#include "assert.h" // <hack> // these are in config.o diff --git a/src/include/interval_set.h b/src/include/interval_set.h index 750571ef6ae..ebe31c309eb 100644 --- a/src/include/interval_set.h +++ b/src/include/interval_set.h @@ -18,7 +18,6 @@ #include <map> #include <ostream> -#include <cassert> using namespace std; #ifndef MIN diff --git a/src/include/lru.h b/src/include/lru.h index 40dce1aa191..a8bebe9bac1 100644 --- a/src/include/lru.h +++ b/src/include/lru.h @@ -18,7 +18,6 @@ #define __LRU_H #include <stdint.h> -#include <assert.h> #include "config.h" diff --git a/src/include/rangeset.h b/src/include/rangeset.h index 547ea3ab722..2bd5dc35a2c 100644 --- a/src/include/rangeset.h +++ b/src/include/rangeset.h @@ -23,7 +23,6 @@ */ #include <map> -#include <cassert> #include <iostream> using namespace std; diff --git a/src/include/types.h b/src/include/types.h index ea17a0343b1..f3f57e81c30 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -21,7 +21,6 @@ extern "C" { #include <stdint.h> #include <sys/types.h> #include <sys/stat.h> -#include <assert.h> #include <fcntl.h> #include "statlite.h" } @@ -40,7 +39,7 @@ using namespace std; using namespace __gnu_cxx; - +#include "assert.h" #include "object.h" #include "utime.h" #include "intarith.h" diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index 94c8eb4e135..8d8f85f383f 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -25,7 +25,6 @@ #include "messages/MLock.h" -#include <cassert> #define dout(x) if (x <= g_conf.debug || x <= g_conf.debug_mds) *_dout << dbeginl << g_clock.now() << " mds" << dir->cache->mds->get_nodeid() << ".cache.den(" << dir->dirfrag() << " " << name << ") " diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index 187fdd359ee..9bda79ddc7a 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -17,7 +17,6 @@ #ifndef __CDENTRY_H #define __CDENTRY_H -#include <assert.h> #include <string> #include <set> using namespace std; diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index a6b5163d9b2..a97c1ba99a3 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -31,8 +31,6 @@ #include "osdc/Objecter.h" -#include <cassert> - #include "config.h" #define dout(x) if (x <= g_conf.debug || x <= g_conf.debug_mds) *_dout << dbeginl << g_clock.now() << " mds" << cache->mds->get_nodeid() << ".cache.dir(" << this->dirfrag() << ") " diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 2a199350be9..91616506c8f 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -24,7 +24,6 @@ #include "common/DecayCounter.h" #include <iostream> -#include <cassert> #include <list> #include <set> diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 901ddb89546..2926d406b0e 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -31,7 +31,6 @@ #include "Capability.h" #include "snap.h" -#include <cassert> #include <list> #include <vector> #include <set> diff --git a/src/mds/FileLock.h b/src/mds/FileLock.h index 961981a4e93..c2bf5e5b0a2 100644 --- a/src/mds/FileLock.h +++ b/src/mds/FileLock.h @@ -16,7 +16,6 @@ #ifndef __FILELOCK_H #define __FILELOCK_H -#include <assert.h> #include <set> using namespace std; diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 351e0c95677..67133cc4e83 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -50,7 +50,6 @@ #include "messages/MMDSSlaveRequest.h" #include <errno.h> -#include <assert.h> #include "config.h" diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index b35bcc161d5..73f29dd3e4a 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -79,7 +79,6 @@ #include "common/Timer.h" -#include <assert.h> #include <errno.h> #include <iostream> #include <string> diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index ffd47d4842a..ba77f562242 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -16,11 +16,10 @@ #ifndef __MDSMAP_H #define __MDSMAP_H +#include "include/types.h" #include "common/Clock.h" #include "msg/Message.h" -#include "include/types.h" - #include <set> #include <map> #include <string> diff --git a/src/mds/events/EExport.h b/src/mds/events/EExport.h index bd1392259b6..0786382275c 100644 --- a/src/mds/events/EExport.h +++ b/src/mds/events/EExport.h @@ -15,7 +15,6 @@ #ifndef __EEXPORT_H #define __EEXPORT_H -#include <assert.h> #include "config.h" #include "include/types.h" diff --git a/src/mds/events/EImportFinish.h b/src/mds/events/EImportFinish.h index b4443b93812..7455cc9113b 100644 --- a/src/mds/events/EImportFinish.h +++ b/src/mds/events/EImportFinish.h @@ -15,7 +15,6 @@ #ifndef __EIMPORTFINISH_H #define __EIMPORTFINISH_H -#include <assert.h> #include "config.h" #include "include/types.h" diff --git a/src/mds/events/EImportStart.h b/src/mds/events/EImportStart.h index 6b92d9f3f02..f652c6b0dae 100644 --- a/src/mds/events/EImportStart.h +++ b/src/mds/events/EImportStart.h @@ -15,7 +15,6 @@ #ifndef __EIMPORTSTART_H #define __EIMPORTSTART_H -#include <assert.h> #include "config.h" #include "include/types.h" diff --git a/src/mds/events/EPurgeFinish.h b/src/mds/events/EPurgeFinish.h index f666ea77816..f6e8c44b069 100644 --- a/src/mds/events/EPurgeFinish.h +++ b/src/mds/events/EPurgeFinish.h @@ -15,7 +15,6 @@ #ifndef __EPURGE_H #define __EPURGE_H -#include <assert.h> #include "config.h" #include "include/types.h" diff --git a/src/mds/events/ESession.h b/src/mds/events/ESession.h index 4e3f2d58239..8771aa1ce73 100644 --- a/src/mds/events/ESession.h +++ b/src/mds/events/ESession.h @@ -15,7 +15,6 @@ #ifndef __MDS_ESESSION_H #define __MDS_ESESSION_H -#include <assert.h> #include "config.h" #include "include/types.h" diff --git a/src/mds/events/ESessions.h b/src/mds/events/ESessions.h index d90e6a24973..ebdc292cce8 100644 --- a/src/mds/events/ESessions.h +++ b/src/mds/events/ESessions.h @@ -15,7 +15,6 @@ #ifndef __MDS_ESESSIONS_H #define __MDS_ESESSIONS_H -#include <assert.h> #include "config.h" #include "include/types.h" diff --git a/src/mds/events/ETableClient.h b/src/mds/events/ETableClient.h index 9b47def918b..833af657a52 100644 --- a/src/mds/events/ETableClient.h +++ b/src/mds/events/ETableClient.h @@ -15,7 +15,6 @@ #ifndef __MDS_ETABLECLIENT_H #define __MDS_ETABLECLIENT_H -#include <assert.h> #include "config.h" #include "include/types.h" diff --git a/src/mds/events/ETableServer.h b/src/mds/events/ETableServer.h index 929d81b6191..709ae4783a9 100644 --- a/src/mds/events/ETableServer.h +++ b/src/mds/events/ETableServer.h @@ -15,7 +15,6 @@ #ifndef __MDS_ETABLESERVER_H #define __MDS_ETABLESERVER_H -#include <assert.h> #include "config.h" #include "include/types.h" diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 5095c00ead5..c7e941f4e10 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -14,8 +14,6 @@ using namespace std; #include "common/DecayCounter.h" #include "include/Context.h" -#include <cassert> - #include "include/frag.h" #include "include/xlist.h" #include "include/nstring.h" diff --git a/src/msg/FakeMessenger.cc b/src/msg/FakeMessenger.cc index 93c46889bd2..c56b980e8e6 100644 --- a/src/msg/FakeMessenger.cc +++ b/src/msg/FakeMessenger.cc @@ -32,7 +32,6 @@ #include <stdio.h> #include <stdlib.h> #include <map> -#include <cassert> #include <iostream> using namespace std; diff --git a/src/msg/Message.cc b/src/msg/Message.cc index 1d909aa40f5..213dab4fe22 100644 --- a/src/msg/Message.cc +++ b/src/msg/Message.cc @@ -1,7 +1,6 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#include <cassert> #include <iostream> using namespace std; diff --git a/src/msg/Message.h b/src/msg/Message.h index 8fba5c1a7d4..21da4132730 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -93,7 +93,6 @@ #include <stdlib.h> -#include <cassert> #include <iostream> #include <list> diff --git a/src/msg/Messenger.cc b/src/msg/Messenger.cc index 5af83462b29..87901433b0c 100644 --- a/src/msg/Messenger.cc +++ b/src/msg/Messenger.cc @@ -21,7 +21,6 @@ #include "Messenger.h" #include "messages/MGenericMessage.h" -#include <cassert> #include <iostream> using namespace std; diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 19746cb796c..688959e839e 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -28,7 +28,6 @@ #include <fcntl.h> #include <sys/file.h> #include <iostream> -#include <cassert> #include <errno.h> #include <dirent.h> #include <sys/ioctl.h> diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index f2ba2435446..e631d0966c8 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -70,7 +70,6 @@ #include "common/ThreadPool.h" #include <iostream> -#include <cassert> #include <errno.h> #include <sys/stat.h> diff --git a/src/osdc/Filer.cc b/src/osdc/Filer.cc index 64b837c203c..0debe242fd5 100644 --- a/src/osdc/Filer.cc +++ b/src/osdc/Filer.cc @@ -13,8 +13,6 @@ */ -#include <assert.h> - #include "Filer.h" #include "osd/OSDMap.h" diff --git a/src/test/testxattr.cc b/src/test/testxattr.cc index 210eef208a8..65bb4b114e1 100644 --- a/src/test/testxattr.cc +++ b/src/test/testxattr.cc @@ -10,7 +10,6 @@ using namespace std; #include <fcntl.h> #include <sys/file.h> #include <iostream> -#include <cassert> #include <errno.h> #include <dirent.h> #include <sys/xattr.h> |