diff mbox series

[v3,01/18] Parameterize op_t from memcopy.h

Message ID 1515588482-15744-2-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show
Series Improve generic string routines | expand

Commit Message

Adhemerval Zanella Netto Jan. 10, 2018, 12:47 p.m. UTC
From: Richard Henderson <rth@twiddle.net>


Basically moves op_t definition out to an specific header, adds
the attribute 'may-alias', and cleanup its duplicated definitions.
It lead to inclusion of tilegx32 gmp-mparam.h similar to x32 so
op_t can be define as a long long (from _LONG_LONG_LIMB).

Checked with a build and check with run-built-tests=no for all major
Linux ABIs (alpha, aarch64, arm, hppa, i686, ia64, m68k, microblaze,
mips, mips64, nios2, powerpc, powerpc64le, s390x, sh4, sparc64,
tilegx, and x86_64).

	Richard Henderson  <rth@twiddle.net>
	Adhemerval Zanella  <adhemerval.zanella@linaro.org>

	* sysdeps/generic/string-optype.h: New file.
	* sysdeps/generic/memcopy.h: Include it.
	* string/memcmp.c (op_t): Remove define.
	* sysdeps/tile/memcmp.c (op_t): Likewise.
	* sysdeps/tile/memcopy.h (op_t): Likewise.
	* sysdeps/tile/tilegx32/gmp-mparam.h: New file.
---
 string/memcmp.c                    |  1 -
 sysdeps/generic/memcopy.h          |  7 +++----
 sysdeps/generic/string-optype.h    | 31 +++++++++++++++++++++++++++++++
 sysdeps/tile/memcmp.c              |  1 -
 sysdeps/tile/memcopy.h             |  7 -------
 sysdeps/tile/tilegx32/gmp-mparam.h | 30 ++++++++++++++++++++++++++++++
 6 files changed, 64 insertions(+), 13 deletions(-)
 create mode 100644 sysdeps/generic/string-optype.h
 create mode 100644 sysdeps/tile/tilegx32/gmp-mparam.h

-- 
2.7.4

Comments

Joseph Myers Jan. 11, 2018, 1:27 p.m. UTC | #1
On Wed, 10 Jan 2018, Adhemerval Zanella wrote:

> +#ifdef _LONG_LONG_LIMB

> +typedef unsigned long long int __attribute__((__may_alias__)) op_t;

> +#else

> +typedef unsigned long int __attribute__((__may_alias__)) op_t;

> +#endif


Missing space between __attribute__ and '('.

> +#if defined __GMP_H__ && ! defined _LONG_LONG_LIMB

> +#error "Included too late for _LONG_LONG_LIMB to take effect"

> +#endif


Missing preprocessor indentation, "# error".

-- 
Joseph S. Myers
joseph@codesourcery.com
Adhemerval Zanella Netto Jan. 11, 2018, 6:04 p.m. UTC | #2
On 11/01/2018 11:27, Joseph Myers wrote:
> On Wed, 10 Jan 2018, Adhemerval Zanella wrote:

> 

>> +#ifdef _LONG_LONG_LIMB

>> +typedef unsigned long long int __attribute__((__may_alias__)) op_t;

>> +#else

>> +typedef unsigned long int __attribute__((__may_alias__)) op_t;

>> +#endif

> 

> Missing space between __attribute__ and '('.

> 

>> +#if defined __GMP_H__ && ! defined _LONG_LONG_LIMB

>> +#error "Included too late for _LONG_LONG_LIMB to take effect"

>> +#endif

> 

> Missing preprocessor indentation, "# error".

> 


Thanks, I fixed locally both observations.
diff mbox series

Patch

diff --git a/string/memcmp.c b/string/memcmp.c
index aea5129..4fd2f83 100644
--- a/string/memcmp.c
+++ b/string/memcmp.c
@@ -46,7 +46,6 @@ 
 /* Type to use for aligned memory operations.
    This should normally be the biggest type supported by a single load
    and store.  Must be an unsigned type.  */
