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.
This commit is contained in:
Lassi Kortela 2019-08-09 21:35:20 +03:00
parent 12fb30462b
commit c84c71adcc
9 changed files with 11 additions and 19 deletions

View File

@ -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);

View File

@ -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

View File

@ -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"

View File

@ -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,

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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];

View File

@ -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;