uposixdefs.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. * Copyright (C) 2011-2015, International Business Machines
  6. * Corporation and others. All Rights Reserved.
  7. *******************************************************************************
  8. * file name: uposixdefs.h
  9. * encoding: UTF-8
  10. * tab size: 8 (not used)
  11. * indentation:4
  12. *
  13. * created on: 2011jul25
  14. * created by: Markus W. Scherer
  15. *
  16. * Common definitions for implementation files working with POSIX functions.
  17. * *Important*: #include this file before any other header files!
  18. */
  19. #ifndef __UPOSIXDEFS_H__
  20. #define __UPOSIXDEFS_H__
  21. /*
  22. * Define _XOPEN_SOURCE for access to POSIX functions.
  23. *
  24. * We cannot use U_PLATFORM from platform.h/utypes.h because
  25. * "The Open Group Base Specifications"
  26. * chapter "2.2 The Compilation Environment" says:
  27. * "In the compilation of an application that #defines a feature test macro
  28. * specified by IEEE Std 1003.1-2001,
  29. * no header defined by IEEE Std 1003.1-2001 shall be included prior to
  30. * the definition of the feature test macro."
  31. */
  32. #ifdef _XOPEN_SOURCE
  33. /* Use the predefined value. */
  34. #else
  35. /*
  36. * Version 6.0:
  37. * The Open Group Base Specifications Issue 6 (IEEE Std 1003.1, 2004 Edition)
  38. * also known as
  39. * SUSv3 = Open Group Single UNIX Specification, Version 3 (UNIX03)
  40. *
  41. * Note: This definition used to be in C source code (e.g., putil.c)
  42. * and define _XOPEN_SOURCE to different values depending on __STDC_VERSION__.
  43. * In C++ source code (e.g., putil.cpp), __STDC_VERSION__ is not defined at all.
  44. */
  45. # define _XOPEN_SOURCE 600
  46. #endif
  47. /*
  48. * Make sure things like readlink and such functions work.
  49. * Poorly upgraded Solaris machines can't have this defined.
  50. * Cleanly installed Solaris can use this #define.
  51. *
  52. * z/OS needs this definition for timeval and to get usleep.
  53. */
  54. #if !defined(_XOPEN_SOURCE_EXTENDED) && defined(__TOS_MVS__)
  55. # define _XOPEN_SOURCE_EXTENDED 1
  56. #endif
  57. /**
  58. * Solaris says:
  59. * "...it is invalid to compile an XPG6 or a POSIX.1-2001 application with anything other
  60. * than a c99 or later compiler."
  61. * Apparently C++11 is not "or later". Work around this.
  62. */
  63. #if defined(__cplusplus) && (defined(sun) || defined(__sun)) && !defined (_STDC_C99)
  64. # define _STDC_C99
  65. #endif
  66. #if !defined _POSIX_C_SOURCE && \
  67. defined(__APPLE__) && defined(__MACH__) && !defined(__clang__)
  68. // Needed to prevent EOWNERDEAD issues with GCC on Mac
  69. #define _POSIX_C_SOURCE 200809L
  70. #endif
  71. #endif /* __UPOSIXDEFS_H__ */