aboutsummaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
authorPaul Eggert2013-10-07 14:37:19 -0700
committerPaul Eggert2013-10-07 14:37:19 -0700
commit595e113b15e2ce80b95d39d1851ce78f25ffa1f4 (patch)
tree42c02de46a13e0af39fcc83de9d57c29e309f99e /m4
parentddb317ba828f05eb48e98fda530443955485e75d (diff)
downloademacs-595e113b15e2ce80b95d39d1851ce78f25ffa1f4.tar.gz
emacs-595e113b15e2ce80b95d39d1851ce78f25ffa1f4.zip
Improve support for popcount and counting trailing zeros.
Do this by using the Gnulib modules for this. This should generate faster code on non-GCC, non-MSC platforms, and make the code a bit more portable, at least in theory. * admin/merge-gnulib (GNULIB_MODULES): Add count-one-bits and count-trailing-zeros. * lib/count-one-bits.c, lib/count-one-bits.h: * lib/count-trailing-zeros.c, lib/count-trailing-zeros.h: * m4/count-one-bits.m4, m4/count-trailing-zeros.m4: New files, copied from gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * nt/gnulib.mk: Merge changes from lib/gnulib.mk. * src/data.c: Include <count-one-bits.h>, <count-trailing-zeros.h>. (USE_MSC_POPCOUNT, POPCOUNT_STATIC_INLINE) (NEED_GENERIC_POPCOUNT, popcount_size_t_generic) (popcount_size_t_msc, popcount_size_t_gcc): Remove; now done by Gnulib. (popcount_size_t): Now a macro that defers to Gnulib. (count_trailing_zero_bits): Return int, for consistency with Gnulib and because Emacs prefers signed to unsigned int. Don't assume that size_t is either unsigned int or unsigned long or unsigned long long. (size_t_to_host_endian): Do not assume that size_t is either exactly 32 or exactly 64 bits wide. * src/lisp.h (BITS_PER_SIZE_T): Define consistently with BITS_PER_LONG etc., so that it's now an enum constant, not a macro. No need to assume that it's either 32 or 64. Fixes: debbugs:15550
Diffstat (limited to 'm4')
-rw-r--r--m4/count-one-bits.m412
-rw-r--r--m4/count-trailing-zeros.m412
-rw-r--r--m4/gnulib-comp.m410
3 files changed, 34 insertions, 0 deletions
diff --git a/m4/count-one-bits.m4 b/m4/count-one-bits.m4
new file mode 100644
index 00000000000..07289641d4a
--- /dev/null
+++ b/m4/count-one-bits.m4
@@ -0,0 +1,12 @@
1# count-one-bits.m4 serial 3
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_COUNT_ONE_BITS],
8[
9 dnl We don't need (and can't compile) count_one_bits_ll
10 dnl unless the type 'unsigned long long int' exists.
11 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
12])
diff --git a/m4/count-trailing-zeros.m4 b/m4/count-trailing-zeros.m4
new file mode 100644
index 00000000000..b4a13c14397
--- /dev/null
+++ b/m4/count-trailing-zeros.m4
@@ -0,0 +1,12 @@
1# count-trailing-zeros.m4
2dnl Copyright (C) 2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_COUNT_TRAILING_ZEROS],
8[
9 dnl We don't need (and can't compile) count_trailing_zeros_ll
10 dnl unless the type 'unsigned long long int' exists.
11 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
12])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index ff36981c8d0..534d56f5bac 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -48,6 +48,8 @@ AC_DEFUN([gl_EARLY],
48 # Code from module careadlinkat: 48 # Code from module careadlinkat:
49 # Code from module clock-time: 49 # Code from module clock-time:
50 # Code from module close-stream: 50 # Code from module close-stream:
51 # Code from module count-one-bits:
52 # Code from module count-trailing-zeros:
51 # Code from module crypto/md5: 53 # Code from module crypto/md5:
52 # Code from module crypto/sha1: 54 # Code from module crypto/sha1:
53 # Code from module crypto/sha256: 55 # Code from module crypto/sha256:
@@ -175,6 +177,8 @@ AC_DEFUN([gl_INIT],
175 gl_CLOCK_TIME 177 gl_CLOCK_TIME
176 gl_CLOSE_STREAM 178 gl_CLOSE_STREAM
177 gl_MODULE_INDICATOR([close-stream]) 179 gl_MODULE_INDICATOR([close-stream])
180 gl_COUNT_ONE_BITS
181 gl_COUNT_TRAILING_ZEROS
178 gl_MD5 182 gl_MD5
179 gl_SHA1 183 gl_SHA1
180 gl_SHA256 184 gl_SHA256
@@ -806,6 +810,10 @@ AC_DEFUN([gl_FILE_LIST], [
806 lib/careadlinkat.h 810 lib/careadlinkat.h
807 lib/close-stream.c 811 lib/close-stream.c
808 lib/close-stream.h 812 lib/close-stream.h
813 lib/count-one-bits.c
814 lib/count-one-bits.h
815 lib/count-trailing-zeros.c
816 lib/count-trailing-zeros.h
809 lib/dirent.in.h 817 lib/dirent.in.h
810 lib/dosname.h 818 lib/dosname.h
811 lib/dtoastr.c 819 lib/dtoastr.c
@@ -919,6 +927,8 @@ AC_DEFUN([gl_FILE_LIST], [
919 m4/c-strtod.m4 927 m4/c-strtod.m4
920 m4/clock_time.m4 928 m4/clock_time.m4
921 m4/close-stream.m4 929 m4/close-stream.m4
930 m4/count-one-bits.m4
931 m4/count-trailing-zeros.m4
922 m4/dirent_h.m4 932 m4/dirent_h.m4
923 m4/dup2.m4 933 m4/dup2.m4
924 m4/environ.m4 934 m4/environ.m4