posix_features.hpp 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // (C) Copyright John Maddock 2001 - 2003.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org for most recent version.
  6. // All POSIX feature tests go in this file,
  7. // Note that we test _POSIX_C_SOURCE and _XOPEN_SOURCE as well
  8. // _POSIX_VERSION and _XOPEN_VERSION: on some systems POSIX API's
  9. // may be present but none-functional unless _POSIX_C_SOURCE and
  10. // _XOPEN_SOURCE have been defined to the right value (it's up
  11. // to the user to do this *before* including any header, although
  12. // in most cases the compiler will do this for you).
  13. # if defined(BOOST_HAS_UNISTD_H)
  14. # include <unistd.h>
  15. // XOpen has <nl_types.h>, but is this the correct version check?
  16. # if defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 3)
  17. # define BOOST_HAS_NL_TYPES_H
  18. # endif
  19. // POSIX version 6 requires <stdint.h>
  20. # if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 200100)
  21. # define BOOST_HAS_STDINT_H
  22. # endif
  23. // POSIX version 2 requires <dirent.h>
  24. # if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 199009L)
  25. # define BOOST_HAS_DIRENT_H
  26. # endif
  27. // POSIX version 3 requires <signal.h> to have sigaction:
  28. # if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 199506L)
  29. # define BOOST_HAS_SIGACTION
  30. # endif
  31. // POSIX defines _POSIX_THREADS > 0 for pthread support,
  32. // however some platforms define _POSIX_THREADS without
  33. // a value, hence the (_POSIX_THREADS+0 >= 0) check.
  34. // Strictly speaking this may catch platforms with a
  35. // non-functioning stub <pthreads.h>, but such occurrences should
  36. // occur very rarely if at all.
  37. # if defined(_POSIX_THREADS) && (_POSIX_THREADS+0 >= 0) && !defined(BOOST_HAS_WINTHREADS) && !defined(BOOST_HAS_MPTASKS)
  38. # define BOOST_HAS_PTHREADS
  39. # endif
  40. // BOOST_HAS_NANOSLEEP:
  41. // This is predicated on _POSIX_TIMERS or _XOPEN_REALTIME:
  42. # if (defined(_POSIX_TIMERS) && (_POSIX_TIMERS+0 >= 0)) \
  43. || (defined(_XOPEN_REALTIME) && (_XOPEN_REALTIME+0 >= 0))
  44. # define BOOST_HAS_NANOSLEEP
  45. # endif
  46. // BOOST_HAS_CLOCK_GETTIME:
  47. // This is predicated on _POSIX_TIMERS (also on _XOPEN_REALTIME
  48. // but at least one platform - linux - defines that flag without
  49. // defining clock_gettime):
  50. # if (defined(_POSIX_TIMERS) && (_POSIX_TIMERS+0 >= 0))
  51. # define BOOST_HAS_CLOCK_GETTIME
  52. # endif
  53. // BOOST_HAS_SCHED_YIELD:
  54. // This is predicated on _POSIX_PRIORITY_SCHEDULING or
  55. // on _POSIX_THREAD_PRIORITY_SCHEDULING or on _XOPEN_REALTIME.
  56. # if defined(_POSIX_PRIORITY_SCHEDULING) && (_POSIX_PRIORITY_SCHEDULING+0 > 0)\
  57. || (defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING+0 > 0))\
  58. || (defined(_XOPEN_REALTIME) && (_XOPEN_REALTIME+0 >= 0))
  59. # define BOOST_HAS_SCHED_YIELD
  60. # endif
  61. // BOOST_HAS_GETTIMEOFDAY:
  62. // BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE:
  63. // These are predicated on _XOPEN_VERSION, and appears to be first released
  64. // in issue 4, version 2 (_XOPEN_VERSION > 500).
  65. // Likewise for the functions log1p and expm1.
  66. # if defined(_XOPEN_VERSION) && (_XOPEN_VERSION+0 >= 500)
  67. # define BOOST_HAS_GETTIMEOFDAY
  68. # if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE+0 >= 500)
  69. # define BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE
  70. # endif
  71. # ifndef BOOST_HAS_LOG1P
  72. # define BOOST_HAS_LOG1P
  73. # endif
  74. # ifndef BOOST_HAS_EXPM1
  75. # define BOOST_HAS_EXPM1
  76. # endif
  77. # endif
  78. # endif