]> git.saurik.com Git - apple/xnu.git/blame - bsd/crypto/aes/i386/edefs.h
xnu-1228.tar.gz
[apple/xnu.git] / bsd / crypto / aes / i386 / edefs.h
CommitLineData
2d21ac55
A
1/*\r
2 ---------------------------------------------------------------------------\r
3 Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.\r
4\r
5 LICENSE TERMS\r
6\r
7 The free distribution and use of this software in both source and binary\r
8 form is allowed (with or without changes) provided that:\r
9\r
10 1. distributions of this source code include the above copyright\r
11 notice, this list of conditions and the following disclaimer;\r
12\r
13 2. distributions in binary form include the above copyright\r
14 notice, this list of conditions and the following disclaimer\r
15 in the documentation and/or other associated materials;\r
16\r
17 3. the copyright holder's name is not used to endorse products\r
18 built using this software without specific written permission.\r
19\r
20 ALTERNATIVELY, provided that this notice is retained in full, this product\r
21 may be distributed under the terms of the GNU General Public License (GPL),\r
22 in which case the provisions of the GPL apply INSTEAD OF those given above.\r
23\r
24 DISCLAIMER\r
25\r
26 This software is provided 'as is' with no explicit or implied warranties\r
27 in respect of its properties, including, but not limited to, correctness\r
28 and/or fitness for purpose.\r
29 ---------------------------------------------------------------------------\r
30 Issue 31/01/2006\r
31*/\r
32\r
33#ifndef EDEFS_H\r
34#define EDEFS_H\r
35#if defined(__cplusplus)\r
36extern "C"\r
37{\r
38#endif\r
39\r
40#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */\r
41#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */\r
42\r
43#if defined(__GNUC__) || defined(__GNU_LIBRARY__)\r
44# if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)\r
45# include <sys/endian.h>\r
46# elif defined( BSD ) && ( BSD >= 199103 ) || defined( __DJGPP__ ) || defined( __CYGWIN32__ ) \r
47# include <machine/endian.h>\r
48# elif defined(__APPLE__)\r
49# if defined(__BIG_ENDIAN__) && !defined( BIG_ENDIAN )\r
50# define BIG_ENDIAN\r
51# elif defined(__LITTLE_ENDIAN__) && !defined( LITTLE_ENDIAN )\r
52# define LITTLE_ENDIAN\r
53# endif\r
54# elif !defined( __MINGW32__ )\r
55# include <endian.h>\r
56# if !defined(__BEOS__)\r
57# include <byteswap.h>\r
58# endif\r
59# endif\r
60#endif\r
61\r
62#if !defined(PLATFORM_BYTE_ORDER)\r
63# if defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN)\r
64# if defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)\r
65# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN\r
66# elif !defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)\r
67# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN\r
68# elif defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)\r
69# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN\r
70# elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)\r
71# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN\r
72# endif\r
73# elif defined(_LITTLE_ENDIAN) || defined(_BIG_ENDIAN)\r
74# if defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)\r
75# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN\r
76# elif !defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)\r
77# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN\r
78# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _LITTLE_ENDIAN)\r
79# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN\r
80# elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)\r
81# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN\r
82# endif\r
83# elif defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__)\r
84# if defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)\r
85# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN\r
86# elif !defined(__LITTLE_ENDIAN__) && defined(__BIG_ENDIAN__)\r
87# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN\r
88# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __LITTLE_ENDIAN__)\r
89# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN\r
90# elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)\r
91# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN\r
92# endif\r
93# endif\r
94#endif\r
95\r
96/* if the platform is still unknown, try to find its byte order */\r
97/* from commonly used machine defines */\r
98\r
99#if !defined(PLATFORM_BYTE_ORDER)\r
100\r
101#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \\r
102 defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \\r
103 defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \\r
104 defined( vax ) || defined( vms ) || defined( VMS ) || \\r
105 defined( __VMS ) || defined( _M_X64 )\r
106# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN\r
107\r
108#elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \\r
109 defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \\r
110 defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \\r
111 defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \\r
112 defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \\r
113 defined( __TANDEM ) || defined( THINK_C ) || defined( __VMCMS__ ) || \\r
114 defined( __VOS__ )\r
115# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN\r
116\r
117#elif 0 /* **** EDIT HERE IF NECESSARY **** */\r
118# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN\r
119#elif 0 /* **** EDIT HERE IF NECESSARY **** */\r
120# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN\r
121#else\r
122# error Please edit edefs.h (lines 117 or 119) to set the platform byte order\r
123#endif\r
124\r
125#endif\r
126\r
127#if defined(__cplusplus)\r
128}\r
129#endif\r
130#endif\r