From e6b5a4e33fac2cbd10969b64afa9d79887dfa754 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Wed, 26 Apr 2017 15:21:02 +0000 Subject: Remove vestigial wordint facility git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2968 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- common.mk | 5 +- editor/pnminvert.c | 4 +- lib/util/wordaccess.h | 75 ------------------------------ lib/util/wordaccess_64_le.h | 28 ------------ lib/util/wordaccess_be_aligned.h | 35 -------------- lib/util/wordaccess_be_unaligned.h | 20 -------- lib/util/wordaccess_generic.h | 29 ------------ lib/util/wordintclz.h | 93 -------------------------------------- 8 files changed, 3 insertions(+), 286 deletions(-) delete mode 100644 lib/util/wordaccess.h delete mode 100644 lib/util/wordaccess_64_le.h delete mode 100644 lib/util/wordaccess_be_aligned.h delete mode 100644 lib/util/wordaccess_be_unaligned.h delete mode 100644 lib/util/wordaccess_generic.h delete mode 100644 lib/util/wordintclz.h diff --git a/common.mk b/common.mk index 82f2adc6..e24d8ff3 100644 --- a/common.mk +++ b/common.mk @@ -150,10 +150,7 @@ IMPORTINC_LIB_HEADERS := \ IMPORTINC_LIB_UTIL_HEADERS := \ bitarith.h bitio.h bitreverse.h filename.h intcode.h floatcode.h io.h \ matrix.h mallocvar.h \ - nsleep.h nstring.h pm_c_util.h runlength.h shhopt.h token.h \ - wordaccess.h wordaccess_generic.h wordaccess_64_le.h \ - wordaccess_be_aligned.h wordaccess_be_unaligned.h \ - wordintclz.h + nsleep.h nstring.h pm_c_util.h runlength.h shhopt.h token.h IMPORTINC_HEADERS := \ $(IMPORTINC_ROOT_HEADERS) \ diff --git a/editor/pnminvert.c b/editor/pnminvert.c index 4bee8837..d4aad503 100644 --- a/editor/pnminvert.c +++ b/editor/pnminvert.c @@ -16,8 +16,8 @@ implements the for statements in our algorithm with instructions that do 16 bytes at a time on CPUs that have them (movdqa on x86). This is "tree vectorization." A more primitive compiler will do one byte at a time; we - could change the code to use libnetpbm's wordaccess.h facility and it will - do one word at a time. (But we don't think it's worth complicating the + could change the code to use uint32_t or uint64_t and it will do four or + eight bytes at a time. (But we don't think it's worth complicating the code for that). */ diff --git a/lib/util/wordaccess.h b/lib/util/wordaccess.h deleted file mode 100644 index df0eaf12..00000000 --- a/lib/util/wordaccess.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef WORDACCESS_H_INCLUDED -#define WORDACCESS_H_INCLUDED - -/* These are facilities for accessing data in C programs in ways that - exploit the way the machine defines words in order to squeeze out - speed and CPU efficiency. - - In particular, routines in this file exploit the endianness of the - machine and use explicit machine instructions to access C - variables. - - A word is the amount of data that fits in a register; the amount of - data that a single machine instruction can process. For example, - on IA32, a word is 32 bits because a single load or store - instruction moves that many bits and a single add instruction - operates on that many bits. - - - These facilities revolve around two data types: wordInt and - wordIntBytes. - - wordint is an unsigned integer with precision (size) of one word. - It is just the number -- nothing is implied about how it is - represented in memory. - - wordintBytes is an array of bytes that represent a word-sized - unsigned integer. x[0] is the high order 8 digits of the binary - coding of the integer, x[1] the next highest 8 digits, etc. - Note that it has big-endian form, regardless of what endianness the - underlying machine uses. - - The actual size of word differs by machine. Usually it is 32 or 64 - bits. Logically it can be as small as one byte. Fixed bit sequences - in each program impose a lower limit of word width. For example, the - longest bit sequence in pbmtog3 has 13 bits, so an 8-bit word won't - work with that. - - We also assume that a char is 8 bits. - - HAVE_GCC_BITCOUNT and HAVE_GCC_BSWAP are set in pm_config.h - - BITS_PER_LONG is the number of bits in long int. -*/ - -#include "pm_config.h" - -#if defined(WORDACCESS_GENERIC) - /* User wants this, regardless of whether machine can do better */ - #include "wordaccess_generic.h" -#elif BYTE_ORDER == BIG_ENDIAN - #if UNALIGNED_OK - #include "wordaccess_be_unaligned.h" - #else - /* Sparc */ - #include "wordaccess_be_aligned.h" - #endif -#elif HAVE_GCC_BITCOUNT - #if (BITS_PER_LONG == 64) - /* AMD Athlon 64, Intel x86_64, Intel Itanium, etc. */ - #include "wordaccess_64_le.h" - #elif (BITS_PER_LONG == 32) - /* Intel x86_32 (80386, 80486, Pentium), etc. */ - #include "wordaccess_generic.h" - #else - /* Extremely rare case. - If long is neither 32 nor 64 bits, (say, 128) it comes here. - */ - #include "wordaccess_generic.h" - #endif -#else - /* Non GCC or GCC prior to v.3.4; little-endian */ - #include "wordaccess_generic.h" -#endif - -#endif diff --git a/lib/util/wordaccess_64_le.h b/lib/util/wordaccess_64_le.h deleted file mode 100644 index 4d148ad2..00000000 --- a/lib/util/wordaccess_64_le.h +++ /dev/null @@ -1,28 +0,0 @@ -/*============================================================================= - This file is the part of wordaccess.h for use under these - conditions: - - * GCC (>=3.4) (__builtin_clz appears in GCC 3.4) - * Little-Endian machines (IA64, X86-64, AMD64) - * 64 bit long - -=============================================================================*/ - -#include "intcode.h" - -typedef uint64_t wordint; -typedef unsigned char wordintBytes[sizeof(wordint)]; - - -static __inline__ wordint -bytesToWordint(wordintBytes const bytes) { - return (wordint) pm_uintFromBigend64(*(bigend64*)bytes); -} - - - -static __inline__ void -wordintToBytes(wordintBytes * const bytesP, - wordint const wordInt) { - *(bigend64*)bytesP = pm_bigendFromUint64(wordInt); -} diff --git a/lib/util/wordaccess_be_aligned.h b/lib/util/wordaccess_be_aligned.h deleted file mode 100644 index f3bbb841..00000000 --- a/lib/util/wordaccess_be_aligned.h +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================= - This file is the part of wordaccess.h for use under with big-endian - machines that require word accesses to be word-aligned. -*===========================================================================*/ - -typedef unsigned long int wordint; -typedef unsigned char wordintBytes[sizeof(wordint)]; - -static __inline__ wordint -bytesToWordint(wordintBytes bytes) { - uint16_t const hi = *((uint16_t *) (bytes + 0)); - uint16_t const mh = *((uint16_t *) (bytes + 2)); - uint16_t const ml = *((uint16_t *) (bytes + 4)); - uint16_t const lo = *((uint16_t *) (bytes + 6)); - return - (((wordint) hi) << 48) | - (((wordint) mh) << 32) | - (((wordint) ml) << 24) | - (((wordint) lo) << 0); -} - - - -static __inline__ void -wordintToBytes(wordintBytes * const bytesP, - wordint const wordInt) { - uint16_t const hi = ((wordInt >> 48) & 0xFF); - uint16_t const mh = ((wordInt >> 32) & 0xFF); - uint16_t const ml = ((wordInt >> 24) & 0xFF); - uint16_t const lo = ((wordInt >> 0) & 0xFF); - *(uint16_t *)(bytesP + 0) = hi; - *(uint16_t *)(bytesP + 2) = mh; - *(uint16_t *)(bytesP + 4) = ml; - *(uint16_t *)(bytesP + 6) = lo; -} diff --git a/lib/util/wordaccess_be_unaligned.h b/lib/util/wordaccess_be_unaligned.h deleted file mode 100644 index 95b68ac7..00000000 --- a/lib/util/wordaccess_be_unaligned.h +++ /dev/null @@ -1,20 +0,0 @@ -/*============================================================================= - This file is the part of wordaccess.h for use on a big-endian machine - that does not require word accesses to be word-aligned. -*===========================================================================*/ - -typedef unsigned long int wordint; -typedef unsigned char wordintBytes[sizeof(wordint)]; - -static __inline__ wordint -bytesToWordint(wordintBytes bytes) { - return *((wordint *)bytes); -} - - - -static __inline__ void -wordintToBytes(wordintBytes * const bytesP, - wordint const wordInt) { - *(wordint *)bytesP = wordInt; -} diff --git a/lib/util/wordaccess_generic.h b/lib/util/wordaccess_generic.h deleted file mode 100644 index 6e0a20ef..00000000 --- a/lib/util/wordaccess_generic.h +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================= - - This file is the part of wordaccess.h for use under any of these - conditions: - - * Compiler other than GCC - * GCC before version 3.4 - * Requested by the user with WORDACCESS_GENERIC -=============================================================================*/ - -#include "intcode.h" - -typedef uint32_t wordint; -typedef unsigned char wordintBytes[sizeof(wordint)]; - - -static __inline__ wordint -bytesToWordint(wordintBytes const bytes) { - - return (wordint) pm_uintFromBigend32( * (bigend32*) bytes); -} - - -static __inline__ void -wordintToBytes(wordintBytes * const bytesP, - wordint const wordInt) { - - * (bigend32*) bytesP = pm_bigendFromUint32((uint32_t)wordInt); -} diff --git a/lib/util/wordintclz.h b/lib/util/wordintclz.h deleted file mode 100644 index 32e6ade8..00000000 --- a/lib/util/wordintclz.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef WORDINTCLZ_H_INCLUDED -#define WORDINTCLZ_H_INCLUDED - -#if (!defined(WORDACCESS_GENERIC) && HAVE_GCC_BITCOUNT ) -/* - Compiler is GCC and has __builtin_clz() - wordint is long - - __builtin_clz is available on GCC 3.4 and above - - Note that the clz scheme does not work and requires adjustment - if long type does not make use of all bits for data storage. - - This is unlikely. According to GNU MP (http://www.swox.com/gmp/), - in rare cases such as Cray, there are smaller data types that take up - the same space as long, but leave the higher bits silent. - Currently, there are no known such cases for data type long. - */ - -static __inline__ unsigned int -wordintClz(wordint const x){ - - assert(sizeof(unsigned long int) == sizeof(wordint)); - - if (x == 0) - return sizeof(wordint) * 8; - else - return (__builtin_clzl( (unsigned long int) x )); -} - -#else - -/* wordint is uint32_t: exactly 32 bits wide */ - -static unsigned char const clz8[256]= { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - - - -static __inline__ unsigned int -clz16(wordint const x) { - - if (x >> 8 != 0) - return clz8[x >> 8]; - else - return clz8[x] + 8; -} - - - -static __inline__ unsigned int -clz32(wordint const x) { - - if (x >> 16 != 0) - return clz16(x >> 16); - else - return clz16(x) + 16; -} - - - -static __inline__ unsigned int -wordintClz(wordint const x) { - - assert(sizeof(wordint) == 4); - - return clz32(x); -} - -/* Another way to calculate leading zeros: - x == 0 ? 32 : 31 - floor(log(x)/log(2)) - (Beware: insufficient precision will cause errors) -*/ - -#endif - -#endif -- cgit 1.4.1