diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-10-02 20:17:46 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-10-02 20:17:46 +0200 |
commit | 663e96ae5bb3cc847b4208110a6fb8acbb8cf91f (patch) | |
tree | e1d7760a1be5e218430b6298a871636e9da8f563 /lib/gllib | |
parent | bb8628e071604d25b68cf3be2e22151b00ebbef5 (diff) | |
download | libtasn1-663e96ae5bb3cc847b4208110a6fb8acbb8cf91f.tar.gz libtasn1-663e96ae5bb3cc847b4208110a6fb8acbb8cf91f.tar.bz2 libtasn1-663e96ae5bb3cc847b4208110a6fb8acbb8cf91f.zip |
Updated gllib and added hash-pjw-bare.
Diffstat (limited to 'lib/gllib')
-rw-r--r-- | lib/gllib/Makefile.am | 14 | ||||
-rw-r--r-- | lib/gllib/dummy.c | 42 | ||||
-rw-r--r-- | lib/gllib/hash-pjw-bare.c | 42 | ||||
-rw-r--r-- | lib/gllib/hash-pjw-bare.h | 24 | ||||
-rw-r--r-- | lib/gllib/stdint.in.h | 2 |
5 files changed, 74 insertions, 50 deletions
diff --git a/lib/gllib/Makefile.am b/lib/gllib/Makefile.am index 86fef38..519e32e 100644 --- a/lib/gllib/Makefile.am +++ b/lib/gllib/Makefile.am @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl --no-vc-files lib-symbol-versions lib-symbol-visibility stdint strverscmp +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl --no-vc-files hash-pjw-bare lib-symbol-versions lib-symbol-visibility stdint strverscmp AUTOMAKE_OPTIONS = 1.5 gnits @@ -50,6 +50,12 @@ EXTRA_libgnu_la_SOURCES = libgnu_la_LDFLAGS = $(AM_LDFLAGS) libgnu_la_LDFLAGS += -no-undefined +## begin gnulib module hash-pjw-bare + +libgnu_la_SOURCES += hash-pjw-bare.h hash-pjw-bare.c + +## end gnulib module hash-pjw-bare + ## begin gnulib module lib-symbol-visibility # The value of $(CFLAG_VISIBILITY) needs to be added to the CFLAGS for the @@ -318,12 +324,6 @@ EXTRA_libgnu_la_SOURCES += strverscmp.c ## end gnulib module strverscmp -## begin gnulib module dummy - -libgnu_la_SOURCES += dummy.c - -## end gnulib module dummy - mostlyclean-local: mostlyclean-generic @for dir in '' $(MOSTLYCLEANDIRS); do \ diff --git a/lib/gllib/dummy.c b/lib/gllib/dummy.c deleted file mode 100644 index ea1f46f..0000000 --- a/lib/gllib/dummy.c +++ /dev/null @@ -1,42 +0,0 @@ -/* A dummy file, to prevent empty libraries from breaking builds. - Copyright (C) 2004, 2007, 2009-2012 Free Software Foundation, Inc. - - This program 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. - - This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ - -/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create - libraries without any object files. You might get an error like: - - > ar cru .libs/libgl.a - > ar: no archive members specified - - Compiling this file, and adding its object file to the library, will - prevent the library from being empty. */ - -/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries - that don't export any symbol. You might get an error like: - - > cc ... libgnu.a - > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a - - Compiling this file, and adding its object file to the library, will - prevent the library from exporting no symbols. */ - -#ifdef __sun -/* This declaration ensures that the library will export at least 1 symbol. */ -int gl_dummy_symbol; -#else -/* This declaration is solely to ensure that after preprocessing - this file is never empty. */ -typedef int dummy; -#endif diff --git a/lib/gllib/hash-pjw-bare.c b/lib/gllib/hash-pjw-bare.c new file mode 100644 index 0000000..92101e3 --- /dev/null +++ b/lib/gllib/hash-pjw-bare.c @@ -0,0 +1,42 @@ +/* hash-pjw-bare.c -- compute a hash value from a provided buffer. + + Copyright (C) 2012 Free Software Foundation, Inc. + + This program 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. + + This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include "hash-pjw-bare.h" + +#include <limits.h> + +#define SIZE_BITS (sizeof (size_t) * CHAR_BIT) + +/* Return a hash of the N bytes of X using the method described by + Bruno Haible in http://www.haible.de/bruno/hashfunc.html. + Note that while many hash functions reduce their result via modulo + to a 0..table_size-1 range, this function does not do that. */ + +size_t +hash_pjw_bare (const void *x, size_t n) +{ + const unsigned char *s = x; + size_t h = 0; + unsigned i; + + for (i = 0; i < n; i++) + h = s[i] + ((h << 9) | (h >> (SIZE_BITS - 9))); + + return h; +} diff --git a/lib/gllib/hash-pjw-bare.h b/lib/gllib/hash-pjw-bare.h new file mode 100644 index 0000000..60852d1 --- /dev/null +++ b/lib/gllib/hash-pjw-bare.h @@ -0,0 +1,24 @@ +/* hash-pjw-bare.h -- declaration for a simple hash function + Copyright (C) 2012 Free Software Foundation, Inc. + + This program 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. + + This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <stddef.h> + +/* Compute a hash code for a buffer starting at X and of size N, + and return the hash code. Note that unlike hash_pjw(), it does not + return it modulo a table size. + The result is platform dependent: it depends on the size of the 'size_t' + type and on the signedness of the 'char' type. */ +extern size_t hash_pjw_bare (const void *x, size_t n) _GL_ATTRIBUTE_PURE; diff --git a/lib/gllib/stdint.in.h b/lib/gllib/stdint.in.h index 3475dbe..4f61f95 100644 --- a/lib/gllib/stdint.in.h +++ b/lib/gllib/stdint.in.h @@ -83,7 +83,7 @@ /* <sys/types.h> defines some of the stdint.h types as well, on glibc, IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). AIX 5.2 <sys/types.h> isn't needed and causes troubles. - MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but + Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but relies on the system <stdint.h> definitions, so include <sys/types.h> after @NEXT_STDINT_H@. */ #if @HAVE_SYS_TYPES_H@ && ! defined _AIX |