ladybird/AK/Traits.h
Andreas Kling e6284a8774 Fix broken SpinLock.
The SpinLock was all backwards and didn't actually work. Fixing it exposed
how wrong most of the locking here is.

I need to come up with a better granularity here.
2018-10-29 22:04:26 +01:00

39 lines
692 B
C++

#pragma once
#include "kstdio.h"
#include "HashFunctions.h"
namespace AK {
template<typename T>
struct Traits
{
};
template<>
struct Traits<int> {
static unsigned hash(int i) { return intHash(i); }
static void dump(int i) { kprintf("%d", i); }
};
template<>
struct Traits<unsigned> {
static unsigned hash(unsigned u) { return intHash(u); }
static void dump(unsigned u) { kprintf("%u", u); }
};
template<typename T>
struct Traits<T*> {
static unsigned hash(const T* p)
{
#ifdef SERENITY
return intHash((dword)p);
#else
return intHash((unsigned long long)p & 0xffffffff);
#endif
}
static void dump(const T* p) { kprintf("%p", p); }
};
}