blob: b364a3b2a7e0c0ea3463a1237f6a96fdf7d73b28 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001From 89071cbc8d3ab9a15503f397580b7590338e5e91 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 12 Jul 2017 17:23:45 -0700
4Subject: [PATCH] utils: Use c99 compiler independent types
5
6Make it portable across different platforms
7
Patrick Williams8e7b46e2023-05-01 14:19:06 -05008Upstream-Status: Pending
Brad Bishop6e60e8b2018-02-01 10:27:11 -05009Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 utils.h | 13 +++++++------
12 1 file changed, 7 insertions(+), 6 deletions(-)
13
14diff --git a/utils.h b/utils.h
15index 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--
492.13.2
50