__sgx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (C) 2011-2017 Intel Corporation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Intel Corporation nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. */
  31. #ifndef __LIBCPP_SGX
  32. #define __LIBCPP_SGX
  33. /*
  34. * libc++ configuration file specific to SGX SDK
  35. * It is internal libc++ header - DO NOT include it directly
  36. */
  37. #ifndef UNREFERENCED_PARAMETER
  38. # define UNREFERENCED_PARAMETER(P) (P)
  39. #endif //UNREFERENCED_PARAMETER
  40. // SECTION 1: NEW DEFINES SPECIFIC TO SGX
  41. #define _LIBCPP_SGX_CONFIG
  42. /* No I/O operations that involve OCALLs allowed */
  43. #define _LIBCPP_SGX_NO_IOSTREAMS
  44. // Define to replace usage of __cplusplus
  45. // The compiler sets this to latest standard it supports although we want code using
  46. // this to conform to C++11 not C++14 or later.
  47. // More specific we should not compile code under __cplusplus > 201103L.
  48. // Code under __cplusplus >= 201103L is fine.
  49. #define sgx__cplusplus 201103L
  50. // We need to make sure that where __cplusplus is used in defines it always goes to path for
  51. // #define __cplusplus 201103L because it might be defined to something higher.
  52. // Set SGX specific endianess below
  53. #include <sys/endian.h>
  54. #ifdef _LIBCPP_LITTLE_ENDIAN
  55. #undef _LIBCPP_LITTLE_ENDIAN
  56. #endif // _LIBCPP_LITTLE_ENDIAN
  57. #ifdef _LIBCPP_BIG_ENDIAN
  58. #undef _LIBCPP_BIG_ENDIAN
  59. #endif //_LIBCPP_BIG_ENDIAN
  60. #if _BYTE_ORDER == _LITTLE_ENDIAN
  61. # define _LIBCPP_LITTLE_ENDIAN 1
  62. # define _LIBCPP_BIG_ENDIAN 0
  63. #else // _BYTE_ORDER == _LITTLE_ENDIAN
  64. # define _LIBCPP_LITTLE_ENDIAN 0
  65. # define _LIBCPP_BIG_ENDIAN 1
  66. #endif // _BYTE_ORDER == _LITTLE_ENDIAN
  67. // Use sgx assert
  68. #include <assert.h>
  69. #if defined(_LIBCPP_ASSERT)
  70. #undef _LIBCPP_ASSERT
  71. #endif // _LIBCPP_ASSERT
  72. #define _LIBCPP_ASSERT(x, m) (assert(x))
  73. // RTTI comes from cpprt. Undefine NO_RTTI
  74. #if defined(_LIBCPP_NO_RTTI)
  75. #undef _LIBCPP_NO_RTTI
  76. #endif // _LIBCPP_NO_RTTI
  77. #if defined(__GNUC__)
  78. /////////////
  79. // SECTION 2: UNDEF VARIOUS LIBC++ DEFINES FOR SUPPORTED FEATURES
  80. /////////////
  81. #undef _LIBCPP_USING_DEV_RANDOM
  82. #define _LIBCPP_USING_SGX_RANDOM
  83. #undef _LIBCPP_NO_EXCEPTIONS
  84. #undef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
  85. #undef _LIBCPP_HAS_NO_CONSTEXPR
  86. #undef _LIBCPP_HAS_NO_UNICODE_CHARS
  87. #undef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
  88. #undef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
  89. #undef _LIBCPP_HAS_NO_VARIADICS
  90. #undef _LIBCPP_HAS_NO_ADVANCED_SFINAE
  91. #undef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES // Will be set
  92. #undef _LIBCPP_HAS_NO_RVALUE_REFERENCES
  93. #undef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
  94. //#undef _LIBCPP_DEBUG // TBD. Debug without I/O?
  95. #undef _LIBCPP_HAS_QUICK_EXIT
  96. #undef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS // Not used
  97. // Current goal is to support C++11 so define the version accordingly.
  98. // Libc++ also supports 14 and beyond.
  99. #define _LIBCPP_STD_VER 11
  100. /////////////
  101. // SECTION 3: DEFINE VARIOUS LIBC++ DEFINES TO CUSTOMIZE USAGE FOR SGX
  102. /////////////
  103. #define _LIBCPP_HAS_NO_THREADS
  104. #define _LIBCPP_HAS_NO_STDIN
  105. #define _LIBCPP_HAS_NO_STDOUT
  106. #define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
  107. #undef _LIBCPP_SGX_HAS_NO_THREADS
  108. #undef _LIBCPP_SGX_HAS_NO_ATOMIC
  109. /////////////
  110. // SECTION 4: SGX specific defines which replace __has_feature(cxx_something)
  111. /////////////
  112. #define _LIBCPP_SGX_HAS_CXX_ATOMIC //__has_feature(cxx_atomic)
  113. #endif
  114. #endif // _LIBCPP_SGX