Add lock and malloc annotations to the code.
This commit is contained in:
parent
562cfeec44
commit
67578f14b7
@ -8,12 +8,33 @@
|
|||||||
#define PERCORE __attribute__((section(".data.percore")))
|
#define PERCORE __attribute__((section(".data.percore")))
|
||||||
|
|
||||||
#define INLINE inline
|
#define INLINE inline
|
||||||
#define NO_RETURN __attribute__((noreturn))
|
#define ALWAYS_INLINE __attribute__((__always_inline__))
|
||||||
|
|
||||||
|
#define NO_RETURN __attribute__((noreturn))
|
||||||
#define UNREACHABLE __builtin_unreachable
|
#define UNREACHABLE __builtin_unreachable
|
||||||
|
|
||||||
#define ROUNDUP(_x, _n) (((_x) + (_n) - 1) & ~((_n) - 1))
|
#define ROUNDUP(_x, _n) (((_x) + (_n) - 1) & ~((_n) - 1))
|
||||||
|
|
||||||
|
#define __MALLOC __attribute__((__malloc__))
|
||||||
|
|
||||||
|
#if __has_extension(c_thread_safety_attributes)
|
||||||
|
#define __NO_LOCK_ANALYSIS __attribute__((no_thread_safety_analysis))
|
||||||
|
#define __LOCKABLE __attribute__((lockable))
|
||||||
|
#define __LOCK_EX(_x) __attribute__((exclusive_lock_function(_x)))
|
||||||
|
#define __TRYLOCK_EX(_x) __attribute__((exclusive_trylock_function(_x)))
|
||||||
|
#define __UNLOCK_EX(_x) __attribute__((unlock_function(_x)))
|
||||||
|
#define __LOCK_EX_ASSERT(_x) __attribute__((assert_exclusive_lock(_x)))
|
||||||
|
#define __GUARDED_BY(_x) __attribute__((guarded_by(_x)))
|
||||||
|
#else
|
||||||
|
#define __NO_LOCK_ANALYSIS
|
||||||
|
#define __LOCKABLE
|
||||||
|
#define __LOCK_EX(_x)
|
||||||
|
#define __TRYLOCK_EX(_x)
|
||||||
|
#define __UNLOCK_EX(_x)
|
||||||
|
#define __LOCK_EX_ASSERT(_x)
|
||||||
|
#define __GUARDED_BY(_x)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define __hidden __attribute__((__visibility__("hidden")))
|
#define __hidden __attribute__((__visibility__("hidden")))
|
||||||
|
|
||||||
#define __printflike(_fmt, _var) __attribute__((__format__(__printf__, _fmt, _var)))
|
#define __printflike(_fmt, _var) __attribute__((__format__(__printf__, _fmt, _var)))
|
||||||
|
@ -59,7 +59,7 @@ typedef struct Slab {
|
|||||||
} Slab;
|
} Slab;
|
||||||
|
|
||||||
void Slab_Init(Slab *slab, const char *name, uintptr_t objsz, uintptr_t align);
|
void Slab_Init(Slab *slab, const char *name, uintptr_t objsz, uintptr_t align);
|
||||||
void *Slab_Alloc(Slab *slab);
|
void *Slab_Alloc(Slab *slab) __attribute__((malloc));
|
||||||
void Slab_Free(Slab *slab, void *obj);
|
void Slab_Free(Slab *slab, void *obj);
|
||||||
|
|
||||||
#define DECLARE_SLAB(_type) \
|
#define DECLARE_SLAB(_type) \
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#ifndef __SPINLOCK_H__
|
#ifndef __SPINLOCK_H__
|
||||||
#define __SPINLOCK_H__
|
#define __SPINLOCK_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
|
||||||
#define SPINLOCK_NAMELEN 32
|
#define SPINLOCK_NAMELEN 32
|
||||||
@ -22,7 +25,7 @@ typedef struct Spinlock
|
|||||||
char name[SPINLOCK_NAMELEN];
|
char name[SPINLOCK_NAMELEN];
|
||||||
LIST_ENTRY(Spinlock) lockList;
|
LIST_ENTRY(Spinlock) lockList;
|
||||||
TAILQ_ENTRY(Spinlock) lockStack;
|
TAILQ_ENTRY(Spinlock) lockStack;
|
||||||
} Spinlock;
|
} __LOCKABLE Spinlock;
|
||||||
|
|
||||||
void Critical_Init();
|
void Critical_Init();
|
||||||
void Critical_Enter();
|
void Critical_Enter();
|
||||||
@ -31,9 +34,9 @@ void Critical_Exit();
|
|||||||
void Spinlock_EarlyInit();
|
void Spinlock_EarlyInit();
|
||||||
void Spinlock_Init(Spinlock *lock, const char *name, uint64_t type);
|
void Spinlock_Init(Spinlock *lock, const char *name, uint64_t type);
|
||||||
void Spinlock_Destroy(Spinlock *lock);
|
void Spinlock_Destroy(Spinlock *lock);
|
||||||
void Spinlock_Lock(Spinlock *lock);
|
void Spinlock_Lock(Spinlock *lock) __LOCK_EX(*lock);
|
||||||
void Spinlock_Unlock(Spinlock *lock);
|
void Spinlock_Unlock(Spinlock *lock) __UNLOCK_EX(*lock);
|
||||||
bool Spinlock_IsHeld(Spinlock *lock);
|
bool Spinlock_IsHeld(Spinlock *lock) __LOCK_EX_ASSERT(*lock);
|
||||||
|
|
||||||
#endif /* __SPINLOCK_H__ */
|
#endif /* __SPINLOCK_H__ */
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ Spinlock_Destroy(Spinlock *lock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Spinlock_Lock(Spinlock *lock)
|
Spinlock_Lock(Spinlock *lock) __NO_LOCK_ANALYSIS
|
||||||
{
|
{
|
||||||
uint64_t startTSC;
|
uint64_t startTSC;
|
||||||
Critical_Enter();
|
Critical_Enter();
|
||||||
@ -91,7 +91,7 @@ Spinlock_Lock(Spinlock *lock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Spinlock_Unlock(Spinlock *lock)
|
Spinlock_Unlock(Spinlock *lock) __NO_LOCK_ANALYSIS
|
||||||
{
|
{
|
||||||
ASSERT(lock->cpu == CPU());
|
ASSERT(lock->cpu == CPU());
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ Thread_Wait(Thread *thr, uint64_t tid)
|
|||||||
extern TaskStateSegment64 TSS[MAX_CPUS];
|
extern TaskStateSegment64 TSS[MAX_CPUS];
|
||||||
|
|
||||||
void
|
void
|
||||||
ThreadKThreadEntry(TrapFrame *tf)
|
ThreadKThreadEntry(TrapFrame *tf) __NO_LOCK_ANALYSIS
|
||||||
{
|
{
|
||||||
TSS[CPU()].rsp0 = curProc[CPU()]->kstack + 4096;
|
TSS[CPU()].rsp0 = curProc[CPU()]->kstack + 4096;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user