retro_environment.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* Copyright (C) 2010-2018 The RetroArch team
  2. *
  3. * ---------------------------------------------------------------------------------------
  4. * The following license statement only applies to this file (retro_environment.h).
  5. * ---------------------------------------------------------------------------------------
  6. *
  7. * Permission is hereby granted, free of charge,
  8. * to any person obtaining a copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation the rights to
  10. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
  11. * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef __LIBRETRO_SDK_ENVIRONMENT_H
  23. #define __LIBRETRO_SDK_ENVIRONMENT_H
  24. /*
  25. This file is designed to create a normalized environment for compiling
  26. libretro-common's private implementations, or any other sources which might
  27. enjoy use of it's environment (RetroArch for instance).
  28. This should be an elaborately crafted environment so that sources don't
  29. need to be full of platform-specific workarounds.
  30. */
  31. #if defined (__cplusplus)
  32. #if 0
  33. printf("This is C++, version %d.\n", __cplusplus);
  34. #endif
  35. /* The expected values would be
  36. * 199711L, for ISO/IEC 14882:1998 or 14882:2003
  37. */
  38. #elif defined(__STDC__)
  39. /* This is standard C. */
  40. #if (__STDC__ == 1)
  41. /* The implementation is ISO-conforming. */
  42. #define __STDC_ISO__
  43. #else
  44. /* The implementation is not ISO-conforming. */
  45. #endif
  46. #if defined(__STDC_VERSION__)
  47. #if (__STDC_VERSION__ >= 201112L)
  48. /* This is C11. */
  49. #define __STDC_C11__
  50. #elif (__STDC_VERSION__ >= 199901L)
  51. /* This is C99. */
  52. #define __STDC_C99__
  53. #elif (__STDC_VERSION__ >= 199409L)
  54. /* This is C89 with amendment 1. */
  55. #define __STDC_C89__
  56. #define __STDC_C89_AMENDMENT_1__
  57. #else
  58. /* This is C89 without amendment 1. */
  59. #define __STDC_C89__
  60. #endif
  61. #else /* !defined(__STDC_VERSION__) */
  62. /* This is C89. __STDC_VERSION__ is not defined. */
  63. #define __STDC_C89__
  64. #endif
  65. #else /* !defined(__STDC__) */
  66. /* This is not standard C. __STDC__ is not defined. */
  67. #endif
  68. #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
  69. /* Try to find out if we're compiling for WinRT or non-WinRT */
  70. #if defined(_MSC_VER) && defined(__has_include)
  71. #if __has_include(<winapifamily.h>)
  72. #define HAVE_WINAPIFAMILY_H 1
  73. #else
  74. #define HAVE_WINAPIFAMILY_H 0
  75. #endif
  76. /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
  77. #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */
  78. #define HAVE_WINAPIFAMILY_H 1
  79. #else
  80. #define HAVE_WINAPIFAMILY_H 0
  81. #endif
  82. #if HAVE_WINAPIFAMILY_H
  83. #include <winapifamily.h>
  84. #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
  85. #else
  86. #define WINAPI_FAMILY_WINRT 0
  87. #endif /* HAVE_WINAPIFAMILY_H */
  88. #if WINAPI_FAMILY_WINRT
  89. #undef __WINRT__
  90. #define __WINRT__ 1
  91. #endif
  92. /* MSVC obviously has to have some non-standard constants... */
  93. #if _M_IX86_FP == 1
  94. #define __SSE__ 1
  95. #elif _M_IX86_FP == 2 || (defined(_M_AMD64) || defined(_M_X64))
  96. #define __SSE__ 1
  97. #define __SSE2__ 1
  98. #endif
  99. #endif
  100. #endif