Print this page
6436 156 lint errors in common/crypto/edonr/edonr.c
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/common/crypto/edonr/edonr_byteorder.h
+++ new/usr/src/common/crypto/edonr/edonr_byteorder.h
1 1 /*
2 2 * IDI,NTNU
3 3 *
4 4 * CDDL HEADER START
5 5 *
6 6 * The contents of this file are subject to the terms of the
7 7 * Common Development and Distribution License (the "License").
8 8 * You may not use this file except in compliance with the License.
9 9 *
10 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 11 * or http://opensource.org/licenses/CDDL-1.0.
12 12 * See the License for the specific language governing permissions
13 13 * and limitations under the License.
14 14 *
15 15 * When distributing Covered Code, include this CDDL HEADER in each
16 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 17 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
18 18 * fields enclosed by brackets "[]" replaced with your own identifying
19 19 * information: Portions Copyright [yyyy] [name of copyright owner]
20 20 *
21 21 * CDDL HEADER END
22 22 *
23 23 * Copyright (C) 2009, 2010, Jorn Amundsen <jorn.amundsen@ntnu.no>
24 24 *
25 25 * C header file to determine compile machine byte order. Take care when cross
26 26 * compiling.
27 27 *
28 - * $Id: byteorder.h 517 2013-02-17 20:34:39Z joern $
29 28 */
30 29 /*
31 30 * Portions copyright (c) 2013, Saso Kiselkov, All rights reserved
31 + * Copyright 2016 Gary Mills
32 32 */
33 33
34 34 #ifndef _CRYPTO_EDONR_BYTEORDER_H
35 35 #define _CRYPTO_EDONR_BYTEORDER_H
36 36
37 37 #if defined(__linux)
38 38 #include <endian.h>
39 39 #else
40 40 #include <sys/param.h>
41 41 #endif
42 42
43 43 #if defined(__BYTE_ORDER)
44 44 #if (__BYTE_ORDER == __BIG_ENDIAN)
45 45 #define MACHINE_IS_BIG_ENDIAN
46 46 #elif (__BYTE_ORDER == __LITTLE_ENDIAN)
47 47 #define MACHINE_IS_LITTLE_ENDIAN
48 48 #endif
49 49 #elif defined(BYTE_ORDER)
50 50 #if (BYTE_ORDER == BIG_ENDIAN)
51 51 #define MACHINE_IS_BIG_ENDIAN
52 52 #elif (BYTE_ORDER == LITTLE_ENDIAN)
53 53 #define MACHINE_IS_LITTLE_ENDIAN
54 54 #endif
55 55 #endif /* __BYTE_ORDER || BYTE_ORDER */
56 56
57 57 #if !defined(MACHINE_IS_BIG_ENDIAN) && !defined(MACHINE_IS_LITTLE_ENDIAN)
58 58 #if defined(_BIG_ENDIAN) || defined(_MIPSEB)
59 59 #define MACHINE_IS_BIG_ENDIAN
60 60 #endif
61 61 #if defined(_LITTLE_ENDIAN) || defined(_MIPSEL)
62 62 #define MACHINE_IS_LITTLE_ENDIAN
63 63 #endif
64 64 #endif /* !MACHINE_IS_BIG_ENDIAN && !MACHINE_IS_LITTLE_ENDIAN */
65 65
66 66 #if !defined(MACHINE_IS_BIG_ENDIAN) && !defined(MACHINE_IS_LITTLE_ENDIAN)
67 67 #error unknown machine byte sex
68 68 #endif
69 69
70 70 #define BYTEORDER_INCLUDED
71 71
72 72 #if defined(MACHINE_IS_BIG_ENDIAN)
73 73 /*
74 74 * Byte swapping macros for big endian architectures and compilers,
75 75 * add as appropriate for other architectures and/or compilers.
76 76 *
77 77 * ld_swap64(src,dst) : uint64_t dst = *(src)
78 78 * st_swap64(src,dst) : *(dst) = uint64_t src
79 79 */
80 80
81 81 #if defined(__PPC__) || defined(_ARCH_PPC)
82 82
83 83 #if defined(__64BIT__)
84 84 #if defined(_ARCH_PWR7)
85 85 #define aix_ld_swap64(s64, d64)\
86 86 __asm__("ldbrx %0,0,%1" : "=r"(d64) : "r"(s64))
87 87 #define aix_st_swap64(s64, d64)\
88 88 __asm__ volatile("stdbrx %1,0,%0" : : "r"(d64), "r"(s64))
89 89 #else
90 90 #define aix_ld_swap64(s64, d64) \
91 91 { \
92 92 uint64_t *s4, h; \
93 93 \
94 94 __asm__("addi %0,%3,4;lwbrx %1,0,%3;lwbrx %2,0,%0;rldimi %1,%2,32,0"\
95 95 : "+r"(s4), "=r"(d64), "=r"(h) : "b"(s64)); \
96 96 }
97 97
98 98 #define aix_st_swap64(s64, d64) \
99 99 { \
100 100 uint64_t *s4, h; \
101 101 h = (s64) >> 32; \
102 102 __asm__ volatile("addi %0,%3,4;stwbrx %1,0,%3;stwbrx %2,0,%0" \
103 103 : "+r"(s4) : "r"(s64), "r"(h), "b"(d64)); \
104 104 }
105 105 #endif /* 64BIT && PWR7 */
106 106 #else
107 107 #define aix_ld_swap64(s64, d64) \
108 108 { \
109 109 uint32_t *s4, h, l; \
110 110 __asm__("addi %0,%3,4;lwbrx %1,0,%3;lwbrx %2,0,%0" \
111 111 : "+r"(s4), "=r"(l), "=r"(h) : "b"(s64)); \
112 112 d64 = ((uint64_t)h<<32) | l; \
113 113 }
114 114
115 115 #define aix_st_swap64(s64, d64) \
116 116 { \
117 117 uint32_t *s4, h, l; \
118 118 l = (s64) & 0xfffffffful, h = (s64) >> 32; \
119 119 __asm__ volatile("addi %0,%3,4;stwbrx %1,0,%3;stwbrx %2,0,%0" \
120 120 : "+r"(s4) : "r"(l), "r"(h), "b"(d64)); \
121 121 }
122 122 #endif /* __64BIT__ */
123 123 #define aix_ld_swap32(s32, d32)\
124 124 __asm__("lwbrx %0,0,%1" : "=r"(d32) : "r"(s32))
125 125 #define aix_st_swap32(s32, d32)\
126 126 __asm__ volatile("stwbrx %1,0,%0" : : "r"(d32), "r"(s32))
↓ open down ↓ |
85 lines elided |
↑ open up ↑ |
127 127 #define ld_swap32(s, d) aix_ld_swap32(s, d)
128 128 #define st_swap32(s, d) aix_st_swap32(s, d)
129 129 #define ld_swap64(s, d) aix_ld_swap64(s, d)
130 130 #define st_swap64(s, d) aix_st_swap64(s, d)
131 131 #endif /* __PPC__ || _ARCH_PPC */
132 132
133 133 #if defined(__sparc)
134 134 #if !defined(__arch64__) && !defined(__sparcv8) && defined(__sparcv9)
135 135 #define __arch64__
136 136 #endif
137 -#if defined(__GNUC__) || (defined(__SUNPRO_C) && __SUNPRO_C > 0x590)
138 -/* need Sun Studio C 5.10 and above for GNU inline assembly */
137 +#if defined(__GNUC__) || (defined(__SUNPRO_C) && __SUNPRO_C > 0x590 && \
138 + !defined(__lint))
139 +/* need Sun Studio C 5.10 and above for GNU inline assembly, but not lint */
139 140 #if defined(__arch64__)
140 141 #define sparc_ld_swap64(s64, d64) \
141 142 __asm__("ldxa [%1]0x88,%0" : "=r"(d64) : "r"(s64))
142 143 #define sparc_st_swap64(s64, d64) \
143 144 __asm__ volatile("stxa %0,[%1]0x88" : : "r"(s64), "r"(d64))
144 145 #define st_swap64(s, d) sparc_st_swap64(s, d)
145 146 #else
146 147 #define sparc_ld_swap64(s64, d64) \
147 148 { \
148 149 uint32_t *s4, h, l; \
149 150 __asm__("add %3,4,%0\n\tlda [%3]0x88,%1\n\tlda [%0]0x88,%2" \
150 151 : "+r"(s4), "=r"(l), "=r"(h) : "r"(s64)); \
151 152 d64 = ((uint64_t)h<<32) | l; \
152 153 }
153 154 #define sparc_st_swap64(s64, d64) \
154 155 { \
155 156 uint32_t *s4, h, l; \
156 157 l = (s64) & 0xfffffffful, h = (s64) >> 32; \
157 158 __asm__ volatile("add %3,4,%0\n\tsta %1,[%3]0x88\n\tsta %2,[%0]0x88"\
158 159 : "+r"(s4) : "r"(l), "r"(h), "r"(d64)); \
159 160 }
160 161 #endif /* sparc64 */
161 162 #define sparc_ld_swap32(s32, d32)\
162 163 __asm__("lda [%1]0x88,%0" : "=r"(d32) : "r"(s32))
163 164 #define sparc_st_swap32(s32, d32)\
164 165 __asm__ volatile("sta %0,[%1]0x88" : : "r"(s32), "r"(d32))
165 166 #define ld_swap32(s, d) sparc_ld_swap32(s, d)
166 167 #define st_swap32(s, d) sparc_st_swap32(s, d)
167 168 #define ld_swap64(s, d) sparc_ld_swap64(s, d)
168 169 #define st_swap64(s, d) sparc_st_swap64(s, d)
169 170 #endif /* GCC || Sun Studio C > 5.9 */
170 171 #endif /* sparc */
171 172
172 173 /* GCC fallback */
173 174 #if ((__GNUC__ >= 4) || defined(__PGIC__)) && !defined(ld_swap32)
174 175 #define ld_swap32(s, d) (d = __builtin_bswap32(*(s)))
175 176 #define st_swap32(s, d) (*(d) = __builtin_bswap32(s))
176 177 #endif /* GCC4/PGIC && !swap32 */
177 178 #if ((__GNUC__ >= 4) || defined(__PGIC__)) && !defined(ld_swap64)
178 179 #define ld_swap64(s, d) (d = __builtin_bswap64(*(s)))
179 180 #define st_swap64(s, d) (*(d) = __builtin_bswap64(s))
180 181 #endif /* GCC4/PGIC && !swap64 */
181 182
182 183 /* generic fallback */
183 184 #if !defined(ld_swap32)
184 185 #define ld_swap32(s, d) \
185 186 (d = (*(s) >> 24) | (*(s) >> 8 & 0xff00) | \
186 187 (*(s) << 8 & 0xff0000) | (*(s) << 24))
187 188 #define st_swap32(s, d) \
188 189 (*(d) = ((s) >> 24) | ((s) >> 8 & 0xff00) | \
189 190 ((s) << 8 & 0xff0000) | ((s) << 24))
190 191 #endif
191 192 #if !defined(ld_swap64)
192 193 #define ld_swap64(s, d) \
193 194 (d = (*(s) >> 56) | (*(s) >> 40 & 0xff00) | \
194 195 (*(s) >> 24 & 0xff0000) | (*(s) >> 8 & 0xff000000) | \
195 196 (*(s) & 0xff000000) << 8 | (*(s) & 0xff0000) << 24 | \
196 197 (*(s) & 0xff00) << 40 | *(s) << 56)
197 198 #define st_swap64(s, d) \
198 199 (*(d) = ((s) >> 56) | ((s) >> 40 & 0xff00) | \
199 200 ((s) >> 24 & 0xff0000) | ((s) >> 8 & 0xff000000) | \
200 201 ((s) & 0xff000000) << 8 | ((s) & 0xff0000) << 24 | \
201 202 ((s) & 0xff00) << 40 | (s) << 56)
202 203 #endif
203 204
204 205 #endif /* MACHINE_IS_BIG_ENDIAN */
205 206
206 207
207 208 #if defined(MACHINE_IS_LITTLE_ENDIAN)
208 209 /* replace swaps with simple assignments on little endian systems */
209 210 #undef ld_swap32
210 211 #undef st_swap32
211 212 #define ld_swap32(s, d) (d = *(s))
212 213 #define st_swap32(s, d) (*(d) = s)
213 214 #undef ld_swap64
214 215 #undef st_swap64
215 216 #define ld_swap64(s, d) (d = *(s))
216 217 #define st_swap64(s, d) (*(d) = s)
217 218 #endif /* MACHINE_IS_LITTLE_ENDIAN */
218 219
219 220 #endif /* _CRYPTO_EDONR_BYTEORDER_H */
↓ open down ↓ |
71 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX