OSDN Git Service

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