* 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:
Ingo Weinhold 2007-08-09 19:47:22 +00:00
parent 5378efc0db
commit bce7e9f695
7 changed files with 65 additions and 7 deletions

View File

@ -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

View File

@ -1,6 +1,6 @@
SubDir HAIKU_TOP src add-ons kernel drivers tty ;
UsePrivateHeaders kernel ;
UsePrivateKernelHeaders ;
KernelAddon <driver>tty :
driver.cpp

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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