Skip to content

Commit

Permalink
__WORDSIZE doesn't seem to be available on platforms other than Mac o…
Browse files Browse the repository at this point in the history
…r 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
  • Loading branch information
dcommander committed May 15, 2015
1 parent 83649cc commit 63ba814
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
9 changes: 5 additions & 4 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
;;
Expand Down
9 changes: 3 additions & 6 deletions jchuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include "jpeglib.h"
#include "jchuff.h" /* Declarations shared with jcphuff.c */
#include <limits.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif

/*
* NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
Expand Down Expand Up @@ -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() \
Expand Down
6 changes: 3 additions & 3 deletions jconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H

/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

/* Define to 1 if the system has the type `unsigned char'. */
#undef HAVE_UNSIGNED_CHAR

Expand Down Expand Up @@ -71,3 +68,6 @@

/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
9 changes: 1 addition & 8 deletions jdhuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#include "jdhuff.h" /* Declarations shared with jdphuff.c */
#include "jpegcomp.h"
#include "jstdhuff.c"
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif


/*
Expand Down Expand Up @@ -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 \
Expand Down
6 changes: 5 additions & 1 deletion jdhuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 63ba814

Please sign in to comment.