openal-soft/include/uintmap.h

36 lines
982 B
C
Raw Normal View History

2013-10-28 12:48:13 -07:00
#ifndef AL_UINTMAP_H
#define AL_UINTMAP_H
#include "AL/al.h"
#include "rwlock.h"
typedef struct UIntMap {
struct {
ALuint key;
ALvoid *value;
} *array;
ALsizei size;
ALsizei maxsize;
ALsizei limit;
RWLock lock;
} UIntMap;
#define UINTMAP_STATIC_INITIALIZE_N(_n) { NULL, 0, 0, (_n), RWLOCK_STATIC_INITIALIZE }
#define UINTMAP_STATIC_INITIALIZE UINTMAP_STATIC_INITIALIZE_N(~0)
2013-10-28 12:48:13 -07:00
void InitUIntMap(UIntMap *map, ALsizei limit);
void ResetUIntMap(UIntMap *map);
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key);
ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key);
2013-11-04 12:12:31 -08:00
inline void LockUIntMapRead(UIntMap *map)
2013-10-28 12:48:13 -07:00
{ ReadLock(&map->lock); }
2013-11-04 12:12:31 -08:00
inline void UnlockUIntMapRead(UIntMap *map)
2013-10-28 12:48:13 -07:00
{ ReadUnlock(&map->lock); }
2013-11-04 12:12:31 -08:00
inline void LockUIntMapWrite(UIntMap *map)
2013-10-28 12:48:13 -07:00
{ WriteLock(&map->lock); }
2013-11-04 12:12:31 -08:00
inline void UnlockUIntMapWrite(UIntMap *map)
2013-10-28 12:48:13 -07:00
{ WriteUnlock(&map->lock); }
#endif /* AL_UINTMAP_H */