common.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. // DO NOT EVER INCLUDE <windows.h> directly _or indirectly_ from this file
  6. // since it slows down the build a lot.
  7. #include <cstdlib>
  8. #include <cstdio>
  9. #include <cstring>
  10. #define STACKALIGN
  11. // An inheritable class to disallow the copy constructor and operator= functions
  12. class NonCopyable
  13. {
  14. protected:
  15. NonCopyable() {}
  16. NonCopyable(const NonCopyable&&) {}
  17. void operator=(const NonCopyable&&) {}
  18. private:
  19. NonCopyable(NonCopyable&);
  20. NonCopyable& operator=(NonCopyable& other);
  21. };
  22. #include "common/assert.h"
  23. #include "common/logging/log.h"
  24. #include "common/common_types.h"
  25. #include "common/common_funcs.h"
  26. #include "common/common_paths.h"
  27. #include "common/platform.h"
  28. #ifdef __APPLE__
  29. // The Darwin ABI requires that stack frames be aligned to 16-byte boundaries.
  30. // This is only needed on i386 gcc - x86_64 already aligns to 16 bytes.
  31. #if defined __i386__ && defined __GNUC__
  32. #undef STACKALIGN
  33. #define STACKALIGN __attribute__((__force_align_arg_pointer__))
  34. #endif
  35. #elif defined _WIN32
  36. // Check MSC ver
  37. #if defined _MSC_VER && _MSC_VER <= 1000
  38. #error needs at least version 1000 of MSC
  39. #endif
  40. #ifndef NOMINMAX
  41. #define NOMINMAX
  42. #endif
  43. // Alignment
  44. #define MEMORY_ALIGNED16(x) __declspec(align(16)) x
  45. #define MEMORY_ALIGNED32(x) __declspec(align(32)) x
  46. #define MEMORY_ALIGNED64(x) __declspec(align(64)) x
  47. #define MEMORY_ALIGNED128(x) __declspec(align(128)) x
  48. #define MEMORY_ALIGNED16_DECL(x) __declspec(align(16)) x
  49. #define MEMORY_ALIGNED64_DECL(x) __declspec(align(64)) x
  50. #endif
  51. // Windows compatibility
  52. #ifndef _WIN32
  53. #ifdef _LP64
  54. #define _M_X64 1
  55. #else
  56. #define _M_IX86 1
  57. #endif
  58. #define __forceinline inline __attribute__((always_inline))
  59. #define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x
  60. #define MEMORY_ALIGNED32(x) __attribute__((aligned(32))) x
  61. #define MEMORY_ALIGNED64(x) __attribute__((aligned(64))) x
  62. #define MEMORY_ALIGNED128(x) __attribute__((aligned(128))) x
  63. #define MEMORY_ALIGNED16_DECL(x) __attribute__((aligned(16))) x
  64. #define MEMORY_ALIGNED64_DECL(x) __attribute__((aligned(64))) x
  65. #endif
  66. #ifdef _MSC_VER
  67. #define __strdup _strdup
  68. #define __getcwd _getcwd
  69. #define __chdir _chdir
  70. #else
  71. #define __strdup strdup
  72. #define __getcwd getcwd
  73. #define __chdir chdir
  74. #endif
  75. #if defined _M_GENERIC
  76. # define _M_SSE 0x0
  77. #elif defined __GNUC__
  78. # if defined __SSE4_2__
  79. # define _M_SSE 0x402
  80. # elif defined __SSE4_1__
  81. # define _M_SSE 0x401
  82. # elif defined __SSSE3__
  83. # define _M_SSE 0x301
  84. # elif defined __SSE3__
  85. # define _M_SSE 0x300
  86. # endif
  87. #elif (_MSC_VER >= 1500) || __INTEL_COMPILER // Visual Studio 2008
  88. # define _M_SSE 0x402
  89. #endif
  90. // Host communication.
  91. enum HOST_COMM
  92. {
  93. // Begin at 10 in case there is already messages with wParam = 0, 1, 2 and so on
  94. WM_USER_STOP = 10,
  95. WM_USER_CREATE,
  96. WM_USER_SETCURSOR,
  97. };
  98. // Used for notification on emulation state
  99. enum EMUSTATE_CHANGE
  100. {
  101. EMUSTATE_CHANGE_PLAY = 1,
  102. EMUSTATE_CHANGE_PAUSE,
  103. EMUSTATE_CHANGE_STOP
  104. };
  105. #include "swap.h"