unixcompat.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /** \file unixcompat.h
  2. * \brief Header: collects differences between the various Unix
  3. *
  4. * This header file collects differences between the various Unix
  5. * variants that are supported by the Midnight Commander and provides
  6. * replacement routines if they are not natively available.
  7. * The major/minor macros are not specified in SUSv3, so we can only hope
  8. * they are provided by the operating system or emulate it.
  9. */
  10. #ifndef MC_UNIXCOMPAT_H
  11. #define MC_UNIXCOMPAT_H
  12. #include <sys/types.h> /* BSD */
  13. #ifdef MAJOR_IN_MKDEV
  14. #include <sys/mkdev.h>
  15. #elif defined MAJOR_IN_SYSMACROS
  16. #include <sys/sysmacros.h>
  17. #endif
  18. #include <unistd.h>
  19. /*** typedefs(not structures) and defined constants **********************************************/
  20. #ifndef major
  21. #warning major() is undefined. Device numbers will not be shown correctly.
  22. #define major(devnum) (((devnum) >> 8) & 0xff)
  23. #endif
  24. #ifndef minor
  25. #warning minor() is undefined. Device numbers will not be shown correctly.
  26. #define minor(devnum) (((devnum) & 0xff))
  27. #endif
  28. #ifndef makedev
  29. #warning makedev() is undefined. Device numbers will not be shown correctly.
  30. #define makedev(major,minor) ((((major) & 0xff) << 8) | ((minor) & 0xff))
  31. #endif
  32. #ifndef STDIN_FILENO
  33. #define STDIN_FILENO 0
  34. #endif
  35. #ifndef STDOUT_FILENO
  36. #define STDOUT_FILENO 1
  37. #endif
  38. #ifndef STDERR_FILENO
  39. #define STDERR_FILENO 2
  40. #endif
  41. /*** enums ***************************************************************************************/
  42. /*** structures declarations (and typedefs of structures)*****************************************/
  43. /*** global variables defined in .c file *********************************************************/
  44. /*** declarations of public functions ************************************************************/
  45. /*** inline functions ****************************************************************************/
  46. #endif