From c84c71adcc50b2d763c94686086f69b4caf2e0d5 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Fri, 9 Aug 2019 21:35:20 +0300 Subject: [PATCH] Get rid of INLINE and STATIC_INLINE Nowadays compilers have good optimizers that know when to inline static functions depending on the user's chosen optimization level (and speed vs size optimization). We don't need to annotate functions manually. --- c/bitvector.h | 2 +- c/dtypes.h | 8 -------- c/flisp.c | 2 +- c/flisp.h | 2 +- c/operators.h | 2 +- c/print.h | 2 +- c/read.h | 2 +- c/utf8.c | 2 +- c/utils.h | 8 ++++---- 9 files changed, 11 insertions(+), 19 deletions(-) diff --git a/c/bitvector.h b/c/bitvector.h index 627d87b..7e89b31 100644 --- a/c/bitvector.h +++ b/c/bitvector.h @@ -6,7 +6,7 @@ #ifdef __INTEL_COMPILER #define count_bits(b) _popcnt32(b) #else -static inline uint32_t count_bits(uint32_t b) +static uint32_t count_bits(uint32_t b) { b = b - ((b >> 1) & 0x55555555); b = ((b >> 2) & 0x33333333) + (b & 0x33333333); diff --git a/c/dtypes.h b/c/dtypes.h index f8fb701..5d59da0 100644 --- a/c/dtypes.h +++ b/c/dtypes.h @@ -66,14 +66,6 @@ typedef int bool_t; -#if defined(__INTEL_COMPILER) && defined(WIN32) -#define STATIC_INLINE static -#define INLINE -#else -#define STATIC_INLINE static inline -#define INLINE inline -#endif - #ifdef BITS64 #define TOP_BIT 0x8000000000000000 #define NBITS 64 diff --git a/c/flisp.c b/c/flisp.c index f46c2c6..fa1d782 100644 --- a/c/flisp.c +++ b/c/flisp.c @@ -423,7 +423,7 @@ value_t alloc_vector(size_t n, int init) // ---------------------------------------------------------------------- static int isnumtok(char *tok, value_t *pval); -static inline int symchar(char c); +static int symchar(char c); #include "print.h" diff --git a/c/flisp.h b/c/flisp.h index ca598ed..b524050 100644 --- a/c/flisp.h +++ b/c/flisp.h @@ -201,7 +201,7 @@ void bounds_error(char *fname, value_t arr, value_t ind) __attribute__((__noreturn__)); extern value_t ArgError, IOError, KeyError, MemoryError, EnumerationError; extern value_t UnboundError; -static inline void argcount(char *fname, uint32_t nargs, uint32_t c) +static void argcount(char *fname, uint32_t nargs, uint32_t c) { if (__unlikely(nargs != c)) lerrorf(ArgError, "%s: too %s arguments", fname, diff --git a/c/operators.h b/c/operators.h index 34072c1..b11ef1e 100644 --- a/c/operators.h +++ b/c/operators.h @@ -1,6 +1,6 @@ extern double trunc(double x); -STATIC_INLINE double fpart(double arg) { return arg - trunc(arg); } +static double fpart(double arg) { return arg - trunc(arg); } // given a number, determine an appropriate type for storing it #if 0 diff --git a/c/print.h b/c/print.h index a7e97b4..7649e49 100644 --- a/c/print.h +++ b/c/print.h @@ -145,7 +145,7 @@ static void print_symbol_name(struct ios *f, char *name) to print anyway. */ #define SMALL_STR_LEN 20 -static inline int tinyp(value_t v) +static int tinyp(value_t v) { if (issymbol(v)) return (u8_strwidth(symbol_name(v)) < SMALL_STR_LEN); diff --git a/c/read.h b/c/read.h index 1d1f896..abd85bf 100644 --- a/c/read.h +++ b/c/read.h @@ -28,7 +28,7 @@ enum { // exceptions are '.', which is an ordinary symbol character // unless it's the only character in the symbol, and '#', which is // an ordinary symbol character unless it's the first character. -static inline int symchar(char c) +static int symchar(char c) { static char *special = "()[]'\";`,\\| \f\n\r\t\v"; return !strchr(special, c); diff --git a/c/utf8.c b/c/utf8.c index 8d5bb25..5995323 100644 --- a/c/utf8.c +++ b/c/utf8.c @@ -447,7 +447,7 @@ size_t u8_unescape(char *buf, size_t sz, const char *src) return c; } -static inline int buf_put2c(char *buf, const char *src) +static int buf_put2c(char *buf, const char *src) { buf[0] = src[0]; buf[1] = src[1]; diff --git a/c/utils.h b/c/utils.h index 4a19b3c..4be3429 100644 --- a/c/utils.h +++ b/c/utils.h @@ -34,14 +34,14 @@ int isdigit_base(char c, int base); #endif #if !defined(__INTEL_COMPILER) && (defined(ARCH_X86) || defined(ARCH_X86_64)) -STATIC_INLINE uint16_t ByteSwap16(uint16_t x) +static uint16_t ByteSwap16(uint16_t x) { __asm("xchgb %b0,%h0" : LEGACY_REGS(x) : "0"(x)); return x; } #define bswap_16(x) ByteSwap16(x) -STATIC_INLINE uint32_t ByteSwap32(uint32_t x) +static uint32_t ByteSwap32(uint32_t x) { #if __CPU__ > 386 __asm("bswap %0" @@ -60,7 +60,7 @@ STATIC_INLINE uint32_t ByteSwap32(uint32_t x) #define bswap_32(x) ByteSwap32(x) -STATIC_INLINE uint64_t ByteSwap64(uint64_t x) +static uint64_t ByteSwap64(uint64_t x) { #ifdef ARCH_X86_64 __asm("bswap %0" : "=r"(x) : "0"(x)); @@ -91,7 +91,7 @@ STATIC_INLINE uint64_t ByteSwap64(uint64_t x) (((x)&0x0000ff00) << 8) | (((x)&0x000000ff) << 24)) #endif -STATIC_INLINE uint64_t ByteSwap64(uint64_t x) +static uint64_t ByteSwap64(uint64_t x) { union { uint64_t ll;