ecrypt_config.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /* ecrypt_config.h */
  2. /* *** Normally, it should not be necessary to edit this file. *** */
  3. #ifndef ECRYPT_CONFIG
  4. #define ECRYPT_CONFIG
  5. /* ------------------------------------------------------------------------- */
  6. /* Guess the endianness of the target architecture. */
  7. /*
  8. * The LITTLE endian machines:
  9. */
  10. #if defined(__ultrix) /* Older MIPS */
  11. #define ECRYPT_LITTLE_ENDIAN
  12. #elif defined(__alpha) /* Alpha */
  13. #define ECRYPT_LITTLE_ENDIAN
  14. #elif defined(i386) /* x86 (gcc) */
  15. #define ECRYPT_LITTLE_ENDIAN
  16. #elif defined(__i386) /* x86 (gcc) */
  17. #define ECRYPT_LITTLE_ENDIAN
  18. #elif defined(__x86_64) /* x86_64 (gcc) */
  19. #define ECRYPT_LITTLE_ENDIAN
  20. #elif defined(_M_IX86) /* x86 (MSC, Borland) */
  21. #define ECRYPT_LITTLE_ENDIAN
  22. #elif defined(_MSC_VER) /* x86 (surely MSC) */
  23. #define ECRYPT_LITTLE_ENDIAN
  24. #elif defined(__INTEL_COMPILER) /* x86 (surely Intel compiler icl.exe) */
  25. #define ECRYPT_LITTLE_ENDIAN
  26. /*
  27. * The BIG endian machines:
  28. */
  29. #elif defined(__sparc) /* Newer Sparc's */
  30. #define ECRYPT_BIG_ENDIAN
  31. #elif defined(__powerpc__) /* PowerPC */
  32. #define ECRYPT_BIG_ENDIAN
  33. #elif defined(__ppc__) /* PowerPC */
  34. #define ECRYPT_BIG_ENDIAN
  35. #elif defined(__hppa) /* HP-PA */
  36. #define ECRYPT_BIG_ENDIAN
  37. /*
  38. * Finally machines with UNKNOWN endianness:
  39. */
  40. #elif defined(_AIX) /* RS6000 */
  41. #define ECRYPT_UNKNOWN
  42. #elif defined(__aux) /* 68K */
  43. #define ECRYPT_UNKNOWN
  44. #elif defined(__dgux) /* 88K (but P6 in latest boxes) */
  45. #define ECRYPT_UNKNOWN
  46. #elif defined(__sgi) /* Newer MIPS */
  47. #define ECRYPT_UNKNOWN
  48. #else /* Any other processor */
  49. #define ECRYPT_UNKNOWN
  50. #endif
  51. /* ------------------------------------------------------------------------- */
  52. /*
  53. * Find minimal-width types to store 8-bit, 16-bit, 32-bit, and 64-bit
  54. * integers.
  55. *
  56. * Note: to enable 64-bit types on 32-bit compilers, it might be
  57. * necessary to switch from ISO C90 mode to ISO C99 mode (e.g., gcc
  58. * -std=c99), or to allow compiler-specific extensions.
  59. */
  60. #include <limits.h>
  61. /* --- check char --- */
  62. #if(UCHAR_MAX / 0xFU > 0xFU)
  63. #ifndef I8T
  64. #define I8T char
  65. #define U8C(v) (v##U)
  66. #if(UCHAR_MAX == 0xFFU)
  67. #define ECRYPT_I8T_IS_BYTE
  68. #endif
  69. #endif
  70. #if(UCHAR_MAX / 0xFFU > 0xFFU)
  71. #ifndef I16T
  72. #define I16T char
  73. #define U16C(v) (v##U)
  74. #endif
  75. #if(UCHAR_MAX / 0xFFFFU > 0xFFFFU)
  76. #ifndef I32T
  77. #define I32T char
  78. #define U32C(v) (v##U)
  79. #endif
  80. #if(UCHAR_MAX / 0xFFFFFFFFU > 0xFFFFFFFFU)
  81. #ifndef I64T
  82. #define I64T char
  83. #define U64C(v) (v##U)
  84. #define ECRYPT_NATIVE64
  85. #endif
  86. #endif
  87. #endif
  88. #endif
  89. #endif
  90. /* --- check short --- */
  91. #if(USHRT_MAX / 0xFU > 0xFU)
  92. #ifndef I8T
  93. #define I8T short
  94. #define U8C(v) (v##U)
  95. #if(USHRT_MAX == 0xFFU)
  96. #define ECRYPT_I8T_IS_BYTE
  97. #endif
  98. #endif
  99. #if(USHRT_MAX / 0xFFU > 0xFFU)
  100. #ifndef I16T
  101. #define I16T short
  102. #define U16C(v) (v##U)
  103. #endif
  104. #if(USHRT_MAX / 0xFFFFU > 0xFFFFU)
  105. #ifndef I32T
  106. #define I32T short
  107. #define U32C(v) (v##U)
  108. #endif
  109. #if(USHRT_MAX / 0xFFFFFFFFU > 0xFFFFFFFFU)
  110. #ifndef I64T
  111. #define I64T short
  112. #define U64C(v) (v##U)
  113. #define ECRYPT_NATIVE64
  114. #endif
  115. #endif
  116. #endif
  117. #endif
  118. #endif
  119. /* --- check int --- */
  120. #if(UINT_MAX / 0xFU > 0xFU)
  121. #ifndef I8T
  122. #define I8T int
  123. #define U8C(v) (v##U)
  124. #if(ULONG_MAX == 0xFFU)
  125. #define ECRYPT_I8T_IS_BYTE
  126. #endif
  127. #endif
  128. #if(UINT_MAX / 0xFFU > 0xFFU)
  129. #ifndef I16T
  130. #define I16T int
  131. #define U16C(v) (v##U)
  132. #endif
  133. #if(UINT_MAX / 0xFFFFU > 0xFFFFU)
  134. #ifndef I32T
  135. #define I32T int
  136. #define U32C(v) (v##U)
  137. #endif
  138. #if(UINT_MAX / 0xFFFFFFFFU > 0xFFFFFFFFU)
  139. #ifndef I64T
  140. #define I64T int
  141. #define U64C(v) (v##U)
  142. #define ECRYPT_NATIVE64
  143. #endif
  144. #endif
  145. #endif
  146. #endif
  147. #endif
  148. /* --- check long --- */
  149. #if(ULONG_MAX / 0xFUL > 0xFUL)
  150. #ifndef I8T
  151. #define I8T long
  152. #define U8C(v) (v##UL)
  153. #if(ULONG_MAX == 0xFFUL)
  154. #define ECRYPT_I8T_IS_BYTE
  155. #endif
  156. #endif
  157. #if(ULONG_MAX / 0xFFUL > 0xFFUL)
  158. #ifndef I16T
  159. #define I16T long
  160. #define U16C(v) (v##UL)
  161. #endif
  162. #if(ULONG_MAX / 0xFFFFUL > 0xFFFFUL)
  163. #ifndef I32T
  164. #define I32T long
  165. #define U32C(v) (v##UL)
  166. #endif
  167. #if(ULONG_MAX / 0xFFFFFFFFUL > 0xFFFFFFFFUL)
  168. #ifndef I64T
  169. #define I64T long
  170. #define U64C(v) (v##UL)
  171. #define ECRYPT_NATIVE64
  172. #endif
  173. #endif
  174. #endif
  175. #endif
  176. #endif
  177. /* --- check long long --- */
  178. #ifdef ULLONG_MAX
  179. #if(ULLONG_MAX / 0xFULL > 0xFULL)
  180. #ifndef I8T
  181. #define I8T long long
  182. #define U8C(v) (v##ULL)
  183. #if(ULLONG_MAX == 0xFFULL)
  184. #define ECRYPT_I8T_IS_BYTE
  185. #endif
  186. #endif
  187. #if(ULLONG_MAX / 0xFFULL > 0xFFULL)
  188. #ifndef I16T
  189. #define I16T long long
  190. #define U16C(v) (v##ULL)
  191. #endif
  192. #if(ULLONG_MAX / 0xFFFFULL > 0xFFFFULL)
  193. #ifndef I32T
  194. #define I32T long long
  195. #define U32C(v) (v##ULL)
  196. #endif
  197. #if(ULLONG_MAX / 0xFFFFFFFFULL > 0xFFFFFFFFULL)
  198. #ifndef I64T
  199. #define I64T long long
  200. #define U64C(v) (v##ULL)
  201. #endif
  202. #endif
  203. #endif
  204. #endif
  205. #endif
  206. #endif
  207. /* --- check __int64 --- */
  208. #if !defined(__STDC__) && defined(_UI64_MAX)
  209. #ifndef I64T
  210. #define I64T __int64
  211. #define U64C(v) (v##ui64)
  212. #endif
  213. #endif
  214. /* --- if platform doesn't announce anything, use most common choices --- */
  215. #ifndef I8T
  216. #define I8T char
  217. #define U8C(v) (v##U)
  218. #endif
  219. #ifndef I16T
  220. #define I16T short
  221. #define U16C(v) (v##U)
  222. #endif
  223. #ifndef I32T
  224. #define I32T int
  225. #define U32C(v) (v##U)
  226. #endif
  227. #ifndef I64T
  228. #define I64T long long
  229. #define U64C(v) (v##ULL)
  230. #endif
  231. /* ------------------------------------------------------------------------- */
  232. /* find the largest type on this platform (used for alignment) */
  233. #if defined(__SSE__) || (defined(_MSC_VER) && (_MSC_VER >= 1300))
  234. #include <xmmintrin.h>
  235. #define MAXT __m128
  236. #elif defined(__MMX__)
  237. #include <mmintrin.h>
  238. #define MAXT __m64
  239. #elif defined(__ALTIVEC__)
  240. #define MAXT __vector int
  241. #else
  242. #define MAXT long
  243. #endif
  244. /* ------------------------------------------------------------------------- */
  245. #endif