From 90d24a16486a6263b6a15f95b673d4dd5d3f90a5 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 11 May 2013 00:07:13 +0200 Subject: [PATCH] Unified usage of the 'inline' attribute for functions Autoconf provides the necessary stuff to detect if inline keyword is supported, and to detect special syntaxes, so let's use this and remove the multiple local definitions, this makes code simpler. --- WINGs/hashtable.c | 10 +++------- WINGs/proplist.c | 4 ++-- WINGs/wconfig.h | 6 ------ WINGs/wtextfield.c | 6 +++--- configure.ac | 1 + src/wconfig.h.in | 6 ------ util/wmagnify.c | 4 +--- wrlib/misc.c | 2 +- 8 files changed, 11 insertions(+), 28 deletions(-) diff --git a/WINGs/hashtable.c b/WINGs/hashtable.c index 27e71e43..aec4f5a2 100644 --- a/WINGs/hashtable.c +++ b/WINGs/hashtable.c @@ -1,3 +1,4 @@ +#include #include #include @@ -8,11 +9,6 @@ #define INITIAL_CAPACITY 23 -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -# define INLINE inline -#else -# define INLINE -#endif typedef struct HashItem { const void *key; @@ -39,7 +35,7 @@ typedef struct W_HashTable { #define RELKEY(table, key) if ((table)->callbacks.releaseKey) \ (*(table)->callbacks.releaseKey)(key) -static INLINE unsigned hashString(const char *key) +static inline unsigned hashString(const char *key) { unsigned ret = 0; unsigned ctr = 0; @@ -52,7 +48,7 @@ static INLINE unsigned hashString(const char *key) return ret; } -static INLINE unsigned hashPtr(const void *key) +static inline unsigned hashPtr(const void *key) { return ((size_t) key / sizeof(char *)); } diff --git a/WINGs/proplist.c b/WINGs/proplist.c index 801206e4..5c5242d0 100644 --- a/WINGs/proplist.c +++ b/WINGs/proplist.c @@ -465,7 +465,7 @@ static char *indentedDescription(WMPropList * plist, int level) return retstr; } -static INLINE int getChar(PLData * pldata) +static inline int getChar(PLData * pldata) { int c; @@ -482,7 +482,7 @@ static INLINE int getChar(PLData * pldata) return c; } -static INLINE int getNonSpaceChar(PLData * pldata) +static inline int getNonSpaceChar(PLData * pldata) { int c; diff --git a/WINGs/wconfig.h b/WINGs/wconfig.h index 819ad5ff..995260a8 100644 --- a/WINGs/wconfig.h +++ b/WINGs/wconfig.h @@ -29,12 +29,6 @@ # define _(text) (text) #endif -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -# define INLINE inline -#else -# define INLINE -#endif - #endif /* WINGS_CONFIG_H_ */ diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index cec8a385..955db533 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -122,7 +122,7 @@ static WMSelectionProcs selectionHandler = { #define TEXT_WIDTH2(tPtr, start, end) (WMWidthOfString((tPtr)->font, \ &((tPtr)->text[(start)]), (end) - (start))) -static INLINE int oneUTF8CharBackward(const char *str, int len) +static inline int oneUTF8CharBackward(const char *str, int len) { const unsigned char *ustr = (const unsigned char *)str; int pos = 0; @@ -131,7 +131,7 @@ static INLINE int oneUTF8CharBackward(const char *str, int len) return pos; } -static INLINE int oneUTF8CharForward(const char *str, int len) +static inline int oneUTF8CharForward(const char *str, int len) { const unsigned char *ustr = (const unsigned char *)str; int pos = 0; @@ -141,7 +141,7 @@ static INLINE int oneUTF8CharForward(const char *str, int len) } // find the beginning of the UTF8 char pointed by str -static INLINE int seekUTF8CharStart(const char *str, int len) +static inline int seekUTF8CharStart(const char *str, int len) { const unsigned char *ustr = (const unsigned char *)str; int pos = 0; diff --git a/configure.ac b/configure.ac index 0e4e7bdf..14190807 100644 --- a/configure.ac +++ b/configure.ac @@ -230,6 +230,7 @@ dnl Checks for typedefs, structures, and compiler characteristics. dnl ============================================================== AC_DECL_SYS_SIGLIST AC_C_CONST +AC_C_INLINE AC_TYPE_SIZE_T AC_TYPE_PID_T AC_TYPE_SIGNAL diff --git a/src/wconfig.h.in b/src/wconfig.h.in index 9201afca..c2a79a35 100644 --- a/src/wconfig.h.in +++ b/src/wconfig.h.in @@ -397,11 +397,5 @@ #define M_(text) (text) #endif -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -#define INLINE inline -#else -#define INLINE -#endif - #endif /* WMCONFIG_H_ */ diff --git a/util/wmagnify.c b/util/wmagnify.c index 91e2d2ad..f77cf10a 100644 --- a/util/wmagnify.c +++ b/util/wmagnify.c @@ -5,6 +5,7 @@ * * This program is in the Public Domain. */ +#include #include @@ -64,9 +65,6 @@ unsigned int black; WMColor *cursorColor1; WMColor *cursorColor2; -#ifndef __GNUC__ -#define inline -#endif static BufferData *makeBufferData(WMWindow * win, WMLabel * label, int width, int height, int magfactor) { diff --git a/wrlib/misc.c b/wrlib/misc.c index 5b0bac4d..4a7c0657 100644 --- a/wrlib/misc.c +++ b/wrlib/misc.c @@ -159,7 +159,7 @@ void RClearImage(RImage * image, const RColor * color) } } -static __inline__ unsigned char clip(int c) +static inline unsigned char clip(int c) { if (c > 255) c = 255; -- 2.11.4.GIT