stdafx.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * This source code is public domain.
  3. *
  4. * Authors: Rani Assaf <[email protected]>,
  5. * Olivier Lapicque <[email protected]>,
  6. * Adam Goode <[email protected]> (endian and char fixes for PPC)
  7. */
  8. #ifndef MODPLUG_STDAFX_H
  9. #define MODPLUG_STDAFX_H
  10. /* Autoconf detection of stdint/inttypes */
  11. #if defined(HAVE_CONFIG_H) && !defined(CONFIG_H_INCLUDED)
  12. # include "config.h"
  13. # define CONFIG_H_INCLUDED 1
  14. #endif
  15. #ifdef HAVE_INTTYPES_H
  16. # include <inttypes.h>
  17. #endif
  18. #ifdef HAVE_STDINT_H
  19. # include <stdint.h>
  20. #endif
  21. /* disable AGC and FILESAVE for all targets for uniformity. */
  22. #define NO_AGC
  23. #define MODPLUG_NO_FILESAVE
  24. #ifdef _WIN32
  25. #ifdef MSC_VER
  26. #pragma warning (disable:4201)
  27. #pragma warning (disable:4514)
  28. #endif
  29. #define WIN32_LEAN_AND_MEAN
  30. #include <windows.h>
  31. #include <windowsx.h>
  32. #include <mmsystem.h>
  33. #include <stdio.h>
  34. #include <malloc.h>
  35. #include <stdint.h>
  36. #define srandom(_seed) srand(_seed)
  37. #define random() rand()
  38. #define sleep(_ms) Sleep(_ms)
  39. inline void ProcessPlugins(int n) {}
  40. #undef strcasecmp
  41. #undef strncasecmp
  42. #define strcasecmp(a,b) _stricmp(a,b)
  43. #define strncasecmp(a,b,c) _strnicmp(a,b,c)
  44. #define HAVE_SINF 1
  45. #ifndef isblank
  46. #define isblank(c) ((c) == ' ' || (c) == '\t')
  47. #endif
  48. #else
  49. #include <stdlib.h>
  50. #include <stdio.h>
  51. #include <string.h>
  52. #ifdef HAVE_MALLOC_H
  53. #include <malloc.h>
  54. #endif
  55. typedef int8_t CHAR;
  56. typedef uint8_t UCHAR;
  57. typedef uint8_t* PUCHAR;
  58. typedef uint16_t USHORT;
  59. typedef uint32_t ULONG;
  60. typedef uint32_t UINT;
  61. typedef uint32_t DWORD;
  62. typedef int32_t LONG;
  63. typedef int64_t LONGLONG;
  64. typedef int32_t* LPLONG;
  65. typedef uint32_t* LPDWORD;
  66. typedef uint16_t WORD;
  67. typedef uint8_t BYTE;
  68. typedef uint8_t* LPBYTE;
  69. typedef bool BOOL;
  70. typedef char* LPSTR;
  71. typedef void* LPVOID;
  72. typedef uint16_t* LPWORD;
  73. typedef const char* LPCSTR;
  74. typedef void* PVOID;
  75. typedef void VOID;
  76. inline LONG MulDiv (long a, long b, long c)
  77. {
  78. /*if (!c) return 0;*/
  79. return ((uint64_t) a * (uint64_t) b ) / c;
  80. }
  81. #define LPCTSTR LPCSTR
  82. #define lstrcpyn strncpy
  83. #define lstrcpy strcpy
  84. #define lstrcmp strcmp
  85. #define wsprintf sprintf
  86. #define WAVE_FORMAT_PCM 1
  87. #define GHND 0
  88. #define GlobalFreePtr(p) free((void *)(p))
  89. inline int8_t * GlobalAllocPtr(unsigned int, size_t size)
  90. {
  91. int8_t * p = (int8_t *) malloc(size);
  92. if (p != NULL) memset(p, 0, size);
  93. return p;
  94. }
  95. inline void ProcessPlugins(int /* n */ ) {}
  96. #ifndef FALSE
  97. #define FALSE false
  98. #endif
  99. #ifndef TRUE
  100. #define TRUE true
  101. #endif
  102. #endif /* _WIN32 */
  103. #if defined(_WIN32) || defined(__CYGWIN__)
  104. # if defined(MODPLUG_BUILD) && defined(DLL_EXPORT) /* building libmodplug as a dll for windows */
  105. # define MODPLUG_EXPORT __declspec(dllexport)
  106. # elif defined(MODPLUG_BUILD) || defined(MODPLUG_STATIC) /* building or using static libmodplug for windows */
  107. # define MODPLUG_EXPORT
  108. # else
  109. # define MODPLUG_EXPORT __declspec(dllimport) /* using libmodplug dll for windows */
  110. # endif
  111. #elif defined(MODPLUG_BUILD) && defined(SYM_VISIBILITY)
  112. # define MODPLUG_EXPORT __attribute__((visibility("default")))
  113. #else
  114. #define MODPLUG_EXPORT
  115. #endif
  116. #endif