libwbfs_os.h 970 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef LIBWBFS_OS_H
  2. #define LIBWBFS_OS_H
  3. // this file abstract the os integration
  4. // libwbfs_glue.h for segher tools env.
  5. // standard u8, u32 and co types, + fatal
  6. #include "tools.h"
  7. #include <stdio.h>
  8. #ifdef WIN32
  9. #define wbfs_fatal non_fatal
  10. #define wbfs_error non_fatal
  11. #define wbfs_warning non_fatal
  12. #else
  13. #define wbfs_fatal non_fatal
  14. #define wbfs_error non_fatal
  15. #define wbfs_warning non_fatal
  16. #endif
  17. #include <stdlib.h>
  18. #define wbfs_malloc(x) malloc(x)
  19. #define wbfs_free(x) free(x)
  20. // alloc memory space suitable for disk io
  21. #define wbfs_ioalloc(x) malloc(x)
  22. #define wbfs_iofree(x) free(x)
  23. #ifdef WIN32
  24. #include <winsock2.h>
  25. #else
  26. #include <arpa/inet.h>
  27. #endif
  28. // endianess tools
  29. #define wbfs_ntohl(x) ntohl(x)
  30. #define wbfs_ntohs(x) ntohs(x)
  31. #define wbfs_htonl(x) htonl(x)
  32. #define wbfs_htons(x) htons(x)
  33. #include <string.h>
  34. #define wbfs_memcmp(x,y,z) memcmp(x,y,z)
  35. #define wbfs_memcpy(x,y,z) memcpy(x,y,z)
  36. #define wbfs_memset(x,y,z) memset(x,y,z)
  37. #endif