stdtypes.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * @file stdtypes.h
  3. * @brief Basic type declarations for cross platform compatibility.
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewergpl$
  6. *
  7. * Copyright (c) 2000-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_STDTYPES_H
  33. #define LL_STDTYPES_H
  34. #include <cfloat>
  35. #include <climits>
  36. #include <stddef.h>
  37. typedef signed char S8;
  38. typedef unsigned char U8;
  39. typedef signed short S16;
  40. typedef unsigned short U16;
  41. typedef signed int S32;
  42. typedef unsigned int U32;
  43. #if LL_WINDOWS
  44. // Windows wchar_t is 16-bit
  45. typedef U32 llwchar;
  46. #else
  47. typedef wchar_t llwchar;
  48. #endif
  49. #if LL_WINDOWS
  50. typedef signed __int64 S64;
  51. typedef unsigned __int64 U64;
  52. // Probably should be 'hyper' or similiar
  53. # define S64L(a) (a)
  54. # define U64L(a) (a)
  55. #else
  56. typedef long long int S64;
  57. typedef long long unsigned int U64;
  58. # define S64L(a) (a##LL)
  59. # define U64L(a) (a##ULL)
  60. #endif
  61. typedef float F32;
  62. typedef double F64;
  63. typedef U8 KEY;
  64. typedef U32 MASK;
  65. typedef U32 TPACKETID;
  66. // Use #define instead of consts to avoid conversion headaches
  67. #define S8_MAX (SCHAR_MAX)
  68. #define U8_MAX (UCHAR_MAX)
  69. #define S16_MAX (SHRT_MAX)
  70. #define U16_MAX (USHRT_MAX)
  71. #define S32_MAX (INT_MAX)
  72. #define U32_MAX (UINT_MAX)
  73. #define F32_MAX (FLT_MAX)
  74. #define F64_MAX (DBL_MAX)
  75. #define S8_MIN (SCHAR_MIN)
  76. #define U8_MIN (0)
  77. #define S16_MIN (SHRT_MIN)
  78. #define U16_MIN (0)
  79. #define S32_MIN (INT_MIN)
  80. #define U32_MIN (0)
  81. #define F32_MIN (FLT_MIN)
  82. #define F64_MIN (DBL_MIN)
  83. #ifndef TRUE
  84. # define TRUE (1)
  85. #endif
  86. #ifndef FALSE
  87. # define FALSE (0)
  88. #endif
  89. #ifndef NULL
  90. # define NULL ((void*)0)
  91. #endif
  92. typedef U8 LLPCode;
  93. #define LL_ARRAY_SIZE( _kArray ) ( sizeof( (_kArray) ) / sizeof( _kArray[0] ) )
  94. // The constants below used to be in the now removed lldefs.h header and have
  95. // been moved here for simplicity. HB
  96. // Often used array indices
  97. constexpr U32 VX = 0;
  98. constexpr U32 VY = 1;
  99. constexpr U32 VZ = 2;
  100. constexpr U32 VW = 3;
  101. constexpr U32 VS = 3;
  102. constexpr U32 VRED = 0;
  103. constexpr U32 VGREEN = 1;
  104. constexpr U32 VBLUE = 2;
  105. constexpr U32 VALPHA = 3;
  106. // Map constants
  107. constexpr U32 EAST = 0;
  108. constexpr U32 NORTH = 1;
  109. constexpr U32 WEST = 2;
  110. constexpr U32 SOUTH = 3;
  111. constexpr U32 NORTHEAST = 4;
  112. constexpr U32 NORTHWEST = 5;
  113. constexpr U32 SOUTHWEST = 6;
  114. constexpr U32 SOUTHEAST = 7;
  115. constexpr U32 MIDDLEMAP = 8;
  116. // *NOTE: These values may be used as hard-coded numbers in scanf() variants.
  117. // --------------
  118. // DO NOT CHANGE.
  119. // --------------
  120. // Buffer size of maximum path + filename string length
  121. constexpr U32 LL_MAX_PATH = 1024;
  122. // For strings we send in messages
  123. constexpr U32 STD_STRING_BUF_SIZE = 255; // Buffer size
  124. constexpr U32 STD_STRING_STR_LEN = 254; // String length, \0 excluded
  125. constexpr U32 MAX_STRING = STD_STRING_BUF_SIZE; // Buffer size
  126. #endif