Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | From 89071cbc8d3ab9a15503f397580b7590338e5e91 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 12 Jul 2017 17:23:45 -0700 |
| 4 | Subject: [PATCH] utils: Use c99 compiler independent types |
| 5 | |
| 6 | Make it portable across different platforms |
| 7 | |
Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame^] | 8 | Upstream-Status: Pending |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | --- |
| 11 | utils.h | 13 +++++++------ |
| 12 | 1 file changed, 7 insertions(+), 6 deletions(-) |
| 13 | |
| 14 | diff --git a/utils.h b/utils.h |
| 15 | index 10dce58..73bba92 100644 |
| 16 | --- a/utils.h |
| 17 | +++ b/utils.h |
| 18 | @@ -3,6 +3,7 @@ |
| 19 | #include <stdio.h> |
| 20 | #include <errno.h> |
| 21 | #include <string.h> |
| 22 | +#include <stdint.h> |
| 23 | |
| 24 | extern long buffering_write(int outf, char *buffer, long num); |
| 25 | extern int buffering_close(int fd); |
| 26 | @@ -18,15 +19,15 @@ static inline int bigendianp(void){ |
| 27 | } |
| 28 | |
| 29 | static inline int32_t swap32(int32_t x){ |
| 30 | - return((((u_int32_t)x & 0x000000ffU) << 24) | |
| 31 | - (((u_int32_t)x & 0x0000ff00U) << 8) | |
| 32 | - (((u_int32_t)x & 0x00ff0000U) >> 8) | |
| 33 | - (((u_int32_t)x & 0xff000000U) >> 24)); |
| 34 | + return((((uint32_t)x & 0x000000ffU) << 24) | |
| 35 | + (((uint32_t)x & 0x0000ff00U) << 8) | |
| 36 | + (((uint32_t)x & 0x00ff0000U) >> 8) | |
| 37 | + (((uint32_t)x & 0xff000000U) >> 24)); |
| 38 | } |
| 39 | |
| 40 | static inline int16_t swap16(int16_t x){ |
| 41 | - return((((u_int16_t)x & 0x00ffU) << 8) | |
| 42 | - (((u_int16_t)x & 0xff00U) >> 8)); |
| 43 | + return((((uint16_t)x & 0x00ffU) << 8) | |
| 44 | + (((uint16_t)x & 0xff00U) >> 8)); |
| 45 | } |
| 46 | |
| 47 | #if BYTE_ORDER == LITTLE_ENDIAN |
| 48 | -- |
| 49 | 2.13.2 |
| 50 | |