diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-09-03 11:37:38 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-09-03 11:37:38 +0400 |
commit | d248f94cf8b3a715297f3e512d0b10c7d7b7a0c1 (patch) | |
tree | 71275d90db69d9f434d69bc0422486dd35830fca /source/blender | |
parent | ca6fa937d498691faf77fa58f7c6c4128ac05866 (diff) |
add endian switch functions to replace macros SWITCH_INT/LONG/SHORT, with BLI_endian_switch_int32/int64/float/double...
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/customdata_file.c | 27 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 12 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_endian_switch.h | 33 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_endian_switch_inline.h | 116 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_utildefines.h | 24 | ||||
-rw-r--r-- | source/blender/blenlib/CMakeLists.txt | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/endian_switch.c | 25 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 82 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_250.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_legacy.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 5 | ||||
-rw-r--r-- | source/blender/imbuf/intern/indexer.c | 9 | ||||
-rw-r--r-- | source/blender/imbuf/intern/thumbs_blend.c | 11 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_sdna_types.h | 7 |
14 files changed, 242 insertions, 114 deletions
diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index 71801c4729f..5794625efa1 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -32,6 +32,7 @@ #include "BLI_fileops.h" #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLI_endian_switch.h" #include "BKE_customdata_file.h" #include "BKE_global.h" @@ -165,9 +166,9 @@ static int cdf_read_header(CDataFile *cdf) header->endian = cdf_endian(); if (cdf->switchendian) { - SWITCH_INT(header->type); - SWITCH_INT(header->totlayer); - SWITCH_INT(header->structbytes); + BLI_endian_switch_int32(&header->type); + BLI_endian_switch_int32(&header->totlayer); + BLI_endian_switch_int32(&header->structbytes); } if (!ELEM(header->type, CDF_TYPE_IMAGE, CDF_TYPE_MESH)) @@ -185,10 +186,10 @@ static int cdf_read_header(CDataFile *cdf) return 0; if (cdf->switchendian) { - SWITCH_INT(image->width); - SWITCH_INT(image->height); - SWITCH_INT(image->tile_size); - SWITCH_INT(image->structbytes); + BLI_endian_switch_int32(&image->width); + BLI_endian_switch_int32(&image->height); + BLI_endian_switch_int32(&image->tile_size); + BLI_endian_switch_int32(&image->structbytes); } offset += image->structbytes; @@ -200,7 +201,7 @@ static int cdf_read_header(CDataFile *cdf) return 0; if (cdf->switchendian) - SWITCH_INT(mesh->structbytes); + BLI_endian_switch_int32(&mesh->structbytes); offset += mesh->structbytes; mesh->structbytes = sizeof(CDataFileMeshHeader); @@ -219,10 +220,10 @@ static int cdf_read_header(CDataFile *cdf) return 0; if (cdf->switchendian) { - SWITCH_INT(layer->type); - SWITCH_INT(layer->datatype); - SWITCH_INT64(layer->datasize); - SWITCH_INT(layer->structbytes); + BLI_endian_switch_int32(&layer->type); + BLI_endian_switch_int32(&layer->datatype); + BLI_endian_switch_uint64(&layer->datasize); + BLI_endian_switch_int32(&layer->structbytes); } if (layer->datatype != CDF_DATA_FLOAT) @@ -329,7 +330,7 @@ int cdf_read_data(CDataFile *cdf, unsigned int size, void *data) fdata = data; for (a = 0; a < size / sizeof(float); a++) { - SWITCH_INT(fdata[a]); + BLI_endian_switch_float(&fdata[a]); } } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 7456f9aab8b..8229df28ab8 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -293,18 +293,6 @@ static IDProperty *IDP_CopyArray(IDProperty *prop) return newp; } -/*taken from readfile.c*/ -#define SWITCH_LONGINT(a) { \ - char s_i, *p_i; \ - p_i = (char *)& (a); \ - s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; \ - s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; \ - s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; \ - s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; \ - } (void)0 - - - /* ---------- String Type ------------ */ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) { diff --git a/source/blender/blenlib/BLI_endian_switch.h b/source/blender/blenlib/BLI_endian_switch.h new file mode 100644 index 00000000000..19da1ff35a3 --- /dev/null +++ b/source/blender/blenlib/BLI_endian_switch.h @@ -0,0 +1,33 @@ +/* + * ***** 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. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BLI_ENDIAN_SWITCH_H__ +#define __BLI_ENDIAN_SWITCH_H__ + +/** \file BLI_endian_switch.h + * \ingroup bli + */ + +#include "BLI_endian_switch_inline.h" + + +#endif /* __BLI_ENDIAN_SWITCH_H__ */ diff --git a/source/blender/blenlib/BLI_endian_switch_inline.h b/source/blender/blenlib/BLI_endian_switch_inline.h new file mode 100644 index 00000000000..b747da3b738 --- /dev/null +++ b/source/blender/blenlib/BLI_endian_switch_inline.h @@ -0,0 +1,116 @@ +/* + * ***** 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. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/* only include from header */ +#ifndef __BLI_ENDIAN_SWITCH_H__ +# error "this file isnt to be directly included" +#endif + +#ifndef __BLI_ENDIAN_SWITCH_INLINE_H__ +#define __BLI_ENDIAN_SWITCH_INLINE_H__ + +/** \file blender/blenlib/BLI_endian_switch_inline.h + * \ingroup bli + */ + + +BLI_INLINE void BLI_endian_switch_int16(short *val) +{ + char *p_i = (char *)val; + char s_i; + + s_i = p_i[0]; + p_i[0] = p_i[1]; + p_i[1] = s_i; +} + +BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) +{ + char *p_i = (char *)val; + char s_i; + + s_i = p_i[0]; + p_i[0] = p_i[1]; + p_i[1] = s_i; +} + +BLI_INLINE void BLI_endian_switch_int32(int *val) +{ + char *p_i = (char *)val; + char s_i; + + s_i = p_i[0]; p_i[0] = p_i[3]; p_i[3] = s_i; + s_i = p_i[1]; p_i[1] = p_i[2]; p_i[2] = s_i; +} + +BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) +{ + char *p_i = (char *)val; + char s_i; + + s_i = p_i[0]; p_i[0] = p_i[3]; p_i[3] = s_i; + s_i = p_i[1]; p_i[1] = p_i[2]; p_i[2] = s_i; +} + +BLI_INLINE void BLI_endian_switch_float(float *val) +{ + char *p_i = (char *)val; + char s_i; + + s_i = p_i[0]; p_i[0] = p_i[3]; p_i[3] = s_i; + s_i = p_i[1]; p_i[1] = p_i[2]; p_i[2] = s_i; +} + +BLI_INLINE void BLI_endian_switch_int64(int64_t *val) +{ + char *p_i = (char *)val; + char s_i; + + s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; + s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; + s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; + s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; +} + +BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) +{ + char *p_i = (char *)val; + char s_i; + + s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; + s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; + s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; + s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; +} + +BLI_INLINE void BLI_endian_switch_double(double *val) +{ + char *p_i = (char *)val; + char s_i; + + s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; + s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; + s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; + s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; +} + +#endif /* __BLI_ENDIAN_SWITCH_INLINE_H__ */ diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 8a459b9b07c..c11d8ed55be 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -225,30 +225,6 @@ (item <= ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)) \ ) -/* This one rotates the bytes in an int64, int (32) and short (16) */ -#define SWITCH_INT64(a) { \ - char s_i, *p_i; \ - p_i = (char *)&(a); \ - s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; \ - s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; \ - s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; \ - s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; \ - } (void)0 - -#define SWITCH_INT(a) { \ - char s_i, *p_i; \ - p_i = (char *)&(a); \ - s_i = p_i[0]; p_i[0] = p_i[3]; p_i[3] = s_i; \ - s_i = p_i[1]; p_i[1] = p_i[2]; p_i[2] = s_i; \ - } (void)0 - -#define SWITCH_SHORT(a) { \ - char s_i, *p_i; \ - p_i = (char *)&(a); \ - s_i = p_i[0]; p_i[0] = p_i[1]; p_i[1] = s_i; \ - } (void)0 - - /* Warning-free macros for storing ints in pointers. Use these _only_ * for storing an int in a pointer, not a pointer in an int (64bit)! */ #define SET_INT_IN_POINTER(i) ((void *)(intptr_t)(i)) diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 0175076fab8..fd755943e70 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -55,6 +55,7 @@ set(SRC intern/cpu.c intern/dynlib.c intern/edgehash.c + intern/endian_switch.c intern/fileops.c intern/fnmatch.c intern/freetypefont.c @@ -105,6 +106,8 @@ set(SRC BLI_dynlib.h BLI_dynstr.h BLI_edgehash.h + BLI_endian_switch.h + BLI_endian_switch_inline.h BLI_fileops.h BLI_fileops_types.h BLI_fnmatch.h diff --git a/source/blender/blenlib/intern/endian_switch.c b/source/blender/blenlib/intern/endian_switch.c new file mode 100644 index 00000000000..db4884d35b9 --- /dev/null +++ b/source/blender/blenlib/intern/endian_switch.c @@ -0,0 +1,25 @@ +/* + * ***** 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. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenlib/intern/endian_switch.c + * \ingroup bli + */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ac792a90735..51211d294ef 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -100,6 +100,7 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" +#include "BLI_endian_switch.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_edgehash.h" @@ -140,7 +141,7 @@ #include "BKE_sequencer.h" #include "BKE_text.h" // for txt_extended_ascii_as_utf8 #include "BKE_tracking.h" -#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND +#include "BKE_utildefines.h" #include "BKE_sound.h" #include "IMB_imbuf.h" // for proxy / timecode versioning stuff @@ -221,16 +222,6 @@ /* from misc_util: flip the bytes from x */ /* #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */ -// only used here in readfile.c -#define SWITCH_LONGINT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ - s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ - s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; \ -} (void)0 - /***/ typedef struct OldNew { @@ -577,9 +568,9 @@ static void switch_endian_bh4(BHead4 *bhead) if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16; if (bhead->code != ENDB) { - SWITCH_INT(bhead->len); - SWITCH_INT(bhead->SDNAnr); - SWITCH_INT(bhead->nr); + BLI_endian_switch_int32(&bhead->len); + BLI_endian_switch_int32(&bhead->SDNAnr); + BLI_endian_switch_int32(&bhead->nr); } } @@ -589,9 +580,9 @@ static void switch_endian_bh8(BHead8 *bhead) if ((bhead->code & 0xFFFF)==0) bhead->code >>= 16; if (bhead->code != ENDB) { - SWITCH_INT(bhead->len); - SWITCH_INT(bhead->SDNAnr); - SWITCH_INT(bhead->nr); + BLI_endian_switch_int32(&bhead->len); + BLI_endian_switch_int32(&bhead->SDNAnr); + BLI_endian_switch_int32(&bhead->nr); } } @@ -612,7 +603,7 @@ static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap) * 0x0000000000000000000012345678 would become 0x12345678000000000000000000000000 */ if (do_endian_swap) { - SWITCH_LONGINT(bhead8->old); + BLI_endian_switch_int64(&bhead8->old); } /* this patch is to avoid a long long being read from not-eight aligned positions @@ -1476,11 +1467,7 @@ static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */ static void test_pointer_array(FileData *fd, void **mat) { -#if defined(WIN32) && !defined(FREE_WINDOWS) - __int64 *lpoin, *lmat; -#else - long long *lpoin, *lmat; -#endif + int64_t *lpoin, *lmat; int *ipoin, *imat; size_t len; @@ -1497,7 +1484,7 @@ static void test_pointer_array(FileData *fd, void **mat) while (len-- > 0) { if ((fd->flags & FD_FLAGS_SWITCH_ENDIAN)) - SWITCH_LONGINT(*lpoin); + BLI_endian_switch_int64(lpoin); *ipoin = (int)((*lpoin) >> 3); ipoin++; lpoin++; @@ -1568,14 +1555,14 @@ static void IDP_DirectLinkArray(IDProperty *prop, int switch_endian, FileData *f else if (prop->subtype == IDP_DOUBLE) { if (switch_endian) { for (i = 0; i < prop->len; i++) { - SWITCH_LONGINT(((double *)prop->data.pointer)[i]); + BLI_endian_switch_double(&((double *)prop->data.pointer)[i]); } } } else { if (switch_endian) { for (i = 0; i < prop->len; i++) { - SWITCH_INT(((int *)prop->data.pointer)[i]); + BLI_endian_switch_int32(&((int *)prop->data.pointer)[i]); } } } @@ -1628,9 +1615,9 @@ static void IDP_DirectLinkProperty(IDProperty *prop, int switch_endian, FileData */ if (switch_endian) { - SWITCH_INT(prop->data.val); - SWITCH_INT(prop->data.val2); - SWITCH_LONGINT(prop->data.val); + BLI_endian_switch_int32(&prop->data.val); + BLI_endian_switch_int32(&prop->data.val2); + BLI_endian_switch_int64((int64_t *)&prop->data.val); } break; @@ -1873,7 +1860,7 @@ static void direct_link_fmodifiers(FileData *fd, ListBase *list) if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { unsigned int a; for (a = 0; a < data->arraysize; a++) - SWITCH_INT(data->coefficients[a]); + BLI_endian_switch_float(&data->coefficients[a]); } } break; @@ -2779,7 +2766,7 @@ static void switch_endian_keyblock(Key *key, KeyBlock *kb) b = cp[0]; while (b--) { - SWITCH_INT((*poin)); + BLI_endian_switch_float((float *)poin); poin += 4; } break; @@ -3077,13 +3064,13 @@ static void switch_endian_knots(Nurb *nu) if (nu->knotsu) { len = KNOTSU(nu); while (len--) { - SWITCH_INT(nu->knotsu[len]); + BLI_endian_switch_float(&nu->knotsu[len]); } } if (nu->knotsv) { len = KNOTSV(nu); while (len--) { - SWITCH_INT(nu->knotsv[len]); + BLI_endian_switch_float(&nu->knotsv[len]); } } } @@ -3305,8 +3292,9 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache) int j, tot = (BKE_ptcache_data_size (i) * pm->totpoint)/4; /* data_size returns bytes */ int *poin = pm->data[i]; - for (j = 0; j < tot; j++) - SWITCH_INT(poin[j]); + for (j = 0; j < tot; j++) { + BLI_endian_switch_int32(&poin[j]); + } } } @@ -3778,7 +3766,7 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte int x; float *tmpdisps = *mdisps[i].disps; for (x = 0; x < mdisps[i].totdisp * 3; x++) { - SWITCH_INT(*tmpdisps); + BLI_endian_switch_float(tmpdisps); tmpdisps++; } } @@ -3951,10 +3939,10 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) int i; for (i = 0; i < (mesh->totface); i++, tf++) { - SWITCH_INT(tf->col[0]); - SWITCH_INT(tf->col[1]); - SWITCH_INT(tf->col[2]); - SWITCH_INT(tf->col[3]); + BLI_endian_switch_uint32(&tf->col[0]); + BLI_endian_switch_uint32(&tf->col[1]); + BLI_endian_switch_uint32(&tf->col[2]); + BLI_endian_switch_uint32(&tf->col[3]); } } } @@ -4482,7 +4470,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { int a; for (a = 0; a < hmd->totindex; a++) { - SWITCH_INT(hmd->indexar[a]); + BLI_endian_switch_int32(&hmd->indexar[a]); } } } @@ -4517,20 +4505,20 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) if (mmd->bindoffsets) for (a=0; a<mmd->totvert+1; a++) - SWITCH_INT(mmd->bindoffsets[a]); + BLI_endian_switch_int32(&mmd->bindoffsets[a]); if (mmd->bindcagecos) for (a=0; a<mmd->totcagevert*3; a++) - SWITCH_INT(mmd->bindcagecos[a]); + BLI_endian_switch_float(&mmd->bindcagecos[a]); if (mmd->dynverts) for (a=0; a<mmd->totvert; a++) - SWITCH_INT(mmd->dynverts[a]); + BLI_endian_switch_int32(&mmd->dynverts[a]); if (mmd->bindweights) for (a=0; a<mmd->totcagevert*mmd->totvert; a++) - SWITCH_INT(mmd->bindweights[a]); + BLI_endian_switch_float(&mmd->bindweights[a]); if (mmd->bindcos) for (a=0; a<mmd->totcagevert*3; a++) - SWITCH_INT(mmd->bindcos[a]); + BLI_endian_switch_float(&mmd->bindcos[a]); } } else if (md->type == eModifierType_Ocean) { @@ -4726,7 +4714,7 @@ static void direct_link_object(FileData *fd, Object *ob) if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { int a; for (a = 0; a < hook->totindex; a++) { - SWITCH_INT(hook->indexar[a]); + BLI_endian_switch_int32(&hook->indexar[a]); } } diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 1bad1bd80df..a4f190c8167 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -89,7 +89,6 @@ #include "BKE_screen.h" #include "BKE_sequencer.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND #include "BKE_sound.h" #include "NOD_socket.h" diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 8ace277b42d..1cc0d4180ab 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -95,7 +95,6 @@ #include "BKE_property.h" // for get_ob_property #include "BKE_scene.h" #include "BKE_sequencer.h" -#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND #include "IMB_imbuf.h" // for proxy / timecode versioning stuff diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 24395865a5e..d7e61d0bff3 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -48,6 +48,7 @@ #include "BLI_math.h" #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "BLI_endian_switch.h" #include "BKE_anim.h" #include "BKE_camera.h" @@ -1397,7 +1398,9 @@ unsigned int view3d_sample_backbuf(ViewContext *vc, int x, int y) glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col); glReadBuffer(GL_BACK); - if (ENDIAN_ORDER == B_ENDIAN) SWITCH_INT(col); + if (ENDIAN_ORDER == B_ENDIAN) { + BLI_endian_switch_uint32(&col); + } return WM_framebuffer_to_index(col); } diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 4108f0d89d7..702e9872a91 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" +#include "BLI_endian_switch.h" #include "BLI_string.h" #include "BLI_path_util.h" #include "BLI_fileops.h" @@ -208,10 +209,10 @@ struct anim_index *IMB_indexer_open(const char *name) if (((ENDIAN_ORDER == B_ENDIAN) != (header[8] == 'V'))) { for (i = 0; i < idx->num_entries; i++) { - SWITCH_INT(idx->entries[i].frameno); - SWITCH_INT64(idx->entries[i].seek_pos); - SWITCH_INT64(idx->entries[i].seek_pos_dts); - SWITCH_INT64(idx->entries[i].pts); + BLI_endian_switch_int32(&idx->entries[i].frameno); + BLI_endian_switch_int64((int64_t *)&idx->entries[i].seek_pos); + BLI_endian_switch_int64((int64_t *)&idx->entries[i].seek_pos_dts); + BLI_endian_switch_int64((int64_t *)&idx->entries[i].pts); } } diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index afef2365de4..1a921c4844c 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -29,7 +29,10 @@ #include "zlib.h" +#include "MEM_guardedalloc.h" + #include "BLI_utildefines.h" +#include "BLI_endian_switch.h" #include "BLI_fileops.h" #include "BKE_utildefines.h" @@ -39,8 +42,6 @@ #include "IMB_imbuf.h" #include "IMB_thumbs.h" -#include "MEM_guardedalloc.h" - /* extracts the thumbnail from between the 'REND' and the 'GLOB' * chunks of the header, don't use typical blend loader because its too slow */ @@ -78,7 +79,7 @@ static ImBuf *loadblend_thumb(gzFile gzfile) while (gzread(gzfile, bhead, sizeof_bhead) == sizeof_bhead) { if (endian_switch) - SWITCH_INT(bhead[1]); /* length */ + BLI_endian_switch_int32(&bhead[1]); /* length */ if (bhead[0] == REND) { gzseek(gzfile, bhead[1], SEEK_CUR); /* skip to the next */ @@ -97,8 +98,8 @@ static ImBuf *loadblend_thumb(gzFile gzfile) return NULL; if (endian_switch) { - SWITCH_INT(size[0]); - SWITCH_INT(size[1]); + BLI_endian_switch_int32(&size[0]); + BLI_endian_switch_int32(&size[1]); } /* length */ bhead[1] -= sizeof(int) * 2; diff --git a/source/blender/makesdna/DNA_sdna_types.h b/source/blender/makesdna/DNA_sdna_types.h index ec02db192fd..8b2e7645823 100644 --- a/source/blender/makesdna/DNA_sdna_types.h +++ b/source/blender/makesdna/DNA_sdna_types.h @@ -81,12 +81,7 @@ typedef struct BHead4 { # typedef struct BHead8 { int code, len; -#if defined(WIN32) && !defined(FREE_WINDOWS) - /* This is a compiler type! */ - __int64 old; -#else - long long old; -#endif + int64_t old; int SDNAnr, nr; } BHead8; |