24 #if !defined(AJA_USE_CPLUSPLUS11)
25 #define AJA_USE_CPLUSPLUS11 // If defined, use C++11 features (requires C++11 compiler)
26 #endif // !defined(AJA_USE_CPLUSPLUS11)
28 #if defined(AJA_WINDOWS)
34 #define AJA_PAGE_SIZE (4096)
36 #define AJA_MAX_PATH (256)
38 typedef signed __int8 int8_t;
39 typedef signed __int16 int16_t;
40 typedef signed __int32 int32_t;
41 typedef signed __int64 int64_t;
42 typedef unsigned __int8 uint8_t;
43 typedef unsigned __int16 uint16_t;
44 typedef unsigned __int32 uint32_t;
45 typedef unsigned __int64 uint64_t;
48 typedef signed __int64 intptr_t;
49 typedef unsigned __int64 uintptr_t;
52 typedef signed __int32 intptr_t;
53 typedef unsigned __int32 uintptr_t;
56 #define AJA_LITTLE_ENDIAN
59 #if defined(_MSC_VER) && _MSC_VER >= 1900 // VS2015 or later:
62 # define __PRI64_PREFIX "ll"
66 #define PRId64 __PRI64_PREFIX "d"
69 #define PRIi64 __PRI64_PREFIX "i"
72 #define PRIu64 __PRI64_PREFIX "u"
75 #define PRIo64 __PRI64_PREFIX "o"
78 #define PRIx64 __PRI64_PREFIX "x"
82 #define ajasnprintf(_str_, _maxbytes_, _format_, ...) _snprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ )
83 #define ajavsnprintf(_str_, _maxbytes_, _format_, ...) vsprintf_s( _str_, _maxbytes_, _format_, __VA_ARGS__ )
84 #define ajastrcasecmp(_str1_, _str2_) _stricmp( _str1_, _str2_ )
85 #define ajawcscasecmp(_str1_, _str2_) _wcsicmp( _str1_, _str2_ )
87 #endif // defined(AJA_WINDOWS)
89 #if defined(AJA_LINUX)
95 #define AJA_PAGE_SIZE (4096)
97 #define AJA_MAX_PATH (4096)
101 #include <linux/kernel.h>
102 #include <linux/string.h>
103 #include <linux/version.h>
105 typedef long int intptr_t;
107 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18))
108 typedef unsigned long int uintptr_t;
110 #elif !defined(powerpc)
111 typedef int intptr_t;
112 typedef unsigned int uintptr_t;
124 #if __BYTE_ORDER == __LITTLE_ENDIAN
125 #define AJA_LITTLE_ENDIAN
127 #define AJA_BIG_ENDIAN
131 #if CPU_ARCH == x86_64
132 # define __PRI64_PREFIX "l"
133 # define __PRIPTR_PREFIX "l"
135 # define __PRI64_PREFIX "ll"
136 # define __PRIPTR_PREFIX
141 #define PRId64 __PRI64_PREFIX "d"
144 #define PRIi64 __PRI64_PREFIX "i"
147 #define PRIu64 __PRI64_PREFIX "u"
150 #define PRIo64 __PRI64_PREFIX "o"
153 #define PRIx64 __PRI64_PREFIX "x"
158 #define ajasnprintf(_str_, _maxbytes_, _format_, ...) snprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ )
159 #define ajavsnprintf(_str_, _maxbytes_, _format_, ...) vsnprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ )
160 #define ajastrcasecmp(_str1_, _str2_) strcasecmp( _str1_, _str2_ )
161 #define ajawcscasecmp(_str1_, _str2_) wcscasecmp( _str1_, _str2_ )
163 #endif // defined(AJA_LINUX)
173 #define AJA_PAGE_SIZE (4096)
174 #define AJA_MAX_PATH (1024)
175 #define AJA_LITTLE_ENDIAN
186 # define __PRI64_PREFIX "l"
187 # define __PRIPTR_PREFIX "l"
189 # define __PRI64_PREFIX "ll"
190 # define __PRIPTR_PREFIX
195 #define PRId64 __PRI64_PREFIX "d"
198 #define PRIi64 __PRI64_PREFIX "i"
201 #define PRIu64 __PRI64_PREFIX "u"
204 #define PRIo64 __PRI64_PREFIX "o"
207 #define PRIx64 __PRI64_PREFIX "x"
211 #define ajasnprintf(_str_, _maxbytes_, _format_, ...) snprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ )
212 #define ajavsnprintf(_str_, _maxbytes_, _format_, ...) vsnprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ )
213 #define ajastrcasecmp(_str1_, _str2_) strcasecmp( _str1_, _str2_ )
214 #define ajawcscasecmp(_str1_, _str2_) wcscasecmp( _str1_, _str2_ )
216 #ifndef EXCLUDE_WCHAR
219 inline wchar_t wcstoupper(
wchar_t c)
224 if (c >= (
wchar_t)L
'a' && c <= (
wchar_t)L
'z')
225 newChar = c - (L
'a' - L
'A');
230 inline int wcscasecmp(
const wchar_t *string1,
const wchar_t *string2)
234 int str1Len = (int)wcslen(string1);
235 int str2Len = (int)wcslen(string2);
237 if(str1Len > str2Len)
239 else if(str1Len < str2Len)
244 for(
int i=0;i<str1Len;i++)
246 if(wcstoupper(string1[i]) != wcstoupper(string2[i]))
260 #endif // defined(AJA_MAC)
262 #if defined(AJA_BAREMETAL)
268 #if defined(AJA_USE_CPLUSPLUS11)
272 #define AJA_PAGE_SIZE (4096)
274 #define AJA_MAX_PATH (4096)
283 #define AJA_LITTLE_ENDIAN
285 #define __bswap16(_x) __builtin_bswap16(_x)
286 #define __bswap32(_x) __builtin_bswap32(_x)
287 #define __bswap64(_x) __builtin_bswap64(_x)
289 #define htonl(_x) __bswap32(_x)
290 #define htons(_x) __bswap16(_x)
291 #define ntohl(_x) __bswap32(_x)
292 #define ntohs(_x) __bswap16(_x)
295 # define __PRI64_PREFIX "ll"
296 # define __PRIPTR_PREFIX
300 #define PRId64 __PRI64_PREFIX "d"
303 #define PRIi64 __PRI64_PREFIX "i"
306 #define PRIu64 __PRI64_PREFIX "u"
309 #define PRIo64 __PRI64_PREFIX "o"
312 #define PRIx64 __PRI64_PREFIX "x"
317 #define ajasnprintf(_str_, _maxbytes_, _format_, ...) snprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ )
318 #define ajavsnprintf(_str_, _maxbytes_, _format_, ...) vsnprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ )
319 #define ajastrcasecmp(_str1_, _str2_) strcasecmp( _str1_, _str2_ )
320 #define ajawcscasecmp(_str1_, _str2_) wcscasecmp( _str1_, _str2_ )
322 #endif // defined(AJA_BAREMETAL)
324 #if !defined(NULL_PTR)
332 #if defined(AJA_LITTLE_ENDIAN)
334 ( ((uint32_t)(((uint8_t *)(a))[3]) << 0) + \
335 ((uint32_t)(((uint8_t *)(a))[2]) << 8) + \
336 ((uint32_t)(((uint8_t *)(a))[1]) << 16) + \
337 ((uint32_t)(((uint8_t *)(a))[0]) << 24) )
340 ( ((uint32_t)(((uint8_t *)(a))[0]) << 0) + \
341 ((uint32_t)(((uint8_t *)(a))[1]) << 8) + \
342 ((uint32_t)(((uint8_t *)(a))[2]) << 16) + \
343 ((uint32_t)(((uint8_t *)(a))[3]) << 24) )
350 #if defined(AJA_LITTLE_ENDIAN)
351 #define AJA_FOURCC(a,b,c,d) \
352 ( (((uint32_t)(a)) << 24) + \
353 (((uint32_t)(b)) << 16) + \
354 (((uint32_t)(c)) << 8) + \
355 (((uint32_t)(d)) << 0) )
357 #define AJA_FOURCC(a,b,c,d) \
358 ( (((uint32_t)(a)) << 0) + \
359 (((uint32_t)(b)) << 8) + \
360 (((uint32_t)(c)) << 16) + \
361 (((uint32_t)(d)) << 24) )
363 #define AJA_FOURCC_2(a) (AJA_FOURCC(a,0,0,0))
370 #define AJA_SUCCESS(_status_) (_status_ >= 0)
371 #define AJA_FAILURE(_status_) (_status_ < 0)
424 #define AJA_UNUSED(_x_) (void)_x_;
426 #define AJA_CHECK_NULL(_ptr_, _res_) { if (__ptr__ == NULL) { return _res_; } }
427 #define AJA_RETURN_STATUS(_status_) { const AJAStatus s = _status_; if (s != AJA_STATUS_SUCCESS) { return s; } }
430 #define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
433 #define AJA_ENDIAN_SWAP16(_data_) ( ((uint16_t(_data_) << 8) & uint16_t(0xff00)) | \
434 ((uint16_t(_data_) >> 8) & uint16_t(0x00ff)) )
435 #define AJA_ENDIAN_SWAP32(_data_) ( ((uint32_t(_data_) << 24) & uint32_t(0xff000000)) | \
436 ((uint32_t(_data_) << 8) & uint32_t(0x00ff0000)) | \
437 ((uint32_t(_data_) >> 8) & uint32_t(0x0000ff00)) | \
438 ((uint32_t(_data_) >> 24) & uint32_t(0x000000ff)) )
439 #define AJA_ENDIAN_SWAP64(_data_) ( ((uint64_t(_data_) << 56) & uint64_t(0xff00000000000000)) | \
440 ((uint64_t(_data_) << 40) & uint64_t(0x00ff000000000000)) | \
441 ((uint64_t(_data_) << 24) & uint64_t(0x0000ff0000000000)) | \
442 ((uint64_t(_data_) << 8) & uint64_t(0x000000ff00000000)) | \
443 ((uint64_t(_data_) >> 8) & uint64_t(0x00000000ff000000)) | \
444 ((uint64_t(_data_) >> 24) & uint64_t(0x0000000000ff0000)) | \
445 ((uint64_t(_data_) >> 40) & uint64_t(0x000000000000ff00)) | \
446 ((uint64_t(_data_) >> 56) & uint64_t(0x00000000000000ff)) )
448 #endif // AJA_TYPES_H