win32_compat.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* win32_compat.h
  2. *
  3. * compatibility stuff for Windows
  4. *
  5. * Thanks to Javier Gutiérrez Chamorro for Windows support.
  6. */
  7. #ifndef WIN32_COMPAT_H
  8. #define WIN32_COMPAT_H 1
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #include <process.h>
  13. #include <errno.h>
  14. #include <io.h> /* _findfirst and _findnext set errno iff they return -1 */
  15. #include <fcntl.h>
  16. #include <sys/utime.h>
  17. #define snprintf _snprintf
  18. #define lstat stat
  19. #define realpath(N,R) _fullpath((R),(N),MAXPATHLEN)
  20. #define ftruncate(fildes,length) open(fildes, O_TRUNC|O_WRONLY)
  21. #define set_filemode_binary(file) _setmode(_fileno(file), _O_BINARY)
  22. #define round(x) ((int) (x))
  23. #define getuid(x) 0
  24. #define geteuid() 0
  25. #define chown(outfname,st_uid,st_gid) 0
  26. #ifndef S_ISREG
  27. #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  28. #endif
  29. #ifndef S_ISDIR
  30. #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  31. #endif
  32. #ifndef HOST_TYPE
  33. #if _WIN64
  34. #define HOST_TYPE "Win64"
  35. #elif WIN32
  36. #define HOST_TYPE "Win32"
  37. #endif
  38. #endif
  39. #ifdef __cplusplus
  40. }
  41. #endif
  42. #endif /* WIN32_COMPAT_H */