This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [Various] libc/2757: Multiple <bits/byteswap.h> erroneusinclude
- From: Andreas Jaeger <aj at suse dot de>
- To: Roland McGrath <roland at frob dot com>
- Cc: libc-alpha at sources dot redhat dot com, serassio at libero dot it
- Date: Mon, 07 Jan 2002 09:39:40 +0100
- Subject: Re: [Various] libc/2757: Multiple <bits/byteswap.h> erroneusinclude
- References: <20020106181253.CFF081B9FE@perdition.linnaean.org>
Roland McGrath <roland@frob.com> writes:
>> Shouldn't we add multiple include markers around the files in
>> <bits/*>? Or what should be done?
>
> For this one, yes. That's what's done in others that are included by more
> than one header (e.g. bits/sigcontext.h). For most of these headers there
> should be no need since they should be included only by their corresponding
> sysdeps-independent header.
Like this? Ok to commit for both branches?
Andreas
2002-01-07 Andreas Jaeger <aj@suse.de>
* sysdeps/generic/bits/byteswap.h: Prevent double inclusion.
* sysdeps/i386/bits/byteswap.h: Likewise.
* sysdeps/ia64/bits/byteswap.h: Likewise.
* sysdeps/m68k/bits/byteswap.h: Likewise.
* sysdeps/s390/s390-32/bits/byteswap.h: Likewise.
* sysdeps/s390/s390-64/bits/byteswap.h: Likewise.
============================================================
Index: ./sysdeps/generic/bits/byteswap.h
--- ./sysdeps/generic/bits/byteswap.h 2001/07/06 04:55:50 1.9
+++ ./sysdeps/generic/bits/byteswap.h 2002/01/07 08:37:14
@@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values.
- Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,6 +21,9 @@
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
#endif
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H 1
+
/* Swap bytes in 16 bit value. */
#ifdef __GNUC__
# define __bswap_16(x) \
@@ -77,3 +80,5 @@ __bswap_32 (unsigned int __bsx)
} \
__r.__ll; }))
#endif
+
+#endif /* _BITS_BYTESWAP_H */
============================================================
Index: ./sysdeps/i386/bits/byteswap.h
--- ./sysdeps/i386/bits/byteswap.h 2001/07/06 04:55:53 1.7
+++ ./sysdeps/i386/bits/byteswap.h 2002/01/07 08:37:14
@@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values.
- Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,6 +21,9 @@
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
#endif
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H 1
+
/* Swap bytes in 16 bit value. */
#define __bswap_constant_16(x) \
((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
@@ -108,3 +111,5 @@
} \
__r.__ll; }))
#endif
+
+#endif /* _BITS_BYTESWAP_H */
============================================================
Index: ./sysdeps/ia64/bits/byteswap.h
--- ./sysdeps/ia64/bits/byteswap.h 2001/07/06 04:55:54 1.4
+++ ./sysdeps/ia64/bits/byteswap.h 2002/01/07 08:37:14
@@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values.
- Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,6 +21,9 @@
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
#endif
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H 1
+
/* Swap bytes in 16 bit value. */
#define __bswap_constant_16(x) \
((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
@@ -91,3 +94,5 @@
#else
# define __bswap_64(x) __bswap_constant_64 (x)
#endif
+
+#endif /* _BITS_BYTESWAP_H */
============================================================
Index: ./sysdeps/m68k/bits/byteswap.h
--- ./sysdeps/m68k/bits/byteswap.h 2001/07/06 04:55:55 1.5
+++ ./sysdeps/m68k/bits/byteswap.h 2002/01/07 08:37:14
@@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values. m68k version.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,6 +21,9 @@
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
#endif
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H 1
+
/* Swap bytes in 16 bit value. We don't provide an assembler version
because GCC is smart enough to generate optimal assembler output, and
this allows for better cse. */
@@ -60,3 +63,5 @@
__bswap_64_r.__l[1] = __bswap_32 (__bswap_64_v.__l[0]); \
__bswap_64_r.__ll; })
#endif
+
+#endif /* _BITS_BYTESWAP_H */
============================================================
Index: ./sysdeps/s390/s390-32/bits/byteswap.h
--- ./sysdeps/s390/s390-32/bits/byteswap.h 2001/07/06 04:56:03 1.2
+++ ./sysdeps/s390/s390-32/bits/byteswap.h 2002/01/07 08:37:14
@@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values. s390 version.
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
This file is part of the GNU C Library.
@@ -22,6 +22,9 @@
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
#endif
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H 1
+
#define __bswap_constant_16(x) \
((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
@@ -84,3 +87,5 @@
__r.__l[1] = __bswap_32 (__w.__l[0]); \
__r.__ll; })
#endif
+
+#endif /* _BITS_BYTESWAP_H */
============================================================
Index: ./sysdeps/s390/s390-64/bits/byteswap.h
--- ./sysdeps/s390/s390-64/bits/byteswap.h 2001/07/06 04:56:03 1.2
+++ ./sysdeps/s390/s390-64/bits/byteswap.h 2002/01/07 08:37:14
@@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values. 64 bit S/390 version.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
This file is part of the GNU C Library.
@@ -22,6 +22,9 @@
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
#endif
+#ifndef _BITS_BYTESWAP_H
+#define _BITS_BYTESWAP_H 1
+
#define __bswap_constant_16(x) \
((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
@@ -29,7 +32,7 @@
#if defined __GNUC__ && __GNUC__ >= 2
# define __bswap_16(x) \
(__extension__ \
- ({ unsigned short int __v; \
+ ({ unsigned short int __v; \
if (__builtin_constant_p (x)) \
__v = __bswap_constant_16 (x); \
else { \
@@ -89,5 +92,5 @@
#else
# define __bswap_64(x) __bswap_constant_64 (x)
#endif
-
+#endif /* _BITS_BYTESWAP_H */
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj