From 1a72ee4cbe055b0ad28dc3eeff9e4665ee64b37b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Jun 2021 21:05:50 +1000 Subject: Cleanup: move endian values from BKE_global into BLI_endian_defines This change was prompted by D6408 which moves thumbnail extraction into a shared function that happens use these endian defines but only links blenlib. There is no need for these defines to be associated with globals so move into their own header. --- source/blender/blenkernel/BKE_global.h | 14 -------- source/blender/blenkernel/intern/customdata_file.c | 2 +- source/blender/blenkernel/intern/writeffmpeg.c | 1 + source/blender/blenlib/BLI_endian_defines.h | 38 ++++++++++++++++++++++ source/blender/blenloader/intern/readfile.c | 1 + source/blender/blenloader/intern/writefile.c | 1 + source/blender/imbuf/intern/indexer.c | 3 +- source/blender/imbuf/intern/tiff.c | 1 + source/blender/sequencer/intern/image_cache.c | 2 +- 9 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 source/blender/blenlib/BLI_endian_defines.h (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 9e237679795..74f2bf7c6ad 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -199,20 +199,6 @@ enum { */ #define G_FILE_FLAG_ALL_RUNTIME (G_FILE_NO_UI | G_FILE_RECOVER_READ | G_FILE_RECOVER_WRITE) -/** 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 - -#ifdef __BIG_ENDIAN__ -# define ENDIAN_ORDER B_ENDIAN -#else -# define ENDIAN_ORDER L_ENDIAN -#endif - /** #Global.moving, signals drawing in (3d) window to denote transform */ enum { G_TRANSFORM_OBJ = (1 << 0), diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index 4aaecc26eff..314d5f4ff82 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -24,13 +24,13 @@ #include "MEM_guardedalloc.h" +#include "BLI_endian_defines.h" #include "BLI_endian_switch.h" #include "BLI_fileops.h" #include "BLI_string.h" #include "BLI_utildefines.h" #include "BKE_customdata_file.h" -#include "BKE_global.h" /************************* File Format Definitions ***************************/ diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 92d19f18a93..560ae30967f 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -36,6 +36,7 @@ # include # endif +# include "BLI_endian_defines.h" # include "BLI_math_base.h" # include "BLI_threads.h" # include "BLI_utildefines.h" diff --git a/source/blender/blenlib/BLI_endian_defines.h b/source/blender/blenlib/BLI_endian_defines.h new file mode 100644 index 00000000000..31f28572c79 --- /dev/null +++ b/source/blender/blenlib/BLI_endian_defines.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#pragma once + +/** \file + * \ingroup bli + */ + +/* NOTE: these names are historic and could use a more generic prefix. + * This could be done as part of a bigger refactor. */ + +/** 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 + +#ifdef __BIG_ENDIAN__ +# define ENDIAN_ORDER B_ENDIAN +#else +# define ENDIAN_ORDER L_ENDIAN +#endif diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 801f5864c8d..47ed4e5c06f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -62,6 +62,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_endian_defines.h" #include "BLI_endian_switch.h" #include "BLI_ghash.h" #include "BLI_linklist.h" diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 4ac49d5aebb..38c00b3f132 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -100,6 +100,7 @@ #include "BLI_bitmap.h" #include "BLI_blenlib.h" +#include "BLI_endian_defines.h" #include "BLI_mempool.h" #include "MEM_guardedalloc.h" /* MEM_freeN */ diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 58357e52149..4d116eb73b8 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -24,6 +24,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_endian_defines.h" #include "BLI_endian_switch.h" #include "BLI_fileops.h" #include "BLI_ghash.h" @@ -40,8 +41,6 @@ #include "IMB_indexer.h" #include "imbuf.h" -#include "BKE_global.h" - #ifdef WITH_AVI # include "AVI_avi.h" #endif diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 12f7553d5e4..d9e1db27ef0 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -38,6 +38,7 @@ #include "imbuf.h" +#include "BLI_endian_defines.h" #include "BLI_math.h" #include "BLI_utildefines.h" diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index 5ccf2a027b0..a6e4b6ea7ed 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -35,6 +35,7 @@ #include "IMB_imbuf_types.h" #include "BLI_blenlib.h" +#include "BLI_endian_defines.h" #include "BLI_endian_switch.h" #include "BLI_fileops.h" #include "BLI_fileops_types.h" @@ -44,7 +45,6 @@ #include "BLI_path_util.h" #include "BLI_threads.h" -#include "BKE_global.h" #include "BKE_main.h" #include "BKE_scene.h" -- cgit v1.2.3