diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-02-14 14:41:07 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-02-14 14:41:07 -0500 |
commit | 5f661e03972e3412778c0bee8d20522b9bffea76 (patch) | |
tree | 287495c0d6f9659408ec5becf385f73387e5cf42 /gnulib/import/m4 | |
parent | 8084e579e114e607cb65482c43566e2c5c844bf6 (diff) | |
download | binutils-5f661e03972e3412778c0bee8d20522b9bffea76.zip binutils-5f661e03972e3412778c0bee8d20522b9bffea76.tar.gz binutils-5f661e03972e3412778c0bee8d20522b9bffea76.tar.bz2 |
gnulib: import count-one-bits module and use it
For a fix I intend to submit, I would need a function that counts the
number of set bits in a word. There is __builtin_popcount that is
supported by gcc and clang, but there is also a gnulib module that wraps
that and provides a fallback for other compilers, so I think it would be
good to use it.
I also noticed that there is a bitcount function in arch/arm.c, so I
thought that as a first step I would replace that one with the gnulib
count-one-bits module. This is what this patch does.
The gnulib module provides multiple functions, with various parameter
length (unsigned int, unsigned long int, unsigned long long int), I
chose the one that made sense for each call site based on the argument
type.
gnulib/ChangeLog:
* update-gnulib.sh (IMPORTED_GNULIB_MODULES): Import
count-one-bits module.
* configure: Re-generate.
* aclocal.m4: Re-generate.
* Makefile.in: Re-generate.
* import/count-one-bits.c: New file.
* import/count-one-bits.h: New file.
* import/Makefile.am: Re-generate.
* import/Makefile.in: Re-generate.
* import/m4/gnulib-cache.m4: Re-generate.
* import/m4/gnulib-comp.m4: Re-generate.
* import/m4/count-one-bits.m4: New file.
gdb/ChangeLog:
* arm-tdep.c: Include count-one-bits.h.
(cleanup_block_store_pc): Use count_one_bits.
(cleanup_block_load_pc): Use count_one_bits.
(arm_copy_block_xfer): Use count_one_bits.
(thumb2_copy_block_xfer): Use count_one_bits.
(thumb_copy_pop_pc_16bit): Use count_one_bits.
* arch/arm-get-next-pcs.c: Include count-one-bits.h.
(thumb_get_next_pcs_raw): Use count_one_bits.
(arm_get_next_pcs_raw): Use count_one_bits_l.
* arch/arm.c (bitcount): Remove.
* arch/arm.h (bitcount): Remove.
Diffstat (limited to 'gnulib/import/m4')
-rw-r--r-- | gnulib/import/m4/count-one-bits.m4 | 12 | ||||
-rw-r--r-- | gnulib/import/m4/gnulib-cache.m4 | 2 | ||||
-rw-r--r-- | gnulib/import/m4/gnulib-comp.m4 | 5 |
3 files changed, 19 insertions, 0 deletions
diff --git a/gnulib/import/m4/count-one-bits.m4 b/gnulib/import/m4/count-one-bits.m4 new file mode 100644 index 0000000..b4721b5 --- /dev/null +++ b/gnulib/import/m4/count-one-bits.m4 @@ -0,0 +1,12 @@ +# count-one-bits.m4 serial 3 +dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_COUNT_ONE_BITS], +[ + dnl We don't need (and can't compile) count_one_bits_ll + dnl unless the type 'unsigned long long int' exists. + AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) +]) diff --git a/gnulib/import/m4/gnulib-cache.m4 b/gnulib/import/m4/gnulib-cache.m4 index 428f5c9..03101b6 100644 --- a/gnulib/import/m4/gnulib-cache.m4 +++ b/gnulib/import/m4/gnulib-cache.m4 @@ -40,6 +40,7 @@ # --no-vc-files \ # alloca \ # canonicalize-lgpl \ +# count-one-bits \ # dirent \ # dirfd \ # errno \ @@ -79,6 +80,7 @@ gl_LOCAL_DIR([]) gl_MODULES([ alloca canonicalize-lgpl + count-one-bits dirent dirfd errno diff --git a/gnulib/import/m4/gnulib-comp.m4 b/gnulib/import/m4/gnulib-comp.m4 index be1fd39..fe1da67 100644 --- a/gnulib/import/m4/gnulib-comp.m4 +++ b/gnulib/import/m4/gnulib-comp.m4 @@ -57,6 +57,7 @@ AC_DEFUN([gl_EARLY], # Code from module cloexec: # Code from module close: # Code from module closedir: + # Code from module count-one-bits: # Code from module d-ino: # Code from module d-type: # Code from module dirent: @@ -250,6 +251,7 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([closedir]) fi gl_DIRENT_MODULE_INDICATOR([closedir]) + gl_COUNT_ONE_BITS gl_CHECK_TYPE_STRUCT_DIRENT_D_INO gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE gl_DIRENT_H @@ -855,6 +857,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/cloexec.h lib/close.c lib/closedir.c + lib/count-one-bits.c + lib/count-one-bits.h lib/dirent-private.h lib/dirent.in.h lib/dirfd.c @@ -1045,6 +1049,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/close.m4 m4/closedir.m4 m4/codeset.m4 + m4/count-one-bits.m4 m4/d-ino.m4 m4/d-type.m4 m4/dirent_h.m4 |