-
Notifications
You must be signed in to change notification settings - Fork 0
/
defines.h
56 lines (47 loc) · 1.2 KB
/
defines.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef DEFINES_H
#define DEFINES_H
#include <stdint.h>
#ifdef WORDS_BIGENDIAN
#ifndef MAKEFOURCC
#define MAKEFOURCC( a, b, c, d) \
(((uint32_t)d) | (((uint32_t)c) << 8) | (((uint32_t)b) << 16) | (((uint32_t)a) << 24))
#endif
#else//WORD_BIGENDIAN
#ifndef MAKEFOURCC
#define MAKEFOURCC( a, b, c, d) \
(((uint32_t)a) | (((uint32_t)b) << 8) | (((uint32_t)c) << 16) | (((uint32_t)d) << 24))
#endif
#endif
static inline unsigned clz (unsigned x)
{
//#if VLC_GCC_VERSION(3,4)
return __builtin_clz (x);
//#else
// unsigned i = sizeof (x) * 8;
// while (x)
// {
// x >>= 1;
// i--;
// }
// return i;
//#endif
}
static inline int GetAlignedSize(unsigned size)
{
/* Return the smallest larger or equal power of 2 */
unsigned align = 1 << (8 * sizeof (unsigned) - clz(size));
return ((align >> 1) == size) ? size : align;
}
static inline bool HasExtension(const char *apis, const char *api)
{
size_t apilen = strlen(api);
while (apis) {
while (*apis == ' ')
apis++;
if (!strncmp(apis, api, apilen) && memchr(" ", apis[apilen], 2))
return true;
apis = strchr(apis, ' ');
}
return false;
}
#endif // DEFINES_H