From fca55e374145de586143a340aa46a72d4f0ea47a Mon Sep 17 00:00:00 2001 From: tron Date: Wed, 24 Nov 2004 13:19:48 +0000 Subject: (svn r793) Merge INLINE -> inline replacement (revision 376) --- macros.h | 50 +++++++++++++++++++++++++------------------------- misc.c | 2 +- newgrf.c | 2 +- pathfind.c | 4 ++-- saveload.c | 8 ++++---- smallmap_gui.c | 18 +++++++++--------- station_cmd.c | 4 ++-- stdafx.h | 11 +++++------ viewport.c | 2 +- 9 files changed, 50 insertions(+), 51 deletions(-) diff --git a/macros.h b/macros.h index 6bde10e4a..f45ffac78 100644 --- a/macros.h +++ b/macros.h @@ -11,20 +11,20 @@ #undef max #endif -static INLINE int min(int a, int b) { if (a <= b) return a; return b; } -static INLINE int max(int a, int b) { if (a >= b) return a; return b; } -static INLINE int64 max64(int64 a, int64 b) { if (a >= b) return a; return b; } +static inline int min(int a, int b) { if (a <= b) return a; return b; } +static inline int max(int a, int b) { if (a >= b) return a; return b; } +static inline int64 max64(int64 a, int64 b) { if (a >= b) return a; return b; } -static INLINE uint minu(uint a, uint b) { if (a <= b) return a; return b; } -static INLINE uint maxu(uint a, uint b) { if (a >= b) return a; return b; } +static inline uint minu(uint a, uint b) { if (a <= b) return a; return b; } +static inline uint maxu(uint a, uint b) { if (a >= b) return a; return b; } -static INLINE int clamp(int a, int min, int max) { if (a <= min) return min; if (a >= max) return max; return a; } -static INLINE int clamp2(int a, int min, int max) { if (a <= min) a=min; if (a >= max) a=max; return a; } -static INLINE bool int32_add_overflow(int32 a, int32 b) { return (int32)(a^b)>=0 && (int32)(a^(a+b))<0; } -static INLINE bool int32_sub_overflow(int32 a, int32 b) { return (int32)(a^b)<0 && (int32)(a^(a-b))<0; } +static inline int clamp(int a, int min, int max) { if (a <= min) return min; if (a >= max) return max; return a; } +static inline int clamp2(int a, int min, int max) { if (a <= min) a=min; if (a >= max) a=max; return a; } +static inline bool int32_add_overflow(int32 a, int32 b) { return (int32)(a^b)>=0 && (int32)(a^(a+b))<0; } +static inline bool int32_sub_overflow(int32 a, int32 b) { return (int32)(a^b)<0 && (int32)(a^(a-b))<0; } -static INLINE bool str_eq(const byte *a, const byte *b) +static inline bool str_eq(const byte *a, const byte *b) { int i=0; while (a[i] == b[i]) { @@ -36,7 +36,7 @@ static INLINE bool str_eq(const byte *a, const byte *b) } // Will crash if strings are equal -static INLINE bool str_is_below(byte *a, byte *b) { +static inline bool str_is_below(byte *a, byte *b) { while (*a <= *b) { if (*a < *b) return true; a++; @@ -46,19 +46,19 @@ static INLINE bool str_is_below(byte *a, byte *b) { } -static INLINE int32 BIGMULSS(int32 a, int32 b, int shift) { +static inline int32 BIGMULSS(int32 a, int32 b, int shift) { return (int32)(((int64)(a) * (int64)(b)) >> (shift)); } -static INLINE int64 BIGMULSS64(int64 a, int64 b, int shift) { +static inline int64 BIGMULSS64(int64 a, int64 b, int shift) { return ((a) * (b)) >> (shift); } -static INLINE uint32 BIGMULUS(uint32 a, uint32 b, int shift) { +static inline uint32 BIGMULUS(uint32 a, uint32 b, int shift) { return (uint32)(((uint64)(a) * (uint64)(b)) >> (shift)); } -static INLINE int64 BIGMULS(int32 a, int32 b) { +static inline int64 BIGMULS(int32 a, int32 b) { return (int32)(((int64)(a) * (int64)(b))); } @@ -145,7 +145,7 @@ extern const byte _ffb_64[128]; */ #define KILL_FIRST_BIT(x) _ffb_64[(x)+64] -static INLINE int FindFirstBit2x64(int value) +static inline int FindFirstBit2x64(int value) { int i = 0; if ( (byte) value == 0) { @@ -195,17 +195,17 @@ static INLINE int FindFirstBit2x64(int value) #define abs myabs -static INLINE int intxchg_(int *a, int b) { int t = *a; *a = b; return t; } +static inline int intxchg_(int *a, int b) { int t = *a; *a = b; return t; } #define intxchg(a,b) intxchg_(&(a), (b)) #define intswap(a,b) ((b) = intxchg_(&(a), (b))) -static INLINE int myabs(int a) { if (a<0) a = -a; return a; } -static INLINE int64 myabs64(int64 a) { if (a<0) a = -a; return a; } +static inline int myabs(int a) { if (a<0) a = -a; return a; } +static inline int64 myabs64(int64 a) { if (a<0) a = -a; return a; } -static INLINE void swap_byte(byte *a, byte *b) { byte t = *a; *a = *b; *b = t; } -static INLINE void swap_uint16(uint16 *a, uint16 *b) { uint16 t = *a; *a = *b; *b = t; } -static INLINE void swap_int16(int16 *a, int16 *b) { int16 t = *a; *a = *b; *b = t; } -static INLINE void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a = *b; *b = t; } +static inline void swap_byte(byte *a, byte *b) { byte t = *a; *a = *b; *b = t; } +static inline void swap_uint16(uint16 *a, uint16 *b) { uint16 t = *a; *a = *b; *b = t; } +static inline void swap_int16(int16 *a, int16 *b) { int16 t = *a; *a = *b; *b = t; } +static inline void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a = *b; *b = t; } @@ -214,14 +214,14 @@ static INLINE void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a # define ADD_WORD(x) (x)&0xFF, ((x) >> 8)&0xFF # define ADD_DWORD(x) (x)&0xFF, ((x) >> 8)&0xFF, ((x) >> 16)&0xFF, ((x) >> 24)&0xFF #elif defined(TTD_BIG_ENDIAN) - static INLINE uint16 READ_LE_UINT16(const void *b) { + static inline uint16 READ_LE_UINT16(const void *b) { return ((const byte*)b)[0] + (((const byte*)b)[1] << 8); } # define ADD_WORD(x) ((x) >> 8)&0xFF, (x)&0xFF # define ADD_DWORD(x) ((x) >> 24)&0xFF, ((x) >> 16)&0xFF, ((x) >> 8)&0xFF, (x)&0xFF #endif -static INLINE void WRITE_LE_UINT16(void *b, uint16 x) { +static inline void WRITE_LE_UINT16(void *b, uint16 x) { ((byte*)b)[0] = (byte)x; ((byte*)b)[1] = (byte)(x >> 8); } diff --git a/misc.c b/misc.c index dcd7ae133..6e6bc1b42 100644 --- a/misc.c +++ b/misc.c @@ -10,7 +10,7 @@ extern void InitNewsItemStructs(); byte _name_array[512][32]; -static INLINE uint32 ROR(uint32 x, int n) +static inline uint32 ROR(uint32 x, int n) { return (x >> n) + (x << ((sizeof(x)*8)-n)); } diff --git a/newgrf.c b/newgrf.c index bf70a8596..841a4e73b 100644 --- a/newgrf.c +++ b/newgrf.c @@ -114,7 +114,7 @@ do { \ } while (0) -static byte INLINE grf_load_byte(byte **buf) +static inline byte grf_load_byte(byte **buf) { return *(*buf)++; } diff --git a/pathfind.c b/pathfind.c index 7547d348e..122b79ad9 100644 --- a/pathfind.c +++ b/pathfind.c @@ -434,7 +434,7 @@ typedef struct { // called after a new element was added in the queue at the last index. // move it down to the proper position -static void INLINE HeapifyUp(NewTrackPathFinder *tpf) +static void inline HeapifyUp(NewTrackPathFinder *tpf) { StackedItem si; int i = ++tpf->nstack; @@ -448,7 +448,7 @@ static void INLINE HeapifyUp(NewTrackPathFinder *tpf) } // called after the element 0 was eaten. fill it with a new element -static void INLINE HeapifyDown(NewTrackPathFinder *tpf) +static void inline HeapifyDown(NewTrackPathFinder *tpf) { StackedItem si; int i = 1, j; diff --git a/saveload.c b/saveload.c index 6b0462019..b4ab2982d 100644 --- a/saveload.c +++ b/saveload.c @@ -173,22 +173,22 @@ static uint SlGetGammaLength(uint i) { return (i>=0x80) ? 2 : 1; } -int INLINE SlReadSparseIndex() +int inline SlReadSparseIndex() { return SlReadSimpleGamma(); } -void INLINE SlWriteSparseIndex(uint index) +void inline SlWriteSparseIndex(uint index) { SlWriteSimpleGamma(index); } -int INLINE SlReadArrayLength() +int inline SlReadArrayLength() { return SlReadSimpleGamma(); } -void INLINE SlWriteArrayLength(uint length) +void inline SlWriteArrayLength(uint length) { SlWriteSimpleGamma(length); } diff --git a/smallmap_gui.c b/smallmap_gui.c index d76805ddf..280252054 100644 --- a/smallmap_gui.c +++ b/smallmap_gui.c @@ -221,7 +221,7 @@ static const uint16 * const _legend_table[] = { }; #if defined(TTD_ALIGNMENT_4) - static INLINE void WRITE_PIXELS(void *dst, uint32 val) + static inline void WRITE_PIXELS(void *dst, uint32 val) { byte *d = (byte*)dst; # if defined(TTD_BIG_ENDIAN) @@ -238,7 +238,7 @@ static const uint16 * const _legend_table[] = { } /* need to use OR, otherwise we will overwrite the wrong pixels at the edges :( */ - static INLINE void WRITE_PIXELS_OR(void *dst, uint32 val) + static inline void WRITE_PIXELS_OR(void *dst, uint32 val) { byte *d = (byte*)dst; # if defined(TTD_BIG_ENDIAN) @@ -328,7 +328,7 @@ static const uint32 _smallmap_vegetation_andor[12][2] = { {MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, }; -static uint32 INLINE GetSmallMapCountoursPixels(uint tile) +static inline uint32 GetSmallMapCountoursPixels(uint tile) { uint t; @@ -358,7 +358,7 @@ static void DrawSmallMapContours(byte *dst, uint xc, uint yc, int pitch, int rep } -static uint32 INLINE GetSmallMapVehiclesPixels(uint tile) +static inline uint32 GetSmallMapVehiclesPixels(uint tile) { uint t; @@ -411,7 +411,7 @@ static const byte _industry_smallmap_colors[175] = { 15, 15, 15, 15, 15, 15, 15, }; -static uint32 INLINE GetSmallMapIndustriesPixels(uint tile) +static inline uint32 GetSmallMapIndustriesPixels(uint tile) { int t; @@ -443,7 +443,7 @@ static void DrawSmallMapIndustries(byte *dst, uint xc, uint yc, int pitch, int r } while (xc++,yc++,dst+=pitch,--reps != 0); } -static uint32 INLINE GetSmallMapRoutesPixels(uint tile) +static inline uint32 GetSmallMapRoutesPixels(uint tile) { int t; uint32 bits; @@ -499,7 +499,7 @@ static const uint32 _vegetation_clear_bits[4 + 7] = { MKCOLOR(0x54545454), }; -static uint32 INLINE GetSmallMapVegetationPixels(uint tile) +static inline uint32 GetSmallMapVegetationPixels(uint tile) { int i,t; uint32 bits; @@ -545,7 +545,7 @@ static void DrawSmallMapVegetation(byte *dst, uint xc, uint yc, int pitch, int r static uint32 *_owner_colors; -static uint32 INLINE GetSmallMapOwnerPixels(uint tile) +static inline uint32 GetSmallMapOwnerPixels(uint tile) { int t; @@ -601,7 +601,7 @@ static const byte _vehicle_type_colors[6] = { 184, 191, 152, 15, 215, 184 }; -static INLINE uint32 dup_byte32(byte b) { +static inline uint32 dup_byte32(byte b) { return b + (b << 8) + (b << 16) + (b << 24); } diff --git a/station_cmd.c b/station_cmd.c index 9074324cf..04bb7d526 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -2119,7 +2119,7 @@ static void ClickTile_Station(uint tile) } } -static INLINE bool IsTrainStationTile(uint tile) { +static inline bool IsTrainStationTile(uint tile) { return IS_TILETYPE(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8); } @@ -2233,7 +2233,7 @@ static void StationHandleBigTick(Station *st) } } -static INLINE void byte_inc_sat(byte *p) { byte b = *p + 1; if (b != 0) *p = b; } +static inline void byte_inc_sat(byte *p) { byte b = *p + 1; if (b != 0) *p = b; } static byte _rating_boost[3] = { 0, 31, 63}; diff --git a/stdafx.h b/stdafx.h index 6785f8552..94524f6f5 100644 --- a/stdafx.h +++ b/stdafx.h @@ -43,7 +43,6 @@ #if defined(__GNUC__) # define NORETURN # define FORCEINLINE inline -# define INLINE inline # define CDECL //#include //#include @@ -62,7 +61,7 @@ # include // alloca() # define NORETURN __declspec(noreturn) # define FORCEINLINE __forceinline -# define INLINE _inline +# define inline _inline # define CDECL _cdecl # define NOT_REACHED() _assume(0) # define snprintf _snprintf @@ -116,10 +115,10 @@ typedef unsigned __int64 uint64; # define TTD_ALIGNMENT_2 # define TTD_ALIGNMENT_4 -static uint32 INLINE TO_LE32(uint32 x) { return BSWAP32(x); } -static uint16 INLINE TO_LE16(uint16 x) { return BSWAP16(x); } -static uint32 INLINE FROM_LE32(uint32 x) { return BSWAP32(x); } -static uint16 INLINE FROM_LE16(uint16 x) { return BSWAP16(x); } +static inline uint32 TO_LE32(uint32 x) { return BSWAP32(x); } +static inline uint16 TO_LE16(uint16 x) { return BSWAP16(x); } +static inline uint32 FROM_LE32(uint32 x) { return BSWAP32(x); } +static inline uint16 FROM_LE16(uint16 x) { return BSWAP16(x); } #define TO_BE32(x) x #define TO_BE16(x) x #define FROM_BE32(x) x diff --git a/viewport.c b/viewport.c index 76db3b597..5c195503f 100644 --- a/viewport.c +++ b/viewport.c @@ -1227,7 +1227,7 @@ static void ViewportDrawChk(ViewPort *vp, int left, int top, int right, int bott } } -static void INLINE ViewportDraw(ViewPort *vp, int left, int top, int right, int bottom) +static inline void ViewportDraw(ViewPort *vp, int left, int top, int right, int bottom) { int t; -- cgit v1.2.3-70-g09d2