From 63ba814364b465e03a20d0240cf3c223f18c6180 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 15 May 2015 19:09:44 +0000 Subject: [PATCH] __WORDSIZE doesn't seem to be available on platforms other than Mac or Linux, and best practices are for user-level code not to rely on it anyhow, since it's meant to be an internal macro. Fortunately, autoconf already has a way of determining the word size at configure time, so it can be passed into the compiler. This should work on any platform and has been tested on all of the Un*x platforms we support (Linux, Mac, FreeBSD, Solaris.) git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.4.x@1550 632fc199-4ca6-4c93-a231-07263d6284db --- ChangeLog.txt | 9 +++++---- configure.ac | 7 ++++--- jchuff.c | 9 +++------ jconfig.h.in | 6 +++--- jdhuff.c | 9 +-------- jdhuff.h | 6 +++++- 6 files changed, 21 insertions(+), 25 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 309b5e21d..1619a46bd 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -32,10 +32,11 @@ SIMD-enabled libjpeg-turbo MIPS build was executed with the -nosmooth option on a MIPS machine that lacked DSPr2 support. The MIPS SIMD routines for h2v1 and h2v2 merged upsampling were not properly checking for the existence of DSPr2. -[6] Performance has been improved significantly on 64-bit Mac platforms -(particularly compression performance.) Due to an oversight, the 64-bit -version of the accelerated Huffman codec was not being compiled in when -libjpeg-turbo was built on OS X. Oops. +[6] Performance has been improved significantly on 64-bit non-Linux and +non-Windows platforms (generally 10-20% faster compression and 5-10% faster +decompression.) Due to an oversight, the 64-bit version of the accelerated +Huffman codec was not being compiled in when libjpeg-turbo was built on +platforms other than Windows or Linux. Oops. [7] Fixed an extremely rare bug in the Huffman encoder that caused 64-bit builds of libjpeg-turbo to incorrectly encode a few specific test images when diff --git a/configure.ac b/configure.ac index f2b8cf2e4..6ef4b5c6a 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,8 @@ if test "x$exec_prefix" = "xNONE"; then exec_prefix=${prefix} fi +AC_CHECK_SIZEOF(size_t) + if test "x${libdir}" = 'x${exec_prefix}/lib' -o "x${libdir}" = 'x${prefix}/lib'; then LIBDIR=`eval echo ${libdir}` LIBDIR=`eval echo $LIBDIR` @@ -58,10 +60,9 @@ if test "x${libdir}" = 'x${exec_prefix}/lib' -o "x${libdir}" = 'x${prefix}/lib'; darwin*) ;; *) - AC_CHECK_SIZEOF(long) - if test "${ac_cv_sizeof_long}" = "8"; then + if test "${ac_cv_sizeof_size_t}" = "8"; then libdir='${exec_prefix}/lib64' - elif test "${ac_cv_sizeof_long}" = "4"; then + elif test "${ac_cv_sizeof_size_t}" = "4"; then libdir='${exec_prefix}/lib32' fi ;; diff --git a/jchuff.c b/jchuff.c index 23c665913..4ecc18d61 100644 --- a/jchuff.c +++ b/jchuff.c @@ -21,9 +21,6 @@ #include "jpeglib.h" #include "jchuff.h" /* Declarations shared with jcphuff.c */ #include -#ifdef HAVE_STDINT_H -#include -#endif /* * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be @@ -379,11 +376,11 @@ dump_buffer (working_state * state) } \ } -#if !defined(_WIN32) && !defined(__WORDSIZE) -#error __WORDSIZE is not defined +#if !defined(_WIN32) && !defined(SIZEOF_SIZE_T) +#error Cannot determine word size #endif -#if __WORDSIZE==64 || defined(_WIN64) +#if SIZEOF_SIZE_T==8 || defined(_WIN64) #define EMIT_BITS(code, size) { \ CHECKBUF47() \ diff --git a/jconfig.h.in b/jconfig.h.in index fbf64a586..b99a87e1c 100644 --- a/jconfig.h.in +++ b/jconfig.h.in @@ -32,9 +32,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - /* Define to 1 if the system has the type `unsigned char'. */ #undef HAVE_UNSIGNED_CHAR @@ -71,3 +68,6 @@ /* Define to `unsigned int' if does not define. */ #undef size_t + +/* The size of `size_t', as computed by sizeof. */ +#undef SIZEOF_SIZE_T diff --git a/jdhuff.c b/jdhuff.c index 03e394921..cbdce7d4c 100644 --- a/jdhuff.c +++ b/jdhuff.c @@ -22,9 +22,6 @@ #include "jdhuff.h" /* Declarations shared with jdphuff.c */ #include "jpegcomp.h" #include "jstdhuff.c" -#ifdef HAVE_STDINT_H -#include -#endif /* @@ -422,11 +419,7 @@ jpeg_fill_bit_buffer (bitread_working_state * state, } \ } -#if !defined(_WIN32) && !defined(__WORDSIZE) -#error __WORDSIZE is not defined -#endif - -#if __WORDSIZE == 64 || defined(_WIN64) +#if SIZEOF_SIZE_T==8 || defined(_WIN64) /* Pre-fetch 48 bytes, because the holding register is 64-bit */ #define FILL_BIT_BUFFER_FAST \ diff --git a/jdhuff.h b/jdhuff.h index f2805e46c..c7f3d5008 100644 --- a/jdhuff.h +++ b/jdhuff.h @@ -67,7 +67,11 @@ EXTERN(void) jpeg_make_d_derived_tbl * necessary. */ -#if __WORDSIZE == 64 || defined(_WIN64) +#if !defined(_WIN32) && !defined(SIZEOF_SIZE_T) +#error Cannot determine word size +#endif + +#if SIZEOF_SIZE_T==8 || defined(_WIN64) typedef size_t bit_buf_type; /* type of bit-extraction buffer */ #define BIT_BUF_SIZE 64 /* size of buffer in bits */