From: Marko Kreen Date: Thu, 14 Feb 2008 13:38:52 +0000 (+0000) Subject: system.h + types cleanup X-Git-Tag: pgbouncer_1_2_rc2~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=efbca3111059699fc9380e8a4c503b9f7cb42d91;p=pgbouncer system.h + types cleanup - use proper printf args from inttypes.h instead of casting to ull - remove unused macros - tag replacement functions as _mustcheck --- diff --git a/include/system.h b/include/system.h index 9ef317b..a06401e 100644 --- a/include/system.h +++ b/include/system.h @@ -24,8 +24,6 @@ #include "config.h" #endif -#define _GNU_SOURCE - #include #include #include @@ -65,34 +63,26 @@ #define FLEX_ARRAY 1 #endif -/* gcc has hew positive aspects too */ #ifdef __GNUC__ -#define unlikely(x) __builtin_expect(!!(x), 0) -#define likely(x) __builtin_expect(!!(x), 1) - +/* gcc has hew positive aspects too */ #define _MUSTCHECK __attribute__((warn_unused_result)) #define _DEPRECATED __attribute__((deprecated)) #define _PRINTF(fmtpos, argpos) __attribute__((format(printf, fmtpos, argpos))) #define _MALLOC __attribute__((malloc)) -#if 0 -#define _USED __attribute__((used)) -#define _UNUSED __attribute__((unused)) -#define _NONNULL(args...) __attribute__((nonnull(args))) -#define _REGPARM(num) __attribute__((regparm(num))) -#define _FASTCALL __attribute__((fastcall)) -#endif +/* those do not seem to work well */ +#define unlikely(x) __builtin_expect(!!(x), 0) +#define likely(x) __builtin_expect(!!(x), 1) #else -#define unlikely(x) x -#define likely(x) x - #define _MUSTCHECK #define _DEPRECATED #define _PRINTF(x,y) #define _MALLOC +#define unlikely(x) x +#define likely(x) x #endif @@ -110,7 +100,6 @@ do { \ #endif #ifndef UNIX_PATH_MAX -/* #define UNIX_PATH_MAX (sizeof(((struct sockaddr_un *)0)->sun_path)) */ #define UNIX_PATH_MAX 128 /* actual sizeof() will be applied later anyway */ #endif @@ -119,9 +108,6 @@ do { \ typedef uint64_t usec_t; -/* shortcut to simplify printf of u64 types */ -typedef unsigned long long ull_t; - /* * bool type. */ @@ -143,13 +129,13 @@ typedef unsigned char bool; */ #ifndef HAVE_STRLCPY -size_t strlcpy(char *dst, const char *src, size_t n); +size_t strlcpy(char *dst, const char *src, size_t n) _MUSTCHECK; #endif #ifndef HAVE_STRLCAT -size_t strlcat(char *dst, const char *src, size_t n); +size_t strlcat(char *dst, const char *src, size_t n) _MUSTCHECK; #endif #ifndef HAVE_GETPEEREID -int getpeereid(int fd, uid_t *uid_p, gid_t *gid_p); +int getpeereid(int fd, uid_t *uid_p, gid_t *gid_p) _MUSTCHECK; #endif /* @@ -200,4 +186,3 @@ static inline int _inline_strcmp(const char *a, const char *b) #undef strcmp #define strcmp(a, b) _inline_strcmp(a, b) - diff --git a/src/pktbuf.c b/src/pktbuf.c index 88b6d47..6c18923 100644 --- a/src/pktbuf.c +++ b/src/pktbuf.c @@ -384,7 +384,7 @@ void pktbuf_write_DataRow(PktBuf *buf, const char *tupdesc, ...) sprintf(tmp, "%d", va_arg(ap, int)); val = tmp; } else if (tupdesc[i] == 'q') { - sprintf(tmp, "%llu", (unsigned long long)va_arg(ap, uint64_t)); + sprintf(tmp, "%" PRIu64, va_arg(ap, uint64_t)); val = tmp; } else if (tupdesc[i] == 's') { val = va_arg(ap, char *); diff --git a/src/stats.c b/src/stats.c index cb83581..385904b 100644 --- a/src/stats.c +++ b/src/stats.c @@ -188,10 +188,12 @@ static void refresh_stats(int s, short flags, void *arg) } calc_average(&avg, &cur_total, &old_total); /* send totals to logfile */ - log_info("Stats: %llu req/s, in %llu b/s, " - "out %llu b/s, query %llu us", - (ull_t)avg.request_count, (ull_t)avg.client_bytes, - (ull_t)avg.server_bytes, (ull_t)avg.query_time); + log_info("Stats: %" PRIu64 " req/s," + " in %" PRIu64 " b/s," + " out %" PRIu64 " b/s," + "query %" PRIu64 " us", + avg.request_count, avg.client_bytes, + avg.server_bytes, avg.query_time); safe_evtimer_add(&ev_stats, &period); }