Skip to content

Commit

Permalink
COMMON: Rename FORCEINLINE to XOREOS_FORCEINLINE
Browse files Browse the repository at this point in the history
OGRE also defines a FORCEINLINE
  • Loading branch information
DrMcCoy committed Dec 30, 2013
1 parent c75d4d5 commit ee24658
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 50 deletions.
32 changes: 16 additions & 16 deletions src/common/endianness.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@
// Test for GCC >= 4.3.0 as this version added the bswap builtin
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))

FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) {
XOREOS_FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) {
return __builtin_bswap64(a);
}

FORCEINLINE uint32 SWAP_BYTES_32(uint32 a) {
XOREOS_FORCEINLINE uint32 SWAP_BYTES_32(uint32 a) {
return __builtin_bswap32(a);
}

Expand All @@ -76,11 +76,11 @@

#include <cstdlib>

FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) {
XOREOS_FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) {
return _byteswap_uint64(a);
}

FORCEINLINE uint32 SWAP_BYTES_32(uint32 a) {
XOREOS_FORCEINLINE uint32 SWAP_BYTES_32(uint32 a) {
return _byteswap_ulong(a);
}

Expand Down Expand Up @@ -126,60 +126,60 @@ static inline uint16 SWAP_BYTES_16(const uint16 a) {

#if !defined(XOREOS_NEED_ALIGNMENT)

FORCEINLINE uint16 READ_UINT16(const void *ptr) {
XOREOS_FORCEINLINE uint16 READ_UINT16(const void *ptr) {
return *(const uint16 *)(ptr);
}

FORCEINLINE uint32 READ_UINT32(const void *ptr) {
XOREOS_FORCEINLINE uint32 READ_UINT32(const void *ptr) {
return *(const uint32 *)(ptr);
}

FORCEINLINE uint64 READ_UINT64(const void *ptr) {
XOREOS_FORCEINLINE uint64 READ_UINT64(const void *ptr) {
return *(const uint64 *)(ptr);
}

FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) {
XOREOS_FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) {
*(uint16 *)(ptr) = value;
}

FORCEINLINE void WRITE_UINT32(void *ptr, uint32 value) {
XOREOS_FORCEINLINE void WRITE_UINT32(void *ptr, uint32 value) {
*(uint32 *)(ptr) = value;
}

FORCEINLINE void WRITE_UINT64(void *ptr, uint64 value) {
XOREOS_FORCEINLINE void WRITE_UINT64(void *ptr, uint64 value) {
*(uint64 *)(ptr) = value;
}

// test for GCC >= 4.0. these implementations will automatically use CPU-specific
// instructions for unaligned data when they are available (eg. MIPS)
#elif defined(__GNUC__) && (__GNUC__ >= 4)

FORCEINLINE uint16 READ_UINT16(const void *ptr) {
XOREOS_FORCEINLINE uint16 READ_UINT16(const void *ptr) {
struct Unaligned16 { uint16 val; } __attribute__ ((__packed__));
return ((const Unaligned16 *)ptr)->val;
}

FORCEINLINE uint32 READ_UINT32(const void *ptr) {
XOREOS_FORCEINLINE uint32 READ_UINT32(const void *ptr) {
struct Unaligned32 { uint32 val; } __attribute__ ((__packed__));
return ((const Unaligned32 *)ptr)->val;
}

FORCEINLINE uint64 READ_UINT64(const void *ptr) {
XOREOS_FORCEINLINE uint64 READ_UINT64(const void *ptr) {
struct Unaligned64 { uint64 val; } __attribute__ ((__packed__));
return ((const Unaligned64 *)ptr)->val;
}

FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) {
XOREOS_FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) {
struct Unaligned16 { uint16 val; } __attribute__ ((__packed__));
((Unaligned16 *)ptr)->val = value;
}

FORCEINLINE void WRITE_UINT32(void *ptr, uint32 value) {
XOREOS_FORCEINLINE void WRITE_UINT32(void *ptr, uint32 value) {
struct Unaligned32 { uint32 val; } __attribute__ ((__packed__));
((Unaligned32 *)ptr)->val = value;
}

FORCEINLINE void WRITE_UINT64(void *ptr, uint64 value) {
XOREOS_FORCEINLINE void WRITE_UINT64(void *ptr, uint64 value) {
struct Unaligned64 { uint64 val; } __attribute__ ((__packed__));
((Unaligned64 *)ptr)->val = value;
}
Expand Down
54 changes: 27 additions & 27 deletions src/common/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,43 +148,43 @@ class WriteStream : virtual public Stream {
write(&value, 8);
}

FORCEINLINE void writeSint16LE(int16 value) {
XOREOS_FORCEINLINE void writeSint16LE(int16 value) {
writeUint16LE((uint16)value);
}

FORCEINLINE void writeSint32LE(int32 value) {
XOREOS_FORCEINLINE void writeSint32LE(int32 value) {
writeUint32LE((uint32)value);
}

FORCEINLINE void writeSint64LE(int64 value) {
XOREOS_FORCEINLINE void writeSint64LE(int64 value) {
writeUint64LE((uint64)value);
}

FORCEINLINE void writeSint16BE(int16 value) {
XOREOS_FORCEINLINE void writeSint16BE(int16 value) {
writeUint16BE((uint16)value);
}

FORCEINLINE void writeSint32BE(int32 value) {
XOREOS_FORCEINLINE void writeSint32BE(int32 value) {
writeUint32BE((uint32)value);
}

FORCEINLINE void writeSint64BE(int64 value) {
XOREOS_FORCEINLINE void writeSint64BE(int64 value) {
writeUint64BE((uint64)value);
}

FORCEINLINE void writeIEEEFloatLE(float value) {
XOREOS_FORCEINLINE void writeIEEEFloatLE(float value) {
writeUint32LE((uint32)convertIEEEFloat(value));
}

FORCEINLINE void writeIEEEFloatBE(float value) {
XOREOS_FORCEINLINE void writeIEEEFloatBE(float value) {
writeUint32BE((uint32)convertIEEEFloat(value));
}

FORCEINLINE void writeIEEEDoubleLE(double value) {
XOREOS_FORCEINLINE void writeIEEEDoubleLE(double value) {
writeUint64LE((uint64)convertIEEEDouble(value));
}

FORCEINLINE void writeIEEEDoubleBE(double value) {
XOREOS_FORCEINLINE void writeIEEEDoubleBE(double value) {
writeUint64BE((uint64)convertIEEEDouble(value));
}

Expand Down Expand Up @@ -243,7 +243,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE int8 readSByte() {
XOREOS_FORCEINLINE int8 readSByte() {
return (int8)readByte();
}

Expand Down Expand Up @@ -332,7 +332,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE int16 readSint16LE() {
XOREOS_FORCEINLINE int16 readSint16LE() {
return (int16)readUint16LE();
}

Expand All @@ -343,7 +343,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE int32 readSint32LE() {
XOREOS_FORCEINLINE int32 readSint32LE() {
return (int32)readUint32LE();
}

Expand All @@ -354,7 +354,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE int64 readSint64LE() {
XOREOS_FORCEINLINE int64 readSint64LE() {
return (int64)readUint64LE();
}

Expand All @@ -365,7 +365,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE int16 readSint16BE() {
XOREOS_FORCEINLINE int16 readSint16BE() {
return (int16)readUint16BE();
}

Expand All @@ -376,7 +376,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE int32 readSint32BE() {
XOREOS_FORCEINLINE int32 readSint32BE() {
return (int32)readUint32BE();
}

Expand All @@ -387,7 +387,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE int64 readSint64BE() {
XOREOS_FORCEINLINE int64 readSint64BE() {
return (int64)readUint64BE();
}

Expand All @@ -398,7 +398,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE float readIEEEFloatLE() {
XOREOS_FORCEINLINE float readIEEEFloatLE() {
return convertIEEEFloat(readUint32LE());
}

Expand All @@ -409,7 +409,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE float readIEEEFloatBE() {
XOREOS_FORCEINLINE float readIEEEFloatBE() {
return convertIEEEFloat(readUint32BE());
}

Expand All @@ -420,7 +420,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE double readIEEEDoubleLE() {
XOREOS_FORCEINLINE double readIEEEDoubleLE() {
return convertIEEEDouble(readUint64LE());
}

Expand All @@ -431,7 +431,7 @@ class ReadStream : virtual public Stream {
* if a read error occurred (for which client code can check by
* calling err() and eos() ).
*/
FORCEINLINE double readIEEEDoubleBE() {
XOREOS_FORCEINLINE double readIEEEDoubleBE() {
return convertIEEEDouble(readUint64BE());
}

Expand Down Expand Up @@ -591,15 +591,15 @@ class SeekableSubReadStreamEndian : public SeekableSubReadStream {
return (_bigEndian) ? TO_BE_64(val) : TO_LE_64(val);
}

FORCEINLINE int16 readSint16() {
XOREOS_FORCEINLINE int16 readSint16() {
return (int16)readUint16();
}

FORCEINLINE int32 readSint32() {
XOREOS_FORCEINLINE int32 readSint32() {
return (int32)readUint32();
}

FORCEINLINE int64 readSint64() {
XOREOS_FORCEINLINE int64 readSint64() {
return (int64)readUint64();
}
};
Expand Down Expand Up @@ -725,15 +725,15 @@ class MemoryReadStreamEndian : public MemoryReadStream {
return (_bigEndian) ? TO_BE_64(val) : TO_LE_64(val);
}

FORCEINLINE int16 readSint16() {
XOREOS_FORCEINLINE int16 readSint16() {
return (int16)readUint16();
}

FORCEINLINE int32 readSint32() {
XOREOS_FORCEINLINE int32 readSint32() {
return (int32)readUint32();
}

FORCEINLINE int64 readSint64() {
XOREOS_FORCEINLINE int64 readSint64() {
return (int64)readUint64();
}
};
Expand Down
14 changes: 7 additions & 7 deletions src/common/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@

#define XOREOS_LITTLE_ENDIAN

#define FORCEINLINE __forceinline
#define XOREOS_FORCEINLINE __forceinline
#define NORETURN_PRE __declspec(noreturn)
#define PLUGIN_EXPORT __declspec(dllexport)

static FORCEINLINE int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) {
static XOREOS_FORCEINLINE int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) {
int count = -1;

if (size != 0)
Expand All @@ -61,7 +61,7 @@
return count;
}

static FORCEINLINE int c99_snprintf(char* str, size_t size, const char* format, ...) {
static XOREOS_FORCEINLINE int c99_snprintf(char* str, size_t size, const char* format, ...) {
int count;
va_list ap;

Expand Down Expand Up @@ -108,8 +108,8 @@
#define PACKED_STRUCT __attribute__((__packed__))
#define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y)))

#if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define FORCEINLINE inline __attribute__((__always_inline__))
#if !defined(XOREOS_FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define XOREOS_FORCEINLINE inline __attribute__((__always_inline__))
#endif
#else
#define PACKED_STRUCT
Expand All @@ -119,8 +119,8 @@
//
// Fallbacks / default values for various special macros
//
#ifndef FORCEINLINE
#define FORCEINLINE inline
#ifndef XOREOS_FORCEINLINE
#define XOREOS_FORCEINLINE inline
#endif

#ifndef NORETURN_PRE
Expand Down

0 comments on commit ee24658

Please sign in to comment.