Rizin
unix-like reverse engineering framework and cli tools
rz_endian.h
Go to the documentation of this file.
1 #ifndef RZ_ENDIAN_H
2 #define RZ_ENDIAN_H
3 
4 #include <rz_types.h>
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 /* Endian agnostic functions working on single byte. */
11 
12 static inline ut8 rz_read_ble8(const void *src) {
13  if (!src) {
14  return UT8_MAX;
15  }
16  return *(const ut8 *)src;
17 }
18 
19 static inline ut8 rz_read_at_ble8(const void *src, size_t offset) {
20  return rz_read_ble8(((const ut8 *)src) + offset);
21 }
22 
23 static inline void rz_write_ble8(void *dest, ut8 val) {
24  *(ut8 *)dest = val;
25 }
26 
27 static inline void rz_write_at_ble8(void *dest, ut8 val, size_t offset) {
28  ut8 *d = (ut8 *)dest + offset;
30 }
31 
32 /* Big Endian functions. */
33 
34 static inline ut8 rz_read_be8(const void *src) {
35  return rz_read_ble8(src);
36 }
37 
38 static inline ut8 rz_read_at_be8(const void *src, size_t offset) {
39  return rz_read_at_ble8(src, offset);
40 }
41 
42 static inline void rz_write_be8(void *dest, ut8 val) {
44 }
45 
46 static inline void rz_write_at_be8(void *dest, ut8 val, size_t offset) {
48 }
49 
50 static inline ut16 rz_read_be16(const void *src) {
51  const ut8 *s = (const ut8 *)src;
52  return (((ut16)s[0]) << 8) | (((ut16)s[1]) << 0);
53 }
54 
55 static inline ut16 rz_read_at_be16(const void *src, size_t offset) {
56  const ut8 *s = (const ut8 *)src + offset;
57  return rz_read_be16(s);
58 }
59 
60 static inline void rz_write_be16(void *dest, ut16 val) {
61  rz_write_be8(dest, val >> 8);
62  rz_write_at_be8(dest, (ut8)val, sizeof(ut8));
63 }
64 
65 static inline void rz_write_at_be16(void *dest, ut16 val, size_t offset) {
66  ut8 *d = (ut8 *)dest + offset;
68 }
69 
70 static inline ut32 rz_read_be24(const void *src) {
71  return rz_read_be8(src) << 16 | rz_read_be8((const ut8 *)src + 1) << 8 |
72  rz_read_be8((const ut8 *)src + 2);
73 }
74 
75 static inline ut32 rz_read_at_be24(const void *src, size_t offset) {
76  const ut8 *s = (const ut8 *)src + offset;
77  return rz_read_be24(s);
78 }
79 
80 static inline void rz_write_be24(void *_dest, ut32 val) {
81  ut8 *dest = (ut8 *)_dest;
82  rz_write_be8(dest++, val >> 16);
83  rz_write_be8(dest++, val >> 8);
85 }
86 
87 static inline ut32 rz_read_be32(const void *src) {
88  const ut8 *s = (const ut8 *)src;
89  return (((ut32)s[0]) << 24) | (((ut32)s[1]) << 16) |
90  (((ut32)s[2]) << 8) | (((ut32)s[3]) << 0);
91 }
92 
93 static inline ut32 rz_read_at_be32(const void *src, size_t offset) {
94  const ut8 *s = (const ut8 *)src + offset;
95  return rz_read_be32(s);
96 }
97 
98 static inline void rz_write_be32(void *dest, ut32 val) {
99  rz_write_be16(dest, val >> 16);
100  rz_write_at_be16(dest, val, sizeof(ut16));
101 }
102 
103 static inline void rz_write_at_be32(void *dest, ut32 val, size_t offset) {
104  ut8 *d = (ut8 *)dest + offset;
105  rz_write_be32(d, val);
106 }
107 
108 static inline ut64 rz_read_be64(const void *src) {
109  ut64 val = ((ut64)(rz_read_be32(src))) << 32;
110  val |= rz_read_at_be32(src, sizeof(ut32));
111  return val;
112 }
113 
114 static inline ut64 rz_read_at_be64(const void *src, size_t offset) {
115  const ut8 *s = (const ut8 *)src + offset;
116  return rz_read_be64(s);
117 }
118 
119 static inline void rz_write_be64(void *dest, ut64 val) {
120  rz_write_be32(dest, val >> 32);
121  rz_write_at_be32(dest, (ut32)val, sizeof(ut32));
122 }
123 
124 static inline void rz_write_at_be64(void *dest, ut64 val, size_t offset) {
125  ut8 *d = (ut8 *)dest + offset;
126  rz_write_be64(d, val);
127 }
128 
129 static inline float rz_read_be_float(const void *src) {
130  union {
131  ut32 bits;
132  float flt;
133  } p;
134  p.bits = rz_read_be32(src);
135  return p.flt;
136 }
137 
138 static inline float rz_read_at_be_float(const void *src, size_t offset) {
139  const ut8 *s = (const ut8 *)src + offset;
140  return rz_read_be_float(s);
141 }
142 
143 static inline void rz_write_be_float(void *dest, float val) {
144  union {
145  ut32 bits;
146  float flt;
147  } p;
148  p.flt = val;
149  rz_write_be32(dest, p.bits);
150 }
151 
152 static inline void rz_write_at_be_float(void *dest, float val, size_t offset) {
153  ut8 *d = (ut8 *)dest + offset;
155 }
156 
157 static inline double rz_read_be_double(const void *src) {
158  union {
159  ut64 bits;
160  double dbl;
161  } p;
162  p.bits = rz_read_be64(src);
163  return p.dbl;
164 }
165 
166 static inline double rz_read_at_be_double(const void *src, size_t offset) {
167  const ut8 *s = (const ut8 *)src + offset;
168  return rz_read_be_double(s);
169 }
170 
171 static inline void rz_write_be_double(void *dest, double val) {
172  union {
173  ut64 bits;
174  double dbl;
175  } p;
176  p.dbl = val;
177  rz_write_be64(dest, p.bits);
178 }
179 
180 static inline void rz_write_at_be_double(void *dest, double val, size_t offset) {
181  ut8 *d = (ut8 *)dest + offset;
183 }
184 
185 /* Little Endian functions. */
186 
187 static inline ut8 rz_read_le8(const void *src) {
188  if (!src) {
189  return UT8_MAX;
190  }
191  return rz_read_ble8(src);
192 }
193 
194 static inline ut8 rz_read_at_le8(const void *src, size_t offset) {
195  return rz_read_at_ble8(src, offset);
196 }
197 
198 static inline void rz_write_le8(void *dest, ut8 val) {
200 }
201 
202 static inline void rz_write_at_le8(void *dest, ut8 val, size_t offset) {
204 }
205 
206 static inline ut16 rz_read_le16(const void *src) {
207  if (!src) {
208  return UT16_MAX;
209  }
210  const ut8 *s = (const ut8 *)src;
211  return (((ut16)s[1]) << 8) | (((ut16)s[0]) << 0);
212 }
213 
214 static inline ut16 rz_read_at_le16(const void *src, size_t offset) {
215  if (!src) {
216  return UT16_MAX;
217  }
218  const ut8 *s = (const ut8 *)src + offset;
219  return rz_read_le16(s);
220 }
221 
222 static inline void rz_write_le16(void *dest, ut16 val) {
224  rz_write_at_le8(dest, val >> 8, sizeof(ut8));
225 }
226 
227 static inline void rz_write_at_le16(void *dest, ut16 val, size_t offset) {
228  ut8 *d = (ut8 *)dest + offset;
229  rz_write_le16(d, val);
230 }
231 
232 static inline void rz_write_le24(void *_dest, ut32 val) {
233  ut8 *dest = (ut8 *)_dest;
234  rz_write_le8(dest++, val);
235  rz_write_le8(dest++, val >> 8);
236  rz_write_le8(dest, val >> 16);
237 }
238 
239 static inline ut32 rz_read_le32(const void *src) {
240  if (!src) {
241  return UT32_MAX;
242  }
243  const ut8 *s = (const ut8 *)src;
244  return (((ut32)s[3]) << 24) | (((ut32)s[2]) << 16) |
245  (((ut32)s[1]) << 8) | (((ut32)s[0]) << 0);
246 }
247 
248 static inline ut32 rz_read_at_le32(const void *src, size_t offset) {
249  if (!src) {
250  return UT32_MAX;
251  }
252  const ut8 *s = (const ut8 *)src + offset;
253  return rz_read_le32(s);
254 }
255 
256 static inline void rz_write_le32(void *dest, ut32 val) {
258  rz_write_at_le16(dest, val >> 16, sizeof(ut16));
259 }
260 
261 static inline void rz_write_at_le32(void *dest, ut32 val, size_t offset) {
262  ut8 *d = ((ut8 *)dest) + offset;
263  rz_write_le32(d, val);
264 }
265 
266 static inline ut64 rz_read_le64(const void *src) {
267  ut64 val = ((ut64)(rz_read_at_le32(src, sizeof(ut32)))) << 32;
268  val |= rz_read_le32(src);
269  return val;
270 }
271 
272 static inline ut64 rz_read_at_le64(const void *src, size_t offset) {
273  const ut8 *s = ((const ut8 *)src) + offset;
274  return rz_read_le64(s);
275 }
276 
277 static inline void rz_write_le64(void *dest, ut64 val) {
279  rz_write_at_le32(dest, val >> 32, sizeof(ut32));
280 }
281 
282 static inline void rz_write_at_le64(void *dest, ut64 val, size_t offset) {
283  ut8 *d = (ut8 *)dest + offset;
284  rz_write_le64(d, val);
285 }
286 
287 static inline float rz_read_le_float(const void *src) {
288  union {
289  ut32 bits;
290  float flt;
291  } p;
292  p.bits = rz_read_le32(src);
293  return p.flt;
294 }
295 
296 static inline float rz_read_at_le_float(const void *src, size_t offset) {
297  const ut8 *s = (const ut8 *)src + offset;
298  return rz_read_le_float(s);
299 }
300 
301 static inline void rz_write_le_float(void *dest, float val) {
302  union {
303  ut32 bits;
304  float flt;
305  } p;
306  p.flt = val;
307  rz_write_le32(dest, p.bits);
308 }
309 
310 static inline void rz_write_at_le_float(void *dest, float val, size_t offset) {
311  ut8 *d = (ut8 *)dest + offset;
313 }
314 
315 static inline double rz_read_le_double(const void *src) {
316  union {
317  ut64 bits;
318  double dbl;
319  } p;
320  p.bits = rz_read_le64(src);
321  return p.dbl;
322 }
323 
324 static inline double rz_read_at_le_double(const void *src, size_t offset) {
325  const ut8 *s = (const ut8 *)src + offset;
326  return rz_read_le_double(s);
327 }
328 
329 static inline void rz_write_le_double(void *dest, double val) {
330  union {
331  ut64 bits;
332  double dbl;
333  } p;
334  p.dbl = val;
335  rz_write_le64(dest, p.bits);
336 }
337 
338 static inline void rz_write_at_le_double(void *dest, double val, size_t offset) {
339  ut8 *d = (ut8 *)dest + offset;
341 }
342 
343 /* Middle Endian functions. */
344 
345 static inline ut8 rz_read_me8(const void *src) {
346  return src ? rz_read_ble8(src) : UT8_MAX;
347 }
348 
349 static inline ut8 rz_read_at_me8(const void *src, size_t offset) {
350  return rz_read_at_ble8(src, offset);
351 }
352 
353 static inline void rz_write_me8(void *dest, ut8 val) {
355 }
356 
357 static inline void rz_write_at_me8(void *dest, ut8 val, size_t offset) {
359 }
360 
361 static inline ut16 rz_read_me16(const void *src) {
362  if (!src) {
363  return UT16_MAX;
364  }
365  const ut8 *s = (const ut8 *)src;
366  return (((ut16)s[0]) << 8) | (((ut16)s[1]) << 0);
367 }
368 
369 static inline ut16 rz_read_at_me16(const void *src, size_t offset) {
370  if (!src) {
371  return UT16_MAX;
372  }
373  const ut8 *s = (const ut8 *)src + offset;
374  return rz_read_me16(s);
375 }
376 
377 static inline void rz_write_me16(void *dest, ut16 val) {
378  rz_write_me8(dest, val >> 8);
379  rz_write_at_me8(dest, (ut8)val, sizeof(ut8));
380 }
381 
382 static inline void rz_write_at_me16(void *dest, ut16 val, size_t offset) {
383  ut8 *d = (ut8 *)dest + offset;
384  rz_write_me16(d, val);
385 }
386 
387 static inline ut32 rz_read_me32(const void *src) {
388  if (!src) {
389  return UT32_MAX;
390  }
391  const ut8 *s = (const ut8 *)src;
392  return (((ut32)s[2]) << 24) | (((ut32)s[3]) << 16) |
393  (((ut32)s[0]) << 8) | (((ut32)s[1]) << 0);
394 }
395 
396 static inline ut32 rz_read_at_me32(const void *src, size_t offset) {
397  if (!src) {
398  return UT32_MAX;
399  }
400  const ut8 *s = (const ut8 *)src + offset;
401  return rz_read_me32(s);
402 }
403 
404 static inline void rz_write_me32(void *dest, ut32 val) {
406  rz_write_at_me16(dest, val >> 16, sizeof(ut16));
407 }
408 
409 static inline void rz_write_at_me32(void *dest, ut32 val, size_t offset) {
410  ut8 *d = ((ut8 *)dest) + offset;
411  rz_write_me32(d, val);
412 }
413 
414 static inline ut64 rz_read_me64(const void *src) {
415  ut64 val = ((ut64)(rz_read_at_me32(src, sizeof(ut32)))) << 32;
416  val |= rz_read_me32(src);
417  return val;
418 }
419 
420 static inline ut64 rz_read_at_me64(const void *src, size_t offset) {
421  const ut8 *s = ((const ut8 *)src) + offset;
422  return rz_read_me64(s);
423 }
424 
425 static inline void rz_write_me64(void *dest, ut64 val) {
427  rz_write_at_me32(dest, val >> 32, sizeof(ut32));
428 }
429 
430 static inline void rz_write_at_me64(void *dest, ut64 val, size_t offset) {
431  ut8 *d = (ut8 *)dest + offset;
432  rz_write_me64(d, val);
433 }
434 
435 static inline float rz_read_me_float(const void *src) {
436  union {
437  ut32 bits;
438  float flt;
439  } p;
440  p.bits = rz_read_me32(src);
441  return p.flt;
442 }
443 
444 static inline float rz_read_at_me_float(const void *src, size_t offset) {
445  const ut8 *s = (const ut8 *)src + offset;
446  return rz_read_me_float(s);
447 }
448 
449 static inline void rz_write_me_float(void *dest, float val) {
450  union {
451  ut32 bits;
452  float flt;
453  } p;
454  p.flt = val;
455  rz_write_me32(dest, p.bits);
456 }
457 
458 static inline void rz_write_at_me_float(void *dest, float val, size_t offset) {
459  ut8 *d = (ut8 *)dest + offset;
461 }
462 
463 static inline double rz_read_me_double(const void *src) {
464  union {
465  ut64 bits;
466  double dbl;
467  } p;
468  p.bits = rz_read_me64(src);
469  return p.dbl;
470 }
471 
472 static inline double rz_read_at_me_double(const void *src, size_t offset) {
473  const ut8 *s = (const ut8 *)src + offset;
474  return rz_read_me_double(s);
475 }
476 
477 static inline void rz_write_me_double(void *dest, double val) {
478  union {
479  ut64 bits;
480  double dbl;
481  } p;
482  p.dbl = val;
483  rz_write_me64(dest, p.bits);
484 }
485 
486 static inline void rz_write_at_me_double(void *dest, double val, size_t offset) {
487  ut8 *d = (ut8 *)dest + offset;
489 }
490 
491 /* Helper functions */
492 
493 static inline ut16 rz_read_ble16(const void *src, bool big_endian) {
494  return big_endian ? rz_read_be16(src) : rz_read_le16(src);
495 }
496 
497 static inline ut32 rz_read_ble32(const void *src, bool big_endian) {
498  return big_endian ? rz_read_be32(src) : rz_read_le32(src);
499 }
500 
501 static inline ut64 rz_read_ble64(const void *src, bool big_endian) {
502  return big_endian ? rz_read_be64(src) : rz_read_le64(src);
503 }
504 
505 static inline ut16 rz_read_at_ble16(const void *src, size_t offset, bool big_endian) {
506  return big_endian ? rz_read_at_be16(src, offset) : rz_read_at_le16(src, offset);
507 }
508 
509 static inline ut32 rz_read_at_ble32(const void *src, size_t offset, bool big_endian) {
510  return big_endian ? rz_read_at_be32(src, offset) : rz_read_at_le32(src, offset);
511 }
512 
513 static inline ut64 rz_read_at_ble64(const void *src, size_t offset, bool big_endian) {
514  return big_endian ? rz_read_at_be64(src, offset) : rz_read_at_le64(src, offset);
515 }
516 
517 static inline ut64 rz_read_ble(const void *src, bool big_endian, int size) {
518  switch (size) {
519  case 8:
520  return (ut64)((const ut8 *)src)[0];
521  case 16:
522  return rz_read_ble16(src, big_endian);
523  case 32:
524  return rz_read_ble32(src, big_endian);
525  case 64:
526  return rz_read_ble64(src, big_endian);
527  default:
528  return UT64_MAX;
529  }
530 }
531 
532 static inline void rz_write_ble16(void *dest, ut16 val, bool big_endian) {
533  big_endian ? rz_write_be16(dest, val) : rz_write_le16(dest, val);
534 }
535 
536 static inline void rz_write_ble24(void *dest, ut32 val, bool big_endian) {
537  big_endian ? rz_write_be24(dest, val) : rz_write_le24(dest, val);
538 }
539 
540 static inline void rz_write_ble32(void *dest, ut32 val, bool big_endian) {
541  big_endian ? rz_write_be32(dest, val) : rz_write_le32(dest, val);
542 }
543 
544 static inline void rz_write_ble64(void *dest, ut64 val, bool big_endian) {
545  big_endian ? rz_write_be64(dest, val) : rz_write_le64(dest, val);
546 }
547 
548 static inline void rz_write_ble(void *dst, ut64 val, bool big_endian, int size) {
549  switch (size) {
550  case 8:
551  ((ut8 *)dst)[0] = (ut8)val;
552  break;
553  case 16:
554  rz_write_ble16(dst, (ut16)val, big_endian);
555  break;
556  case 24:
557  rz_write_ble24(dst, (ut32)val, big_endian);
558  break;
559  case 32:
560  rz_write_ble32(dst, (ut32)val, big_endian);
561  break;
562  case 64:
563  rz_write_ble64(dst, val, big_endian);
564  break;
565  default:
566  break;
567  }
568 }
569 
570 /*swap*/
571 static inline ut16 rz_swap_ut16(ut16 val) {
572  return (val << 8) | (val >> 8);
573 }
574 
575 static inline st16 rz_swap_st16(st16 val) {
576  val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF);
577  return (val << 16) | (val >> 16);
578 }
579 
580 static inline ut32 rz_swap_ut32(ut32 val) {
581  val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF);
582  return (val << 16) | (val >> 16);
583 }
584 
585 static inline st32 rz_swap_st32(st32 val) {
586  val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF);
587  return (val << 16) | ((val >> 16) & 0xFFFF);
588 }
589 
590 static inline ut64 rz_swap_ut64(ut64 val) {
591  val = ((val << 8) & 0xFF00FF00FF00FF00ULL) | ((val >> 8) & 0x00FF00FF00FF00FFULL);
592  val = ((val << 16) & 0xFFFF0000FFFF0000ULL) | ((val >> 16) & 0x0000FFFF0000FFFFULL);
593  return (val << 32) | (val >> 32);
594 }
595 
596 static inline st64 rz_swap_st64(st64 val) {
597  val = ((val << 8) & 0xFF00FF00FF00FF00ULL) | ((val >> 8) & 0x00FF00FF00FF00FFULL);
598  val = ((val << 16) & 0xFFFF0000FFFF0000ULL) | ((val >> 16) & 0x0000FFFF0000FFFFULL);
599  return (val << 32) | ((val >> 32) & 0xFFFFFFFFULL);
600 }
601 
602 /* Some "secured" functions, to do basic operation (mul, sub, add...) on integers */
603 static inline int UT64_ADD(ut64 *r, ut64 a, ut64 b) {
604  if (UT64_MAX - a < b) {
605  return 0;
606  }
607  if (r) {
608  *r = a + b;
609  }
610  return 1;
611 }
612 
613 static inline int UT64_MUL(ut64 *r, ut64 a, ut64 b) {
614  if (a && UT64_MAX / a < b) {
615  return 0;
616  }
617  if (r) {
618  *r = a * b;
619  }
620  return 1;
621 }
622 
623 static inline int UT64_SUB(ut64 *r, ut64 a, ut64 b) {
624  if (b > a) {
625  return 0;
626  }
627  if (r) {
628  *r = a - b;
629  }
630  return 1;
631 }
632 
633 static inline int UT32_ADD(ut32 *r, ut32 a, ut32 b) {
634  if (UT32_MAX - a < b) {
635  return 0;
636  }
637  if (r) {
638  *r = a + b;
639  }
640  return 1;
641 }
642 
643 static inline int UT32_MUL(ut32 *r, ut32 a, ut32 b) {
644  if (a && UT32_MAX / a < b) {
645  return 0;
646  }
647  if (r) {
648  *r = a * b;
649  }
650  return 1;
651 }
652 
653 static inline int UT32_SUB(ut32 *r, ut32 a, ut32 b) {
654  if (b > a) {
655  return 0;
656  }
657  if (r) {
658  *r = a - b;
659  }
660  return 1;
661 }
662 
663 static inline int UT16_ADD(ut16 *r, ut16 a, ut16 b) {
664  if (UT16_MAX - a < b) {
665  return 0;
666  }
667  if (r) {
668  *r = a + b;
669  }
670  return 1;
671 }
672 
673 static inline int UT16_MUL(ut16 *r, ut16 a, ut16 b) {
674  if (a && UT16_MAX / a < b) {
675  return 0;
676  }
677  if (r) {
678  *r = a * b;
679  }
680  return 1;
681 }
682 
683 static inline int UT16_SUB(ut16 *r, ut16 a, ut16 b) {
684  if (b > a) {
685  return 0;
686  }
687  if (r) {
688  *r = a - b;
689  }
690  return 1;
691 }
692 
693 static inline int UT8_ADD(ut8 *r, ut8 a, ut8 b) {
694  if (UT8_MAX - a < b) {
695  return 0;
696  }
697  if (r) {
698  *r = a + b;
699  }
700  return 1;
701 }
702 
703 static inline int UT8_MUL(ut8 *r, ut8 a, ut8 b) {
704  if (a && UT8_MAX / a < b) {
705  return 0;
706  }
707  if (r) {
708  *r = a * b;
709  }
710  return 1;
711 }
712 
713 static inline int UT8_SUB(ut8 *r, ut8 a, ut8 b) {
714  if (b > a) {
715  return 0;
716  }
717  if (r) {
718  *r = a - b;
719  }
720  return 1;
721 }
722 
723 #ifdef __cplusplus
724 }
725 #endif
726 
727 #endif
lzma_index * src
Definition: index.h:567
ut16 val
Definition: armass64_const.h:6
int bits(struct state *s, int need)
Definition: blast.c:72
#define r
Definition: crypto_rc6.c:12
#define ut8
Definition: dcpu16.h:8
uint16_t ut16
uint32_t ut32
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
uint8_t ut8
Definition: lh5801.h:11
void * p
Definition: libc.cpp:67
char * dst
Definition: lz4.h:724
char * dest
Definition: lz4.h:697
static RzSocket * s
Definition: rtr.c:28
static void rz_write_le32(void *dest, ut32 val)
Definition: rz_endian.h:256
static void rz_write_at_me32(void *dest, ut32 val, size_t offset)
Definition: rz_endian.h:409
static ut64 rz_read_ble64(const void *src, bool big_endian)
Definition: rz_endian.h:501
static void rz_write_le16(void *dest, ut16 val)
Definition: rz_endian.h:222
static float rz_read_at_be_float(const void *src, size_t offset)
Definition: rz_endian.h:138
static int UT16_ADD(ut16 *r, ut16 a, ut16 b)
Definition: rz_endian.h:663
static double rz_read_me_double(const void *src)
Definition: rz_endian.h:463
static ut8 rz_read_me8(const void *src)
Definition: rz_endian.h:345
static ut8 rz_read_at_me8(const void *src, size_t offset)
Definition: rz_endian.h:349
static double rz_read_at_le_double(const void *src, size_t offset)
Definition: rz_endian.h:324
static void rz_write_at_me64(void *dest, ut64 val, size_t offset)
Definition: rz_endian.h:430
static ut8 rz_read_ble8(const void *src)
Definition: rz_endian.h:12
static void rz_write_le_float(void *dest, float val)
Definition: rz_endian.h:301
static void rz_write_at_be_double(void *dest, double val, size_t offset)
Definition: rz_endian.h:180
static ut16 rz_read_at_le16(const void *src, size_t offset)
Definition: rz_endian.h:214
static ut64 rz_read_be64(const void *src)
Definition: rz_endian.h:108
static st64 rz_swap_st64(st64 val)
Definition: rz_endian.h:596
static void rz_write_at_ble8(void *dest, ut8 val, size_t offset)
Definition: rz_endian.h:27
static void rz_write_be16(void *dest, ut16 val)
Definition: rz_endian.h:60
static ut64 rz_read_at_le64(const void *src, size_t offset)
Definition: rz_endian.h:272
static void rz_write_me_float(void *dest, float val)
Definition: rz_endian.h:449
static void rz_write_at_be8(void *dest, ut8 val, size_t offset)
Definition: rz_endian.h:46
static void rz_write_ble8(void *dest, ut8 val)
Definition: rz_endian.h:23
static int UT64_ADD(ut64 *r, ut64 a, ut64 b)
Definition: rz_endian.h:603
static void rz_write_at_le16(void *dest, ut16 val, size_t offset)
Definition: rz_endian.h:227
static ut32 rz_read_at_le32(const void *src, size_t offset)
Definition: rz_endian.h:248
static ut16 rz_read_le16(const void *src)
Definition: rz_endian.h:206
static ut32 rz_read_be24(const void *src)
Definition: rz_endian.h:70
static ut16 rz_read_at_me16(const void *src, size_t offset)
Definition: rz_endian.h:369
static void rz_write_me_double(void *dest, double val)
Definition: rz_endian.h:477
static void rz_write_at_be_float(void *dest, float val, size_t offset)
Definition: rz_endian.h:152
static void rz_write_be64(void *dest, ut64 val)
Definition: rz_endian.h:119
static st32 rz_swap_st32(st32 val)
Definition: rz_endian.h:585
static double rz_read_at_be_double(const void *src, size_t offset)
Definition: rz_endian.h:166
static void rz_write_ble(void *dst, ut64 val, bool big_endian, int size)
Definition: rz_endian.h:548
static float rz_read_at_me_float(const void *src, size_t offset)
Definition: rz_endian.h:444
static ut8 rz_read_at_be8(const void *src, size_t offset)
Definition: rz_endian.h:38
static void rz_write_le_double(void *dest, double val)
Definition: rz_endian.h:329
static ut64 rz_read_at_be64(const void *src, size_t offset)
Definition: rz_endian.h:114
static void rz_write_me8(void *dest, ut8 val)
Definition: rz_endian.h:353
static void rz_write_at_me_float(void *dest, float val, size_t offset)
Definition: rz_endian.h:458
static ut32 rz_read_le32(const void *src)
Definition: rz_endian.h:239
static ut32 rz_read_ble32(const void *src, bool big_endian)
Definition: rz_endian.h:497
static void rz_write_me64(void *dest, ut64 val)
Definition: rz_endian.h:425
static float rz_read_le_float(const void *src)
Definition: rz_endian.h:287
static void rz_write_at_le8(void *dest, ut8 val, size_t offset)
Definition: rz_endian.h:202
static ut32 rz_swap_ut32(ut32 val)
Definition: rz_endian.h:580
static ut16 rz_read_ble16(const void *src, bool big_endian)
Definition: rz_endian.h:493
static void rz_write_at_me16(void *dest, ut16 val, size_t offset)
Definition: rz_endian.h:382
static void rz_write_ble32(void *dest, ut32 val, bool big_endian)
Definition: rz_endian.h:540
static void rz_write_ble64(void *dest, ut64 val, bool big_endian)
Definition: rz_endian.h:544
static void rz_write_at_me_double(void *dest, double val, size_t offset)
Definition: rz_endian.h:486
static void rz_write_be24(void *_dest, ut32 val)
Definition: rz_endian.h:80
static void rz_write_be8(void *dest, ut8 val)
Definition: rz_endian.h:42
static st16 rz_swap_st16(st16 val)
Definition: rz_endian.h:575
static void rz_write_le24(void *_dest, ut32 val)
Definition: rz_endian.h:232
static void rz_write_at_me8(void *dest, ut8 val, size_t offset)
Definition: rz_endian.h:357
static int UT8_ADD(ut8 *r, ut8 a, ut8 b)
Definition: rz_endian.h:693
static ut8 rz_read_le8(const void *src)
Definition: rz_endian.h:187
static int UT16_SUB(ut16 *r, ut16 a, ut16 b)
Definition: rz_endian.h:683
static ut64 rz_read_me64(const void *src)
Definition: rz_endian.h:414
static int UT8_SUB(ut8 *r, ut8 a, ut8 b)
Definition: rz_endian.h:713
static float rz_read_at_le_float(const void *src, size_t offset)
Definition: rz_endian.h:296
static ut16 rz_read_at_ble16(const void *src, size_t offset, bool big_endian)
Definition: rz_endian.h:505
static int UT16_MUL(ut16 *r, ut16 a, ut16 b)
Definition: rz_endian.h:673
static ut32 rz_read_at_be24(const void *src, size_t offset)
Definition: rz_endian.h:75
static int UT32_SUB(ut32 *r, ut32 a, ut32 b)
Definition: rz_endian.h:653
static double rz_read_be_double(const void *src)
Definition: rz_endian.h:157
static void rz_write_ble16(void *dest, ut16 val, bool big_endian)
Definition: rz_endian.h:532
static ut8 rz_read_at_ble8(const void *src, size_t offset)
Definition: rz_endian.h:19
static ut64 rz_read_le64(const void *src)
Definition: rz_endian.h:266
static void rz_write_me32(void *dest, ut32 val)
Definition: rz_endian.h:404
static ut64 rz_read_ble(const void *src, bool big_endian, int size)
Definition: rz_endian.h:517
static int UT64_SUB(ut64 *r, ut64 a, ut64 b)
Definition: rz_endian.h:623
static ut8 rz_read_at_le8(const void *src, size_t offset)
Definition: rz_endian.h:194
static ut16 rz_read_me16(const void *src)
Definition: rz_endian.h:361
static int UT32_ADD(ut32 *r, ut32 a, ut32 b)
Definition: rz_endian.h:633
static int UT8_MUL(ut8 *r, ut8 a, ut8 b)
Definition: rz_endian.h:703
static ut8 rz_read_be8(const void *src)
Definition: rz_endian.h:34
static void rz_write_le64(void *dest, ut64 val)
Definition: rz_endian.h:277
static double rz_read_at_me_double(const void *src, size_t offset)
Definition: rz_endian.h:472
static void rz_write_at_le_double(void *dest, double val, size_t offset)
Definition: rz_endian.h:338
static void rz_write_me16(void *dest, ut16 val)
Definition: rz_endian.h:377
static void rz_write_at_le64(void *dest, ut64 val, size_t offset)
Definition: rz_endian.h:282
static float rz_read_me_float(const void *src)
Definition: rz_endian.h:435
static ut16 rz_swap_ut16(ut16 val)
Definition: rz_endian.h:571
static void rz_write_at_le_float(void *dest, float val, size_t offset)
Definition: rz_endian.h:310
static void rz_write_be_float(void *dest, float val)
Definition: rz_endian.h:143
static ut64 rz_read_at_me64(const void *src, size_t offset)
Definition: rz_endian.h:420
static ut32 rz_read_me32(const void *src)
Definition: rz_endian.h:387
static void rz_write_at_be32(void *dest, ut32 val, size_t offset)
Definition: rz_endian.h:103
static void rz_write_at_be64(void *dest, ut64 val, size_t offset)
Definition: rz_endian.h:124
static ut32 rz_read_at_be32(const void *src, size_t offset)
Definition: rz_endian.h:93
static ut32 rz_read_be32(const void *src)
Definition: rz_endian.h:87
static void rz_write_at_be16(void *dest, ut16 val, size_t offset)
Definition: rz_endian.h:65
static void rz_write_be32(void *dest, ut32 val)
Definition: rz_endian.h:98
static ut64 rz_read_at_ble64(const void *src, size_t offset, bool big_endian)
Definition: rz_endian.h:513
static ut64 rz_swap_ut64(ut64 val)
Definition: rz_endian.h:590
static float rz_read_be_float(const void *src)
Definition: rz_endian.h:129
static void rz_write_ble24(void *dest, ut32 val, bool big_endian)
Definition: rz_endian.h:536
static void rz_write_le8(void *dest, ut8 val)
Definition: rz_endian.h:198
static ut16 rz_read_at_be16(const void *src, size_t offset)
Definition: rz_endian.h:55
static void rz_write_be_double(void *dest, double val)
Definition: rz_endian.h:171
static int UT32_MUL(ut32 *r, ut32 a, ut32 b)
Definition: rz_endian.h:643
static ut16 rz_read_be16(const void *src)
Definition: rz_endian.h:50
static double rz_read_le_double(const void *src)
Definition: rz_endian.h:315
static void rz_write_at_le32(void *dest, ut32 val, size_t offset)
Definition: rz_endian.h:261
static int UT64_MUL(ut64 *r, ut64 a, ut64 b)
Definition: rz_endian.h:613
static ut32 rz_read_at_ble32(const void *src, size_t offset, bool big_endian)
Definition: rz_endian.h:509
static ut32 rz_read_at_me32(const void *src, size_t offset)
Definition: rz_endian.h:396
#define st64
Definition: rz_types_base.h:10
#define UT32_MAX
Definition: rz_types_base.h:99
#define UT64_MAX
Definition: rz_types_base.h:86
#define UT8_MAX
#define st16
Definition: rz_types_base.h:14
#define st32
Definition: rz_types_base.h:12
#define UT16_MAX
#define d(i)
Definition: sha256.c:44
#define b(i)
Definition: sha256.c:42
#define a(i)
Definition: sha256.c:41
ut64(WINAPI *w32_GetEnabledXStateFeatures)()