| 1 |
#ifndef PA_TYPES_H |
| 2 |
#define PA_TYPES_H |
| 3 |
|
| 4 |
/* |
| 5 |
* Portable Audio I/O Library |
| 6 |
* integer type definitions |
| 7 |
* |
| 8 |
* Based on the Open Source API proposed by Ross Bencina |
| 9 |
* Copyright (c) 1999-2006 Ross Bencina, Phil Burk |
| 10 |
* |
| 11 |
* Permission is hereby granted, free of charge, to any person obtaining |
| 12 |
* a copy of this software and associated documentation files |
| 13 |
* (the "Software"), to deal in the Software without restriction, |
| 14 |
* including without limitation the rights to use, copy, modify, merge, |
| 15 |
* publish, distribute, sublicense, and/or sell copies of the Software, |
| 16 |
* and to permit persons to whom the Software is furnished to do so, |
| 17 |
* subject to the following conditions: |
| 18 |
* |
| 19 |
* The above copyright notice and this permission notice shall be |
| 20 |
* included in all copies or substantial portions of the Software. |
| 21 |
* |
| 22 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 23 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 24 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 25 |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR |
| 26 |
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 27 |
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 28 |
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 29 |
*/ |
| 30 |
|
| 31 |
/* |
| 32 |
* The text above constitutes the entire PortAudio license; however, |
| 33 |
* the PortAudio community also makes the following non-binding requests: |
| 34 |
* |
| 35 |
* Any person wishing to distribute modifications to the Software is |
| 36 |
* requested to send the modifications to the original developer so that |
| 37 |
* they can be incorporated into the canonical version. It is also |
| 38 |
* requested that these non-binding requests be included along with the |
| 39 |
* license above. |
| 40 |
*/ |
| 41 |
|
| 42 |
/** @file |
| 43 |
@ingroup common_src |
| 44 |
|
| 45 |
@brief Definition of 16 and 32 bit integer types (PaInt16, PaInt32 etc) |
| 46 |
|
| 47 |
SIZEOF_SHORT, SIZEOF_INT and SIZEOF_LONG are set by the configure script |
| 48 |
when it is used. Otherwise we default to the common 32 bit values, if your |
| 49 |
platform doesn't use configure, and doesn't use the default values below |
| 50 |
you will need to explicitly define these symbols in your make file. |
| 51 |
|
| 52 |
A PA_VALIDATE_SIZES macro is provided to assert that the values set in this |
| 53 |
file are correct. |
| 54 |
*/ |
| 55 |
|
| 56 |
#ifndef SIZEOF_SHORT |
| 57 |
#define SIZEOF_SHORT 2 |
| 58 |
#endif |
| 59 |
|
| 60 |
#ifndef SIZEOF_INT |
| 61 |
#define SIZEOF_INT 4 |
| 62 |
#endif |
| 63 |
|
| 64 |
#ifndef SIZEOF_LONG |
| 65 |
#define SIZEOF_LONG 4 |
| 66 |
#endif |
| 67 |
|
| 68 |
|
| 69 |
#if SIZEOF_SHORT == 2 |
| 70 |
typedef signed short PaInt16; |
| 71 |
typedef unsigned short PaUint16; |
| 72 |
#elif SIZEOF_INT == 2 |
| 73 |
typedef signed int PaInt16; |
| 74 |
typedef unsigned int PaUint16; |
| 75 |
#else |
| 76 |
#error pa_types.h was unable to determine which type to use for 16bit integers on the target platform |
| 77 |
#endif |
| 78 |
|
| 79 |
#if SIZEOF_SHORT == 4 |
| 80 |
typedef signed short PaInt32; |
| 81 |
typedef unsigned short PaUint32; |
| 82 |
#elif SIZEOF_INT == 4 |
| 83 |
typedef signed int PaInt32; |
| 84 |
typedef unsigned int PaUint32; |
| 85 |
#elif SIZEOF_LONG == 4 |
| 86 |
typedef signed long PaInt32; |
| 87 |
typedef unsigned long PaUint32; |
| 88 |
#else |
| 89 |
#error pa_types.h was unable to determine which type to use for 32bit integers on the target platform |
| 90 |
#endif |
| 91 |
|
| 92 |
|
| 93 |
/* PA_VALIDATE_TYPE_SIZES compares the size of the integer types at runtime to |
| 94 |
ensure that PortAudio was configured correctly, and raises an assertion if |
| 95 |
they don't match the expected values. <assert.h> must be included in the |
| 96 |
context in which this macro is used. |
| 97 |
*/ |
| 98 |
#define PA_VALIDATE_TYPE_SIZES \ |
| 99 |
{ \ |
| 100 |
assert( "PortAudio: type sizes are not correct in pa_types.h" && sizeof( PaUint16 ) == 2 ); \ |
| 101 |
assert( "PortAudio: type sizes are not correct in pa_types.h" && sizeof( PaInt16 ) == 2 ); \ |
| 102 |
assert( "PortAudio: type sizes are not correct in pa_types.h" && sizeof( PaUint32 ) == 4 ); \ |
| 103 |
assert( "PortAudio: type sizes are not correct in pa_types.h" && sizeof( PaInt32 ) == 4 ); \ |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
#endif /* PA_TYPES_H */ |