Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-09-19 12:02:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-19 12:02:17 +0400
commit83a2f02a78cd01aaf31b9b4ae8a217a1ecea6a49 (patch)
tree9a2b9e2d5aa4f5b5bc4835848c3dc78029643d9a /source/blender
parent425a81a29b8adf1fc2d913dfc679d6ca62cd05fa (diff)
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
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/avi/intern/avirgb.c4
-rw-r--r--source/blender/avi/intern/endian.c16
-rw-r--r--source/blender/blenkernel/BKE_endian.h50
-rw-r--r--source/blender/blenkernel/BKE_global.h11
-rw-r--r--source/blender/blenkernel/BKE_utildefines.h26
-rw-r--r--source/blender/blenkernel/CMakeLists.txt1
-rw-r--r--source/blender/blenkernel/intern/blender.c4
-rw-r--r--source/blender/blenlib/BLI_utildefines.h6
-rw-r--r--source/blender/imbuf/intern/IMB_anim.h10
-rw-r--r--source/blender/imbuf/intern/imbuf.h2
-rw-r--r--source/blender/makesdna/DNA_ID.h18
-rw-r--r--source/blender/render/intern/source/shadbuf.c18
12 files changed, 58 insertions, 108 deletions
diff --git a/source/blender/avi/intern/avirgb.c b/source/blender/avi/intern/avirgb.c
index b7f6a58b6d7..9e40b00adfc 100644
--- a/source/blender/avi/intern/avirgb.c
+++ b/source/blender/avi/intern/avirgb.c
@@ -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
diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c
index a985e8c3d5e..50ec2330beb 100644
--- a/source/blender/avi/intern/endian.c
+++ b/source/blender/avi/intern/endian.c
@@ -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__ */
}
diff --git a/source/blender/blenkernel/BKE_endian.h b/source/blender/blenkernel/BKE_endian.h
deleted file mode 100644
index 5647645e990..00000000000
--- a/source/blender/blenkernel/BKE_endian.h
+++ /dev/null
@@ -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
-
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 0e48673f1b1..a59d43d315d 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -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
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index 14e622c972e..87684e4895d 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -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) )
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 9cf0a92742f..09b38195ef3 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -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
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 2d4354bdd9f..2b6261b1c81 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -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
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 9a3b81e5776..456ee72c4e0 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -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) )
diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h
index cd60c0362ad..43168b97b88 100644
--- a/source/blender/imbuf/intern/IMB_anim.h
+++ b/source/blender/imbuf/intern/IMB_anim.h
@@ -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 */
diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h
index 88be4ffbb5f..22481241812 100644
--- a/source/blender/imbuf/intern/imbuf.h
+++ b/source/blender/imbuf/intern/imbuf.h
@@ -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
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 8fd9f49cd0a..80fc6f63363 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -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 */
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
index e4b2a0cf1d1..a4bf6c6b5e1 100644
--- a/source/blender/render/intern/source/shadbuf.c
+++ b/source/blender/render/intern/source/shadbuf.c
@@ -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
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */