diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2023-02-11 06:20:24 (GMT) |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2023-02-11 06:20:24 (GMT) |
commit | f867d7b44080fa9716deeff4476275f9a489879f (patch) | |
tree | bc964662fc3300dc626fb6d833d8ed5c8f46eca7 /gl/byteswap.in.h | |
parent | 9734c439cba0a02b087e50789e94ec9b07754608 (diff) | |
parent | c07206f2ccc2356aa74bc6813a94c2190017d44e (diff) | |
download | monitoring-plugins-f867d7b44080fa9716deeff4476275f9a489879f.tar.gz |
Merge branch 'master' into curlfixes
Diffstat (limited to 'gl/byteswap.in.h')
-rw-r--r-- | gl/byteswap.in.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gl/byteswap.in.h b/gl/byteswap.in.h new file mode 100644 index 0000000..e61be27 --- /dev/null +++ b/gl/byteswap.in.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* byteswap.h - Byte swapping | ||
2 | Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc. | ||
3 | Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005. | ||
4 | |||
5 | This file is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU Lesser General Public License as | ||
7 | published by the Free Software Foundation; either version 2.1 of the | ||
8 | License, or (at your option) any later version. | ||
9 | |||
10 | This file is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public License | ||
16 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #ifndef _GL_BYTESWAP_H | ||
19 | #define _GL_BYTESWAP_H | ||
20 | |||
21 | /* Given an unsigned 16-bit argument X, return the value corresponding to | ||
22 | X with reversed byte order. */ | ||
23 | #define bswap_16(x) ((((x) & 0x00FF) << 8) | \ | ||
24 | (((x) & 0xFF00) >> 8)) | ||
25 | |||
26 | /* Given an unsigned 32-bit argument X, return the value corresponding to | ||
27 | X with reversed byte order. */ | ||
28 | #define bswap_32(x) ((((x) & 0x000000FF) << 24) | \ | ||
29 | (((x) & 0x0000FF00) << 8) | \ | ||
30 | (((x) & 0x00FF0000) >> 8) | \ | ||
31 | (((x) & 0xFF000000) >> 24)) | ||
32 | |||
33 | /* Given an unsigned 64-bit argument X, return the value corresponding to | ||
34 | X with reversed byte order. */ | ||
35 | #define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \ | ||
36 | (((x) & 0x000000000000FF00ULL) << 40) | \ | ||
37 | (((x) & 0x0000000000FF0000ULL) << 24) | \ | ||
38 | (((x) & 0x00000000FF000000ULL) << 8) | \ | ||
39 | (((x) & 0x000000FF00000000ULL) >> 8) | \ | ||
40 | (((x) & 0x0000FF0000000000ULL) >> 24) | \ | ||
41 | (((x) & 0x00FF000000000000ULL) >> 40) | \ | ||
42 | (((x) & 0xFF00000000000000ULL) >> 56)) | ||
43 | |||
44 | #endif /* _GL_BYTESWAP_H */ | ||