KeccakP-brg_endian_avx2.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. ---------------------------------------------------------------------------
  3. Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
  4. LICENSE TERMS
  5. The redistribution and use of this software (with or without changes)
  6. is allowed without the payment of fees or royalties provided that:
  7. 1. source code distributions include the above copyright notice, this
  8. list of conditions and the following disclaimer;
  9. 2. binary distributions include the above copyright notice, this list
  10. of conditions and the following disclaimer in their documentation;
  11. 3. the name of the copyright holder is not used to endorse products
  12. built using this software without specific written permission.
  13. DISCLAIMER
  14. This software is provided 'as is' with no explicit or implied warranties
  15. in respect of its properties, including, but not limited to, correctness
  16. and/or fitness for purpose.
  17. ---------------------------------------------------------------------------
  18. Issue Date: 20/12/2007
  19. Changes for ARM 9/9/2010
  20. */
  21. #pragma once
  22. #define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
  23. #define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
  24. #if 0
  25. /* Include files where endian defines and byteswap functions may reside */
  26. #if defined( __sun )
  27. # error #include <sys/isa_defs.h>
  28. #elif defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ )
  29. # include <sys/endian.h>
  30. #elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \
  31. defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ )
  32. # include <machine/endian.h>
  33. #elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
  34. # if !defined( __MINGW32__ ) && !defined( _AIX )
  35. # include <endian.h>
  36. # if !defined( __BEOS__ )
  37. # include <byteswap.h>
  38. # endif
  39. # endif
  40. #endif
  41. #endif
  42. /* Now attempt to set the define for platform byte order using any */
  43. /* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */
  44. /* seem to encompass most endian symbol definitions */
  45. #if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN )
  46. # if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN
  47. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  48. # elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN
  49. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  50. # endif
  51. #elif defined( BIG_ENDIAN )
  52. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  53. #elif defined( LITTLE_ENDIAN )
  54. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  55. #endif
  56. #if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN )
  57. # if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN
  58. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  59. # elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN
  60. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  61. # endif
  62. #elif defined( _BIG_ENDIAN )
  63. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  64. #elif defined( _LITTLE_ENDIAN )
  65. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  66. #endif
  67. #if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN )
  68. # if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN
  69. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  70. # elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN
  71. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  72. # endif
  73. #elif defined( __BIG_ENDIAN )
  74. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  75. #elif defined( __LITTLE_ENDIAN )
  76. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  77. #endif
  78. #if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ )
  79. # if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__
  80. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  81. # elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__
  82. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  83. # endif
  84. #elif defined( __BIG_ENDIAN__ )
  85. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  86. #elif defined( __LITTLE_ENDIAN__ )
  87. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  88. #endif
  89. /* if the platform byte order could not be determined, then try to */
  90. /* set this define using common machine defines */
  91. #if !defined(PLATFORM_BYTE_ORDER)
  92. #if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \
  93. defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \
  94. defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \
  95. defined( vax ) || defined( vms ) || defined( VMS ) || \
  96. defined( __VMS ) || defined( _M_X64 )
  97. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  98. #elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \
  99. defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \
  100. defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \
  101. defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \
  102. defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \
  103. defined( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \
  104. defined( THINK_C ) || defined( __VMCMS__ ) || defined( _AIX )
  105. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  106. #elif defined(__arm__)
  107. # ifdef __BIG_ENDIAN
  108. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  109. # else
  110. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  111. # endif
  112. #elif 1 /* **** EDIT HERE IF NECESSARY **** */
  113. # define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
  114. #elif 0 /* **** EDIT HERE IF NECESSARY **** */
  115. # define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
  116. #else
  117. # error Please edit lines 132 or 134 in brg_endian.h to set the platform byte order
  118. #endif
  119. #endif