diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-07-11 15:50:46 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-07-11 15:50:46 +0000 |
commit | 14c7f45cdae826f88dc539c8c38dd95caf305731 (patch) | |
tree | 832da054b7cfb2dc6fd63339af736625f31d21aa /utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h | |
parent | 7c84ede3781c27db73403bd6302f320c76a58c8c (diff) | |
download | rockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.tar.gz rockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.zip |
Add zook's ZenUtils to SVN
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18010 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h')
-rwxr-xr-x | utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h new file mode 100755 index 0000000000..e136aa59f9 --- /dev/null +++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * endianness.h | ||
3 | * | ||
4 | * Endian-dependant encoding/decoding, header | ||
5 | * | ||
6 | * Copyright (c) 1998, 1999, 2000, 2001, 2004 Beeyond Software Holding | ||
7 | * | ||
8 | * Author: Bob Deblier <bob.deblier@telenet.be> | ||
9 | * | ||
10 | * This library is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU Lesser General Public | ||
12 | * License as published by the Free Software Foundation; either | ||
13 | * version 2.1 of the License, or (at your option) any later version. | ||
14 | * | ||
15 | * This library is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 | * Lesser General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU Lesser General Public | ||
21 | * License along with this library; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #ifndef _ENDIANNESS_H | ||
27 | #define _ENDIANNESS_H | ||
28 | |||
29 | #include "beecrypt/beecrypt.h" | ||
30 | |||
31 | #if defined(__cplusplus) || HAVE_INLINE | ||
32 | |||
33 | static inline int16_t _swap16(int16_t n) | ||
34 | { | ||
35 | return ( ((n & 0xff) << 8) | | ||
36 | ((n & 0xff00) >> 8) ); | ||
37 | } | ||
38 | # define swap16(n) _swap16(n) | ||
39 | |||
40 | static inline uint16_t _swapu16(uint16_t n) | ||
41 | { | ||
42 | return ( ((n & 0xffU) << 8) | | ||
43 | ((n & 0xff00U) >> 8) ); | ||
44 | } | ||
45 | # define swapu16(n) _swap16(n) | ||
46 | |||
47 | # ifdef __arch__swab32 | ||
48 | # define swap32(n) __arch__swab32(n) | ||
49 | # define swapu32(n) __arch__swab32(n) | ||
50 | # else | ||
51 | |||
52 | static inline int32_t _swap32(int32_t n) | ||
53 | { | ||
54 | return ( ((n & 0xff) << 24) | | ||
55 | ((n & 0xff00) << 8) | | ||
56 | ((n & 0xff0000) >> 8) | | ||
57 | ((n & 0xff000000) >> 24) ); | ||
58 | } | ||
59 | # define swap32(n) _swap32(n) | ||
60 | |||
61 | static inline uint32_t _swapu32(uint32_t n) | ||
62 | { | ||
63 | return ( ((n & 0xffU) << 24) | | ||
64 | ((n & 0xff00U) << 8) | | ||
65 | ((n & 0xff0000U) >> 8) | | ||
66 | ((n & 0xff000000U) >> 24) ); | ||
67 | } | ||
68 | # define swapu32(n) _swapu32(n) | ||
69 | |||
70 | # endif | ||
71 | |||
72 | # ifdef __arch__swab64 | ||
73 | # define swap64(n) __arch__swab64(n) | ||
74 | # define swapu64(n) __arch__swab64(n) | ||
75 | # else | ||
76 | |||
77 | static inline int64_t _swap64(int64_t n) | ||
78 | { | ||
79 | return ( ((n & ((int64_t) 0xff) ) << 56) | | ||
80 | ((n & ((int64_t) 0xff) << 8) << 40) | | ||
81 | ((n & ((int64_t) 0xff) << 16) << 24) | | ||
82 | ((n & ((int64_t) 0xff) << 24) << 8) | | ||
83 | ((n & ((int64_t) 0xff) << 32) >> 8) | | ||
84 | ((n & ((int64_t) 0xff) << 40) >> 24) | | ||
85 | ((n & ((int64_t) 0xff) << 48) >> 40) | | ||
86 | ((n & ((int64_t) 0xff) << 56) >> 56) ); | ||
87 | } | ||
88 | # define swap64(n) _swap64(n) | ||
89 | |||
90 | static inline uint64_t _swapu64(uint64_t n) | ||
91 | { | ||
92 | return ( ((n & ((uint64_t) 0xff) ) << 56) | | ||
93 | ((n & ((uint64_t) 0xff) << 8) << 40) | | ||
94 | ((n & ((uint64_t) 0xff) << 16) << 24) | | ||
95 | ((n & ((uint64_t) 0xff) << 24) << 8) | | ||
96 | ((n & ((uint64_t) 0xff) << 32) >> 8) | | ||
97 | ((n & ((uint64_t) 0xff) << 40) >> 24) | | ||
98 | ((n & ((uint64_t) 0xff) << 48) >> 40) | | ||
99 | ((n & ((uint64_t) 0xff) << 56) >> 56) ); | ||
100 | } | ||
101 | # define swapu64(n) _swapu64(n) | ||
102 | |||
103 | # endif | ||
104 | |||
105 | #else | ||
106 | BEECRYPTAPI | ||
107 | int16_t swap16 (int16_t); | ||
108 | BEECRYPTAPI | ||
109 | uint16_t swapu16(uint16_t); | ||
110 | BEECRYPTAPI | ||
111 | int32_t swap32 (int32_t); | ||
112 | BEECRYPTAPI | ||
113 | uint32_t swapu32(uint32_t); | ||
114 | BEECRYPTAPI | ||
115 | int64_t swap64 (int64_t); | ||
116 | BEECRYPTAPI | ||
117 | uint64_t swapu64(uint64_t); | ||
118 | #endif | ||
119 | |||
120 | #ifdef __cplusplus | ||
121 | extern "C" { | ||
122 | #endif | ||
123 | |||
124 | #ifdef __cplusplus | ||
125 | } | ||
126 | #endif | ||
127 | |||
128 | #endif | ||