To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at https://github.com/sonic-visualiser/sv-dependency-builds .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / src / portaudio_20161030_catalina_patch / src / common / pa_endianness.h @ 164:9fa11135915a

History | View | Annotate | Download (5.34 KB)

1
#ifndef PA_ENDIANNESS_H
2
#define PA_ENDIANNESS_H
3
/*
4
 * $Id$
5
 * Portable Audio I/O Library current platform endianness macros
6
 *
7
 * Based on the Open Source API proposed by Ross Bencina
8
 * Copyright (c) 1999-2002 Phil Burk, Ross Bencina
9
 *
10
 * Permission is hereby granted, free of charge, to any person obtaining
11
 * a copy of this software and associated documentation files
12
 * (the "Software"), to deal in the Software without restriction,
13
 * including without limitation the rights to use, copy, modify, merge,
14
 * publish, distribute, sublicense, and/or sell copies of the Software,
15
 * and to permit persons to whom the Software is furnished to do so,
16
 * subject to the following conditions:
17
 *
18
 * The above copyright notice and this permission notice shall be
19
 * included in all copies or substantial portions of the Software.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
25
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
 */
29

    
30
/*
31
 * The text above constitutes the entire PortAudio license; however, 
32
 * the PortAudio community also makes the following non-binding requests:
33
 *
34
 * Any person wishing to distribute modifications to the Software is
35
 * requested to send the modifications to the original developer so that
36
 * they can be incorporated into the canonical version. It is also 
37
 * requested that these non-binding requests be included along with the 
38
 * license above.
39
 */
40

    
41
/** @file
42
 @ingroup common_src
43

44
 @brief Configure endianness symbols for the target processor.
45

46
 Arrange for either the PA_LITTLE_ENDIAN or PA_BIG_ENDIAN preprocessor symbols
47
 to be defined. The one that is defined reflects the endianness of the target
48
 platform and may be used to implement conditional compilation of byte-order
49
 dependent code.
50

51
 If either PA_LITTLE_ENDIAN or PA_BIG_ENDIAN is defined already, then no attempt
52
 is made to override that setting. This may be useful if you have a better way
53
 of determining the platform's endianness. The autoconf mechanism uses this for
54
 example.
55

56
 A PA_VALIDATE_ENDIANNESS macro is provided to compare the compile time
57
 and runtime endiannes and raise an assertion if they don't match.
58
*/
59

    
60

    
61
#ifdef __cplusplus
62
extern "C"
63
{
64
#endif /* __cplusplus */
65

    
66
/* If this is an apple, we need to do detect endianness this way */
67
#if defined(__APPLE__)
68
    /* we need to do some endian detection that is sensitive to harware arch */
69
    #if defined(__LITTLE_ENDIAN__)
70
       #if !defined( PA_LITTLE_ENDIAN )
71
          #define PA_LITTLE_ENDIAN
72
       #endif
73
       #if defined( PA_BIG_ENDIAN )
74
          #undef PA_BIG_ENDIAN
75
       #endif
76
    #else
77
       #if !defined( PA_BIG_ENDIAN )
78
          #define PA_BIG_ENDIAN
79
       #endif
80
       #if defined( PA_LITTLE_ENDIAN )
81
          #undef PA_LITTLE_ENDIAN
82
       #endif
83
    #endif
84
#else
85
    /* this is not an apple, so first check the existing defines, and, failing that,
86
       detect well-known architechtures. */
87

    
88
    #if defined(PA_LITTLE_ENDIAN) || defined(PA_BIG_ENDIAN)
89
        /* endianness define has been set externally, such as by autoconf */
90

    
91
        #if defined(PA_LITTLE_ENDIAN) && defined(PA_BIG_ENDIAN)
92
        #error both PA_LITTLE_ENDIAN and PA_BIG_ENDIAN have been defined externally to pa_endianness.h - only one endianness at a time please
93
        #endif
94

    
95
    #else
96
        /* endianness define has not been set externally */
97

    
98
        /* set PA_LITTLE_ENDIAN or PA_BIG_ENDIAN by testing well known platform specific defines */
99

    
100
        #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(LITTLE_ENDIAN) || defined(__i386) || defined(_M_IX86) || defined(__x86_64__)
101
            #define PA_LITTLE_ENDIAN /* win32, assume intel byte order */
102
        #else
103
            #define PA_BIG_ENDIAN
104
        #endif
105
    #endif
106

    
107
    #if !defined(PA_LITTLE_ENDIAN) && !defined(PA_BIG_ENDIAN)
108
        /*
109
         If the following error is raised, you either need to modify the code above
110
         to automatically determine the endianness from other symbols defined on your
111
         platform, or define either PA_LITTLE_ENDIAN or PA_BIG_ENDIAN externally.
112
        */
113
        #error pa_endianness.h was unable to automatically determine the endianness of the target platform
114
    #endif
115

    
116
#endif
117

    
118

    
119
/* PA_VALIDATE_ENDIANNESS compares the compile time and runtime endianness,
120
 and raises an assertion if they don't match. <assert.h> must be included in
121
 the context in which this macro is used.
122
*/
123
#if defined(NDEBUG)
124
    #define PA_VALIDATE_ENDIANNESS
125
#else
126
    #if defined(PA_LITTLE_ENDIAN)
127
        #define PA_VALIDATE_ENDIANNESS \
128
        { \
129
            const long nativeOne = 1; \
130
            assert( "PortAudio: compile time and runtime endianness don't match" && (((char *)&nativeOne)[0]) == 1 ); \
131
        }
132
    #elif defined(PA_BIG_ENDIAN)
133
        #define PA_VALIDATE_ENDIANNESS \
134
        { \
135
            const long nativeOne = 1; \
136
            assert( "PortAudio: compile time and runtime endianness don't match" && (((char *)&nativeOne)[0]) == 0 ); \
137
        }
138
    #endif
139
#endif
140

    
141

    
142
#ifdef __cplusplus
143
}
144
#endif /* __cplusplus */
145
#endif /* PA_ENDIANNESS_H */