| 1 |
/* |
| 2 |
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. |
| 3 |
* |
| 4 |
* Licensed under the Apache License 2.0 (the "License"). You may not use |
| 5 |
* this file except in compliance with the License. You can obtain a copy |
| 6 |
* in the file LICENSE in the source distribution or at |
| 7 |
* https://www.openssl.org/source/license.html |
| 8 |
*/ |
| 9 |
|
| 10 |
#undef c2l |
| 11 |
#define c2l(c, l) (l = ((unsigned long)(*((c)++))), \ |
| 12 |
l |= ((unsigned long)(*((c)++))) << 8L, \ |
| 13 |
l |= ((unsigned long)(*((c)++))) << 16L, \ |
| 14 |
l |= ((unsigned long)(*((c)++))) << 24L) |
| 15 |
|
| 16 |
/* NOTE - c is not incremented as per c2l */ |
| 17 |
#undef c2ln |
| 18 |
#define c2ln(c, l1, l2, n) \ |
| 19 |
{ \ |
| 20 |
c += n; \ |
| 21 |
l1 = l2 = 0; \ |
| 22 |
switch (n) { \ |
| 23 |
case 8: \ |
| 24 |
l2 = ((unsigned long)(*(--(c)))) << 24L; \ |
| 25 |
/* fall through */ \ |
| 26 |
case 7: \ |
| 27 |
l2 |= ((unsigned long)(*(--(c)))) << 16L; \ |
| 28 |
/* fall through */ \ |
| 29 |
case 6: \ |
| 30 |
l2 |= ((unsigned long)(*(--(c)))) << 8L; \ |
| 31 |
/* fall through */ \ |
| 32 |
case 5: \ |
| 33 |
l2 |= ((unsigned long)(*(--(c)))); \ |
| 34 |
/* fall through */ \ |
| 35 |
case 4: \ |
| 36 |
l1 = ((unsigned long)(*(--(c)))) << 24L; \ |
| 37 |
/* fall through */ \ |
| 38 |
case 3: \ |
| 39 |
l1 |= ((unsigned long)(*(--(c)))) << 16L; \ |
| 40 |
/* fall through */ \ |
| 41 |
case 2: \ |
| 42 |
l1 |= ((unsigned long)(*(--(c)))) << 8L; \ |
| 43 |
/* fall through */ \ |
| 44 |
case 1: \ |
| 45 |
l1 |= ((unsigned long)(*(--(c)))); \ |
| 46 |
} \ |
| 47 |
} |
| 48 |
|
| 49 |
#undef l2c |
| 50 |
#define l2c(l, c) (*((c)++) = (unsigned char)(((l)) & 0xff), \ |
| 51 |
*((c)++) = (unsigned char)(((l) >> 8L) & 0xff), \ |
| 52 |
*((c)++) = (unsigned char)(((l) >> 16L) & 0xff), \ |
| 53 |
*((c)++) = (unsigned char)(((l) >> 24L) & 0xff)) |
| 54 |
|
| 55 |
/* NOTE - c is not incremented as per l2c */ |
| 56 |
#undef l2cn |
| 57 |
#define l2cn(l1, l2, c, n) \ |
| 58 |
{ \ |
| 59 |
c += n; \ |
| 60 |
switch (n) { \ |
| 61 |
case 8: \ |
| 62 |
*(--(c)) = (unsigned char)(((l2) >> 24L) & 0xff); \ |
| 63 |
/* fall through */ \ |
| 64 |
case 7: \ |
| 65 |
*(--(c)) = (unsigned char)(((l2) >> 16L) & 0xff); \ |
| 66 |
/* fall through */ \ |
| 67 |
case 6: \ |
| 68 |
*(--(c)) = (unsigned char)(((l2) >> 8L) & 0xff); \ |
| 69 |
/* fall through */ \ |
| 70 |
case 5: \ |
| 71 |
*(--(c)) = (unsigned char)(((l2)) & 0xff); \ |
| 72 |
/* fall through */ \ |
| 73 |
case 4: \ |
| 74 |
*(--(c)) = (unsigned char)(((l1) >> 24L) & 0xff); \ |
| 75 |
/* fall through */ \ |
| 76 |
case 3: \ |
| 77 |
*(--(c)) = (unsigned char)(((l1) >> 16L) & 0xff); \ |
| 78 |
/* fall through */ \ |
| 79 |
case 2: \ |
| 80 |
*(--(c)) = (unsigned char)(((l1) >> 8L) & 0xff); \ |
| 81 |
/* fall through */ \ |
| 82 |
case 1: \ |
| 83 |
*(--(c)) = (unsigned char)(((l1)) & 0xff); \ |
| 84 |
} \ |
| 85 |
} |