openal-soft/common/uintmap.h

42 lines
1.1 KiB
C
Raw Normal View History

2013-10-28 12:48:13 -07:00
#ifndef AL_UINTMAP_H
#define AL_UINTMAP_H
2017-08-30 12:01:49 -07:00
#include <limits.h>
2013-10-28 12:48:13 -07:00
#include "AL/al.h"
#include "rwlock.h"
2014-05-29 04:22:30 -07:00
#ifdef __cplusplus
extern "C" {
#endif
2013-10-28 12:48:13 -07:00
typedef struct UIntMap {
ALuint *keys;
/* Shares memory with keys. */
ALvoid **values;
2013-10-28 12:48:13 -07:00
ALsizei size;
ALsizei capacity;
2013-10-28 12:48:13 -07: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 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);
inline void LockUIntMapRead(UIntMap *map) { ReadLock(&map->lock); }
inline void UnlockUIntMapRead(UIntMap *map) { ReadUnlock(&map->lock); }
inline void LockUIntMapWrite(UIntMap *map) { WriteLock(&map->lock); }
inline void UnlockUIntMapWrite(UIntMap *map) { WriteUnlock(&map->lock); }
2013-10-28 12:48:13 -07:00
2014-05-29 04:22:30 -07:00
#ifdef __cplusplus
}
#endif
2013-10-28 12:48:13 -07:00
#endif /* AL_UINTMAP_H */