Merge pull request #19372 from cotequeiroz/libgd
[feed/packages.git] / libs / libowfat / patches / 030-pure.patch
1 --- a/byte.h
2 +++ b/byte.h
3 @@ -9,17 +9,24 @@
4 extern "C" {
5 #endif
6
7 -#ifndef __pure__
8 -#define __pure__
9 +#ifndef ATTR_PURE
10 +# if defined __has_attribute
11 +# if __has_attribute (pure)
12 +# define ATTR_PURE __attribute__ ((pure))
13 +# endif
14 +# endif
15 +#endif
16 +#ifndef ATTR_PURE
17 +# define ATTR_PURE
18 #endif
19
20 /* byte_chr returns the smallest integer i between 0 and len-1
21 * inclusive such that one[i] equals needle, or len if not found. */
22 -size_t byte_chr(const void* haystack, size_t len, char needle) __pure__;
23 +size_t byte_chr(const void* haystack, size_t len, char needle) ATTR_PURE;
24
25 /* byte_rchr returns the largest integer i between 0 and len-1 inclusive
26 * such that one[i] equals needle, or len if not found. */
27 -size_t byte_rchr(const void* haystack,size_t len,char needle) __pure__;
28 +size_t byte_rchr(const void* haystack,size_t len,char needle) ATTR_PURE;
29
30 /* byte_copy copies in[0] to out[0], in[1] to out[1], ... and in[len-1]
31 * to out[len-1]. */
32 @@ -34,14 +41,14 @@ void byte_copyr(void* out, size_t len, c
33 * than, equal to, or greater than the string b[0], b[1], ...,
34 * b[len-1]. When the strings are different, byte_diff does not read
35 * bytes past the first difference. */
36 -int byte_diff(const void* a, size_t len, const void* b) __pure__;
37 +int byte_diff(const void* a, size_t len, const void* b) ATTR_PURE;
38
39 /* byte_zero sets the bytes out[0], out[1], ..., out[len-1] to 0 */
40 void byte_zero(void* out, size_t len);
41
42 #define byte_equal(s,n,t) (!byte_diff((s),(n),(t)))
43
44 -int byte_equal_notimingattack(const void* a, size_t len,const void* b) __pure__;
45 +int byte_equal_notimingattack(const void* a, size_t len,const void* b) ATTR_PURE;
46
47 #if defined(__i386__) || defined(__x86_64__)
48 #define UNALIGNED_ACCESS_OK
49 --- a/critbit.h
50 +++ b/critbit.h
51 @@ -5,18 +5,25 @@
52 extern "C" {
53 #endif
54
55 -/* for __pure__ if we are compiling under dietlibc */
56 +/* for ATTR_PURE if we are compiling under dietlibc */
57 #include <stddef.h>
58
59 -#ifndef __pure__
60 -#define __pure__
61 +#ifndef ATTR_PURE
62 +# if defined __has_attribute
63 +# if __has_attribute (pure)
64 +# define ATTR_PURE __attribute__ ((pure))
65 +# endif
66 +# endif
67 +#endif
68 +#ifndef ATTR_PURE
69 +# define ATTR_PURE
70 #endif
71
72 typedef struct {
73 void *root;
74 } critbit0_tree;
75
76 -int critbit0_contains(critbit0_tree *t, const char *u) __pure__;
77 +int critbit0_contains(critbit0_tree *t, const char *u) ATTR_PURE;
78 int critbit0_insert(critbit0_tree *t, const char *u);
79 int critbit0_delete(critbit0_tree *t, const char *u);
80 void critbit0_clear(critbit0_tree *t);
81 --- a/scan.h
82 +++ b/scan.h
83 @@ -15,8 +15,15 @@
84 extern "C" {
85 #endif
86
87 -#ifndef __pure__
88 -#define __pure__
89 +#ifndef ATTR_PURE
90 +# if defined __has_attribute
91 +# if __has_attribute (pure)
92 +# define ATTR_PURE __attribute__ ((pure))
93 +# endif
94 +# endif
95 +#endif
96 +#ifndef ATTR_PURE
97 +# define ATTR_PURE
98 #endif
99
100 /* This file declared functions used to decode / scan / unmarshal
101 @@ -84,18 +91,18 @@ size_t scan_double(const char *in, doubl
102 size_t scan_plusminus(const char *src,signed int *dest);
103
104 /* return the highest integer n<=limit so that isspace(in[i]) for all 0<=i<=n */
105 -size_t scan_whitenskip(const char *in,size_t limit) __pure__;
106 +size_t scan_whitenskip(const char *in,size_t limit) ATTR_PURE;
107
108 /* return the highest integer n<=limit so that !isspace(in[i]) for all 0<=i<=n */
109 -size_t scan_nonwhitenskip(const char *in,size_t limit) __pure__;
110 +size_t scan_nonwhitenskip(const char *in,size_t limit) ATTR_PURE;
111
112 /* return the highest integer n<=limit so that in[i] is element of
113 * charset (ASCIIZ string) for all 0<=i<=n */
114 -size_t scan_charsetnskip(const char *in,const char *charset,size_t limit) __pure__;
115 +size_t scan_charsetnskip(const char *in,const char *charset,size_t limit) ATTR_PURE;
116
117 /* return the highest integer n<=limit so that in[i] is not element of
118 * charset (ASCIIZ string) for all 0<=i<=n */
119 -size_t scan_noncharsetnskip(const char *in,const char *charset,size_t limit) __pure__;
120 +size_t scan_noncharsetnskip(const char *in,const char *charset,size_t limit) ATTR_PURE;
121
122 /* try to parse ASCII GMT date; does not understand time zones. */
123 /* example dates:
124 @@ -103,17 +110,17 @@ size_t scan_noncharsetnskip(const char *
125 * "Sunday, 06-Nov-94 08:49:37 GMT"
126 * "Sun Nov 6 08:49:37 1994"
127 */
128 -size_t scan_httpdate(const char *in,time_t *t) __pure__;
129 +size_t scan_httpdate(const char *in,time_t *t) ATTR_PURE;
130
131 /* try to parse ASCII ISO-8601 date; does not understand time zones. */
132 /* example date: "2014-05-27T19:22:16Z" */
133 -size_t scan_iso8601(const char* in,struct timespec* t) __pure__;
134 +size_t scan_iso8601(const char* in,struct timespec* t) ATTR_PURE;
135
136 /* some variable length encodings for integers */
137 -size_t scan_utf8(const char* in,size_t len,uint32_t* n) __pure__;
138 -size_t scan_utf8_sem(const char* in,size_t len,uint32_t* n) __pure__;
139 -size_t scan_asn1derlength(const char* in,size_t len,unsigned long long* n) __pure__;
140 -size_t scan_asn1dertag(const char* in,size_t len,unsigned long long* n) __pure__;
141 +size_t scan_utf8(const char* in,size_t len,uint32_t* n) ATTR_PURE;
142 +size_t scan_utf8_sem(const char* in,size_t len,uint32_t* n) ATTR_PURE;
143 +size_t scan_asn1derlength(const char* in,size_t len,unsigned long long* n) ATTR_PURE;
144 +size_t scan_asn1dertag(const char* in,size_t len,unsigned long long* n) ATTR_PURE;
145
146 /* Google protocol buffers */
147 /* A protocol buffer is a sequence of (tag,value).
148 @@ -122,15 +129,15 @@ size_t scan_asn1dertag(const char* in,si
149 * 0, double type 1, strings type 2 and floats type 5. However, you
150 * have to check this yourself.
151 */
152 -size_t scan_varint(const char* in,size_t len, unsigned long long* n) __pure__; /* internal */
153 -size_t scan_pb_tag(const char* in,size_t len, size_t* fieldno,unsigned char* type) __pure__;
154 +size_t scan_varint(const char* in,size_t len, unsigned long long* n) ATTR_PURE; /* internal */
155 +size_t scan_pb_tag(const char* in,size_t len, size_t* fieldno,unsigned char* type) ATTR_PURE;
156
157 /* Then, depending on the field number, validate the type and call the
158 * corresponding of these functions to parse the value */
159 -size_t scan_pb_type0_int(const char* in,size_t len,unsigned long long* l) __pure__;
160 -size_t scan_pb_type0_sint(const char* in,size_t len,signed long long* l) __pure__;
161 -size_t scan_pb_type1_double(const char* in,size_t len,double* d) __pure__;
162 -size_t scan_pb_type1_fixed64(const char* in,size_t len,uint64_t* b) __pure__;
163 +size_t scan_pb_type0_int(const char* in,size_t len,unsigned long long* l) ATTR_PURE;
164 +size_t scan_pb_type0_sint(const char* in,size_t len,signed long long* l) ATTR_PURE;
165 +size_t scan_pb_type1_double(const char* in,size_t len,double* d) ATTR_PURE;
166 +size_t scan_pb_type1_fixed64(const char* in,size_t len,uint64_t* b) ATTR_PURE;
167 /* NOTE: scan_pb_type2_stringlen only parses the length of the string,
168 * not the string itself. It will return the number of bytes parsed in
169 * the length, then set slen to the value of the length integer it just
170 @@ -141,9 +148,9 @@ size_t scan_pb_type1_fixed64(const char*
171 * parsing early without having to read and allocate memory for the rest
172 * (potentially gigabytes) of the data announced by one unreasonable
173 * string length value. */
174 -size_t scan_pb_type2_stringlen(const char* in,size_t len,const char** string, size_t* slen) __pure__;
175 -size_t scan_pb_type5_float(const char* in,size_t len,float* f) __pure__;
176 -size_t scan_pb_type5_fixed32(const char* in,size_t len,uint32_t* b) __pure__;
177 +size_t scan_pb_type2_stringlen(const char* in,size_t len,const char** string, size_t* slen) ATTR_PURE;
178 +size_t scan_pb_type5_float(const char* in,size_t len,float* f) ATTR_PURE;
179 +size_t scan_pb_type5_fixed32(const char* in,size_t len,uint32_t* b) ATTR_PURE;
180
181 /* parse a netstring, input buffer is in (len bytes).
182 * if parsing is successful:
183 @@ -153,7 +160,7 @@ size_t scan_pb_type5_fixed32(const char*
184 * return 0
185 * Note: *dest will point inside the input buffer!
186 */
187 -size_t scan_netstring(const char* in,size_t len,char** dest,size_t* slen) __pure__;
188 +size_t scan_netstring(const char* in,size_t len,char** dest,size_t* slen) ATTR_PURE;
189
190 /* internal function that might be useful independently */
191 /* convert from hex ASCII, return 0 to 15 for success or -1 for failure */
192 --- a/str.h
193 +++ b/str.h
194 @@ -8,8 +8,15 @@
195 extern "C" {
196 #endif
197
198 -#ifndef __pure__
199 -#define __pure__
200 +#ifndef ATTR_PURE
201 +# if defined __has_attribute
202 +# if __has_attribute (pure)
203 +# define ATTR_PURE __attribute__ ((pure))
204 +# endif
205 +# endif
206 +#endif
207 +#ifndef ATTR_PURE
208 +# define ATTR_PURE
209 #endif
210
211 /* str_copy copies leading bytes from in to out until \0.
212 @@ -21,7 +28,7 @@ size_t str_copy(char *out,const char *in
213 * equal to, or greater than the string b[0], b[1], ..., b[m-1]=='\0'.
214 * If the strings are different, str_diff does not read bytes past the
215 * first difference. */
216 -int str_diff(const char *a,const char *b) __pure__;
217 +int str_diff(const char *a,const char *b) ATTR_PURE;
218
219 /* str_diffn returns negative, 0, or positive, depending on whether the
220 * string a[0], a[1], ..., a[n]=='\0' is lexicographically smaller than,
221 @@ -29,24 +36,24 @@ int str_diff(const char *a,const char *b
222 * If the strings are different, str_diffn does not read bytes past the
223 * first difference. The strings will be considered equal if the first
224 * limit characters match. */
225 -int str_diffn(const char *a,const char *b,size_t limit) __pure__;
226 +int str_diffn(const char *a,const char *b,size_t limit) ATTR_PURE;
227
228 #ifdef __dietlibc__
229 #include <string.h>
230 #define str_len(foo) strlen(foo)
231 #else
232 /* str_len returns the index of \0 in s */
233 -size_t str_len(const char *s) __pure__;
234 +size_t str_len(const char *s) ATTR_PURE;
235 #endif
236
237 /* str_chr returns the index of the first occurance of needle or \0 in haystack */
238 -size_t str_chr(const char *haystack,char needle) __pure__;
239 +size_t str_chr(const char *haystack,char needle) ATTR_PURE;
240
241 /* str_rchr returns the index of the last occurance of needle or \0 in haystack */
242 -size_t str_rchr(const char *haystack,char needle) __pure__;
243 +size_t str_rchr(const char *haystack,char needle) ATTR_PURE;
244
245 /* str_start returns 1 if the b is a prefix of a, 0 otherwise */
246 -int str_start(const char *a,const char *b) __pure__;
247 +int str_start(const char *a,const char *b) ATTR_PURE;
248
249 /* convenience shortcut to test for string equality */
250 #define str_equal(s,t) (!str_diff((s),(t)))
251 --- a/stralloc.h
252 +++ b/stralloc.h
253 @@ -8,8 +8,15 @@
254 extern "C" {
255 #endif
256
257 -#ifndef __pure__
258 -#define __pure__
259 +#ifndef ATTR_PURE
260 +# if defined __has_attribute
261 +# if __has_attribute (pure)
262 +# define ATTR_PURE __attribute__ ((pure))
263 +# endif
264 +# endif
265 +#endif
266 +#ifndef ATTR_PURE
267 +# define ATTR_PURE
268 #endif
269
270 /* stralloc is the internal data structure all functions are working on.
271 @@ -101,17 +108,17 @@ static inline int stralloc_APPEND(strall
272 /* stralloc_starts returns 1 if the \0-terminated string in "in", without
273 * the terminating \0, is a prefix of the string stored in sa. Otherwise
274 * it returns 0. sa must already be allocated. */
275 -int stralloc_starts(stralloc* sa,const char* in) __pure__;
276 +int stralloc_starts(stralloc* sa,const char* in) ATTR_PURE;
277
278 /* stralloc_diff returns negative, 0, or positive, depending on whether
279 * a is lexicographically smaller than, equal to, or greater than the
280 * string b. */
281 -int stralloc_diff(const stralloc* a,const stralloc* b) __pure__;
282 +int stralloc_diff(const stralloc* a,const stralloc* b) ATTR_PURE;
283
284 /* stralloc_diffs returns negative, 0, or positive, depending on whether
285 * a is lexicographically smaller than, equal to, or greater than the
286 * string b[0], b[1], ..., b[n]=='\0'. */
287 -int stralloc_diffs(const stralloc* a,const char* b) __pure__;
288 +int stralloc_diffs(const stralloc* a,const char* b) ATTR_PURE;
289
290 #define stralloc_equal(a,b) (!stralloc_diff((a),(b)))
291 #define stralloc_equals(a,b) (!stralloc_diffs((a),(b)))