Enhance the support of endianess with cmake and inside the code (credit to Winfried)

This commit is contained in:
Mickael Savinaud 2011-09-21 10:01:54 +00:00
parent 7062c01b68
commit ba0c271774
8 changed files with 23 additions and 30 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed ! : changed
+ : added + : added
September 21, 2011
+ [mickael] Enhance the support of endianess with cmake and inside the code (credit to Winfried)
September 20, 2011 September 20, 2011
* [mickael] WIP: fixed build issues with MJ2 option ON * [mickael] WIP: fixed build issues with MJ2 option ON
* [mickael] WIP: fixed build issues with JPWL option ON * [mickael] WIP: fixed build issues with JPWL option ON

View File

@ -39,12 +39,13 @@ SET(OPENJPEG_LIBRARY_PROPERTIES
SOVERSION "${OPENJPEG_VERSION_MAJOR}" SOVERSION "${OPENJPEG_VERSION_MAJOR}"
) )
# --------------------------------------------------------------------------
# Path to additional CMake modules # Path to additional CMake modules
SET(CMAKE_MODULE_PATH SET(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/CMake ${CMAKE_SOURCE_DIR}/CMake
${CMAKE_MODULE_PATH}) ${CMAKE_MODULE_PATH})
# --------------------------------------------------------------------------
# On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security # On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
# warnings # warnings
IF(WIN32) IF(WIN32)
@ -108,6 +109,7 @@ ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Test for some required system information. # Test for some required system information.
# For example this macro test the endianness (CMAKE_WORDS_BIGENDIAN)
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake) INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@ -94,7 +94,7 @@ struct tga_header
static unsigned short get_ushort(unsigned short val) { static unsigned short get_ushort(unsigned short val) {
#ifdef ORDER_BIGENDIAN #ifdef OPJ_BIG_ENDIAN
return( ((val & 0xff) << 8) + (val >> 8) ); return( ((val & 0xff) << 8) + (val >> 8) );
#else #else
return( val ); return( val );

View File

@ -29,6 +29,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -49,7 +50,6 @@
#define _strnicmp strncasecmp #define _strnicmp strncasecmp
#endif /* _WIN32 */ #endif /* _WIN32 */
#include "opj_config.h"
#include "openjpeg.h" #include "openjpeg.h"
#include "opj_getopt.h" #include "opj_getopt.h"
#include "convert.h" #include "convert.h"

View File

@ -24,6 +24,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -44,7 +45,6 @@
#define _strnicmp strncasecmp #define _strnicmp strncasecmp
#endif /* _WIN32 */ #endif /* _WIN32 */
#include "opj_config.h"
#include "openjpeg.h" #include "openjpeg.h"
#include "j2k.h" #include "j2k.h"
#include "jp2.h" #include "jp2.h"

View File

@ -29,6 +29,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "opj_config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -89,27 +89,19 @@ void cio_skip(opj_cio_t *cio, int n);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
#if defined(OPJ_BIG_ENDIAN) #if defined(OPJ_BIG_ENDIAN)
#if !defined(OPJ_LITTLE_ENDIAN) #define opj_write_bytes opj_write_bytes_BE
#define opj_write_bytes opj_write_bytes_BE #define opj_read_bytes opj_read_bytes_BE
#define opj_read_bytes opj_read_bytes_BE #define opj_write_double opj_write_double_BE
#define opj_write_double opj_write_double_BE #define opj_read_double opj_read_double_BE
#define opj_read_double opj_read_double_BE #define opj_write_float opj_write_float_BE
#define opj_write_float opj_write_float_BE #define opj_read_float opj_read_float_BE
#define opj_read_float opj_read_float_BE
#else
#error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
#endif
#else #else
#if defined(OPJ_LITTLE_ENDIAN) #define opj_write_bytes opj_write_bytes_LE
#define opj_write_bytes opj_write_bytes_LE #define opj_read_bytes opj_read_bytes_LE
#define opj_read_bytes opj_read_bytes_LE #define opj_write_double opj_write_double_LE
#define opj_write_double opj_write_double_LE #define opj_read_double opj_read_double_LE
#define opj_read_double opj_read_double_LE #define opj_write_float opj_write_float_LE
#define opj_write_float opj_write_float_LE #define opj_read_float opj_read_float_LE
#define opj_read_float opj_read_float_LE
#else
#error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not none."
#endif
#endif #endif

View File

@ -20,9 +20,4 @@
#cmakedefine HAVE_LCMS1_H @HAVE_LCMS1_H@ #cmakedefine HAVE_LCMS1_H @HAVE_LCMS1_H@
#cmakedefine HAVE_LCMS2_H @HAVE_LCMS2_H@ #cmakedefine HAVE_LCMS2_H @HAVE_LCMS2_H@
#cmakedefine CMAKE_WORDS_BIGENDIAN #cmakedefine OPJ_BIG_ENDIAN @CMAKE_WORDS_BIGENDIAN@
#ifdef CMAKE_WORDS_BIGENDIAN
#define OPJ_BIG_ENDIAN
#else
#define OPJ_LITTLE_ENDIAN
#endif