AuroraOpenALSoft/common/uintmap.h

50 lines
1.3 KiB
C
Raw Normal View History

2013-10-28 19:48:13 +00:00
#ifndef AL_UINTMAP_H
#define AL_UINTMAP_H
2017-08-30 19:01:49 +00:00
#include <limits.h>
2013-10-28 19:48:13 +00:00
#include "AL/al.h"
#include "rwlock.h"
2014-05-29 11:22:30 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2013-10-28 19:48:13 +00:00
typedef struct UIntMap {
ALuint *keys;
/* Shares memory with keys. */
ALvoid **values;
2013-10-28 19:48:13 +00:00
ALsizei size;
ALsizei capacity;
2013-10-28 19:48:13 +00:00
ALsizei limit;
RWLock lock;
} UIntMap;
#define UINTMAP_STATIC_INITIALIZE_N(_n) { NULL, NULL, 0, 0, (_n), RWLOCK_STATIC_INITIALIZE }
#define UINTMAP_STATIC_INITIALIZE UINTMAP_STATIC_INITIALIZE_N(INT_MAX)
2013-10-28 19:48:13 +00:00
void InitUIntMap(UIntMap *map, ALsizei limit);
void ResetUIntMap(UIntMap *map);
void RelimitUIntMapNoLock(UIntMap *map, ALsizei limit);
2013-10-28 19:48:13 +00:00
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
ALenum InsertUIntMapEntryNoLock(UIntMap *map, ALuint key, ALvoid *value);
2013-10-28 19:48:13 +00:00
ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key);
ALvoid *RemoveUIntMapKeyNoLock(UIntMap *map, ALuint key);
2013-10-28 19:48:13 +00:00
ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key);
ALvoid *LookupUIntMapKeyNoLock(UIntMap *map, ALuint key);
2013-10-28 19:48:13 +00:00
2013-11-04 20:12:31 +00:00
inline void LockUIntMapRead(UIntMap *map)
2013-10-28 19:48:13 +00:00
{ ReadLock(&map->lock); }
2013-11-04 20:12:31 +00:00
inline void UnlockUIntMapRead(UIntMap *map)
2013-10-28 19:48:13 +00:00
{ ReadUnlock(&map->lock); }
2013-11-04 20:12:31 +00:00
inline void LockUIntMapWrite(UIntMap *map)
2013-10-28 19:48:13 +00:00
{ WriteLock(&map->lock); }
2013-11-04 20:12:31 +00:00
inline void UnlockUIntMapWrite(UIntMap *map)
2013-10-28 19:48:13 +00:00
{ WriteUnlock(&map->lock); }
2014-05-29 11:22:30 +00:00
#ifdef __cplusplus
}
#endif
2013-10-28 19:48:13 +00:00
#endif /* AL_UINTMAP_H */