mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 03:00:38 +00:00
Remove #define compat_h_macrodef__ and its absent case, which was only ever used for an old JFDuke3D port to PalmOS.
If for some reason you need to target a platform that lacks a libc, you're better off finding a libc, or putting together your own shim layer. It's a weekend project at most. git-svn-id: https://svn.eduke32.com/eduke32@6070 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
6d7191b848
commit
ee4d69093c
2 changed files with 159 additions and 421 deletions
|
@ -156,16 +156,9 @@
|
|||
|
||||
#include "libdivide.h"
|
||||
|
||||
// Define this to rewrite all 'B' versions to library functions. This
|
||||
// is for platforms which give us a standard sort of C library so we
|
||||
// link directly. Platforms like PalmOS which don't have a standard C
|
||||
// library will need to wrap these functions with suitable emulations.
|
||||
#define compat_h_macrodef__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef compat_h_macrodef__
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -180,7 +173,6 @@
|
|||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -505,8 +497,6 @@ FORCE_INLINE int32_t Blrintf(const float x)
|
|||
# define FP_OFF(__p) ((uintptr_t)(__p))
|
||||
#endif
|
||||
|
||||
#ifdef compat_h_macrodef__
|
||||
|
||||
#ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
#endif
|
||||
|
@ -544,29 +534,6 @@ FORCE_INLINE int32_t Blrintf(const float x)
|
|||
#define BSEEK_SET SEEK_SET
|
||||
#define BSEEK_CUR SEEK_CUR
|
||||
#define BSEEK_END SEEK_END
|
||||
#else
|
||||
# define BO_BINARY 0
|
||||
# define BO_TEXT 1
|
||||
# define BO_RDONLY 2
|
||||
# define BO_WRONLY 4
|
||||
# define BO_RDWR 6
|
||||
# define BO_APPEND 8
|
||||
# define BO_CREAT 16
|
||||
# define BO_TRUNC 32
|
||||
# define BS_IRGRP 0
|
||||
# define BS_IWGRP 0
|
||||
# define BS_IEXEC 1
|
||||
# define BS_IWRITE 2
|
||||
# define BS_IREAD 4
|
||||
# define BS_IFIFO 0x1000
|
||||
# define BS_IFCHR 0x2000
|
||||
# define BS_IFBLK 0x3000
|
||||
# define BS_IFDIR 0x4000
|
||||
# define BS_IFREG 0x8000
|
||||
# define BSEEK_SET 0
|
||||
# define BSEEK_CUR 1
|
||||
# define BSEEK_END 2
|
||||
#endif
|
||||
|
||||
#ifdef UNDERSCORES
|
||||
# define ASMSYM(x) "_" x
|
||||
|
@ -631,15 +598,9 @@ int32_t Bclosedir(BDIR *dir);
|
|||
typedef intptr_t ssize_t;
|
||||
#endif
|
||||
|
||||
#ifdef compat_h_macrodef__
|
||||
typedef FILE BFILE;
|
||||
# define bsize_t size_t
|
||||
# define bssize_t ssize_t
|
||||
#else
|
||||
typedef void BFILE;
|
||||
typedef uint32_t bsize_t;
|
||||
typedef int32_t bssize_t;
|
||||
#endif
|
||||
typedef size_t bsize_t;
|
||||
typedef ssize_t bssize_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
@ -681,11 +642,9 @@ FORCE_INLINE uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7fff
|
|||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// XXX: non-__compat_h_macrodef__ version?
|
||||
#define strtoll _strtoi64
|
||||
#endif
|
||||
|
||||
#ifdef compat_h_macrodef__
|
||||
#define Bassert assert
|
||||
#define Brand rand
|
||||
#define Balloca alloca
|
||||
|
@ -800,56 +759,6 @@ FORCE_INLINE uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7fff
|
|||
#define Btime() time(NULL)
|
||||
#define Butime utime
|
||||
|
||||
#else
|
||||
|
||||
void Bassert(int);
|
||||
int32_t Brand(void);
|
||||
void *Bmalloc(bsize_t size);
|
||||
void Bfree(void *ptr);
|
||||
int32_t Bopen(const char *pathname, int32_t flags, unsigned mode);
|
||||
int32_t Bclose(int32_t fd);
|
||||
bssize_t Bwrite(int32_t fd, const void *buf, bsize_t count);
|
||||
bssize_t Bread(int32_t fd, void *buf, bsize_t count);
|
||||
int32_t Blseek(int32_t fildes, int32_t offset, int32_t whence);
|
||||
BFILE *Bfopen(const char *path, const char *mode);
|
||||
int32_t Bfclose(BFILE *stream);
|
||||
int32_t Bfeof(BFILE *stream);
|
||||
int32_t Bfgetc(BFILE *stream);
|
||||
void Brewind(BFILE *stream);
|
||||
char *Bfgets(char *s, int32_t size, BFILE *stream);
|
||||
int32_t Bfputc(int32_t c, BFILE *stream);
|
||||
int32_t Bfputs(const char *s, BFILE *stream);
|
||||
bsize_t Bfread(void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream);
|
||||
bsize_t Bfwrite(const void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream);
|
||||
char *Bstrdup(const char *s);
|
||||
char *Bstrcpy(char *dest, const char *src);
|
||||
char *Bstrncpy(char *dest, const char *src, bsize_t n);
|
||||
int32_t Bstrcmp(const char *s1, const char *s2);
|
||||
int32_t Bstrncmp(const char *s1, const char *s2, bsize_t n);
|
||||
int32_t Bstrcasecmp(const char *s1, const char *s2);
|
||||
int32_t Bstrncasecmp(const char *s1, const char *s2, bsize_t n);
|
||||
char *Bstrcat(char *dest, const char *src);
|
||||
char *Bstrncat(char *dest, const char *src, bsize_t n);
|
||||
bsize_t Bstrlen(const char *s);
|
||||
char *Bstrchr(const char *s, int32_t c);
|
||||
char *Bstrrchr(const char *s, int32_t c);
|
||||
int32_t Batoi(const char *nptr);
|
||||
int32_t Batol(const char *nptr);
|
||||
int32_t Bstrtol(const char *nptr, char **endptr, int32_t base);
|
||||
uint32_t Bstrtoul(const char *nptr, char **endptr, int32_t base);
|
||||
void *Bmemcpy(void *dest, const void *src, bsize_t n);
|
||||
void *Bmemmove(void *dest, const void *src, bsize_t n);
|
||||
void *Bmemchr(const void *s, int32_t c, bsize_t n);
|
||||
void *Bmemset(void *s, int32_t c, bsize_t n);
|
||||
int32_t Bmemcmp(const void *s1, const void *s2, bsize_t n);
|
||||
int32_t Bprintf(const char *format, ...) ATTRIBUTE((format(printf, 1, 2)));
|
||||
int32_t Bsprintf(char *str, const char *format, ...) ATTRIBUTE((format(printf, 2, 3)));
|
||||
int32_t Bsnprintf(char *str, bsize_t size, const char *format, ...) ATTRIBUTE((format(printf, 3, 4)));
|
||||
int32_t Bvsnprintf(char *str, bsize_t size, const char *format, va_list ap);
|
||||
char *Bgetcwd(char *buf, bsize_t size);
|
||||
char *Bgetenv(const char *name);
|
||||
#endif
|
||||
|
||||
char *Bgethomedir(void);
|
||||
char *Bgetappdir(void);
|
||||
uint32_t Bgetsysmemsize(void);
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
/*
|
||||
* Playing-field leveller for Build
|
||||
* by Jonathon Fowler
|
||||
*
|
||||
* A note about this:
|
||||
* 1. There is some kind of problem somewhere in the functions below because
|
||||
* compiling with __compat_h_macrodef__ disabled makes stupid things happen.
|
||||
* 2. The functions below, aside from the ones which aren't trivial, were never
|
||||
* really intended to be used for anything except tracking anr removing ties
|
||||
* to the standard C library from games. Using the Bxx versions of functions
|
||||
* means we can redefine those names to link up with different runtime library
|
||||
* names.
|
||||
*/
|
||||
|
||||
#include "compat.h"
|
||||
|
@ -76,167 +66,6 @@ void set_memerr_handler(void(*handlerfunc)(int32_t, const char *, const char *))
|
|||
g_MemErrHandler = handlerfunc;
|
||||
}
|
||||
|
||||
//////////
|
||||
|
||||
#ifndef compat_h_macrodef__
|
||||
|
||||
void Bassert(int expr) { assert(expr); }
|
||||
int32_t Brand(void) { return rand(); }
|
||||
void *Bmalloc(bsize_t size) { return malloc(size); }
|
||||
void Bfree(void *ptr) { free(ptr); }
|
||||
|
||||
int32_t Bopen(const char *pathname, int32_t flags, uint32_t mode)
|
||||
{
|
||||
int32_t n = 0, o = 0;
|
||||
|
||||
if (flags & BO_BINARY)
|
||||
n |= O_BINARY;
|
||||
else
|
||||
n |= O_TEXT;
|
||||
if ((flags & BO_RDWR) == BO_RDWR)
|
||||
n |= O_RDWR;
|
||||
else if ((flags & BO_RDWR) == BO_WRONLY)
|
||||
n |= O_WRONLY;
|
||||
else if ((flags & BO_RDWR) == BO_RDONLY)
|
||||
n |= O_RDONLY;
|
||||
if (flags & BO_APPEND)
|
||||
n |= O_APPEND;
|
||||
if (flags & BO_CREAT)
|
||||
n |= O_CREAT;
|
||||
if (flags & BO_TRUNC)
|
||||
n |= O_TRUNC;
|
||||
if (mode & BS_IREAD)
|
||||
o |= S_IREAD;
|
||||
if (mode & BS_IWRITE)
|
||||
o |= S_IWRITE;
|
||||
if (mode & BS_IEXEC)
|
||||
o |= S_IEXEC;
|
||||
|
||||
return open(pathname, n, o);
|
||||
}
|
||||
|
||||
int32_t Bclose(int32_t fd) { return close(fd); }
|
||||
bssize_t Bwrite(int32_t fd, const void *buf, bsize_t count) { return write(fd, buf, count); }
|
||||
bssize_t Bread(int32_t fd, void *buf, bsize_t count) { return read(fd, buf, count); }
|
||||
|
||||
int32_t Blseek(int32_t fildes, int32_t offset, int32_t whence)
|
||||
{
|
||||
switch (whence)
|
||||
{
|
||||
case BSEEK_SET: whence = SEEK_SET; break;
|
||||
case BSEEK_CUR: whence = SEEK_CUR; break;
|
||||
case BSEEK_END: whence = SEEK_END; break;
|
||||
}
|
||||
return lseek(fildes, offset, whence);
|
||||
}
|
||||
|
||||
BFILE *Bfopen(const char *path, const char *mode) { return (BFILE *)fopen(path, mode); }
|
||||
int32_t Bfclose(BFILE *stream) { return fclose((FILE *)stream); }
|
||||
void Brewind(BFILE *stream) { rewind((FILE *)stream); }
|
||||
int32_t Bfgetc(BFILE *stream) { return fgetc((FILE *)stream); }
|
||||
char *Bfgets(char *s, int32_t size, BFILE *stream) { return fgets(s, size, (FILE *)stream); }
|
||||
int32_t Bfputc(int32_t c, BFILE *stream) { return fputc(c, (FILE *)stream); }
|
||||
int32_t Bfputs(const char *s, BFILE *stream) { return fputs(s, (FILE *)stream); }
|
||||
bsize_t Bfread(void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream) { return fread(ptr, size, nmemb, (FILE *)stream); }
|
||||
bsize_t Bfwrite(const void *ptr, bsize_t size, bsize_t nmemb, BFILE *stream) { return fwrite(ptr, size, nmemb, (FILE *)stream); }
|
||||
char *Bstrdup(const char *s) { return strdup(s); }
|
||||
char *Bstrcpy(char *dest, const char *src) { return strcpy(dest, src); }
|
||||
char *Bstrncpy(char *dest, const char *src, bsize_t n) { return Bstrncpy(dest, src, n); }
|
||||
int32_t Bstrcmp(const char *s1, const char *s2) { return strcmp(s1, s2); }
|
||||
int32_t Bstrncmp(const char *s1, const char *s2, bsize_t n) { return strncmp(s1, s2, n); }
|
||||
|
||||
int32_t Bstrcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
return _stricmp(s1, s2);
|
||||
#else
|
||||
return strcasecmp(s1, s2);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t Bstrncasecmp(const char *s1, const char *s2, bsize_t n)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
return _strnicmp(s1, s2, n);
|
||||
#else
|
||||
return strncasecmp(s1, s2, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
char *Bstrcat(char *dest, const char *src) { return strcat(dest, src); }
|
||||
char *Bstrncat(char *dest, const char *src, bsize_t n) { return strncat(dest, src, n); }
|
||||
bsize_t Bstrlen(const char *s) { return strlen(s); }
|
||||
char *Bstrchr(const char *s, int32_t c) { return strchr(s, c); }
|
||||
char *Bstrrchr(const char *s, int32_t c) { return strrchr(s, c); }
|
||||
int32_t Batoi(const char *nptr) { return strtol(nptr, NULL, 10); }
|
||||
int32_t Batol(const char *nptr) { return strtol(nptr, NULL, 10); }
|
||||
int32_t Bstrtol(const char *nptr, char **endptr, int32_t base) { return strtol(nptr, endptr, base); }
|
||||
uint32_t Bstrtoul(const char *nptr, char **endptr, int32_t base) { return strtoul(nptr, endptr, base); }
|
||||
void *Bmemcpy(void *dest, const void *src, bsize_t n) { return memcpy(dest, src, n); }
|
||||
void *Bmemmove(void *dest, const void *src, bsize_t n) { return memmove(dest, src, n); }
|
||||
void *Bmemchr(const void *s, int32_t c, bsize_t n) { return memchr(s, c, n); }
|
||||
void *Bmemset(void *s, int32_t c, bsize_t n) { return memset(s, c, n); }
|
||||
|
||||
int32_t Bprintf(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int32_t r;
|
||||
|
||||
va_start(ap, format);
|
||||
#ifdef _MSC_VER
|
||||
r = _vprintf(format, ap);
|
||||
#else
|
||||
r = vprintf(format, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
int32_t Bsprintf(char *str, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int32_t r;
|
||||
|
||||
va_start(ap, format);
|
||||
#ifdef _MSC_VER
|
||||
r = _vsprintf(str, format, ap);
|
||||
#else
|
||||
r = vsprintf(str, format, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
int32_t Bsnprintf(char *str, bsize_t size, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int32_t r;
|
||||
|
||||
va_start(ap, format);
|
||||
#ifdef _MSC_VER
|
||||
r = _vsnprintf(str, size, format, ap);
|
||||
#else
|
||||
r = vsnprintf(str, size, format, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
int32_t Bvsnprintf(char *str, bsize_t size, const char *format, va_list ap)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
return _vsnprintf(str, size, format, ap);
|
||||
#else
|
||||
return vsnprintf(str, size, format, ap);
|
||||
#endif
|
||||
}
|
||||
|
||||
char *Bgetenv(const char *name) { return getenv(name); }
|
||||
char *Bgetcwd(char *buf, bsize_t size) { return getcwd(buf, size); }
|
||||
|
||||
#endif // __compat_h_macrodef__
|
||||
|
||||
|
||||
//
|
||||
// Stuff which must be a function
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue