* Added AutoLocker instantiations IterruptsLocker (disables/restores
interrupts) and SpinLocker (acquires/releases spinlocks). * Adjusted Jamfiles of components that used <util/AutoLock.h> but didn't add all header directories required now (<int.h> was added). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21873 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5378efc0db
commit
bce7e9f695
@ -6,9 +6,13 @@
|
||||
#define KERNEL_UTIL_AUTO_LOCKER_H
|
||||
|
||||
|
||||
#include <lock.h>
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <shared/AutoLocker.h>
|
||||
|
||||
#include <int.h>
|
||||
#include <lock.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
@ -63,11 +67,60 @@ public:
|
||||
// BenaphoreLocker
|
||||
typedef AutoLocker<benaphore, BenaphoreLocking> BenaphoreLocker;
|
||||
|
||||
// InterruptsLocking
|
||||
class InterruptsLocking {
|
||||
public:
|
||||
inline bool Lock(int* lockable)
|
||||
{
|
||||
*lockable = disable_interrupts();
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void Unlock(int* lockable)
|
||||
{
|
||||
restore_interrupts(*lockable);
|
||||
}
|
||||
};
|
||||
|
||||
// InterruptsLocker
|
||||
class InterruptsLocker : AutoLocker<int, InterruptsLocking> {
|
||||
public:
|
||||
inline InterruptsLocker(bool alreadyLocked = false,
|
||||
bool lockIfNotLocked = true)
|
||||
: AutoLocker<int, InterruptsLocking>(&fState, alreadyLocked,
|
||||
lockIfNotLocked)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
int fState;
|
||||
};
|
||||
|
||||
// SpinLocking
|
||||
class SpinLocking {
|
||||
public:
|
||||
inline bool Lock(spinlock* lockable)
|
||||
{
|
||||
acquire_spinlock(lockable);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void Unlock(spinlock* lockable)
|
||||
{
|
||||
release_spinlock(lockable);
|
||||
}
|
||||
};
|
||||
|
||||
// SpinLocker
|
||||
typedef AutoLocker<spinlock, SpinLocking> SpinLocker;
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using BPrivate::AutoLocker;
|
||||
using BPrivate::MutexLocker;
|
||||
using BPrivate::RecursiveLocker;
|
||||
using BPrivate::BenaphoreLocker;
|
||||
using BPrivate::InterruptsLocker;
|
||||
using BPrivate::SpinLocker;
|
||||
|
||||
#endif // KERNEL_UTIL_AUTO_LOCKER_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
SubDir HAIKU_TOP src add-ons kernel drivers tty ;
|
||||
|
||||
UsePrivateHeaders kernel ;
|
||||
UsePrivateKernelHeaders ;
|
||||
|
||||
KernelAddon <driver>tty :
|
||||
driver.cpp
|
||||
|
@ -10,7 +10,8 @@ if $(TARGET_PLATFORM) != haiku {
|
||||
# Unfortunately we get more than we want, namely all POSIX headers.
|
||||
}
|
||||
|
||||
UsePrivateHeaders kernel net ;
|
||||
UsePrivateKernelHeaders ;
|
||||
UsePrivateHeaders net ;
|
||||
|
||||
KernelAddon <module>arp :
|
||||
arp.cpp
|
||||
|
@ -10,7 +10,8 @@ if $(TARGET_PLATFORM) != haiku {
|
||||
# Unfortunately we get more than we want, namely all POSIX headers.
|
||||
}
|
||||
|
||||
UsePrivateHeaders kernel net ;
|
||||
UsePrivateKernelHeaders ;
|
||||
UsePrivateHeaders net ;
|
||||
|
||||
KernelAddon ethernet :
|
||||
ethernet.cpp
|
||||
|
@ -10,7 +10,8 @@ if $(TARGET_PLATFORM) != haiku {
|
||||
# Unfortunately we get more than we want, namely all POSIX headers.
|
||||
}
|
||||
|
||||
UsePrivateHeaders kernel net ;
|
||||
UsePrivateKernelHeaders ;
|
||||
UsePrivateHeaders net ;
|
||||
|
||||
KernelAddon ipv4 :
|
||||
ipv4.cpp
|
||||
|
@ -10,7 +10,8 @@ if $(TARGET_PLATFORM) != haiku {
|
||||
# Unfortunately we get more than we want, namely all POSIX headers.
|
||||
}
|
||||
|
||||
UsePrivateHeaders kernel net ;
|
||||
UsePrivateKernelHeaders ;
|
||||
UsePrivateHeaders net ;
|
||||
|
||||
KernelAddon tcp :
|
||||
tcp.cpp
|
||||
|
@ -10,7 +10,8 @@ if $(TARGET_PLATFORM) != haiku {
|
||||
# Unfortunately we get more than we want, namely all POSIX headers.
|
||||
}
|
||||
|
||||
UsePrivateHeaders kernel net ;
|
||||
UsePrivateKernelHeaders ;
|
||||
UsePrivateHeaders net ;
|
||||
|
||||
KernelAddon udp :
|
||||
udp.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user