* Made the private kernel locking primitives available to file systems as well.

* Applied Korli's mutex_unlock() fix to block_cache.cpp.
* Removed block_cache_priv.h, as it's no longer needed (moved its definitions
  into block_cache.cpp, as in the kernel file).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26296 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-07-07 15:19:19 +00:00
parent 36bf05cac9
commit 589f1a9133
13 changed files with 470 additions and 541 deletions
@@ -33,6 +33,7 @@
#include "fssh_fs_query.h"
#include "fssh_fs_volume.h"
#include "fssh_kernel_export.h"
#include "fssh_lock.h"
#include "fssh_module.h"
#include "fssh_node_monitor.h"
#include "fssh_os.h"
@@ -953,6 +954,46 @@
#define remove_debugger_command fssh_remove_debugger_command
////////////////////////////////////////////////////////////////////////////////
// #pragma mark - fssh_lock.h
#define mutex fssh_mutex
#define rw_lock fssh_rw_lock
#define recursive_lock fssh_recursive_lock
#define MUTEX_FLAG_CLONE_NAME FSSH_MUTEX_FLAG_CLONE_NAME
#define RW_LOCK_FLAG_CLONE_NAME FSSH_RW_LOCK_FLAG_CLONE_NAME
#define ASSERT_LOCKED_RECURSIVE(r) FSSH_ASSERT_LOCKED_RECURSIVE(r)
#define ASSERT_LOCKED_MUTEX(m) FSSH_ASSERT_LOCKED_MUTEX(m)
#define MUTEX_INITIALIZER(name) FSSH_MUTEX_INITIALIZER(name)
#define RECURSIVE_LOCK_INITIALIZER(name) FSSH_RECURSIVE_LOCK_INITIALIZER(name)
#define RW_LOCK_INITIALIZER(name) FSSH_RW_LOCK_INITIALIZER(name)
#define recursive_lock_init fssh_recursive_lock_init
#define recursive_lock_init_etc fssh_recursive_lock_init_etc
#define recursive_lock_destroy fssh_recursive_lock_destroy
#define recursive_lock_lock fssh_recursive_lock_lock
#define recursive_lock_unlock fssh_recursive_lock_unlock
#define recursive_lock_get_recursion fssh_recursive_lock_get_recursion
#define rw_lock_init fssh_rw_lock_init
#define rw_lock_init_etc fssh_rw_lock_init_etc
#define rw_lock_destroy fssh_rw_lock_destroy
#define rw_lock_read_lock fssh_rw_lock_read_lock
#define rw_lock_read_unlock fssh_rw_lock_read_unlock
#define rw_lock_write_lock fssh_rw_lock_write_lock
#define rw_lock_write_unlock fssh_rw_lock_write_unlock
#define mutex_init fssh_mutex_init
#define mutex_init_etc fssh_mutex_init_etc
#define mutex_destroy fssh_mutex_destroy
#define mutex_lock fssh_mutex_lock
#define mutex_trylock fssh_mutex_trylock
#define mutex_unlock fssh_mutex_unlock
////////////////////////////////////////////////////////////////////////////////
// #pragma mark - fssh_module.h
+125
View File
@@ -0,0 +1,125 @@
/*
* Copyright 2008, Ingo Weinhold, [email protected].
* Copyright 2002-2008, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
* Distributed under the terms of the NewOS License.
*/
#ifndef _FSSH_KERNEL_LOCK_H
#define _FSSH_KERNEL_LOCK_H
#include <fssh_auto_locker.h>
#include <fssh_errors.h>
#include <fssh_os.h>
typedef struct fssh_mutex {
fssh_sem_id sem;
fssh_thread_id holder;
} fssh_mutex;
#define FSSH_MUTEX_FLAG_CLONE_NAME 0x1
typedef struct fssh_recursive_lock {
fssh_sem_id sem;
fssh_thread_id holder;
int recursion;
} fssh_recursive_lock;
typedef struct fssh_rw_lock {
fssh_sem_id sem;
int32_t count;
} fssh_rw_lock;
#define FSSH_RW_LOCK_FLAG_CLONE_NAME 0x1
#define FSSH_ASSERT_LOCKED_RECURSIVE(r)
#define FSSH_ASSERT_LOCKED_MUTEX(m)
// static initializers
#define FSSH_MUTEX_INITIALIZER(name) { name, NULL, 0, 0 }
#define FSSH_RECURSIVE_LOCK_INITIALIZER(name) { FSSH_MUTEX_INITIALIZER(name), -1, 0 }
#define FSSH_RW_LOCK_INITIALIZER(name) { name, NULL, -1, 0, 0, 0 }
#ifdef __cplusplus
extern "C" {
#endif
extern void fssh_recursive_lock_init(fssh_recursive_lock *lock, const char *name);
// name is *not* cloned nor freed in recursive_lock_destroy()
extern void fssh_recursive_lock_init_etc(fssh_recursive_lock *lock, const char *name,
uint32_t flags);
extern void fssh_recursive_lock_destroy(fssh_recursive_lock *lock);
extern fssh_status_t fssh_recursive_lock_lock(fssh_recursive_lock *lock);
extern void fssh_recursive_lock_unlock(fssh_recursive_lock *lock);
extern int32_t fssh_recursive_lock_get_recursion(fssh_recursive_lock *lock);
extern void fssh_rw_lock_init(fssh_rw_lock* lock, const char* name);
// name is *not* cloned nor freed in rw_lock_destroy()
extern void fssh_rw_lock_init_etc(fssh_rw_lock* lock, const char* name, uint32_t flags);
extern void fssh_rw_lock_destroy(fssh_rw_lock* lock);
extern fssh_status_t fssh_rw_lock_read_lock(fssh_rw_lock* lock);
extern fssh_status_t fssh_rw_lock_read_unlock(fssh_rw_lock* lock);
extern fssh_status_t fssh_rw_lock_write_lock(fssh_rw_lock* lock);
extern fssh_status_t fssh_rw_lock_write_unlock(fssh_rw_lock* lock);
extern void fssh_mutex_init(fssh_mutex* lock, const char* name);
// name is *not* cloned nor freed in mutex_destroy()
extern void fssh_mutex_init_etc(fssh_mutex* lock, const char* name, uint32_t flags);
extern void fssh_mutex_destroy(fssh_mutex* lock);
extern fssh_status_t fssh_mutex_lock(fssh_mutex* lock);
extern fssh_status_t fssh_mutex_trylock(fssh_mutex* lock);
extern void fssh_mutex_unlock(fssh_mutex* lock);
#ifdef __cplusplus
}
namespace FSShell {
// MutexLocking
class MutexLocking {
public:
inline bool Lock(fssh_mutex *lockable)
{
return fssh_mutex_lock(lockable) == FSSH_B_OK;
}
inline void Unlock(fssh_mutex *lockable)
{
fssh_mutex_unlock(lockable);
}
};
// MutexLocker
typedef AutoLocker<fssh_mutex, MutexLocking> MutexLocker;
// RecursiveLockLocking
class RecursiveLockLocking {
public:
inline bool Lock(fssh_recursive_lock *lockable)
{
return fssh_recursive_lock_lock(lockable) == FSSH_B_OK;
}
inline void Unlock(fssh_recursive_lock *lockable)
{
fssh_recursive_lock_unlock(lockable);
}
};
// RecursiveLocker
typedef AutoLocker<fssh_recursive_lock, RecursiveLockLocking> RecursiveLocker;
} // namespace FSShell
using FSShell::AutoLocker;
using FSShell::MutexLocker;
using FSShell::RecursiveLocker;
#endif // __cplusplus
#endif /* _FSSH_KERNEL_LOCK_H */