summaryrefslogtreecommitdiff
path: root/bits
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2012-07-22 19:58:41 +0200
committerThomas Schwinge <thomas@codesourcery.com>2012-07-22 19:58:41 +0200
commitef724a37cdb3012efb5b7233eb8b450ad91d3d69 (patch)
tree2334455220f417223cc1a75aebe76302cdffdf5a /bits
parent6f276c2517990f6569b961b4d4919cbce570ac45 (diff)
parent47e5dcdf349a1aea5c8997104ef785412f0d34fa (diff)
Merge branch 'baseline' into refs/top-bases/tschwinge/Roger_Whittaker
Conflicts: configure configure.in elf/rtld.c misc/syslog.c sysdeps/gnu/configure sysdeps/gnu/configure.in sysdeps/mach/hurd/accept4.c sysdeps/mach/hurd/bits/posix_opt.h sysdeps/mach/hurd/dup3.c sysdeps/mach/hurd/i386/init-first.c sysdeps/mach/hurd/kernel-features.h sysdeps/mach/hurd/readlinkat.c
Diffstat (limited to 'bits')
-rw-r--r--bits/byteswap-16.h34
-rw-r--r--bits/byteswap.h58
-rw-r--r--bits/types.h10
-rw-r--r--bits/typesizes.h5
4 files changed, 88 insertions, 19 deletions
diff --git a/bits/byteswap-16.h b/bits/byteswap-16.h
new file mode 100644
index 0000000000..6cc1d30932
--- /dev/null
+++ b/bits/byteswap-16.h
@@ -0,0 +1,34 @@
+/* Macros to swap the order of bytes in 16-bit integer values.
+ Copyright (C) 2012 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_BYTESWAP_H
+# error "Never use <bits/byteswap-16.h> directly; include <byteswap.h> instead."
+#endif
+
+#ifdef __GNUC__
+# define __bswap_16(x) \
+ (__extension__ \
+ ({ unsigned short int __bsx = (unsigned short int) (x); \
+ __bswap_constant_16 (__bsx); }))
+#else
+static __inline unsigned short int
+__bswap_16 (unsigned short int __bsx)
+{
+ return __bswap_constant_16 (__bsx);
+}
+#endif
diff --git a/bits/byteswap.h b/bits/byteswap.h
index 9d658e4472..3ca0ad6986 100644
--- a/bits/byteswap.h
+++ b/bits/byteswap.h
@@ -1,6 +1,5 @@
/* Macros to swap the order of bytes in integer values.
- Copyright (C) 1997,1998,2000-2002,2005,2008,2011
- Free Software Foundation, Inc.
+ Copyright (C) 1997-2012 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
@@ -24,21 +23,14 @@
#ifndef _BITS_BYTESWAP_H
#define _BITS_BYTESWAP_H 1
+#include <features.h>
+
/* Swap bytes in 16 bit value. */
#define __bswap_constant_16(x) \
- ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
+ ((unsigned short int)((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
-#ifdef __GNUC__
-# define __bswap_16(x) \
- (__extension__ \
- ({ unsigned short int __bsx = (x); __bswap_constant_16 (__bsx); }))
-#else
-static __inline unsigned short int
-__bswap_16 (unsigned short int __bsx)
-{
- return __bswap_constant_16 (__bsx);
-}
-#endif
+/* Get __bswap_16. */
+#include <bits/byteswap-16.h>
/* Swap bytes in 32 bit value. */
#define __bswap_constant_32(x) \
@@ -46,9 +38,17 @@ __bswap_16 (unsigned short int __bsx)
(((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
#ifdef __GNUC__
-# define __bswap_32(x) \
+# if __GNUC_PREREQ (4, 2)
+static __inline unsigned int
+__bswap_32 (unsigned int __bsx)
+{
+ return __builtin_bswap32 (__bsx);
+}
+# else
+# define __bswap_32(x) \
(__extension__ \
({ register unsigned int __bsx = (x); __bswap_constant_32 (__bsx); }))
+# endif
#else
static __inline unsigned int
__bswap_32 (unsigned int __bsx)
@@ -57,8 +57,8 @@ __bswap_32 (unsigned int __bsx)
}
#endif
-#if defined __GNUC__ && __GNUC__ >= 2
/* Swap bytes in 64 bit value. */
+#if __GNUC_PREREQ (2, 0)
# define __bswap_constant_64(x) \
(__extension__ ((((x) & 0xff00000000000000ull) >> 56) \
| (((x) & 0x00ff000000000000ull) >> 40) \
@@ -69,7 +69,14 @@ __bswap_32 (unsigned int __bsx)
| (((x) & 0x000000000000ff00ull) << 40) \
| (((x) & 0x00000000000000ffull) << 56)))
-# define __bswap_64(x) \
+# if __GNUC_PREREQ (4, 2)
+static __inline unsigned long long int
+__bswap_64 (unsigned long long int __bsx)
+{
+ return __builtin_bswap64 (__bsx);
+}
+# else
+# define __bswap_64(x) \
(__extension__ \
({ union { __extension__ unsigned long long int __ll; \
unsigned int __l[2]; } __w, __r; \
@@ -82,6 +89,23 @@ __bswap_32 (unsigned int __bsx)
__r.__l[1] = __bswap_32 (__w.__l[0]); \
} \
__r.__ll; }))
+# endif
+#elif __GLIBC_HAVE_LONG_LONG
+# define __bswap_constant_64(x) \
+ ((((x) & 0xff00000000000000ull) >> 56) \
+ | (((x) & 0x00ff000000000000ull) >> 40) \
+ | (((x) & 0x0000ff0000000000ull) >> 24) \
+ | (((x) & 0x000000ff00000000ull) >> 8) \
+ | (((x) & 0x00000000ff000000ull) << 8) \
+ | (((x) & 0x0000000000ff0000ull) << 24) \
+ | (((x) & 0x000000000000ff00ull) << 40) \
+ | (((x) & 0x00000000000000ffull) << 56))
+
+static __inline unsigned long long int
+__bswap_64 (unsigned long long int __bsx)
+{
+ return __bswap_constant_64 (__bsx);
+}
#endif
#endif /* _BITS_BYTESWAP_H */
diff --git a/bits/types.h b/bits/types.h
index a9bf0add0c..041ace6316 100644
--- a/bits/types.h
+++ b/bits/types.h
@@ -1,5 +1,5 @@
/* bits/types.h -- definitions of __*_t types underlying *_t types.
- Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2002-2012 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
@@ -176,8 +176,16 @@ __STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;
__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;
__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;
+/* Type of miscellaneous file system fields. */
+__STD_TYPE __FSWORD_T_TYPE __fsword_t;
+
__STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error. */
+/* Signed long type used in system calls. */
+__STD_TYPE __SYSCALL_SLONG_TYPE __syscall_slong_t;
+/* Unsigned long type used in system calls. */
+__STD_TYPE __SYSCALL_ULONG_TYPE __syscall_ulong_t;
+
/* These few don't really vary by system, they always correspond
to one of the other defined types. */
typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */
diff --git a/bits/typesizes.h b/bits/typesizes.h
index e1c5a27bb7..3fd4a2e067 100644
--- a/bits/typesizes.h
+++ b/bits/typesizes.h
@@ -1,5 +1,5 @@
/* bits/typesizes.h -- underlying types for *_t. Generic version.
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002-2012 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
@@ -44,6 +44,7 @@
#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
+#define __FSWORD_T_TYPE __SWORD_TYPE
#define __ID_T_TYPE __U32_TYPE
#define __CLOCK_T_TYPE __SLONGWORD_TYPE
#define __TIME_T_TYPE __SLONGWORD_TYPE
@@ -57,6 +58,8 @@
#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
#define __FSID_T_TYPE struct { int __val[2]; }
#define __SSIZE_T_TYPE __SWORD_TYPE
+#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
+#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024