Core: move all base integral types to dedicated header

There was always a problem dealing with core integral types accros various projects, since we typically only use IDA's pseudo definitions for rebuilding decompiled functions. It however did define almost all the integral types we use throughout the SDK. These types have been commented out and a new header has been made that defines everything we need (and we can add more in the future if this deems necessary). This new header is included with tier0/basetypes.h, so all projects have access to it and the tier0 headers will work out of the box without defining anything new.
This commit is contained in:
Kawe Mazidjatari 2024-07-06 17:10:21 +02:00
parent a3fb26dab6
commit 6c6a9b0140
6 changed files with 99 additions and 43 deletions

View File

@ -42,23 +42,25 @@
#define HEXRAYS_CONSTEXPR
#endif
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned long ulong;
typedef char int8;
typedef signed char sint8;
typedef unsigned char uint8;
typedef short int16;
typedef signed short sint16;
typedef unsigned short uint16;
typedef int int32;
typedef signed int sint32;
typedef unsigned int uint32;
typedef ll int64;
typedef ll sint64;
typedef ull uint64;
// R5Sdk: commented as we already define these.
//typedef unsigned int uint;
//typedef unsigned char uchar;
//typedef unsigned short ushort;
//typedef unsigned long ulong;
//
//typedef char int8;
//typedef signed char sint8;
//typedef unsigned char uint8;
//typedef short int16;
//typedef signed short sint16;
//typedef unsigned short uint16;
//typedef int int32;
//typedef signed int sint32;
//typedef unsigned int uint32;
//typedef ll int64;
//typedef ll sint64;
//typedef ull uint64;
#include "sdkint.h"
// Partially defined types. They are used when the decompiler does not know
// anything about the type except its size.

View File

@ -17,18 +17,8 @@ using std::ostringstream;
using std::unordered_map;
typedef DWORD ThreadId_t;
typedef uintptr_t uintp;
typedef intptr_t intp;
typedef const unsigned char* rsig_t;
// 32bit and 64bit wide boolean type
typedef int32_t b32;
typedef int64_t b64;
// signed size types
typedef std::make_signed_t<std::size_t> ssize_t;
#ifndef SSIZE_MAX
#ifdef _WIN64
#define SSIZE_MAX 9223372036854775807i64

73
src/common/sdkint.h Normal file
View File

@ -0,0 +1,73 @@
//============================================================================//
//
// Purpose: portable integral data type definitions
//
//============================================================================//
#ifndef COMMON_SDKINT_H
#define COMMON_SDKINT_H
//-----------------------------------------------------------------------------
typedef char int8;
typedef signed char sint8;
typedef unsigned char uint8;
typedef int8 i8;
typedef sint8 s8;
typedef uint8 u8;
typedef uint8 byte;
typedef uint8 uchar;
//-----------------------------------------------------------------------------
typedef short int16;
typedef signed short sint16;
typedef unsigned short uint16;
typedef int16 i16;
typedef sint16 s16;
typedef uint16 u16;
typedef uint16 ushort;
//-----------------------------------------------------------------------------
typedef int int32;
typedef signed int sint32;
typedef unsigned int uint32;
typedef int32 i32;
typedef sint32 s32;
typedef uint32 u32;
typedef uint32 uint;
typedef uint32 ulong;
//-----------------------------------------------------------------------------
typedef long long int64;
typedef signed long long sint64;
typedef unsigned long long uint64;
typedef int64 i64;
typedef sint64 s64;
typedef uint64 u64;
typedef uint64 ulonglong;
//-----------------------------------------------------------------------------
typedef float float32;
typedef double float64;
typedef float32 f32;
typedef float32 f64;
//-----------------------------------------------------------------------------
// 8-bit <--> 64-bit wide boolean type
typedef int8 b8;
typedef int16 b16;
typedef int32 b32;
typedef int64 b64;
//-----------------------------------------------------------------------------
// intp is an integer that can accommodate a pointer
// (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *)
typedef intptr_t intp;
typedef uintptr_t uintp;
//-----------------------------------------------------------------------------
// Signed size type
typedef std::make_signed_t<std::size_t> ssize_t;
//-----------------------------------------------------------------------------
#endif // COMMON_SDKINT_H

View File

@ -199,6 +199,7 @@ add_sources( SOURCE_GROUP "Common"
"${ENGINE_SOURCE_DIR}/common/protocol.h"
"${ENGINE_SOURCE_DIR}/common/pseudodefs.h"
"${ENGINE_SOURCE_DIR}/common/qlimits.h"
"${ENGINE_SOURCE_DIR}/common/sdkint.h"
"${ENGINE_SOURCE_DIR}/common/sdkdefs.h"
"${ENGINE_SOURCE_DIR}/common/x86defs.h"
"${ENGINE_SOURCE_DIR}/common/xbox/xboxstubs.h"

View File

@ -1,4 +1,5 @@
#pragma once
#include "common/sdkint.h"
/*-----------------------------------------------------------------------------
* _basetypes
@ -266,9 +267,6 @@ typedef int qboolean;
typedef float vec_t;
typedef float vec3_t[3];
typedef float float32;
typedef double float64;
struct vrect_t
{
int x, y, width, height;

View File

@ -1,5 +1,5 @@
#ifndef DTPCH_H
#define DTPCH_H
#ifndef RDPCH_H
#define RDPCH_H
#define _USE_MATH_DEFINES
#include <math.h>
@ -55,16 +55,8 @@
#include "NavEditor/Include/imguiRenderGL.h"
// SDK types
#include "tier0/basetypes.h"
#include "tier0/commonmacros.h"
#include "common/sdkdefs.h"
typedef uint8_t byte;
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#endif // DTPCH_H
#endif // RDPCH_H