Fix #33226: error loading .blend files with different endian on Mac. The cause
[blender.git] / source / blender / blenlib / BLI_endian_switch.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Campbell Barton
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 #ifndef __BLI_ENDIAN_SWITCH_H__
24 #define __BLI_ENDIAN_SWITCH_H__
25
26 /** \file BLI_endian_switch.h
27  *  \ingroup bli
28  */
29
30 #ifdef __GNUC__
31 #  define ATTR_ENDIAN_SWITCH \
32         __attribute__((nonnull(1)))
33 #else
34 #  define ATTR_ENDIAN_SWITCH
35 #endif
36
37 /* BLI_endian_switch_inline.h */
38 BLI_INLINE void BLI_endian_switch_int16(short *val)                       ATTR_ENDIAN_SWITCH;
39 BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val)             ATTR_ENDIAN_SWITCH;
40 BLI_INLINE void BLI_endian_switch_int32(int *val)                         ATTR_ENDIAN_SWITCH;
41 BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val)               ATTR_ENDIAN_SWITCH;
42 BLI_INLINE void BLI_endian_switch_float(float *val)                       ATTR_ENDIAN_SWITCH;
43 BLI_INLINE void BLI_endian_switch_int64(int64_t *val)                     ATTR_ENDIAN_SWITCH;
44 BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val)                   ATTR_ENDIAN_SWITCH;
45 BLI_INLINE void BLI_endian_switch_double(double *val)                     ATTR_ENDIAN_SWITCH;
46
47 /* endian_switch.c */
48 void BLI_endian_switch_int16_array(short *val, const int size)            ATTR_ENDIAN_SWITCH;
49 void BLI_endian_switch_uint16_array(unsigned short *val, const int size)  ATTR_ENDIAN_SWITCH;
50 void BLI_endian_switch_int32_array(int *val, const int size)              ATTR_ENDIAN_SWITCH;
51 void BLI_endian_switch_uint32_array(unsigned int *val, const int size)    ATTR_ENDIAN_SWITCH;
52 void BLI_endian_switch_float_array(float *val, const int size)            ATTR_ENDIAN_SWITCH;
53 void BLI_endian_switch_int64_array(int64_t *val, const int size)          ATTR_ENDIAN_SWITCH;
54 void BLI_endian_switch_uint64_array(uint64_t *val, const int size)        ATTR_ENDIAN_SWITCH;
55 void BLI_endian_switch_double_array(double *val, const int size)          ATTR_ENDIAN_SWITCH;
56
57 #include "BLI_endian_switch_inline.h"
58
59 #undef ATTR_ENDIAN_SWITCH
60
61 #endif  /* __BLI_ENDIAN_SWITCH_H__ */