CCStdC.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /****************************************************************************
  2. Copyright (c) 2010 cocos2d-x.org
  3. Copyright (c) Microsoft Open Technologies, Inc.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __CC_STD_C_H__
  22. #define __CC_STD_C_H__
  23. #include "platform/CCPlatformConfig.h"
  24. #if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
  25. #include "platform/CCPlatformMacros.h"
  26. #include <float.h>
  27. #include <BaseTsd.h>
  28. #include <cmath>
  29. #ifndef __SSIZE_T
  30. #define __SSIZE_T
  31. typedef SSIZE_T ssize_t;
  32. #endif // __SSIZE_T
  33. // for math.h on win32 platform
  34. #if !defined(_USE_MATH_DEFINES)
  35. #define _USE_MATH_DEFINES // make M_PI can be use
  36. #endif
  37. #if _MSC_VER < 1900
  38. #ifndef snprintf
  39. #define snprintf _snprintf
  40. #endif
  41. #endif
  42. #include <math.h>
  43. #include <string.h>
  44. #include <stdarg.h>
  45. #include <stdio.h>
  46. #include <stdlib.h>
  47. #include <time.h>
  48. #ifndef M_PI
  49. #define M_PI 3.14159265358
  50. #endif
  51. #ifndef M_PI_2
  52. #define M_PI_2 1.57079632679
  53. #endif
  54. // for MIN MAX and sys/time.h on win32 platform
  55. #ifndef NOMINMAX
  56. #define NOMINMAX
  57. #endif
  58. #ifndef MIN
  59. #define MIN(x,y) (((x) > (y)) ? (y) : (x))
  60. #endif // MIN
  61. #ifndef MAX
  62. #define MAX(x,y) (((x) < (y)) ? (y) : (x))
  63. #endif // MAX
  64. #include <stdint.h>
  65. #ifdef WINRT_NO_WINSOCK
  66. #undef timeval
  67. struct timeval
  68. {
  69. long tv_sec; // seconds
  70. long tv_usec; // microSeconds
  71. };
  72. #else
  73. // Structure timeval has define in winsock.h, include windows.h for it.
  74. #define _WINSOCKAPI_
  75. #include <WinSock2.h>
  76. #ifndef WIN32_LEAN_AND_MEAN
  77. #define WIN32_LEAN_AND_MEAN 1
  78. #include <Windows.h>
  79. #endif
  80. #endif
  81. struct timezone
  82. {
  83. int tz_minuteswest;
  84. int tz_dsttime;
  85. };
  86. int CC_DLL gettimeofday(struct timeval *, struct timezone *);
  87. #endif // CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
  88. #endif // __CC_STD_C_H__