From dd8b293d2269304cd96ae3e25e94eeabb03b4385 Mon Sep 17 00:00:00 2001 From: Matthew Brush Date: Mon, 4 Mar 2013 03:17:00 -0800 Subject: [PATCH] Fixup header inclusion and C++ guards a bit * Now headers only include headers they use (at least std headers). * Remove CFU_DEBUG stuff since NDEBUG automatically controls assert() * Make use of CFU_BEGIN_DECLS and CFU_END_DECLS macros from cfu.h. --- Makefile.am | 11 ----------- configure.ac | 11 +---------- src/cfu.h | 2 -- src/cfuconf.c | 10 ---------- src/cfuconf.h | 10 ++-------- src/cfuhash.c | 16 +++------------- src/cfuhash.h | 11 +++-------- src/cfulist.c | 13 ++----------- src/cfulist.h | 13 +++---------- src/cfuopt.c | 11 +---------- src/cfuopt.h | 2 +- src/cfustring.c | 11 +---------- src/cfustring.h | 11 +++-------- src/cfuthread_queue.c | 10 ---------- src/cfuthread_queue.h | 9 ++------- src/cfutime.c | 12 ++---------- src/cfutime.h | 10 ++-------- 17 files changed, 26 insertions(+), 147 deletions(-) diff --git a/Makefile.am b/Makefile.am index 57d962c..39e68d0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,12 +1 @@ SUBDIRS = src examples doc -if DEBUG -AM_CFLAGS = -DCFU_VERSION="\"@VERSION@\"" -DCFU_DEBUG=1 -else -AM_CFLAGS = -DCFU_VERSION="\"@VERSION@\"" -endif - -LIBCFU_TYPE_u_int=@LIBCFU_TYPE_u_int@ - -INCLUDES = -I$(top_srcdir)/include - -EXTRA_DIST = include/cfutypes.h.in include/cfu.h.in diff --git a/configure.ac b/configure.ac index cdcfae6..bccf6c4 100644 --- a/configure.ac +++ b/configure.ac @@ -8,6 +8,7 @@ AM_INIT_AUTOMAKE([foreign -Wall silent-rules dist-bzip2]) AM_SILENT_RULES([yes]) AC_PROG_CC +AM_PROG_CC_C_O AC_PROG_RANLIB # Checks for header files. @@ -39,16 +40,6 @@ then fi AM_CONDITIONAL([USE_PTHREADS], [test x$have_pthreads = xyes]) -# Allow enabling debug mode using configure argument -AC_ARG_ENABLE(debug, - [ --enable-debug Turn on debugging], - [case "${enableval}" in - yes) debug=true ;; - no) debug=false ;; - *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;; - esac],[debug=false]) -AM_CONDITIONAL([DEBUG], [test x$debug = xtrue]) - AC_CONFIG_FILES([ Makefile src/Makefile diff --git a/src/cfu.h b/src/cfu.h index 10177d8..b45b69b 100644 --- a/src/cfu.h +++ b/src/cfu.h @@ -41,8 +41,6 @@ #ifndef _LIBCFU_H_ #define _LIBCFU_H_ -#include - #ifdef __cplusplus #define CFU_BEGIN_DECLS extern "C" { #define CFU_END_DECLS } diff --git a/src/cfuconf.c b/src/cfuconf.c index 68eb934..0bb907d 100644 --- a/src/cfuconf.c +++ b/src/cfuconf.c @@ -46,16 +46,6 @@ #include #include #include - -#ifdef CFU_DEBUG -#ifdef NDEBUG -#undef NDEBUG -#endif -#else -#ifndef NDEBUG -#define NDEBUG 1 -#endif -#endif #include struct cfuconf { diff --git a/src/cfuconf.h b/src/cfuconf.h index 3c54a33..f735621 100644 --- a/src/cfuconf.h +++ b/src/cfuconf.h @@ -46,11 +46,7 @@ #include #include -#include - -#ifdef __cplusplus -extern "C" { -#endif +CFU_BEGIN_DECLS struct cfuconf; typedef struct cfuconf cfuconf_t; @@ -119,8 +115,6 @@ extern "C" { /* Print out a representation of the parsed configuration */ extern void cfuconf_pretty_print_conf(cfuconf_t *conf, FILE *fp, size_t indent_level); -#ifdef __cplusplus -} -#endif +CFU_END_DECLS #endif diff --git a/src/cfuhash.c b/src/cfuhash.c index 0914ddf..95a7259 100644 --- a/src/cfuhash.c +++ b/src/cfuhash.c @@ -43,28 +43,18 @@ #endif #include "cfu.h" +#include "cfuhash.h" +#include "cfustring.h" #include #include #include +#include #ifdef HAVE_PTHREAD_H # include #endif -#include "cfuhash.h" -#include "cfustring.h" - -#ifdef CFU_DEBUG -#ifdef NDEBUG -#undef NDEBUG -#endif -#else -#ifndef NDEBUG -#define NDEBUG 1 -#endif -#endif -#include typedef struct cfuhash_event_flags { int resized:1; diff --git a/src/cfuhash.h b/src/cfuhash.h index 0e281d3..ab4a5ed 100644 --- a/src/cfuhash.h +++ b/src/cfuhash.h @@ -42,13 +42,10 @@ #define _CFU_HASH_H_ #include - -#include #include +#include -#ifdef __cplusplus -extern "C" { -#endif +CFU_BEGIN_DECLS /* The hash table itself. */ struct cfuhash_table; @@ -270,8 +267,6 @@ extern "C" { #define CFUHASH_IGNORE_CASE (1 << 5) /* treat keys case-insensitively */ -#ifdef __cplusplus -} -#endif +CFU_END_DECLS #endif diff --git a/src/cfulist.c b/src/cfulist.c index 29d4d53..3bc2626 100644 --- a/src/cfulist.c +++ b/src/cfulist.c @@ -45,6 +45,8 @@ #include "cfu.h" #include +#include +#include #ifdef HAVE_PTHREAD_H # include @@ -53,17 +55,6 @@ #include "cfulist.h" #include "cfustring.h" -#ifdef CFU_DEBUG -#ifdef NDEBUG -#undef NDEBUG -#endif -#else -#ifndef NDEBUG -#define NDEBUG 1 -#endif -#endif -#include - typedef struct cfulist_entry { void *data; size_t data_size; diff --git a/src/cfulist.h b/src/cfulist.h index 2da7f1d..1a268fa 100644 --- a/src/cfulist.h +++ b/src/cfulist.h @@ -42,14 +42,9 @@ #define _CFU_LIST_ #include +#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif +CFU_BEGIN_DECLS /* The list itself. */ struct cfulist; @@ -159,8 +154,6 @@ extern "C" { extern char *cfulist_join(cfulist_t *list, const char *delimiter); -#ifdef __cplusplus -} -#endif +CFU_END_DECLS #endif diff --git a/src/cfuopt.c b/src/cfuopt.c index eb082f7..c7754c0 100644 --- a/src/cfuopt.c +++ b/src/cfuopt.c @@ -10,16 +10,7 @@ #include "cfustring.h" #include - -#ifdef CFU_DEBUG -#ifdef NDEBUG -#undef NDEBUG -#endif -#else -#ifndef NDEBUG -#define NDEBUG 1 -#endif -#endif +#include #include struct cfuopt_struct { diff --git a/src/cfuopt.h b/src/cfuopt.h index 32aea58..dcd5e22 100644 --- a/src/cfuopt.h +++ b/src/cfuopt.h @@ -3,7 +3,7 @@ * Change log: */ -#include "cfu.h" +#include #ifndef _CFU_OPT_H_ #define _CFU_OPT_H_ diff --git a/src/cfustring.c b/src/cfustring.c index 9d2b62c..f88c1c0 100644 --- a/src/cfustring.c +++ b/src/cfustring.c @@ -45,16 +45,7 @@ #include #include #include - -#ifdef CFU_DEBUG -#ifdef NDEBUG -#undef NDEBUG -#endif -#else -#ifndef NDEBUG -#define NDEBUG 1 -#endif -#endif +#include #include struct cfustring { diff --git a/src/cfustring.h b/src/cfustring.h index 440942c..2a55bbd 100644 --- a/src/cfustring.h +++ b/src/cfustring.h @@ -42,13 +42,10 @@ #define _CFU_STRING_H_ #include - -#include #include +#include -#ifdef __cplusplus -extern "C" { -#endif +CFU_BEGIN_DECLS struct cfustring; typedef struct cfustring cfustring_t; @@ -119,8 +116,6 @@ extern "C" { /* Like cfustring_split_to_c_str(), but split a char * instead of a cfustring_t *. */ extern char ** cfustring_c_str_split(const char *c_str, size_t *num_strings, size_t limit, ...); -#ifdef __cplusplus -} -#endif +CFU_END_DECLS #endif diff --git a/src/cfuthread_queue.c b/src/cfuthread_queue.c index 9b7267a..6d4b1f9 100644 --- a/src/cfuthread_queue.c +++ b/src/cfuthread_queue.c @@ -11,16 +11,6 @@ #include #include #include - -#ifdef CFU_DEBUG -#ifdef NDEBUG -#undef NDEBUG -#endif -#else -#ifndef NDEBUG -#define NDEBUG 1 -#endif -#endif #include struct cfuthread_queue { diff --git a/src/cfuthread_queue.h b/src/cfuthread_queue.h index b80596a..5ada249 100644 --- a/src/cfuthread_queue.h +++ b/src/cfuthread_queue.h @@ -44,9 +44,7 @@ #include -#ifdef __cplusplus -extern "C" { -#endif +CFU_BEGIN_DECLS /* cfuthread_queue provides a way to serialize requests for a * resource where you want the resource to be accessed from a @@ -92,9 +90,6 @@ extern "C" { */ extern void cfuthread_queue_destroy(cfuthread_queue_t *); -#ifdef __cplusplus -} -#endif - +CFU_END_DECLS #endif diff --git a/src/cfutime.c b/src/cfutime.c index d444442..918f92e 100644 --- a/src/cfutime.c +++ b/src/cfutime.c @@ -40,19 +40,11 @@ #include "cfu.h" #include "cfutime.h" + #include #include - -#ifdef CFU_DEBUG -#ifdef NDEBUG -#undef NDEBUG -#endif -#else -#ifndef NDEBUG -#define NDEBUG 1 -#endif -#endif #include +#include typedef struct cfutime { libcfu_type type; diff --git a/src/cfutime.h b/src/cfutime.h index 019534d..cbac1af 100644 --- a/src/cfutime.h +++ b/src/cfutime.h @@ -43,11 +43,7 @@ #include -#include - -#ifdef __cplusplus -extern "C" { -#endif +CFU_BEGIN_DECLS struct cfutime; typedef struct cfutime cfutime_t; @@ -67,8 +63,6 @@ extern "C" { /* Deallocate resources allocated for time. */ extern void cfutime_free(cfutime_t *time); -#ifdef __cplusplus -} -#endif +CFU_END_DECLS #endif