cleanup endian handling
- define __BIG_ENDIAN__ or __LITTLE_ENDIAN__ with cmake & scons. - ENDIAN_ORDER is now a define rather than a global short. - replace checks like this with single ifdef: #if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) - remove BKE_endian.h which isn't used
This commit is contained in:
@@ -105,6 +105,7 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE )
|
||||
|
||||
get_blender_version()
|
||||
|
||||
|
||||
# Blender internal features
|
||||
option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
|
||||
mark_as_advanced(WITH_BLENDER)
|
||||
@@ -1150,6 +1151,18 @@ if(WITH_RAYOPTIMIZATION)
|
||||
unset(_sse2)
|
||||
endif()
|
||||
|
||||
|
||||
# set the endian define
|
||||
include(TestBigEndian)
|
||||
test_big_endian(_SYSTEM_BIG_ENDIAN)
|
||||
if(_SYSTEM_BIG_ENDIAN)
|
||||
add_definitions(-D__BIG_ENDIAN__)
|
||||
else()
|
||||
add_definitions(-D__LITTLE_ENDIAN__)
|
||||
endif()
|
||||
unset(_SYSTEM_BIG_ENDIAN)
|
||||
|
||||
|
||||
if(WITH_IMAGE_OPENJPEG)
|
||||
if(UNIX AND NOT APPLE)
|
||||
# dealt with above
|
||||
|
11
SConstruct
11
SConstruct
@@ -337,6 +337,17 @@ if env['BF_NO_ELBEEM'] == 1:
|
||||
env['CXXFLAGS'].append('-DDISABLE_ELBEEM')
|
||||
env['CCFLAGS'].append('-DDISABLE_ELBEEM')
|
||||
|
||||
|
||||
if btools.ENDIAN == "big":
|
||||
env['CPPFLAGS'].append('-D__BIG_ENDIAN__')
|
||||
env['CXXFLAGS'].append('-D__BIG_ENDIAN__')
|
||||
env['CCFLAGS'].append('-D__BIG_ENDIAN__')
|
||||
else:
|
||||
env['CPPFLAGS'].append('-D__LITTLE_ENDIAN__')
|
||||
env['CXXFLAGS'].append('-D__LITTLE_ENDIAN__')
|
||||
env['CCFLAGS'].append('-D__LITTLE_ENDIAN__')
|
||||
|
||||
|
||||
# TODO, make optional
|
||||
env['CPPFLAGS'].append('-DWITH_AUDASPACE')
|
||||
env['CXXFLAGS'].append('-DWITH_AUDASPACE')
|
||||
|
@@ -63,9 +63,27 @@ def get_revision():
|
||||
|
||||
return 'r' + build_rev
|
||||
|
||||
|
||||
# copied from: http://www.scons.org/wiki/AutoconfRecipes
|
||||
def checkEndian():
|
||||
import struct
|
||||
array = struct.pack('cccc', '\x01', '\x02', '\x03', '\x04')
|
||||
i = struct.unpack('i', array)
|
||||
# Little Endian
|
||||
if i == struct.unpack('<i', array):
|
||||
return "little"
|
||||
# Big Endian
|
||||
elif i == struct.unpack('>i', array):
|
||||
return "big"
|
||||
else:
|
||||
raise Exception("cant find endian")
|
||||
|
||||
|
||||
# This is used in creating the local config directories
|
||||
VERSION, VERSION_DISPLAY = get_version()
|
||||
REVISION = get_revision()
|
||||
ENDIAN = checkEndian()
|
||||
|
||||
|
||||
def print_arguments(args, bc):
|
||||
if len(args):
|
||||
|
@@ -36,9 +36,6 @@ AUD_ConverterReader::AUD_ConverterReader(AUD_Reference<AUD_IReader> reader,
|
||||
AUD_EffectReader(reader),
|
||||
m_format(specs.format)
|
||||
{
|
||||
int bigendian = 1;
|
||||
bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian
|
||||
|
||||
switch(m_format)
|
||||
{
|
||||
case AUD_FORMAT_U8:
|
||||
@@ -48,10 +45,11 @@ AUD_ConverterReader::AUD_ConverterReader(AUD_Reference<AUD_IReader> reader,
|
||||
m_convert = AUD_convert_float_s16;
|
||||
break;
|
||||
case AUD_FORMAT_S24:
|
||||
if(bigendian)
|
||||
m_convert = AUD_convert_float_s24_be;
|
||||
else
|
||||
m_convert = AUD_convert_float_s24_le;
|
||||
#ifdef __BIG_ENDIAN__
|
||||
m_convert = AUD_convert_float_s24_be;
|
||||
#else
|
||||
m_convert = AUD_convert_float_s24_le;
|
||||
#endif
|
||||
break;
|
||||
case AUD_FORMAT_S32:
|
||||
m_convert = AUD_convert_float_s32;
|
||||
|
@@ -37,9 +37,6 @@
|
||||
AUD_Mixer::AUD_Mixer(AUD_DeviceSpecs specs) :
|
||||
m_specs(specs)
|
||||
{
|
||||
int bigendian = 1;
|
||||
bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian
|
||||
|
||||
switch(m_specs.format)
|
||||
{
|
||||
case AUD_FORMAT_U8:
|
||||
@@ -49,10 +46,12 @@ AUD_Mixer::AUD_Mixer(AUD_DeviceSpecs specs) :
|
||||
m_convert = AUD_convert_float_s16;
|
||||
break;
|
||||
case AUD_FORMAT_S24:
|
||||
if(bigendian)
|
||||
m_convert = AUD_convert_float_s24_be;
|
||||
else
|
||||
m_convert = AUD_convert_float_s24_le;
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
m_convert = AUD_convert_float_s24_be;
|
||||
#else
|
||||
m_convert = AUD_convert_float_s24_le;
|
||||
#endif
|
||||
break;
|
||||
case AUD_FORMAT_S32:
|
||||
m_convert = AUD_convert_float_s32;
|
||||
|
@@ -124,10 +124,10 @@ static const char *check_memlist(MemHead *memh);
|
||||
/* locally used defines */
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
#if defined( __sgi) || defined (__sun) || defined (__sun__) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || (defined (__APPLE__) && !defined(__LITTLE_ENDIAN__))
|
||||
#define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
|
||||
#ifdef __BIG_ENDIAN__
|
||||
# define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
|
||||
#else
|
||||
#define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
|
||||
# define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
|
||||
#endif
|
||||
|
||||
#define MEMTAG1 MAKE_ID('M', 'E', 'M', 'O')
|
||||
|
@@ -45,7 +45,7 @@
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#if defined(__sun__) || defined( __sun ) || defined (__sparc) || defined (__sparc__) || defined (_AIX)
|
||||
#include <strings.h>
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include "STR_String.h"
|
||||
|
||||
|
@@ -42,8 +42,8 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "avirgb.h"
|
||||
|
||||
#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__)
|
||||
#define WORDS_BIGENDIAN
|
||||
#ifdef __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -43,11 +43,7 @@
|
||||
#include "endian.h"
|
||||
#include "avi_intern.h"
|
||||
|
||||
#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__)
|
||||
#define WORDS_BIGENDIAN
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#ifdef __BIG_ENDIAN__
|
||||
static void invert (int *num) {
|
||||
int new=0,i,j;
|
||||
|
||||
@@ -79,7 +75,7 @@ static void Ichunk (AviChunk *chunk) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#ifdef __BIG_ENDIAN__
|
||||
static void Ilist (AviList *list){
|
||||
invert (&list->fcc);
|
||||
invert (&list->size);
|
||||
@@ -159,10 +155,10 @@ static void Iindexe (AviIndexEntry *indexe) {
|
||||
invert (&indexe->Offset);
|
||||
invert (&indexe->Size);
|
||||
}
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
#endif /* __BIG_ENDIAN__ */
|
||||
|
||||
void awrite (AviMovie *movie, void *datain, int block, int size, FILE *fp, int type) {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#ifdef __BIG_ENDIAN__
|
||||
void *data;
|
||||
|
||||
data = MEM_mallocN (size, "avi endian");
|
||||
@@ -209,9 +205,9 @@ void awrite (AviMovie *movie, void *datain, int block, int size, FILE *fp, int t
|
||||
}
|
||||
|
||||
MEM_freeN (data);
|
||||
#else /* WORDS_BIGENDIAN */
|
||||
#else /* __BIG_ENDIAN__ */
|
||||
(void)movie; /* unused */
|
||||
(void)type; /* unused */
|
||||
fwrite (datain, block, size, fp);
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
#endif /* __BIG_ENDIAN__ */
|
||||
}
|
||||
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
* Are we little or big endian? From Harbison&Steele.
|
||||
*/
|
||||
#ifndef BKE_ENDIAN_H
|
||||
#define BKE_ENDIAN_H
|
||||
|
||||
/** \file BKE_endian.h
|
||||
* \ingroup bke
|
||||
*/
|
||||
|
||||
/**
|
||||
* BKE_ENDIANNESS(a) returns 1 if big endian and returns 0 if little endian
|
||||
*/
|
||||
#define BKE_ENDIANNESS(a) { \
|
||||
union { \
|
||||
intptr_t l; \
|
||||
char c[sizeof (intptr_t)]; \
|
||||
} u; \
|
||||
u.l = 1; \
|
||||
a = (u.c[sizeof (intptr_t) - 1] == 1) ? 1 : 0; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -151,9 +151,18 @@ typedef struct Global {
|
||||
|
||||
/* ENDIAN_ORDER: indicates what endianness the platform where the file was
|
||||
* written had. */
|
||||
#if !defined( __BIG_ENDIAN__ ) && !defined( __LITTLE_ENDIAN__ )
|
||||
# error Either __BIG_ENDIAN__ or __LITTLE_ENDIAN__ must be defined.
|
||||
#endif
|
||||
|
||||
#define L_ENDIAN 1
|
||||
#define B_ENDIAN 0
|
||||
extern short ENDIAN_ORDER;
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
# define ENDIAN_ORDER B_ENDIAN
|
||||
#else
|
||||
# define ENDIAN_ORDER L_ENDIAN
|
||||
#endif
|
||||
|
||||
/* G.moving, signals drawing in (3d) window to denote transform */
|
||||
#define G_TRANSFORM_OBJ 1
|
||||
|
@@ -47,18 +47,18 @@
|
||||
|
||||
/* this weirdo pops up in two places ... */
|
||||
#if !defined(WIN32)
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
# ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* INTEGER CODES */
|
||||
#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__)
|
||||
/* Big Endian */
|
||||
#define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
|
||||
#ifdef __BIG_ENDIAN__
|
||||
/* Big Endian */
|
||||
# define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
|
||||
#else
|
||||
/* Little Endian */
|
||||
#define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
|
||||
/* Little Endian */
|
||||
# define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
|
||||
#endif
|
||||
|
||||
#define ID_NEW(a) if( (a) && (a)->id.newid ) (a)= (void *)(a)->id.newid
|
||||
@@ -74,11 +74,11 @@
|
||||
#define ENDB MAKE_ID('E','N','D','B')
|
||||
|
||||
/* Bit operations */
|
||||
#define BTST(a,b) ( ( (a) & 1<<(b) )!=0 )
|
||||
#define BNTST(a,b) ( ( (a) & 1<<(b) )==0 )
|
||||
#define BTST2(a,b,c) ( BTST( (a), (b) ) || BTST( (a), (c) ) )
|
||||
#define BSET(a,b) ( (a) | 1<<(b) )
|
||||
#define BCLR(a,b) ( (a) & ~(1<<(b)) )
|
||||
#define BTST(a,b) ( ( (a) & 1<<(b) )!=0 )
|
||||
#define BNTST(a,b) ( ( (a) & 1<<(b) )==0 )
|
||||
#define BTST2(a,b,c) ( BTST( (a), (b) ) || BTST( (a), (c) ) )
|
||||
#define BSET(a,b) ( (a) | 1<<(b) )
|
||||
#define BCLR(a,b) ( (a) & ~(1<<(b)) )
|
||||
/* bit-row */
|
||||
#define BROW(min, max) (((max)>=31? 0xFFFFFFFF: (1<<(max+1))-1) - ((min)? ((1<<(min))-1):0) )
|
||||
|
||||
|
@@ -179,7 +179,6 @@ set(SRC
|
||||
BKE_depsgraph.h
|
||||
BKE_displist.h
|
||||
BKE_effect.h
|
||||
BKE_endian.h
|
||||
BKE_fcurve.h
|
||||
BKE_fluidsim.h
|
||||
BKE_font.h
|
||||
|
@@ -98,7 +98,6 @@
|
||||
Global G;
|
||||
UserDef U;
|
||||
/* ListBase = {NULL, NULL}; */
|
||||
short ENDIAN_ORDER;
|
||||
|
||||
char versionstr[48]= "";
|
||||
|
||||
@@ -132,9 +131,6 @@ void initglobals(void)
|
||||
|
||||
strcpy(G.ima, "//");
|
||||
|
||||
ENDIAN_ORDER= 1;
|
||||
ENDIAN_ORDER= (((char*)&ENDIAN_ORDER)[0])? L_ENDIAN: B_ENDIAN;
|
||||
|
||||
if(BLENDER_SUBVERSION)
|
||||
BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
|
||||
else
|
||||
|
@@ -35,11 +35,11 @@
|
||||
*/
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
# define TRUE 1
|
||||
#endif
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
/* some math and copy defines */
|
||||
|
||||
#ifndef SWAP
|
||||
#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
|
||||
# define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
|
||||
#endif
|
||||
|
||||
#define ABS(a) ( (a)<0 ? (-(a)) : (a) )
|
||||
|
@@ -108,12 +108,12 @@
|
||||
#define SWAP_S(x) (((x << 8) & 0xff00) | ((x >> 8) & 0xff))
|
||||
|
||||
/* more endianness... should move to a separate file... */
|
||||
#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__)
|
||||
#define GET_ID GET_BIG_LONG
|
||||
#define LITTLE_LONG SWAP_LONG
|
||||
#ifdef __BIG_ENDIAN__
|
||||
# define GET_ID GET_BIG_LONG
|
||||
# define LITTLE_LONG SWAP_LONG
|
||||
#else
|
||||
#define GET_ID GET_LITTLE_LONG
|
||||
#define LITTLE_LONG ENDIAN_NOP
|
||||
# define GET_ID GET_LITTLE_LONG
|
||||
# define LITTLE_LONG ENDIAN_NOP
|
||||
#endif
|
||||
|
||||
/* anim.curtype, runtime only */
|
||||
|
@@ -62,7 +62,7 @@
|
||||
|
||||
#define ENDIAN_NOP(x) (x)
|
||||
|
||||
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__hppa__) || (defined (__APPLE__) && !defined(__LITTLE_ENDIAN__))
|
||||
#ifdef __BIG_ENDIAN__
|
||||
# define LITTLE_SHORT SWAP_SHORT
|
||||
# define LITTLE_LONG SWAP_LONG
|
||||
# define BIG_SHORT ENDIAN_NOP
|
||||
|
@@ -146,16 +146,16 @@ typedef struct PreviewImage {
|
||||
*
|
||||
**/
|
||||
|
||||
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__)
|
||||
/* big endian */
|
||||
#define MAKE_ID2(c, d) ( (c)<<8 | (d) )
|
||||
#define MOST_SIG_BYTE 0
|
||||
#define BBIG_ENDIAN
|
||||
#ifdef __BIG_ENDIAN__
|
||||
/* big endian */
|
||||
# define MAKE_ID2(c, d) ( (c)<<8 | (d) )
|
||||
# define MOST_SIG_BYTE 0
|
||||
# define BBIG_ENDIAN
|
||||
#else
|
||||
/* little endian */
|
||||
#define MAKE_ID2(c, d) ( (d)<<8 | (c) )
|
||||
#define MOST_SIG_BYTE 1
|
||||
#define BLITTLE_ENDIAN
|
||||
/* little endian */
|
||||
# define MAKE_ID2(c, d) ( (d)<<8 | (c) )
|
||||
# define MOST_SIG_BYTE 1
|
||||
# define BLITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
/* ID from database */
|
||||
|
@@ -61,16 +61,16 @@
|
||||
|
||||
/* XXX, could be better implemented... this is for endian issues
|
||||
*/
|
||||
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__)
|
||||
#define RCOMP 3
|
||||
#define GCOMP 2
|
||||
#define BCOMP 1
|
||||
#define ACOMP 0
|
||||
#ifdef __BIG_ENDIAN__
|
||||
# define RCOMP 3
|
||||
# define GCOMP 2
|
||||
# define BCOMP 1
|
||||
# define ACOMP 0
|
||||
#else
|
||||
#define RCOMP 0
|
||||
#define GCOMP 1
|
||||
#define BCOMP 2
|
||||
#define ACOMP 3
|
||||
# define RCOMP 0
|
||||
# define GCOMP 1
|
||||
# define BCOMP 2
|
||||
# define ACOMP 3
|
||||
#endif
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
Reference in New Issue
Block a user