| 2 | 
  | 
/* | 
| 3 | 
  | 
 *  platform.h - header file for platform specific definitions | 
| 4 | 
  | 
 */ | 
| 5 | 
– | 
 | 
| 6 | 
– | 
#include "copyright.h" | 
| 7 | 
– | 
 | 
| 8 | 
– | 
 | 
| 5 | 
  | 
#ifndef _RAD_PLATFORM_H_ | 
| 6 | 
  | 
#define _RAD_PLATFORM_H_ | 
| 7 | 
  | 
 | 
| 8 | 
+ | 
#if defined(_WIN32) || defined(_WIN64) | 
| 9 | 
  | 
 | 
| 10 | 
< | 
#ifdef _WIN32 | 
| 10 | 
> | 
  #include <io.h>     /* _setmode() and stuff from unistd.h */ | 
| 11 | 
> | 
  #include <stdio.h> | 
| 12 | 
> | 
  typedef long off_t; | 
| 13 | 
> | 
  #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 | 
> | 
  #define snprintf _snprintf | 
| 22 | 
> | 
  #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 <stdio.h>  /* fileno() */ | 
| 30 | 
< | 
#include <fcntl.h>  /* _O_BINARY, _O_TEXT */ | 
| 31 | 
< | 
#include <io.h>     /* _setmode() */ | 
| 32 | 
< | 
#include <stdlib.h> /* _fmode */ | 
| 29 | 
> | 
  #include <string.h> | 
| 30 | 
> | 
  #define strcasecmp _stricmp | 
| 31 | 
> | 
  #define strncasecmp _strnicmp | 
| 32 | 
> | 
  #define strdup _strdup | 
| 33 | 
  | 
 | 
| 34 | 
< | 
#define SET_DEFAULT_BINARY() _fmode = _O_BINARY | 
| 35 | 
< | 
#define SET_FILE_BINARY(fp) _setmode(fileno(fp),_O_BINARY) | 
| 36 | 
< | 
#define SET_FD_BINARY(fd) _setmode(fd,_O_BINARY) | 
| 34 | 
> | 
  #include <windows.h> | 
| 35 | 
> | 
  /* 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 | 
> | 
  #define sleep(s) Sleep(s*1000) | 
| 49 | 
  | 
 | 
| 50 | 
+ | 
  #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 | 
+ | 
  #include <fcntl.h>  /* _O_BINARY, _O_TEXT */ | 
| 59 | 
+ | 
  #include <stdlib.h> /* _fmode */ | 
| 60 | 
+ | 
  #define SET_DEFAULT_BINARY() _fmode = _O_BINARY | 
| 61 | 
+ | 
  #define SET_FILE_BINARY(fp) _setmode(_fileno(fp),_O_BINARY) | 
| 62 | 
+ | 
  #define SET_FD_BINARY(fd) _setmode(fd,_O_BINARY) | 
| 63 | 
+ | 
  #define putenv _putenv | 
| 64 | 
  | 
 | 
| 65 | 
+ | 
#else /* _WIN32 || _WIN64 */ | 
| 66 | 
  | 
 | 
| 67 | 
+ | 
  #ifdef AMIGA | 
| 68 | 
+ | 
    #define NON_POSIX | 
| 69 | 
+ | 
  #else | 
| 70 | 
+ | 
    /* assumedly posix systems */ | 
| 71 | 
+ | 
        #include <unistd.h> | 
| 72 | 
+ | 
    #define RHAS_STAT | 
| 73 | 
+ | 
    #define RHAS_FORK_EXEC | 
| 74 | 
+ | 
  #endif | 
| 75 | 
  | 
 | 
| 76 | 
+ | 
  /* everybody except Windows */ | 
| 77 | 
  | 
 | 
| 78 | 
< | 
#else /* _WIN32 */ | 
| 78 | 
> | 
  /* NOPs */ | 
| 79 | 
> | 
  #define SET_DEFAULT_BINARY() | 
| 80 | 
> | 
  #define SET_FILE_BINARY(fp) | 
| 81 | 
> | 
  #define SET_FD_BINARY(fd) | 
| 82 | 
  | 
 | 
| 83 | 
< | 
/* NOPs on unix */ | 
| 33 | 
< | 
#define SET_DEFAULT_BINARY() | 
| 34 | 
< | 
#define SET_FILE_BINARY(fp) | 
| 35 | 
< | 
#define SET_FD_BINARY(fd) | 
| 83 | 
> | 
#endif /* _WIN32 || _WIN64 */ | 
| 84 | 
  | 
 | 
| 85 | 
+ | 
#ifdef __cplusplus | 
| 86 | 
+ | 
extern "C" { | 
| 87 | 
+ | 
#endif | 
| 88 | 
  | 
 | 
| 89 | 
+ | 
/* nothing to protect yet */ | 
| 90 | 
  | 
 | 
| 91 | 
< | 
 | 
| 92 | 
< | 
 | 
| 93 | 
< | 
 | 
| 42 | 
< | 
 | 
| 43 | 
< | 
#endif /* _WIN32 */ | 
| 44 | 
< | 
 | 
| 91 | 
> | 
#ifdef __cplusplus | 
| 92 | 
> | 
} | 
| 93 | 
> | 
#endif | 
| 94 | 
  | 
#endif /* _RAD_PLATFORM_H_ */ | 
| 95 | 
  | 
 |