add endian functions
This commit is contained in:
parent
bc6340588e
commit
929df6a38c
6 changed files with 148 additions and 18 deletions
39
engine/include/GearBox/Endian.h
Normal file
39
engine/include/GearBox/Endian.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef __GEARBOX_ENDIAN_H__
|
||||
#define __GEARBOX_ENDIAN_H__
|
||||
|
||||
#include <GearBox/MachDep.h>
|
||||
#include <GearBox/TypeDefs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)
|
||||
#define GBEndianHostLittle
|
||||
#else
|
||||
#define GBEndianHostBig
|
||||
#endif
|
||||
|
||||
#ifdef GBEndianHostLittle
|
||||
GBDECL GBI16 GBEndianSwapI16BE(GBI16 in);
|
||||
GBDECL GBI32 GBEndianSwapI32BE(GBI32 in);
|
||||
GBDECL GBI64 GBEndianSwapI64BE(GBI64 in);
|
||||
|
||||
GBDECL GBU16 GBEndianSwapU16BE(GBU16 in);
|
||||
GBDECL GBU32 GBEndianSwapU32BE(GBU32 in);
|
||||
GBDECL GBU64 GBEndianSwapU64BE(GBU64 in);
|
||||
#else
|
||||
#define GBEndianSwapI16BE(in) (in)
|
||||
#define GBEndianSwapI32BE(in) (in)
|
||||
#define GBEndianSwapI64BE(in) (in)
|
||||
|
||||
#define GBEndianSwapU16BE(in) (in)
|
||||
#define GBEndianSwapU32BE(in) (in)
|
||||
#define GBEndianSwapU64BE(in) (in)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -13,5 +13,6 @@
|
|||
#include <GearBox/GL.h>
|
||||
#include <GearBox/File.h>
|
||||
#include <GearBox/Resource.h>
|
||||
#include <GearBox/Endian.h>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,6 +3,40 @@
|
|||
|
||||
#include <GearBox/MachDep.h>
|
||||
|
||||
#if defined(_MSC_VER) || defined(__WATCOMC__)
|
||||
typedef __int8_t GBI8;
|
||||
typedef __int16_t GBI16;
|
||||
typedef __int32_t GBI32;
|
||||
typedef __int64_t GBI64;
|
||||
|
||||
typedef unsigned __int8_t GBU8;
|
||||
typedef unsigned __int16_t GBU16;
|
||||
typedef unsigned __int32_t GBU32;
|
||||
typedef unsigned __int64_t GBU64;
|
||||
#elif __STDC_VERSION__ >= 199901L
|
||||
#include <stdint.h>
|
||||
|
||||
typedef int8_t GBI8;
|
||||
typedef int16_t GBI16;
|
||||
typedef int32_t GBI32;
|
||||
typedef int64_t GBI64;
|
||||
|
||||
typedef uint8_t GBU8;
|
||||
typedef uint16_t GBU16;
|
||||
typedef uint32_t GBU32;
|
||||
typedef uint64_t GBU64;
|
||||
#else
|
||||
typedef signed char GBI8;
|
||||
typedef short GBI16;
|
||||
typedef int GBI32;
|
||||
typedef long GBI64;
|
||||
|
||||
typedef unsigned char GBU8;
|
||||
typedef unsigned short GBU16;
|
||||
typedef unsigned int GBU32;
|
||||
typedef unsigned long GBU64;
|
||||
#endif
|
||||
|
||||
typedef struct _GBVersion GBVersion;
|
||||
typedef struct _GBEngineParam GBEngineParam;
|
||||
typedef struct _GBResourceKV GBResourceKV;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue