From 2039f6b74df84ee50091647629f3c65b57371135 Mon Sep 17 00:00:00 2001 From: Philip Guenther Date: Sat, 12 Jul 2014 16:25:10 +0000 Subject: Tackle the endian.h mess. Make it so that: * you can #include instead of , and ditto (fixes code that pulls in first) * those will always export the symbols that POSIX specified for , including the new {be,le}{16,32,64}toh() set. c.f. http://austingroupbugs.net/view.php?id=162 if __BSD_VISIBLE then you also get the symbols that our currently exports (ntohs, NTOHS, dlg's bemtoh*, etc) * when doing POSIX compiles (not __BSD_VISIBLE), then and will *stop* exporting the extra symbols like BYTE_ORDER and betoh* ok deraadt@ --- sys/arch/i386/include/endian.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'sys/arch/i386/include') diff --git a/sys/arch/i386/include/endian.h b/sys/arch/i386/include/endian.h index 817d6c6abb4..1f58500c862 100644 --- a/sys/arch/i386/include/endian.h +++ b/sys/arch/i386/include/endian.h @@ -1,4 +1,4 @@ -/* $OpenBSD: endian.h,v 1.17 2011/03/12 04:03:04 guenther Exp $ */ +/* $OpenBSD: endian.h,v 1.18 2014/07/12 16:25:08 guenther Exp $ */ /*- * Copyright (c) 1997 Niklas Hallqvist. All rights reserved. @@ -30,31 +30,34 @@ #ifdef __GNUC__ #define __swap32md(x) __statement({ \ - u_int32_t __swap32md_x = (x); \ + __uint32_t __swap32md_x = (x); \ \ __asm ("bswap %0" : "+r" (__swap32md_x)); \ __swap32md_x; \ }) #define __swap64md(x) __statement({ \ - u_int64_t __swap64md_x = (x); \ + __uint64_t __swap64md_x = (x); \ \ - (u_int64_t)__swap32md(__swap64md_x >> 32) | \ - (u_int64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \ + (__uint64_t)__swap32md(__swap64md_x >> 32) | \ + (__uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \ }) #define __swap16md(x) __statement({ \ - u_int16_t __swap16md_x = (x); \ + __uint16_t __swap16md_x = (x); \ \ __asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \ __swap16md_x; \ }) /* Tell sys/endian.h we have MD variants of the swap macros. */ -#define MD_SWAP +#define __HAVE_MD_SWAP #endif /* __GNUC__ */ #define _BYTE_ORDER _LITTLE_ENDIAN + +#ifndef __FROM_SYS__ENDIAN #include +#endif #endif /* _MACHINE_ENDIAN_H_ */ -- cgit v1.2.3