summaryrefslogtreecommitdiff
path: root/com32/include/netinet
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-08-24 15:41:30 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-08-24 15:41:30 -0700
commitcd20609d1e2bb3dad3881cc7f6286f165b9a2d42 (patch)
treee2265a07bb6f0ec0d9d7a249a6d78e2a629bbbc5 /com32/include/netinet
parent4d5026e38d741a75b0fdfd2a04f40dc43f544b76 (diff)
downloadsyslinux-cd20609d1e2bb3dad3881cc7f6286f165b9a2d42.tar.gz
netinet/in.h: fix output types
We need casts not just on input but on output, in order to make sure only the correct bits are visible. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/include/netinet')
-rw-r--r--com32/include/netinet/in.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/com32/include/netinet/in.h b/com32/include/netinet/in.h
index ea0a1788..ccf04750 100644
--- a/com32/include/netinet/in.h
+++ b/com32/include/netinet/in.h
@@ -6,7 +6,9 @@
#include <stdint.h>
#include <klibc/compiler.h>
-#define __htons_macro(v) (((uint16_t)(v) << 8) | ((uint16_t)(v) >> 8))
+#define __htons_macro(v) ((uint16_t) \
+ (((uint16_t)(v) << 8) | \
+ ((uint16_t)(v) >> 8)))
static inline __constfunc uint16_t __htons(uint16_t v)
{
@@ -16,31 +18,29 @@ static inline __constfunc uint16_t __htons(uint16_t v)
#define htons(x) (__builtin_constant_p(x) ? __htons_macro(x) : __htons(x))
#define ntohs(x) htons(x)
-#define __htonl_macro(v) ((((uint32_t)(v) & 0x000000ff) << 24) | \
- (((uint32_t)(v) & 0x0000ff00) << 8) | \
+#define __htonl_macro(v) ((uint32_t) \
+ ((((uint32_t)(v) & 0x000000ff) << 24) | \
+ (((uint32_t)(v) & 0x0000ff00) << 8) | \
(((uint32_t)(v) & 0x00ff0000) >> 8) | \
- (((uint32_t)(v) & 0xff000000) >> 24))
+ (((uint32_t)(v) & 0xff000000) >> 24)))
static inline __constfunc uint32_t __htonl(uint32_t v)
{
- if (__builtin_constant_p(v)) {
- return __htonl_macro(v);
- } else {
- asm("xchgb %h0,%b0 ; roll $16,%0 ; xchgb %h0,%b0" : "+q"(v));
- return v;
- }
+ asm("xchgb %h0,%b0 ; roll $16,%0 ; xchgb %h0,%b0"
+ : "+q" (v));
+ return v;
}
#define htonl(x) (__builtin_constant_p(x) ? __htonl_macro(x) : __htonl(x))
#define ntohl(x) htonl(x)
-#define __htonq_macro(v) \
- (((uint64_t)__htonl_macro((uint32_t)(v)) << 32) | \
- (__htonl_macro((uint32_t)((uint64_t)(v) >> 32))))
+#define __htonq_macro(v) ((uint64_t) \
+ (((uint64_t)__htonl_macro((uint32_t)(v)) << 32) | \
+ (__htonl_macro((uint32_t)((uint64_t)(v) >> 32)))))
static inline __constfunc uint64_t __htonq(uint64_t v)
{
- return ((uint64_t) __htonl(v) << 32) | __htonl(v >> 32);
+ return ((uint64_t)__htonl(v) << 32) | __htonl(v >> 32);
}
#define htonq(x) (__builtin_constant_p(x) ? __htonq_macro(x) : __htonq(x))