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) 30 #if defined(AJA_WINDOWS) 36 #define AJA_PAGE_SIZE (4096) 38 #define AJA_MAX_PATH (256) 40 typedef signed __int8 int8_t;
41 typedef signed __int16 int16_t;
42 typedef signed __int32 int32_t;
43 typedef signed __int64 int64_t;
44 typedef unsigned __int8 uint8_t;
45 typedef unsigned __int16 uint16_t;
46 typedef unsigned __int32 uint32_t;
47 typedef unsigned __int64 uint64_t;
50 typedef signed __int64 intptr_t;
51 typedef unsigned __int64 uintptr_t;
54 typedef signed __int32 intptr_t;
55 typedef unsigned __int32 uintptr_t;
58 #define AJA_LITTLE_ENDIAN 61 #if defined(_MSC_VER) && _MSC_VER >= 1900 // VS2015 or later: 64 # define __PRI64_PREFIX "ll" 68 #define PRId64 __PRI64_PREFIX "d" 71 #define PRIi64 __PRI64_PREFIX "i" 74 #define PRIu64 __PRI64_PREFIX "u" 77 #define PRIo64 __PRI64_PREFIX "o" 80 #define PRIx64 __PRI64_PREFIX "x" 84 #define ajasnprintf(_str_, _maxbytes_, _format_, ...) _snprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ ) 85 #define ajavsnprintf(_str_, _maxbytes_, _format_, ...) vsprintf_s( _str_, _maxbytes_, _format_, __VA_ARGS__ ) 86 #define ajastrcasecmp(_str1_, _str2_) _stricmp( _str1_, _str2_ ) 87 #define ajawcscasecmp(_str1_, _str2_) _wcsicmp( _str1_, _str2_ ) 89 #endif // defined(AJA_WINDOWS) 91 #if defined(AJA_LINUX) 97 #define AJA_PAGE_SIZE (4096) 99 #define AJA_MAX_PATH (4096) 103 #include <linux/kernel.h> 104 #include <linux/string.h> 105 #include <linux/version.h> 107 typedef long int intptr_t;
109 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)) 110 typedef unsigned long int uintptr_t;
112 #elif !defined(powerpc) 113 typedef int intptr_t;
114 typedef unsigned int uintptr_t;
126 #if __BYTE_ORDER == __LITTLE_ENDIAN 127 #define AJA_LITTLE_ENDIAN 129 #define AJA_BIG_ENDIAN 133 #if CPU_ARCH == x86_64 134 # define __PRI64_PREFIX "l" 135 # define __PRIPTR_PREFIX "l" 137 # define __PRI64_PREFIX "ll" 138 # define __PRIPTR_PREFIX 143 #define PRId64 __PRI64_PREFIX "d" 146 #define PRIi64 __PRI64_PREFIX "i" 149 #define PRIu64 __PRI64_PREFIX "u" 152 #define PRIo64 __PRI64_PREFIX "o" 155 #define PRIx64 __PRI64_PREFIX "x" 160 #define ajasnprintf(_str_, _maxbytes_, _format_, ...) snprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ ) 161 #define ajavsnprintf(_str_, _maxbytes_, _format_, ...) vsnprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ ) 162 #define ajastrcasecmp(_str1_, _str2_) strcasecmp( _str1_, _str2_ ) 163 #define ajawcscasecmp(_str1_, _str2_) wcscasecmp( _str1_, _str2_ ) 165 #endif // defined(AJA_LINUX) 175 #define AJA_PAGE_SIZE (4096) 176 #define AJA_MAX_PATH (1024) 177 #define AJA_LITTLE_ENDIAN 188 # define __PRI64_PREFIX "l" 189 # define __PRIPTR_PREFIX "l" 191 # define __PRI64_PREFIX "ll" 192 # define __PRIPTR_PREFIX 197 #define PRId64 __PRI64_PREFIX "d" 200 #define PRIi64 __PRI64_PREFIX "i" 203 #define PRIu64 __PRI64_PREFIX "u" 206 #define PRIo64 __PRI64_PREFIX "o" 209 #define PRIx64 __PRI64_PREFIX "x" 213 #define ajasnprintf(_str_, _maxbytes_, _format_, ...) snprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ ) 214 #define ajavsnprintf(_str_, _maxbytes_, _format_, ...) vsnprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ ) 215 #define ajastrcasecmp(_str1_, _str2_) strcasecmp( _str1_, _str2_ ) 216 #define ajawcscasecmp(_str1_, _str2_) wcscasecmp( _str1_, _str2_ ) 218 #ifndef EXCLUDE_WCHAR 221 inline wchar_t wcstoupper(
wchar_t c)
226 if (c >= (
wchar_t)L
'a' && c <= (
wchar_t)L
'z')
227 newChar = c - (L
'a' - L
'A');
232 inline int wcscasecmp(
const wchar_t *string1,
const wchar_t *string2)
236 int str1Len = (int)wcslen(string1);
237 int str2Len = (int)wcslen(string2);
239 if(str1Len > str2Len)
241 else if(str1Len < str2Len)
246 for(
int i=0;i<str1Len;i++)
248 if(wcstoupper(string1[i]) != wcstoupper(string2[i]))
262 #endif // defined(AJA_MAC) 264 #if defined(AJA_BAREMETAL) 270 #if defined(AJA_USE_CPLUSPLUS11) 274 #define AJA_PAGE_SIZE (4096) 276 #define AJA_MAX_PATH (4096) 285 #define AJA_LITTLE_ENDIAN 287 #define __bswap16(_x) __builtin_bswap16(_x) 288 #define __bswap32(_x) __builtin_bswap32(_x) 289 #define __bswap64(_x) __builtin_bswap64(_x) 291 #define htonl(_x) __bswap32(_x) 292 #define htons(_x) __bswap16(_x) 293 #define ntohl(_x) __bswap32(_x) 294 #define ntohs(_x) __bswap16(_x) 297 # define __PRI64_PREFIX "ll" 298 # define __PRIPTR_PREFIX 302 #define PRId64 __PRI64_PREFIX "d" 305 #define PRIi64 __PRI64_PREFIX "i" 308 #define PRIu64 __PRI64_PREFIX "u" 311 #define PRIo64 __PRI64_PREFIX "o" 314 #define PRIx64 __PRI64_PREFIX "x" 319 #define ajasnprintf(_str_, _maxbytes_, _format_, ...) snprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ ) 320 #define ajavsnprintf(_str_, _maxbytes_, _format_, ...) vsnprintf( _str_, _maxbytes_, _format_, __VA_ARGS__ ) 321 #define ajastrcasecmp(_str1_, _str2_) strcasecmp( _str1_, _str2_ ) 322 #define ajawcscasecmp(_str1_, _str2_) wcscasecmp( _str1_, _str2_ ) 324 #endif // defined(AJA_BAREMETAL) 326 #if !defined(NULL_PTR) 334 #if defined(AJA_LITTLE_ENDIAN) 336 ( ((uint32_t)(((uint8_t *)(a))[3]) << 0) + \ 337 ((uint32_t)(((uint8_t *)(a))[2]) << 8) + \ 338 ((uint32_t)(((uint8_t *)(a))[1]) << 16) + \ 339 ((uint32_t)(((uint8_t *)(a))[0]) << 24) ) 342 ( ((uint32_t)(((uint8_t *)(a))[0]) << 0) + \ 343 ((uint32_t)(((uint8_t *)(a))[1]) << 8) + \ 344 ((uint32_t)(((uint8_t *)(a))[2]) << 16) + \ 345 ((uint32_t)(((uint8_t *)(a))[3]) << 24) ) 352 #if defined(AJA_LITTLE_ENDIAN) 353 #define AJA_FOURCC(a,b,c,d) \ 354 ( (((uint32_t)(a)) << 24) + \ 355 (((uint32_t)(b)) << 16) + \ 356 (((uint32_t)(c)) << 8) + \ 357 (((uint32_t)(d)) << 0) ) 359 #define AJA_FOURCC(a,b,c,d) \ 360 ( (((uint32_t)(a)) << 0) + \ 361 (((uint32_t)(b)) << 8) + \ 362 (((uint32_t)(c)) << 16) + \ 363 (((uint32_t)(d)) << 24) ) 365 #define AJA_FOURCC_2(a) (AJA_FOURCC(a,0,0,0)) 372 #define AJA_SUCCESS(_status_) (_status_ >= 0) 373 #define AJA_FAILURE(_status_) (_status_ < 0) 426 #define AJA_UNUSED(_x_) (void)_x_; 428 #define AJA_CHECK_NULL(_ptr_, _res_) { if (__ptr__ == NULL) { return _res_; } } 429 #define AJA_RETURN_STATUS(_status_) { const AJAStatus s = _status_; if (s != AJA_STATUS_SUCCESS) { return s; } } 432 #define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0])) 435 #define AJA_ENDIAN_SWAP16(_data_) ( ((uint16_t(_data_) << 8) & uint16_t(0xff00)) | \ 436 ((uint16_t(_data_) >> 8) & uint16_t(0x00ff)) ) 437 #define AJA_ENDIAN_SWAP32(_data_) ( ((uint32_t(_data_) << 24) & uint32_t(0xff000000)) | \ 438 ((uint32_t(_data_) << 8) & uint32_t(0x00ff0000)) | \ 439 ((uint32_t(_data_) >> 8) & uint32_t(0x0000ff00)) | \ 440 ((uint32_t(_data_) >> 24) & uint32_t(0x000000ff)) ) 441 #define AJA_ENDIAN_SWAP64(_data_) ( ((uint64_t(_data_) << 56) & uint64_t(0xff00000000000000)) | \ 442 ((uint64_t(_data_) << 40) & uint64_t(0x00ff000000000000)) | \ 443 ((uint64_t(_data_) << 24) & uint64_t(0x0000ff0000000000)) | \ 444 ((uint64_t(_data_) << 8) & uint64_t(0x000000ff00000000)) | \ 445 ((uint64_t(_data_) >> 8) & uint64_t(0x00000000ff000000)) | \ 446 ((uint64_t(_data_) >> 24) & uint64_t(0x0000000000ff0000)) | \ 447 ((uint64_t(_data_) >> 40) & uint64_t(0x000000000000ff00)) | \ 448 ((uint64_t(_data_) >> 56) & uint64_t(0x00000000000000ff)) ) 450 #endif // AJA_TYPES_H
Deprecation control macros.