| 1 |
greg |
3.14 |
/* RCSid $Id: platform.h,v 3.13 2016/08/05 00:12:46 greg Exp $ */ |
| 2 |
schorsch |
3.1 |
/* |
| 3 |
|
|
* platform.h - header file for platform specific definitions |
| 4 |
|
|
*/ |
| 5 |
|
|
#ifndef _RAD_PLATFORM_H_ |
| 6 |
|
|
#define _RAD_PLATFORM_H_ |
| 7 |
|
|
|
| 8 |
schorsch |
3.12 |
#if defined(_WIN32) || defined(_WIN64) |
| 9 |
schorsch |
3.1 |
|
| 10 |
schorsch |
3.7 |
#include <io.h> /* _setmode() and stuff from unistd.h */ |
| 11 |
schorsch |
3.12 |
#include <stdio.h> |
| 12 |
schorsch |
3.7 |
typedef long off_t; |
| 13 |
schorsch |
3.12 |
#define fdopen _fdopen |
| 14 |
|
|
#define read _read |
| 15 |
|
|
#define open _open |
| 16 |
|
|
#define close _close |
| 17 |
|
|
#define write _write |
| 18 |
|
|
#define ftruncate _chsize_s |
| 19 |
|
|
#define unlink _unlink |
| 20 |
|
|
#define fileno _fileno |
| 21 |
schorsch |
3.10 |
#define snprintf _snprintf |
| 22 |
schorsch |
3.12 |
#define vsnprintf _vsnprintf |
| 23 |
|
|
/* XXX should we check first if size_t is 32 bit? */ |
| 24 |
|
|
#define fseeko _fseeki64 |
| 25 |
|
|
#define lseek _lseek |
| 26 |
|
|
#define access _access |
| 27 |
|
|
#define mktemp _mktemp |
| 28 |
|
|
|
| 29 |
|
|
#include <string.h> |
| 30 |
|
|
#define strcasecmp _stricmp |
| 31 |
|
|
#define strncasecmp _strnicmp |
| 32 |
|
|
#define strdup _strdup |
| 33 |
schorsch |
3.6 |
|
| 34 |
schorsch |
3.7 |
#include <windows.h> |
| 35 |
schorsch |
3.12 |
/* really weird defines by Microsoft in <resource.h> |
| 36 |
|
|
generating lots of name collisions in Radiance. */ |
| 37 |
|
|
#if defined(rad1) |
| 38 |
|
|
#undef rad1 |
| 39 |
|
|
#undef rad2 |
| 40 |
|
|
#undef rad3 |
| 41 |
|
|
#undef rad4 |
| 42 |
|
|
#undef rad5 |
| 43 |
|
|
#undef rad6 |
| 44 |
|
|
#undef rad7 |
| 45 |
|
|
#undef rad8 |
| 46 |
|
|
#undef rad9 |
| 47 |
|
|
#endif |
| 48 |
greg |
3.13 |
#define sleep(s) Sleep((DWORD)((s)*1000)) |
| 49 |
schorsch |
3.7 |
|
| 50 |
schorsch |
3.6 |
#define NON_POSIX |
| 51 |
|
|
|
| 52 |
|
|
#include <sys/types.h> |
| 53 |
|
|
#include <sys/stat.h> |
| 54 |
|
|
#define RHAS_STAT |
| 55 |
|
|
#define S_IFREG _S_IFREG |
| 56 |
|
|
#define W_IFDIR _S_IFDIR |
| 57 |
|
|
|
| 58 |
schorsch |
3.5 |
#include <fcntl.h> /* _O_BINARY, _O_TEXT */ |
| 59 |
|
|
#include <stdlib.h> /* _fmode */ |
| 60 |
greg |
3.14 |
#define SET_DEFAULT_BINARY() (_fmode = _O_BINARY) |
| 61 |
|
|
#define SET_DEFAULT_TEXT() (_fmode = _O_TEXT) |
| 62 |
schorsch |
3.12 |
#define SET_FILE_BINARY(fp) _setmode(_fileno(fp),_O_BINARY) |
| 63 |
greg |
3.14 |
#define SET_FILE_TEXT(fp) _setmode(_fileno(fp),_O_TEXT) |
| 64 |
schorsch |
3.5 |
#define SET_FD_BINARY(fd) _setmode(fd,_O_BINARY) |
| 65 |
greg |
3.14 |
#define SET_FD_TEXT(fd) _setmode(fd,_O_TEXT) |
| 66 |
schorsch |
3.12 |
#define putenv _putenv |
| 67 |
schorsch |
3.1 |
|
| 68 |
schorsch |
3.12 |
#else /* _WIN32 || _WIN64 */ |
| 69 |
schorsch |
3.1 |
|
| 70 |
schorsch |
3.5 |
#ifdef AMIGA |
| 71 |
|
|
#define NON_POSIX |
| 72 |
|
|
#else |
| 73 |
|
|
/* assumedly posix systems */ |
| 74 |
schorsch |
3.9 |
#include <unistd.h> |
| 75 |
schorsch |
3.6 |
#define RHAS_STAT |
| 76 |
schorsch |
3.5 |
#define RHAS_FORK_EXEC |
| 77 |
|
|
#endif |
| 78 |
|
|
|
| 79 |
|
|
/* everybody except Windows */ |
| 80 |
|
|
|
| 81 |
|
|
/* NOPs */ |
| 82 |
|
|
#define SET_DEFAULT_BINARY() |
| 83 |
|
|
#define SET_FILE_BINARY(fp) |
| 84 |
|
|
#define SET_FD_BINARY(fd) |
| 85 |
greg |
3.14 |
#define SET_DEFAULT_TEXT() |
| 86 |
|
|
#define SET_FILE_TEXT(fp) |
| 87 |
|
|
#define SET_FD_TEXT(fd) |
| 88 |
schorsch |
3.1 |
|
| 89 |
schorsch |
3.12 |
#endif /* _WIN32 || _WIN64 */ |
| 90 |
schorsch |
3.1 |
|
| 91 |
schorsch |
3.8 |
#ifdef __cplusplus |
| 92 |
|
|
extern "C" { |
| 93 |
|
|
#endif |
| 94 |
|
|
|
| 95 |
|
|
/* nothing to protect yet */ |
| 96 |
schorsch |
3.2 |
|
| 97 |
|
|
#ifdef __cplusplus |
| 98 |
|
|
} |
| 99 |
|
|
#endif |
| 100 |
schorsch |
3.1 |
#endif /* _RAD_PLATFORM_H_ */ |
| 101 |
|
|
|