blob: 34f73864766856ebb401138b32a33c2c54859d31 (
plain)
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
|
#ifndef ALHELPERS_H
#define ALHELPERS_H
#include "AL/al.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Some helper functions to get the name from the format enums. */
const char *FormatName(ALenum type);
/* Easy device init/deinit functions. InitAL returns 0 on success. */
int InitAL(char ***argv, int *argc);
void CloseAL(void);
/* Cross-platform timeget and sleep functions. */
int altime_get(void);
void al_nssleep(unsigned long nsec);
/* C doesn't allow casting between function and non-function pointer types, so
* with C99 we need to use a union to reinterpret the pointer type. Pre-C99
* still needs to use a normal cast and live with the warning (C++ is fine with
* a regular reinterpret_cast).
*/
#if __STDC_VERSION__ >= 199901L
#define FUNCTION_CAST(T, ptr) (union{void *p; T f;}){ptr}.f
#elif defined(__cplusplus)
#define FUNCTION_CAST(T, ptr) reinterpret_cast<T>(ptr)
#else
#define FUNCTION_CAST(T, ptr) (T)(ptr)
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* ALHELPERS_H */
|