forked from mirrors/0ad
some files that weren't committed for some reason
This was SVN commit r164.
This commit is contained in:
+37
-241
@@ -2,12 +2,12 @@
|
||||
//
|
||||
// Copyright (c) 2003 Jan Wassenberg
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// This file is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// This file is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
@@ -17,55 +17,37 @@
|
||||
// http://www.stud.uni-karlsruhe.de/~urkt/
|
||||
|
||||
// things missing in POSIX, SDL, and OpenGL :P
|
||||
// large platform-specific routines (e.g. CPU or gfx card info)
|
||||
// are split out of here.
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "win.h"
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "version.lib")
|
||||
#pragma comment(lib, "advapi32.lib")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "lib.h"
|
||||
#include "detect.h"
|
||||
#include "ia32.h"
|
||||
#include "time.h"
|
||||
#include "sysdep/ia32.h"
|
||||
#include "timer.h"
|
||||
#include "ogl.h"
|
||||
#include "wsdl.h"
|
||||
#include "sdl.h"
|
||||
|
||||
#ifdef HAVE_X_WINDOWS
|
||||
#include <Xlib.h>
|
||||
#endif
|
||||
// HACK
|
||||
extern int win_get_gfx_card();
|
||||
extern int win_get_gfx_drv();
|
||||
extern int win_get_cpu_info();
|
||||
|
||||
/*
|
||||
// useful for choosing a video mode. not called by detect().
|
||||
// currently not implemented for non-Win32 systems (returns 800x600).
|
||||
void get_cur_resolution(int& xres, int& yres)
|
||||
{
|
||||
// guess
|
||||
xres = 800; yres = 600;
|
||||
|
||||
#ifdef _WIN32
|
||||
static DEVMODE dm;
|
||||
dm.dmSize = sizeof(dm);
|
||||
EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm);
|
||||
xres = dm.dmPelsWidth;
|
||||
yres = dm.dmPelsHeight;
|
||||
#endif
|
||||
#ifdef HAVE_X_WINDOWS
|
||||
Display *disp=XOpenDisplay(NULL);
|
||||
if (disp)
|
||||
{
|
||||
int screen=XDefaultScreen(disp);
|
||||
xres=XDisplayWidth(disp, screen);
|
||||
yres=XDisplayHeight(disp, screen);
|
||||
XCloseDisplay(disp);
|
||||
}
|
||||
#endif
|
||||
xres = 1024; yres = 768;
|
||||
}
|
||||
*/
|
||||
|
||||
//
|
||||
// memory
|
||||
//
|
||||
|
||||
size_t tot_mem = 0;
|
||||
size_t avl_mem = 0;
|
||||
@@ -74,23 +56,9 @@ size_t page_size = 0;
|
||||
|
||||
void get_mem_status()
|
||||
{
|
||||
// Win32
|
||||
#ifdef _WIN32
|
||||
|
||||
MEMORYSTATUS ms;
|
||||
GlobalMemoryStatus(&ms);
|
||||
tot_mem = round_up(ms.dwTotalPhys, 1*MB);
|
||||
// fixes results for my machine - off by 528 KB. why?!
|
||||
avl_mem = ms.dwAvailPhys;
|
||||
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
page_size = si.dwPageSize;
|
||||
|
||||
#else // !_WIN32
|
||||
|
||||
#ifdef _SC_PAGESIZE
|
||||
page_size = (size_t)sysconf(_SC_PAGESIZE);
|
||||
if(!page_size)
|
||||
page_size = (size_t)sysconf(_SC_PAGESIZE);
|
||||
#endif
|
||||
|
||||
// Sys V derived (GNU/Linux, Solaris)
|
||||
@@ -109,74 +77,25 @@ void get_mem_status()
|
||||
sysctl(mib, 2, &avl_mem, &len, 0, 0);
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// graphics card
|
||||
//
|
||||
|
||||
char gfx_card[64] = "unknown";
|
||||
char gfx_drv[128] = "unknown";
|
||||
|
||||
|
||||
// attempt to detect graphics card without OpenGL (in case ogl init fails,
|
||||
// or we want more detailed info). gfx_card[] is unchanged on failure.
|
||||
void get_gfx_card()
|
||||
inline void get_gfx_info()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
||||
// gfx card
|
||||
// EnumDisplayDevices is not available on Win95 or NT
|
||||
HMODULE h = LoadLibrary("user32.dll");
|
||||
int (__stdcall *_EnumDisplayDevices)(void*, u32, void*, u32);
|
||||
*(void**)&_EnumDisplayDevices = GetProcAddress(h, "EnumDisplayDevicesA");
|
||||
if(_EnumDisplayDevices)
|
||||
{
|
||||
DISPLAY_DEVICE dev;
|
||||
dev.cb = sizeof(dev);
|
||||
if(_EnumDisplayDevices(0, 0, &dev, 0))
|
||||
strcpy(gfx_card, (const char*)dev.DeviceString);
|
||||
}
|
||||
|
||||
// driver
|
||||
{
|
||||
// .. get driver DLL name
|
||||
static DEVMODE dm; // note: dmDriverVersion is something else
|
||||
dm.dmSize = sizeof(dm);
|
||||
if(!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm))
|
||||
goto ver_fail;
|
||||
char drv_name[CCHDEVICENAME+4];
|
||||
strcpy(drv_name, (const char*)dm.dmDeviceName);
|
||||
strcat(drv_name, ".dll");
|
||||
// .. read the DLL's version info
|
||||
DWORD unused;
|
||||
DWORD ver_size = GetFileVersionInfoSize(drv_name, &unused);
|
||||
if(!ver_size)
|
||||
goto ver_fail;
|
||||
void* buf = malloc(ver_size);
|
||||
if(!buf)
|
||||
goto ver_fail;
|
||||
if(GetFileVersionInfo(drv_name, 0, ver_size, buf))
|
||||
{
|
||||
u16* lang; // -> 16 bit language ID, 16 bit codepage
|
||||
uint lang_len;
|
||||
int ret = VerQueryValue(buf, "\\VarFileInfo\\Translation", (void**)&lang, &lang_len);
|
||||
if(ret && lang && lang_len == 4)
|
||||
{
|
||||
char subblock[37];
|
||||
sprintf(subblock, "\\StringFileInfo\\%04X%04X\\ProductName", lang[0], lang[1]);
|
||||
const char* ver;
|
||||
uint len;
|
||||
if(VerQueryValue(buf, subblock, (void**)&ver, &len))
|
||||
strncpy(gfx_drv, ver, sizeof(gfx_drv));
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
ver_fail:;
|
||||
|
||||
win_get_gfx_card();
|
||||
win_get_gfx_drv();
|
||||
#endif
|
||||
|
||||
// driver version: http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/009679.html
|
||||
}
|
||||
|
||||
|
||||
@@ -184,154 +103,31 @@ ver_fail:;
|
||||
// CPU
|
||||
//
|
||||
|
||||
char cpu_type[49] = "unknown"; // processor brand string is 48 chars
|
||||
char cpu_type[64] = "unknown"; // processor brand string is 48 chars
|
||||
double cpu_freq = 0.f;
|
||||
|
||||
long cpu_caps = 0;
|
||||
long cpu_ext_caps = 0;
|
||||
|
||||
// -1 if detect not yet called, or cannot be determined
|
||||
int cpus = -1;
|
||||
int is_notebook = -1;
|
||||
int has_tsc = -1;
|
||||
int cpu_speedstep = -1;
|
||||
|
||||
|
||||
static void get_cpu_info()
|
||||
static inline void get_cpu_info()
|
||||
{
|
||||
#ifdef _M_IX86
|
||||
static char cpu_vendor[13];
|
||||
int family, model;
|
||||
|
||||
__asm
|
||||
{
|
||||
; make sure CPUID is supported (size opt.)
|
||||
pushfd
|
||||
or byte ptr [esp+2], 32
|
||||
popfd
|
||||
pushfd
|
||||
pop eax
|
||||
shr eax, 22 ; bit 21 toggled?
|
||||
jnc no_cpuid
|
||||
|
||||
; get vendor string
|
||||
xor eax, eax
|
||||
cpuid
|
||||
mov dword ptr [cpu_vendor], ebx
|
||||
mov dword ptr [cpu_vendor+4], edx
|
||||
mov dword ptr [cpu_vendor+8], ecx
|
||||
; (already 0 terminated)
|
||||
|
||||
; get CPU signature and std feature bits
|
||||
mov eax, 1
|
||||
cpuid
|
||||
mov [cpu_caps], edx
|
||||
mov edx, eax
|
||||
shr edx, 4
|
||||
and edx, 0x0f
|
||||
mov [model], edx
|
||||
shr eax, 8
|
||||
and eax, 0x0f
|
||||
mov [family], eax
|
||||
|
||||
; make sure CPUID ext functions are supported
|
||||
mov eax, 0x80000000
|
||||
cpuid
|
||||
cmp eax, 0x80000000
|
||||
jbe no_brand_str
|
||||
|
||||
; get CPU brand string (>= Athlon XP, P4)
|
||||
mov edi, offset cpu_type
|
||||
mov esi, -2 ; loop counter: -2 to 0
|
||||
$1: lea eax, [0x80000004+esi]
|
||||
cpuid
|
||||
stosd
|
||||
xchg eax, ebx
|
||||
stosd
|
||||
xchg eax, ecx
|
||||
stosd
|
||||
xchg eax, edx
|
||||
stosd
|
||||
inc esi
|
||||
jle $1
|
||||
; already 0 terminated
|
||||
|
||||
; get extended feature flags
|
||||
mov eax, 0x80000001
|
||||
cpuid
|
||||
mov [cpu_ext_caps], edx
|
||||
}
|
||||
|
||||
// strip (tm) from Athlon string
|
||||
if(!strncmp(cpu_type, "AMD Athlon(tm)", 14))
|
||||
memmove(cpu_type+10, cpu_type+14, 34);
|
||||
|
||||
// remove 2x (R) and CPU freq from P4 string
|
||||
float a; // not used; sscanf returns # fields actually stored
|
||||
if(sscanf(cpu_type, " Intel(R) Pentium(R) 4 CPU %fGHz", &a) == 1)
|
||||
strcpy(cpu_type, "Intel Pentium 4");
|
||||
|
||||
goto have_brand_str;
|
||||
|
||||
no_brand_str:
|
||||
|
||||
// AMD
|
||||
if(!strcmp(cpu_vendor, "AuthenticAMD"))
|
||||
{
|
||||
if(family == 6)
|
||||
strcpy(cpu_type, (model == 3)? "AMD Duron" : "AMD Athlon");
|
||||
}
|
||||
// Intel
|
||||
else if(!strcmp(cpu_vendor, "GenuineIntel"))
|
||||
{
|
||||
if(family == 6 && model >= 7)
|
||||
strcpy(cpu_type, "Intel Pentium III / Celeron");
|
||||
}
|
||||
|
||||
have_brand_str:
|
||||
|
||||
// calc CPU freq (count clocks in 50 ms)
|
||||
if(cpu_caps & TSC)
|
||||
{
|
||||
u64 clocks1 = rdtsc();
|
||||
|
||||
// .. wait at at least 50 ms
|
||||
double t1 = get_time();
|
||||
double t2;
|
||||
do
|
||||
t2 = get_time();
|
||||
while(t2 < t1 + 50e-3);
|
||||
|
||||
u64 clocks2 = rdtsc();
|
||||
|
||||
// .. freq = (clocks / 50 [ms]) / 50 [ms] * 1000
|
||||
// cpuid/rdtsc overhead is negligible
|
||||
cpu_freq = (__int64)(clocks2-clocks1) / (t2-t1);
|
||||
// VC6 can't convert u64 -> double, and we don't need full range
|
||||
}
|
||||
// don't bother with a WAG timing loop
|
||||
|
||||
no_cpuid:
|
||||
|
||||
#endif // #ifdef _M_IX86
|
||||
|
||||
#ifdef _WIN32
|
||||
HW_PROFILE_INFO hi;
|
||||
GetCurrentHwProfile(&hi);
|
||||
is_notebook = !(hi.dwDockInfo & DOCKINFO_DOCKED) ^
|
||||
!(hi.dwDockInfo & DOCKINFO_UNDOCKED);
|
||||
// both flags set <==> this is a desktop machine.
|
||||
// both clear is unspecified; we assume it's not a notebook.
|
||||
win_get_cpu_info();
|
||||
#endif
|
||||
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
cpus = si.dwNumberOfProcessors;
|
||||
#ifdef _M_IX86
|
||||
ia32_get_cpu_info();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void detect()
|
||||
{
|
||||
get_mem_status();
|
||||
get_gfx_card();
|
||||
get_gfx_info();
|
||||
get_cpu_info();
|
||||
}
|
||||
|
||||
+2
-22
@@ -27,7 +27,6 @@ extern "C" {
|
||||
|
||||
|
||||
// useful for choosing a video mode. not called by detect().
|
||||
// currently not implemented for non-Win32 systems (returns 800x600).
|
||||
extern void get_cur_resolution(int& xres, int& yres);
|
||||
|
||||
|
||||
@@ -36,7 +35,7 @@ extern char gfx_drv[128]; // default: "unknown"
|
||||
|
||||
// attempt to detect graphics card without OpenGL (in case ogl init fails,
|
||||
// or we want more detailed info). gfx_card[] is unchanged on failure.
|
||||
extern void get_gfx_card();
|
||||
extern void get_gfx_info();
|
||||
|
||||
|
||||
//
|
||||
@@ -57,28 +56,9 @@ extern void get_mem_status();
|
||||
extern char cpu_type[];
|
||||
extern double cpu_freq;
|
||||
|
||||
enum
|
||||
{
|
||||
TSC = BIT(4),
|
||||
CMOV = BIT(15),
|
||||
MMX = BIT(23),
|
||||
SSE = BIT(25),
|
||||
SSE2 = BIT(26)
|
||||
};
|
||||
|
||||
extern long cpu_caps;
|
||||
|
||||
// define instead of enum to avoid stupid sign conversion warning
|
||||
#define EXT_3DNOW_PRO BIT(30)
|
||||
#define EXT_3DNOW BIT(31)
|
||||
|
||||
extern long cpu_ext_caps;
|
||||
|
||||
// -1 if detect not yet called, or cannot be determined
|
||||
extern int cpus;
|
||||
extern int is_notebook;
|
||||
extern int has_tsc;
|
||||
|
||||
extern int cpu_speedstep;
|
||||
|
||||
extern void detect();
|
||||
|
||||
|
||||
+11
-11
@@ -27,17 +27,17 @@ FUNC(int, glIsFenceNV, (unsigned int))
|
||||
FUNC(void, glGetFenceivNV, (unsigned int, int, int*))
|
||||
|
||||
// ARB_vertex_array_object
|
||||
FUNC(void, BindBufferARB, (int target, GLuint buffer))
|
||||
FUNC(void, DeleteBuffersARB, (GLsizei n, const GLuint* buffers))
|
||||
FUNC(void, GenBuffersARB, (GLsizei n, GLuint* buffers))
|
||||
FUNC(bool, IsBufferARB, (GLuint buffer))
|
||||
FUNC(void, BufferDataARB, (int target, GLsizeiptrARB size, const void* data, int usage))
|
||||
FUNC(void, BufferSubDataARB, (int target, GLintptrARB offset, GLsizeiptrARB size, const void* data))
|
||||
FUNC(void, GetBufferSubDataARB, (int target, GLintptrARB offset, GLsizeiptrARB size, void* data))
|
||||
FUNC(void*, MapBufferARB, (int target, int access))
|
||||
FUNC(bool, UnmapBufferARB, (int target))
|
||||
FUNC(void, GetBufferParameterivARB, (int target, int pname, int* params))
|
||||
FUNC(void, GetBufferPointervARB, (int target, int pname, void** params))
|
||||
FUNC(void, glBindBufferARB, (int target, GLuint buffer))
|
||||
FUNC(void, glDeleteBuffersARB, (GLsizei n, const GLuint* buffers))
|
||||
FUNC(void, glGenBuffersARB, (GLsizei n, GLuint* buffers))
|
||||
FUNC(bool, glIsBufferARB, (GLuint buffer))
|
||||
FUNC(void, glBufferDataARB, (int target, GLsizeiptrARB size, const void* data, int usage))
|
||||
FUNC(void, glBufferSubDataARB, (int target, GLintptrARB offset, GLsizeiptrARB size, const void* data))
|
||||
FUNC(void, glGetBufferSubDataARB, (int target, GLintptrARB offset, GLsizeiptrARB size, void* data))
|
||||
FUNC(void*, glMapBufferARB, (int target, int access))
|
||||
FUNC(bool, glUnmapBufferARB, (int target))
|
||||
FUNC(void, glGetBufferParameterivARB, (int target, int pname, int* params))
|
||||
FUNC(void, glGetBufferPointervARB, (int target, int pname, void** params))
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
#define __INPUT_H__
|
||||
|
||||
|
||||
#include "wsdl.h"
|
||||
#include "sdl.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
*
|
||||
* src and len must be multiples of CHUNK_SIZE.
|
||||
*/
|
||||
|
||||
#if _MSC_VER >= 0x1300
|
||||
|
||||
void memcpy_nt(void* dst, void* src, int len)
|
||||
{
|
||||
__asm
|
||||
@@ -59,4 +62,6 @@ write_loop:
|
||||
|
||||
pop esi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #if _MSC_VER >= 0x1300
|
||||
+4
-65
@@ -21,7 +21,8 @@
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
|
||||
#include "time.h"
|
||||
#include "lib.h"
|
||||
#include "timer.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
@@ -107,9 +108,9 @@ $loop: mov eax, [edx]
|
||||
}
|
||||
|
||||
|
||||
bool is_pow2(const int n)
|
||||
bool is_pow2(const long n)
|
||||
{
|
||||
return (n > 0) && !(n & (n-1));
|
||||
return (n != 0) && !(n & (n-1));
|
||||
}
|
||||
|
||||
|
||||
@@ -190,28 +191,6 @@ float fminf(float a, float b)
|
||||
#endif
|
||||
|
||||
|
||||
// replaces pathetic MS libc implementation
|
||||
#if defined(_M_IX86) && defined(_WIN32)
|
||||
|
||||
double _ceil(double f)
|
||||
{
|
||||
double r;
|
||||
|
||||
const float _49 = 0.499999f;
|
||||
__asm
|
||||
{
|
||||
fld [f]
|
||||
fadd [_49]
|
||||
frndint
|
||||
fstp [r]
|
||||
}
|
||||
|
||||
UNUSED(f)
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// big endian!
|
||||
@@ -237,47 +216,7 @@ void base32(const int len, const u8* in, u8* out)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
char *_itoa(int val, char *buffer, int radix)
|
||||
{
|
||||
return _ltoa(val, buffer, radix);
|
||||
}
|
||||
|
||||
static const char digits[]="0123456789abcdef";
|
||||
|
||||
char *_ultoa(unsigned long int value, char *out, int radix)
|
||||
{
|
||||
char buf[21];
|
||||
char *p=buf+21;
|
||||
|
||||
while (value)
|
||||
{
|
||||
*(--p)=digits[value % radix];
|
||||
value /= radix;
|
||||
}
|
||||
|
||||
memcpy(out, p, (buf+21)-p);
|
||||
return out;
|
||||
}
|
||||
|
||||
char *_ltoa(long val, char *out, int radix)
|
||||
{
|
||||
char buf[21];
|
||||
char *p=buf+21;
|
||||
bool sign=val < 0;
|
||||
if (sign) val=-val;
|
||||
|
||||
while (val)
|
||||
{
|
||||
*(--p)=digits[val % radix];
|
||||
val /= radix;
|
||||
}
|
||||
|
||||
if (sign) *(--p) = '-';
|
||||
|
||||
memcpy(out, p, (buf+21)-p);
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+12
-84
@@ -26,86 +26,6 @@
|
||||
//extern "C" {
|
||||
#endif
|
||||
|
||||
// check if compiler supports C99
|
||||
// nested #if to avoid ICC warning about undefined macro value
|
||||
#undef HAVE_C99
|
||||
#if defined(__STDC_VERSION__)
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
#define HAVE_C99
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define UNUSED(param) (void)param;
|
||||
|
||||
#define ONCE(code) \
|
||||
{ \
|
||||
static pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER; \
|
||||
static bool done=false; \
|
||||
if(pthread_mutex_lock(&(mutex))==0 && !done) \
|
||||
{ \
|
||||
code; \
|
||||
done=true; \
|
||||
} \
|
||||
pthread_mutex_unlock(&mutex); \
|
||||
}
|
||||
|
||||
#define STMT(_code) do { _code ; } while (0)
|
||||
|
||||
template<bool>
|
||||
struct cassert_checker
|
||||
{
|
||||
cassert_checker(...) { }
|
||||
};
|
||||
|
||||
template<> struct cassert_checker<false> { };
|
||||
|
||||
#define cassert(expr, id) {\
|
||||
struct CASSERT_##id { };\
|
||||
typedef cassert_checker<(expr)> type;\
|
||||
type temp = type(CASSERT_##id());\
|
||||
(void)sizeof(temp);\
|
||||
}
|
||||
|
||||
#define cassert2(expr, id) struct CASSERT_##id { a : expr; };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const u32 KB = 1 << 10;
|
||||
const u32 MB = 1 << 20;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DIR_SEP '\\'
|
||||
#else
|
||||
#define DIR_SEP '/'
|
||||
#endif
|
||||
|
||||
|
||||
extern u32 fnv_hash(const char* str, size_t len);
|
||||
|
||||
#ifdef _WIN32
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
extern char *_itoa(int value, char* buffer, int radix);
|
||||
extern char *_ultoa(unsigned long int value, char *buffer, int radix);
|
||||
extern char *_ltoa(long value, char *buffer, int radix);
|
||||
|
||||
#endif
|
||||
|
||||
#define BIT(n) (1ul << (n))
|
||||
|
||||
#ifndef min
|
||||
inline int min(int a, int b)
|
||||
@@ -144,11 +64,10 @@ static inline u32 read_le32(const void* p)
|
||||
{
|
||||
#ifdef BIG_ENDIAN
|
||||
u32 t = 0;
|
||||
const u8 *_p=(const u8 *)p;
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
t <<= 8;
|
||||
t |= *(_p++);
|
||||
t |= *(const u8*)p++;
|
||||
}
|
||||
return t;
|
||||
#else
|
||||
@@ -157,7 +76,7 @@ static inline u32 read_le32(const void* p)
|
||||
}
|
||||
|
||||
|
||||
extern bool is_pow2(int n);
|
||||
extern bool is_pow2(long n);
|
||||
|
||||
|
||||
// return -1 if not an integral power of 2,
|
||||
@@ -167,18 +86,27 @@ extern int ilog2(const int n);
|
||||
|
||||
extern uintptr_t round_up(uintptr_t val, uintptr_t multiple);
|
||||
|
||||
|
||||
// provide fminf for non-C99 compilers
|
||||
#ifndef HAVE_C99
|
||||
extern float fminf(float, float);
|
||||
#endif
|
||||
|
||||
extern double _ceil(double);
|
||||
|
||||
|
||||
|
||||
// big endian!
|
||||
extern void base32(const int len, const u8* in, u8* out);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
//}
|
||||
#endif
|
||||
|
||||
+1
-2
@@ -2,7 +2,7 @@
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include "wsdl.h"
|
||||
#include "sdl.h"
|
||||
#include "ogl.h"
|
||||
#include "detect.h"
|
||||
|
||||
@@ -78,7 +78,6 @@ int max_VAR_elements = -1; // GF2: 64K; GF3: 1M
|
||||
bool tex_compression_avail; // S3TC / DXT{1,3,5}
|
||||
int video_mem; // [MB]; approximate
|
||||
|
||||
#include "time.h"
|
||||
|
||||
// call after each video mode change
|
||||
void oglInit()
|
||||
|
||||
+6
-579
@@ -1,24 +1,10 @@
|
||||
// POSIX emulation for Win32
|
||||
//
|
||||
// Copyright (c) 2003 Jan Wassenberg
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// Contact info:
|
||||
// Jan.Wassenberg@stud.uni-karlsruhe.de
|
||||
// http://www.stud.uni-karlsruhe.de/~urkt/
|
||||
|
||||
#include <stddef.h>
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "sysdep/win/wposix.h"
|
||||
#include "sysdep/win/win.h"
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
@@ -31,567 +17,8 @@
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define __POSIX_H__ // => rest of header ignored
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __POSIX_H__
|
||||
#define __POSIX_H__
|
||||
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define IMP(ret, name, param) extern "C" __declspec(dllimport) ret __stdcall name param;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// <inttypes.h>
|
||||
//
|
||||
|
||||
typedef unsigned short u16_t;
|
||||
|
||||
|
||||
//
|
||||
// <sys/types.h>
|
||||
//
|
||||
|
||||
typedef long ssize_t;
|
||||
|
||||
|
||||
//
|
||||
// <limits.h>
|
||||
//
|
||||
|
||||
#define PATH_MAX 260
|
||||
|
||||
|
||||
//
|
||||
// <errno.h>
|
||||
//
|
||||
|
||||
#define EINPROGRESS 100000
|
||||
|
||||
/*
|
||||
enum
|
||||
{
|
||||
EINPROGRESS = 1000, // Operation in progress.
|
||||
ENOMEM // Not enough space.
|
||||
EACCES, // Permission denied.
|
||||
EADDRINUSE, // Address in use.
|
||||
EADDRNOTAVAIL, // Address not available.
|
||||
EAGAIN, // Resource unavailable, try again (may be the same value as EWOULDBLOCK]).
|
||||
EALREADY, // Connection already in progress.
|
||||
EBADF, // Bad file descriptor.
|
||||
ECANCELED, // Operation canceled.
|
||||
ECONNABORTED, // Connection aborted.
|
||||
ECONNREFUSED, // Connection refused.
|
||||
ECONNRESET, // Connection reset.
|
||||
EDOM, // Mathematics argument out of domain of IMPtion.
|
||||
EEXIST, // File exists.
|
||||
EFAULT, // Bad address.
|
||||
EHOSTUNREACH, // Host is unreachable.
|
||||
EINTR, // Interrupted IMPtion.
|
||||
EINVAL, // Invalid argument.
|
||||
EISCONN, // Socket is connected.
|
||||
EISDIR, // Is a directory.
|
||||
ENAMETOOLONG, // Filename too long.
|
||||
ENETDOWN, // Network is down.
|
||||
ENETRESET, // Connection aborted by network.
|
||||
ENETUNREACH, // Network unreachable.
|
||||
ENOENT, // No such file or directory.
|
||||
ENOEXEC, // Executable file format error.
|
||||
|
||||
ENOSPC, // No space left on device.
|
||||
ENOSYS, // IMPtion not supported.
|
||||
ENOTCONN, // The socket is not connected.
|
||||
ENOTDIR, // Not a directory.
|
||||
ENOTEMPTY, // Directory not empty.
|
||||
ENOTSOCK, // Not a socket.
|
||||
ENOTSUP, // Not supported.
|
||||
EOVERFLOW, // Value too large to be stored in data type.
|
||||
EPERM, // Operation not permitted.
|
||||
EPIPE, // Broken pipe.
|
||||
EPROTO, // Protocol error.
|
||||
ERANGE, // Result too large.
|
||||
ETIMEDOUT, // Connection timed out.
|
||||
EWOULDBLOCK // Operation would block (may be the same value as EAGAIN]).
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
//
|
||||
// <time.h>
|
||||
//
|
||||
|
||||
typedef long time_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CLOCK_REALTIME
|
||||
}
|
||||
clockid_t;
|
||||
|
||||
struct timespec
|
||||
{
|
||||
time_t tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
|
||||
extern time_t time(time_t*);
|
||||
extern int clock_gettime(clockid_t clock_id, struct timespec* tp);
|
||||
extern int nanosleep(const struct timespec* rqtp, struct timespec* rmtp);
|
||||
|
||||
|
||||
//
|
||||
// sys/stat.h
|
||||
//
|
||||
|
||||
typedef unsigned short ino_t;
|
||||
typedef unsigned int mode_t;
|
||||
typedef long off_t;
|
||||
typedef unsigned int dev_t;
|
||||
|
||||
// struct stat defined in VC sys/stat.h
|
||||
|
||||
#define stat _stat
|
||||
|
||||
extern int mkdir(const char*, mode_t);
|
||||
|
||||
|
||||
//
|
||||
// dirent.h
|
||||
//
|
||||
|
||||
typedef void DIR;
|
||||
|
||||
struct dirent
|
||||
{
|
||||
ino_t d_ino;
|
||||
char* d_name;
|
||||
};
|
||||
|
||||
extern DIR* opendir(const char* name);
|
||||
extern struct dirent* readdir(DIR*);
|
||||
extern int closedir(DIR*);
|
||||
|
||||
|
||||
//
|
||||
// <sys/mman.h>
|
||||
//
|
||||
|
||||
#define PROT_READ 0x01 // page can be read
|
||||
#define PROT_WRITE 0x02 // page can be written
|
||||
|
||||
#define MAP_SHARED 0x01 // share changes across processes
|
||||
#define MAP_PRIVATE 0x02 // private copy on write mapping
|
||||
#define MAP_FIXED 0x04
|
||||
|
||||
#define MAP_FAILED 0
|
||||
|
||||
extern void* mmap(void* start, unsigned int len, int prot, int flags, int fd, long offset);
|
||||
extern int munmap(void* start, unsigned int len);
|
||||
|
||||
|
||||
//
|
||||
// <fcntl.h>
|
||||
//
|
||||
|
||||
// values from MS _open - do not change!
|
||||
#define O_RDONLY 0x0000 // open for reading only
|
||||
#define O_WRONLY 0x0001 // open for writing only
|
||||
#define O_RDWR 0x0002 // open for reading and writing
|
||||
#define O_APPEND 0x0008 // writes done at eof
|
||||
#define O_CREAT 0x0100 // create and open file
|
||||
#define O_TRUNC 0x0200 // open and truncate
|
||||
#define O_EXCL 0x0400 // open only if file doesn't already exist
|
||||
#define O_BINARY 0x8000 // file mode is binary (untranslated)
|
||||
|
||||
#define O_NONBLOCK 0x1000000
|
||||
|
||||
extern int open(const char* fn, int mode, ...);
|
||||
|
||||
|
||||
//
|
||||
// <unistd.h>
|
||||
//
|
||||
|
||||
#define F_OK 0
|
||||
#define R_OK 1
|
||||
#define W_OK 2
|
||||
#define X_OK 4
|
||||
|
||||
#define read _read
|
||||
#define write _write
|
||||
|
||||
extern int close(int);
|
||||
extern int access(const char*, int);
|
||||
extern int chdir(const char*);
|
||||
|
||||
extern unsigned int sleep(unsigned int sec);
|
||||
|
||||
#ifndef _WINSOCKAPI_
|
||||
|
||||
|
||||
IMP(int, gethostname, (char* name, size_t namelen))
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// <stdlib.h>
|
||||
//
|
||||
|
||||
extern char* realpath(const char*, char*);
|
||||
|
||||
|
||||
//
|
||||
// <signal.h>
|
||||
//
|
||||
|
||||
union sigval
|
||||
{
|
||||
int sival_int; // Integer signal value.
|
||||
void* sival_ptr; // Pointer signal value.
|
||||
};
|
||||
|
||||
struct sigevent
|
||||
{
|
||||
int sigev_notify; // notification mode
|
||||
int sigev_signo; // signal number
|
||||
union sigval sigev_value; // signal value
|
||||
void (*sigev_notify_function)(union sigval);
|
||||
// pthread_attr_t *sigev_notify_attributes;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// <termios.h>
|
||||
//
|
||||
|
||||
#define TCSANOW 0
|
||||
|
||||
struct termios
|
||||
{
|
||||
long c_lflag;
|
||||
};
|
||||
|
||||
#define ICANON 2 // do not change - correspond to ENABLE_LINE_INPUT / ENABLE_ECHO_INPUT
|
||||
#define ECHO 4
|
||||
|
||||
extern int tcgetattr(int fd, struct termios* termios_p);
|
||||
extern int tcsetattr(int fd, int optional_actions, const struct termios* termios_p);
|
||||
|
||||
|
||||
//
|
||||
// <sched.h>
|
||||
//
|
||||
|
||||
struct sched_param
|
||||
{
|
||||
int sched_priority;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SCHED_RR,
|
||||
SCHED_FIFO,
|
||||
SCHED_OTHER
|
||||
};
|
||||
|
||||
#define sched_get_priority_max(policy) 15 // TIME_CRITICAL
|
||||
#define sched_get_priority_min(policy) -15 // IDLE
|
||||
|
||||
|
||||
//
|
||||
// <pthread.h>
|
||||
//
|
||||
|
||||
typedef unsigned int pthread_t;
|
||||
|
||||
extern pthread_t pthread_self();
|
||||
extern int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param* param);
|
||||
extern int pthread_create(pthread_t* thread, const void* attr, void*(*IMP)(void*), void* arg);
|
||||
|
||||
typedef void* pthread_mutex_t;
|
||||
typedef void pthread_mutexattr_t;
|
||||
|
||||
extern pthread_mutex_t pthread_mutex_initializer();
|
||||
#define PTHREAD_MUTEX_INITIALIZER pthread_mutex_initializer()
|
||||
|
||||
extern int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*);
|
||||
extern int pthread_mutex_destroy(pthread_mutex_t*);
|
||||
|
||||
extern int pthread_mutex_lock(pthread_mutex_t*);
|
||||
extern int pthread_mutex_trylock(pthread_mutex_t*);
|
||||
extern int pthread_mutex_unlock(pthread_mutex_t*);
|
||||
|
||||
|
||||
|
||||
//
|
||||
// <sys/socket.h>
|
||||
//
|
||||
|
||||
typedef unsigned long socklen_t;
|
||||
typedef unsigned short sa_family_t;
|
||||
|
||||
// Win32 values - do not change
|
||||
|
||||
#ifndef _WINSOCKAPI_
|
||||
|
||||
#define SOCK_STREAM 1
|
||||
#define SOCK_DGRAM 2
|
||||
#define AF_INET 2
|
||||
#define PF_INET AF_INET
|
||||
#define AF_INET6 23
|
||||
#define PF_INET6 AF_INET6
|
||||
|
||||
IMP(int, socket, (int, int, int))
|
||||
IMP(int, setsockopt, (int, int, int, const void*, socklen_t))
|
||||
IMP(int, ioctlsocket, (int, int, const void *))
|
||||
IMP(int, shutdown, (int, int))
|
||||
IMP(int, closesocket, (int))
|
||||
|
||||
#define SOL_SOCKET 0xffff /* options for socket level */
|
||||
#define TCP_NODELAY 0x0001
|
||||
|
||||
/* This is the slightly unreadable encoded form of the windows ioctl that sets
|
||||
non-blocking mode for a socket */
|
||||
#define FIONBIO 0x8004667E
|
||||
|
||||
enum {
|
||||
SHUT_RD=0,
|
||||
SHUT_WR=1,
|
||||
SHUT_RDWR=2
|
||||
};
|
||||
IMP(int, getsockopt, (int, int, int, void*, socklen_t*))
|
||||
|
||||
|
||||
struct sockaddr;
|
||||
|
||||
//
|
||||
// <netinet/in.h>
|
||||
//
|
||||
|
||||
typedef unsigned long in_addr_t;
|
||||
typedef unsigned short in_port_t;
|
||||
|
||||
struct in_addr
|
||||
{
|
||||
in_addr_t s_addr;
|
||||
};
|
||||
|
||||
struct sockaddr_in
|
||||
{
|
||||
sa_family_t sin_family;
|
||||
in_port_t sin_port;
|
||||
struct in_addr sin_addr;
|
||||
unsigned char sin_zero[8];
|
||||
};
|
||||
|
||||
#define INET_ADDRSTRLEN 16
|
||||
|
||||
#define INADDR_ANY 0
|
||||
#define INADDR_NONE ((in_addr_t)-1)
|
||||
|
||||
#define IPPROTO_IP 0
|
||||
#define IP_ADD_MEMBERSHIP 5
|
||||
#define IP_DROP_MEMBERSHIP 6
|
||||
|
||||
struct ip_mreq
|
||||
{
|
||||
struct in_addr imr_multiaddr; /* multicast group to join */
|
||||
struct in_addr imr_interface; /* interface to join on */
|
||||
};
|
||||
|
||||
// IPv6 Structures
|
||||
|
||||
struct in6_addr {
|
||||
unsigned char s6_addr[16];
|
||||
};
|
||||
|
||||
struct sockaddr_in6 {
|
||||
sa_family_t sin6_family; /* AF_INET6 */
|
||||
in_port_t sin6_port; /* Transport level port number */
|
||||
unsigned long sin6_flowinfo; /* IPv6 flow information */
|
||||
struct in6_addr sin6_addr; /* IPv6 address */
|
||||
unsigned long sin6_scope_id; /* set of interfaces for a scope */
|
||||
};
|
||||
|
||||
// IPv6 Defines and Constants
|
||||
|
||||
extern const struct in6_addr in6addr_any; /* :: */
|
||||
extern const struct in6_addr in6addr_loopback; /* ::1 */
|
||||
#define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||
#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
|
||||
|
||||
//
|
||||
// <netdb.h>
|
||||
//
|
||||
|
||||
struct hostent
|
||||
{
|
||||
char* h_name; // Official name of the host.
|
||||
char** h_aliases; // A pointer to an array of pointers to
|
||||
// alternative host names, terminated by a
|
||||
// null pointer.
|
||||
short h_addrtype; // Address type.
|
||||
short h_length; // The length, in bytes, of the address.
|
||||
char** h_addr_list; // A pointer to an array of pointers to network
|
||||
// addresses (in network byte order) for the host,
|
||||
// terminated by a null pointer.
|
||||
};
|
||||
|
||||
IMP(struct hostent*, gethostbyname, (const char *name))
|
||||
|
||||
#define h_error WSAGetLastError()
|
||||
#define TRY_AGAIN 11002
|
||||
#define HOST_NOT_FOUND 11001
|
||||
|
||||
/* addrinfo struct */
|
||||
struct addrinfo
|
||||
{
|
||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
|
||||
int ai_family; /* PF_xxx */
|
||||
int ai_socktype; /* SOCK_xxx */
|
||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
||||
size_t ai_addrlen; /* Length of ai_addr */
|
||||
char *ai_canonname; /* Canonical name for nodename */
|
||||
struct sockaddr *ai_addr; /* Binary address */
|
||||
struct addrinfo *ai_next; /* Next structure in linked list */
|
||||
};
|
||||
|
||||
/* Hint flags for getaddrinfo */
|
||||
#define AI_PASSIVE 0x1 /* Socket address will be used in bind() call */
|
||||
|
||||
/* Flags for getnameinfo() */
|
||||
#define NI_NUMERICHOST 0x02 /* Return numeric form of the host's address */
|
||||
|
||||
/* Various Constants */
|
||||
#define NI_MAXHOST 1025
|
||||
#define NI_MAXSERV 32
|
||||
|
||||
/* Note that these are function pointers. They will be initialized by the
|
||||
entry point function in posix.cpp */
|
||||
typedef int (*fp_getnameinfo_t)(const struct sockaddr *sa, socklen_t salen, char *node,
|
||||
socklen_t nodelen, char *serv, socklen_t servlen, unsigned int flags);
|
||||
typedef int (*fp_getaddrinfo_t)(const char *nodename, const char *servname,
|
||||
const struct addrinfo *hints, struct addrinfo **res);
|
||||
typedef void (*fp_freeaddrinfo_t)(struct addrinfo *ai);
|
||||
|
||||
extern fp_getnameinfo_t p_getnameinfo;
|
||||
extern fp_getaddrinfo_t p_getaddrinfo;
|
||||
extern fp_freeaddrinfo_t p_freeaddrinfo;
|
||||
|
||||
#define getnameinfo p_getnameinfo
|
||||
#define getaddrinfo p_getaddrinfo
|
||||
#define freeaddrinfo p_freeaddrinfo
|
||||
|
||||
// getaddr/nameinfo error codes
|
||||
#define EAI_NONAME HOST_NOT_FOUND
|
||||
|
||||
//
|
||||
// <arpa/inet.h>
|
||||
//
|
||||
|
||||
extern u16_t htons(u16_t hostshort);
|
||||
IMP(unsigned long, htonl, (unsigned long hostlong))
|
||||
#define ntohs htons
|
||||
|
||||
IMP(in_addr_t, inet_addr, (const char*))
|
||||
IMP(char*, inet_ntoa, (in_addr))
|
||||
IMP(int, accept, (int, struct sockaddr*, socklen_t*))
|
||||
IMP(int, bind, (int, const struct sockaddr*, socklen_t))
|
||||
IMP(int, connect, (int, const struct sockaddr*, socklen_t))
|
||||
IMP(int, listen, (int, int))
|
||||
IMP(ssize_t, recv, (int, void*, size_t, int))
|
||||
IMP(ssize_t, send, (int, const void*, size_t, int))
|
||||
IMP(ssize_t, sendto, (int, const void*, size_t, int, const struct sockaddr*, socklen_t))
|
||||
IMP(ssize_t, recvfrom, (int, void*, size_t, int, struct sockaddr*, socklen_t*))
|
||||
|
||||
#endif /* _WINSOCKAPI_ */
|
||||
|
||||
//
|
||||
// <poll.h>
|
||||
//
|
||||
|
||||
struct pollfd
|
||||
{
|
||||
int fd;
|
||||
short int events, revents;
|
||||
};
|
||||
|
||||
#define POLLIN 1
|
||||
|
||||
extern int poll(struct pollfd[], int, int);
|
||||
|
||||
|
||||
//
|
||||
// <sys/utsname.h>
|
||||
//
|
||||
|
||||
struct utsname
|
||||
{
|
||||
char sysname[9]; // Name of this implementation of the operating system.
|
||||
char nodename[16]; // Name of this node within an implementation-defined
|
||||
// communications network.
|
||||
// Win9x requires this minimum buffer size.
|
||||
char release[9]; // Current release level of this implementation.
|
||||
char version[16]; // Current version level of this release.
|
||||
char machine[9]; // Name of the hardware type on which the system is running.
|
||||
};
|
||||
|
||||
extern int uname(struct utsname*);
|
||||
|
||||
|
||||
//
|
||||
// serial port IOCTL
|
||||
//
|
||||
|
||||
// use with TIOCMBIS
|
||||
#define TIOCM_RTS 1
|
||||
|
||||
// use with TIOCMGET or TIOCMIWAIT
|
||||
#define TIOCM_CD 0x80 // MS_RLSD_ON
|
||||
#define TIOCM_CTS 0x10 // MS_CTS_ON
|
||||
|
||||
enum
|
||||
{
|
||||
TIOCMBIS, // set control line
|
||||
TIOCMGET, // get line state
|
||||
TIOCMIWAIT // wait for status change
|
||||
};
|
||||
|
||||
extern int ioctl(int fd, int op, int* data);
|
||||
|
||||
#define FIONREAD 0
|
||||
|
||||
extern void _get_console();
|
||||
extern void _hide_console();
|
||||
|
||||
|
||||
#include "posix/aio.h"
|
||||
|
||||
extern void entry(void);
|
||||
extern void mainCRTStartup();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // #ifndef __POSIX_H__
|
||||
#endif // #ifdef _WIN32 else
|
||||
+22
-11
@@ -9,30 +9,41 @@
|
||||
|
||||
#define uint unsigned int
|
||||
|
||||
#define int8 signed char
|
||||
#define int16 short
|
||||
#define int32 long
|
||||
#define i8 signed char
|
||||
#define i16 short
|
||||
#define i32 long
|
||||
|
||||
#define u8 unsigned char
|
||||
#define u16 unsigned short
|
||||
#define u32 unsigned long // long to match Win32 DWORD
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__INTEL_COMPILER) || defined(__LCC__)
|
||||
#define i64 __int64
|
||||
#define u64 unsigned __int64
|
||||
#else
|
||||
#elif defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__DMC__)
|
||||
#define i64 long long
|
||||
#define u64 unsigned long long
|
||||
#else
|
||||
#error "TODO: port u64"
|
||||
#endif
|
||||
|
||||
|
||||
#define int8 i8
|
||||
#define int16 i16
|
||||
#define int32 i32
|
||||
|
||||
#include <stddef.h>
|
||||
#ifdef _MSC_VER
|
||||
#ifndef _UINTPTR_T_DEFINED
|
||||
#define _UINTPTR_T_DEFINED
|
||||
#define uintptr_t u32
|
||||
#endif // _UINTPTR_T_DEFINED
|
||||
#else
|
||||
#include <stdint.h>
|
||||
# ifndef _UINTPTR_T_DEFINED
|
||||
# define _UINTPTR_T_DEFINED
|
||||
# define uintptr_t u32
|
||||
# endif // _UINTPTR_T_DEFINED
|
||||
# ifndef _INTPTR_T_DEFINED
|
||||
# define _INTPTR_T_DEFINED
|
||||
# define intptr_t i32
|
||||
# endif // _INTPTR_T_DEFINED
|
||||
#else // !_MSC_VER
|
||||
# include <stdint.h>
|
||||
#endif // _MSC_VER
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user