Descent3/lib/linux/linux_fix.h

57 lines
1.3 KiB
C
Raw Normal View History

2024-04-16 03:43:29 +00:00
#ifndef __LINUX_FIX_H_
#define __LINUX_FIX_H_
#include <sys/stat.h>
#include <math.h>
2024-04-16 03:43:29 +00:00
#define LOKI_VERSION ""
2024-04-16 18:56:40 +00:00
#define HGLOBAL void *
2024-04-16 03:43:29 +00:00
void GlobalFree(void *);
2024-04-16 18:56:40 +00:00
void *GlobalAlloc(int flags, int size);
2024-04-16 03:43:29 +00:00
void *GlobalLock(HGLOBAL hMem);
void Sleep(int millis);
2024-04-16 18:56:40 +00:00
char *itoa(int value, char *string, int radix);
2024-04-16 03:43:29 +00:00
char *strupr(char *string);
// Replace missing defines from stdlib.h
2024-04-16 18:56:40 +00:00
#define _MAX_PATH 260 /* max. length of full pathname*/
#define _MAX_FNAME 256 /* max. length of path component*/
#define _MAX_EXT 256 /* max. length of extension component*/
2024-04-16 03:43:29 +00:00
#if !defined(MAX_PATH)
#define MAX_PATH _MAX_PATH
#endif
#define HANDLE int
// _cdecl replacement
#define __cdecl __attribute__((cdecl))
// _stdcall replacement
#define _stdcall __attribute__((stdcall))
2024-04-16 18:56:40 +00:00
inline int _filelength(int fd) {
struct stat statbuf;
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
if (fstat(fd, &statbuf) != 0) {
return -1;
}
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
return statbuf.st_size;
2024-04-16 03:43:29 +00:00
}
#ifndef stricmp
2024-04-16 18:56:40 +00:00
#define stricmp(a, b) strcasecmp(a, b)
2024-04-16 03:43:29 +00:00
#endif
2024-04-16 18:56:40 +00:00
#define strnicmp(a, b, c) strncasecmp(a, b, c)
#define _fstat(a, b) fstat(a, b)
2024-04-16 03:43:29 +00:00
#define _fileno(a) fileno(a)
2024-04-16 18:56:40 +00:00
#define strcmpi(a, b) stricmp(a, b)
#define strcmpni(a, b, c) strnicmp(a, b, c)
#define _chmod(a, b) chmod(a, b)
#if defined(__aarch64__)
#define _finite(a) isfinite(a)
#else
2024-04-16 03:43:29 +00:00
#define _finite(a) finite(a)
#endif
2024-04-16 03:43:29 +00:00
#endif