-# define op_t	unsigned long int
 # define OPSIZ	(sizeof(op_t))
 
 /* Threshold value for when to enter the unrolled loops.  */
diff --git a/sysdeps/generic/memcopy.h b/sysdeps/generic/memcopy.h
index c0d8da3..c7e9cc9 100644
--- a/sysdeps/generic/memcopy.h
+++ b/sysdeps/generic/memcopy.h
@@ -56,10 +56,9 @@ 
      [I fail to understand.  I feel stupid.  --roland]
 */
 
-/* Type to use for aligned memory operations.
-   This should normally be the biggest type supported by a single load
-   and store.  */
-#define	op_t	unsigned long int
+/* Type to use for aligned memory operations.  */
+#include <string-optype.h>
+
 #define OPSIZ	(sizeof(op_t))
 
 /* Type to use for unaligned operations.  */
diff --git a/sysdeps/generic/string-optype.h b/sysdeps/generic/string-optype.h
new file mode 100644
index 0000000..1324070
--- /dev/null
+++ b/sysdeps/generic/string-optype.h
@@ -0,0 +1,31 @@ 
+/* Define a type to use for word access.  Generic version.
+   Copyright (C) 2018 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 STRING_OPTYPE_H
+#define STRING_OPTYPE_H 1
+
+/* Use the existing parameterization from gmp as a default.  */
+#include <gmp-mparam.h>
+
+#ifdef _LONG_LONG_LIMB
+typedef unsigned long long int __attribute__((__may_alias__)) op_t;
+#else
+typedef unsigned long int __attribute__((__may_alias__)) op_t;
+#endif
+
+#endif /* string-optype.h */
diff --git a/sysdeps/tile/memcmp.c b/sysdeps/tile/memcmp.c
index b7cf00a..89fff57 100644
--- a/sysdeps/tile/memcmp.c
+++ b/sysdeps/tile/memcmp.c
@@ -45,7 +45,6 @@ 
 /* Type to use for aligned memory operations.
    This should normally be the biggest type supported by a single load
    and store.  Must be an unsigned type.  */
-# define op_t	unsigned long int
 # define OPSIZ	(sizeof(op_t))
 
 /* Threshold value for when to enter the unrolled loops.  */
diff --git a/sysdeps/tile/memcopy.h b/sysdeps/tile/memcopy.h
index 0c357c1..748f648 100644
--- a/sysdeps/tile/memcopy.h
+++ b/sysdeps/tile/memcopy.h
@@ -22,10 +22,3 @@ 
 /* The tilegx implementation of memcpy is safe to use for memmove.  */
 #undef MEMCPY_OK_FOR_FWD_MEMMOVE
 #define MEMCPY_OK_FOR_FWD_MEMMOVE 1
-
-/* Support more efficient copying on tilegx32, which supports
-   long long as a native 64-bit type.  */
-#if __WORDSIZE == 32
-# undef op_t
-# define op_t	unsigned long long int
-#endif
diff --git a/sysdeps/tile/tilegx32/gmp-mparam.h b/sysdeps/tile/tilegx32/gmp-mparam.h
new file mode 100644
index 0000000..7d1cb98
--- /dev/null
+++ b/sysdeps/tile/tilegx32/gmp-mparam.h
@@ -0,0 +1,30 @@ 
+/* Compiler/machine parameter header file.  TileGX32 version.
+
+   Copyright (C) 2018 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/>.  */
+
+#if defined __GMP_H__ && ! defined _LONG_LONG_LIMB
+#error "Included too late for _LONG_LONG_LIMB to take effect"
+#endif
+
+#define _LONG_LONG_LIMB
+#define BITS_PER_MP_LIMB 64
+#define BYTES_PER_MP_LIMB 8
+#define BITS_PER_LONGINT 32
+#define BITS_PER_INT 32
+#define BITS_PER_SHORTINT 16
+#define BITS_PER_CHAR 8