diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_block_cache.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_block_cache.cpp index 8d868336e4..d9b1970c34 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_block_cache.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_block_cache.cpp @@ -13,6 +13,7 @@ #include #include +#include #include @@ -21,7 +22,6 @@ #include "haiku_hash.h" #include "haiku_lock.h" #include "haiku_slab.h" -#include "kernel_emu.h" // TODO: this is a naive but growing implementation to test the API: @@ -46,15 +46,6 @@ #define FATAL(x) panic x -using UserlandFS::KernelEmu::dprintf; -using UserlandFS::KernelEmu::dump_block; -using UserlandFS::KernelEmu::panic; -using UserlandFS::KernelEmu::spawn_kernel_thread; - -namespace UserlandFS { -namespace HaikuKernelEmu { - - static const bigtime_t kTransactionIdleTime = 2000000LL; // a transaction is considered idle after 2 seconds of inactivity @@ -813,7 +804,7 @@ block_cache::Init() cache_transaction dummyTransaction; transaction_hash = hash_init(16, offset_of_member(dummyTransaction, next), - &transaction_compare, &UserlandFS::HaikuKernelEmu::transaction_hash); + &transaction_compare, &::transaction_hash); if (transaction_hash == NULL) return B_NO_MEMORY; @@ -2343,7 +2334,7 @@ block_cache_delete(void* _cache, bool allowWrites) block_cache* cache = (block_cache*)_cache; if (allowWrites) - UserlandFS::HaikuKernelEmu::block_cache_sync(cache); + block_cache_sync(cache); mutex_lock(&sCachesLock); sCaches.Remove(cache); @@ -2627,6 +2618,3 @@ block_cache_put(void* _cache, off_t blockNumber) put_cached_block(cache, blockNumber); } - -} // namespace HaikuKernelEmu -} // namespace UserlandFS diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_block_cache.h b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_block_cache.h index 16aa4a06ed..c39f9f43a9 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_block_cache.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_block_cache.h @@ -9,14 +9,12 @@ #include -namespace UserlandFS { -namespace HaikuKernelEmu { +extern "C" { status_t block_cache_init(void); size_t block_cache_used_memory(); -} // namespace HaikuKernelEmu -} // namespace UserlandFS +} #endif // USERLAND_FS_HAIKU_BLOCK_CACHE_H diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_condition_variable.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_condition_variable.cpp index bc6223eb1d..8ef5a1bf3c 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_condition_variable.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_condition_variable.cpp @@ -10,6 +10,7 @@ #include #include +#include // libroot #include @@ -18,19 +19,12 @@ #include #include -#include "kernel_emu.h" #include "haiku_lock.h" -namespace UserlandFS { -namespace HaikuKernelEmu { - #define STATUS_ADDED 1 #define STATUS_WAITING 2 -using UserlandFS::KernelEmu::dprintf; -using UserlandFS::KernelEmu::panic; - static const int kConditionVariableHashSize = 512; @@ -258,6 +252,3 @@ condition_variable_init() return error; } - -} // namespace HaikuKernelEmu -} // namespace UserlandFS diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_condition_variable.h b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_condition_variable.h index 29587a713c..708e1984aa 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_condition_variable.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_condition_variable.h @@ -11,10 +11,6 @@ #include -namespace UserlandFS { -namespace HaikuKernelEmu { - - class ConditionVariable; @@ -95,7 +91,4 @@ ConditionVariable::NotifyAll(bool threadsLocked) status_t condition_variable_init(); -} // namespace HaikuKernelEmu -} // namespace UserlandFS - #endif // USERLAND_FS_HAIKU_CONDITION_VARIABLE_H diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_fs_cache.h b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_fs_cache.h index e241ac595c..a0ef4235de 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_fs_cache.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_fs_cache.h @@ -17,70 +17,6 @@ class HaikuKernelVolume; namespace HaikuKernelEmu { -/* transactions */ -extern int32 cache_start_transaction(void *cache); -extern status_t cache_sync_transaction(void *cache, int32 id); -extern status_t cache_end_transaction(void *cache, int32 id, - transaction_notification_hook hook, void *data); -extern status_t cache_abort_transaction(void *cache, int32 id); -extern int32 cache_detach_sub_transaction(void *cache, int32 id, - transaction_notification_hook hook, void *data); -extern status_t cache_abort_sub_transaction(void *cache, int32 id); -extern status_t cache_start_sub_transaction(void *cache, int32 id); -extern status_t cache_add_transaction_listener(void *cache, int32 id, - int32 events, transaction_notification_hook hook, - void *data); -extern status_t cache_remove_transaction_listener(void *cache, int32 id, - transaction_notification_hook hook, void *data); -extern status_t cache_next_block_in_transaction(void *cache, int32 id, - bool mainOnly, long *_cookie, off_t *_blockNumber, - void **_data, void **_unchangedData); -extern int32 cache_blocks_in_transaction(void *cache, int32 id); -extern int32 cache_blocks_in_main_transaction(void *cache, int32 id); -extern int32 cache_blocks_in_sub_transaction(void *cache, int32 id); - -/* block cache */ -extern void block_cache_delete(void *cache, bool allowWrites); -extern void *block_cache_create(int fd, off_t numBlocks, size_t blockSize, - bool readOnly); -extern status_t block_cache_sync(void *cache); -extern status_t block_cache_sync_etc(void *cache, off_t blockNumber, - size_t numBlocks); -extern void block_cache_discard(void *cache, off_t blockNumber, - size_t numBlocks); -extern status_t block_cache_make_writable(void *cache, off_t blockNumber, - int32 transaction); -extern void *block_cache_get_writable_etc(void *cache, off_t blockNumber, - off_t base, off_t length, int32 transaction); -extern void *block_cache_get_writable(void *cache, off_t blockNumber, - int32 transaction); -extern void *block_cache_get_empty(void *cache, off_t blockNumber, - int32 transaction); -extern const void *block_cache_get_etc(void *cache, off_t blockNumber, - off_t base, off_t length); -extern const void *block_cache_get(void *cache, off_t blockNumber); -extern status_t block_cache_set_dirty(void *cache, off_t blockNumber, - bool isDirty, int32 transaction); -extern void block_cache_put(void *cache, off_t blockNumber); - -/* file cache */ -extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size, - int fd); -extern void file_cache_delete(void *_cacheRef); -extern status_t file_cache_set_size(void *_cacheRef, off_t size); -extern status_t file_cache_sync(void *_cache); -extern status_t file_cache_invalidate_file_map(void *_cacheRef, off_t offset, - off_t size); - -extern status_t file_cache_read_pages(void *_cacheRef, off_t offset, - const iovec *vecs, size_t count, size_t *_numBytes); -extern status_t file_cache_write_pages(void *_cacheRef, off_t offset, - const iovec *vecs, size_t count, size_t *_numBytes); -extern status_t file_cache_read(void *_cacheRef, off_t offset, void *bufferBase, - size_t *_size); -extern status_t file_cache_write(void *_cacheRef, off_t offset, - const void *buffer, size_t *_size); - // interface for the emulation layer status_t file_cache_init(); status_t file_cache_register_volume(HaikuKernelVolume* volume); diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_hash.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_hash.cpp index f7e1fe8c99..267435ba81 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_hash.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_hash.cpp @@ -11,8 +11,8 @@ #include #include +#include -#include "kernel_emu.h" #undef TRACE #define TRACE_HASH 0 @@ -22,12 +22,6 @@ # define TRACE(x) ; #endif -using UserlandFS::KernelEmu::dprintf; -using UserlandFS::KernelEmu::panic; - -namespace UserlandFS { -namespace HaikuKernelEmu { - // TODO: the hashtable is not expanded when necessary (no load factor, nothing) // resizing should be optional, though, in case the hash is used at times @@ -438,6 +432,3 @@ hash_dump_table(struct hash_table* table) } } } - -} // namespace HaikuKernelEmu -} // namespace UserlandFS diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_hash.h b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_hash.h index 7e4b33af58..59bac09de8 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_hash.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_hash.h @@ -10,8 +10,6 @@ #include -namespace UserlandFS { -namespace HaikuKernelEmu { // The use of offsetof() on non-PODs is invalid. Since many structs use // templated members (i.e. DoublyLinkedList) which makes them non-PODs we @@ -28,6 +26,8 @@ typedef struct hash_iterator { typedef struct hash_table hash_table; +extern "C" { + struct hash_table *hash_init(uint32 table_size, int next_ptr_offset, int compare_func(void *element, const void *key), uint32 hash_func(void *element, const void *key, uint32 range)); @@ -60,7 +60,6 @@ void hash_dump_table(struct hash_table* table); uint32 hash_hash_string(const char *str); -} // namespace HaikuKernelEmu -} // namespace UserlandFS +} // extern "C" #endif /* USERLAND_FS_HAIKU_HASH_H */ diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_kernel_emu.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_kernel_emu.cpp index 644a232aaa..4fd7d5cb63 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_kernel_emu.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_kernel_emu.cpp @@ -10,7 +10,6 @@ #include #include "Debug.h" -#include "haiku_fs_cache.h" #include "HaikuKernelNode.h" #include "HaikuKernelVolume.h" #include "kernel_emu.h" @@ -227,260 +226,6 @@ volume_for_vnode(fs_vnode *vnode) } -// #pragma mark - Transaction - - -// cache_start_transaction -int32 -cache_start_transaction(void *_cache) -{ - return UserlandFS::HaikuKernelEmu::cache_start_transaction(_cache); -} - -// cache_sync_transaction -status_t -cache_sync_transaction(void *_cache, int32 id) -{ - return UserlandFS::HaikuKernelEmu::cache_sync_transaction(_cache, id); -} - -// cache_end_transaction -status_t -cache_end_transaction(void *_cache, int32 id, - transaction_notification_hook hook, void *data) -{ - return UserlandFS::HaikuKernelEmu::cache_end_transaction(_cache, id, hook, - data); -} - -// cache_abort_transaction -status_t -cache_abort_transaction(void *_cache, int32 id) -{ - return UserlandFS::HaikuKernelEmu::cache_abort_transaction(_cache, id); -} - -// cache_detach_sub_transaction -int32 -cache_detach_sub_transaction(void *_cache, int32 id, - transaction_notification_hook hook, void *data) -{ - return UserlandFS::HaikuKernelEmu::cache_detach_sub_transaction(_cache, id, - hook, data); -} - -// cache_abort_sub_transaction -status_t -cache_abort_sub_transaction(void *_cache, int32 id) -{ - return UserlandFS::HaikuKernelEmu::cache_abort_sub_transaction(_cache, id); -} - -// cache_start_sub_transaction -status_t -cache_start_sub_transaction(void *_cache, int32 id) -{ - return UserlandFS::HaikuKernelEmu::cache_start_sub_transaction(_cache, id); -} - -// cache_next_block_in_transaction -status_t -cache_next_block_in_transaction(void *_cache, int32 id, uint32 *_cookie, - off_t *_blockNumber, void **_data, void **_unchangedData) -{ - return UserlandFS::HaikuKernelEmu::cache_next_block_in_transaction(_cache, - id, _cookie, _blockNumber, _data, _unchangedData); -} - -// cache_blocks_in_transaction -int32 -cache_blocks_in_transaction(void *_cache, int32 id) -{ - return UserlandFS::HaikuKernelEmu::cache_blocks_in_transaction(_cache, id); -} - -// cache_blocks_in_sub_transaction -int32 -cache_blocks_in_sub_transaction(void *_cache, int32 id) -{ - return UserlandFS::HaikuKernelEmu::cache_blocks_in_sub_transaction(_cache, - id); -} - - -// #pragma mark - Block Cache - - -// block_cache_delete -void -block_cache_delete(void *_cache, bool allowWrites) -{ - UserlandFS::HaikuKernelEmu::block_cache_delete(_cache, allowWrites); -} - -// block_cache_create -void * -block_cache_create(int fd, off_t numBlocks, size_t blockSize, bool readOnly) -{ - return UserlandFS::HaikuKernelEmu::block_cache_create(fd, numBlocks, - blockSize, readOnly); -} - -// block_cache_sync -status_t -block_cache_sync(void *_cache) -{ - return UserlandFS::HaikuKernelEmu::block_cache_sync(_cache); -} - -// block_cache_sync_etc -status_t -block_cache_sync_etc(void *_cache, off_t blockNumber, size_t numBlocks) -{ - return UserlandFS::HaikuKernelEmu::block_cache_sync_etc(_cache, - blockNumber, numBlocks); -} - -// block_cache_make_writable -status_t -block_cache_make_writable(void *_cache, off_t blockNumber, int32 transaction) -{ - return UserlandFS::HaikuKernelEmu::block_cache_make_writable(_cache, - blockNumber, transaction); -} - -// block_cache_get_writable_etc -void * -block_cache_get_writable_etc(void *_cache, off_t blockNumber, off_t base, - off_t length, int32 transaction) -{ - return UserlandFS::HaikuKernelEmu::block_cache_get_writable_etc(_cache, - blockNumber, base, length, transaction); -} - -// block_cache_get_writable -void * -block_cache_get_writable(void *_cache, off_t blockNumber, int32 transaction) -{ - return UserlandFS::HaikuKernelEmu::block_cache_get_writable(_cache, - blockNumber, transaction); -} - -// block_cache_get_empty -void * -block_cache_get_empty(void *_cache, off_t blockNumber, int32 transaction) -{ - return UserlandFS::HaikuKernelEmu::block_cache_get_empty(_cache, - blockNumber, transaction); -} - -// block_cache_get_etc -const void * -block_cache_get_etc(void *_cache, off_t blockNumber, off_t base, off_t length) -{ - return UserlandFS::HaikuKernelEmu::block_cache_get_etc(_cache, blockNumber, - base, length); -} - -// block_cache_get -const void * -block_cache_get(void *_cache, off_t blockNumber) -{ - return UserlandFS::HaikuKernelEmu::block_cache_get(_cache, blockNumber); -} - -// block_cache_set_dirty -status_t -block_cache_set_dirty(void *_cache, off_t blockNumber, bool isDirty, - int32 transaction) -{ - return UserlandFS::HaikuKernelEmu::block_cache_set_dirty(_cache, - blockNumber, isDirty, transaction); -} - -// block_cache_put -void -block_cache_put(void *_cache, off_t blockNumber) -{ - UserlandFS::HaikuKernelEmu::block_cache_put(_cache, blockNumber); -} - - -// #pragma mark - File Cache - -// file_cache_create -void * -file_cache_create(dev_t mountID, ino_t vnodeID, off_t size, int fd) -{ - return UserlandFS::HaikuKernelEmu::file_cache_create(mountID, vnodeID, - size, fd); -} - -// file_cache_delete -void -file_cache_delete(void *_cacheRef) -{ - UserlandFS::HaikuKernelEmu::file_cache_delete(_cacheRef); -} - -// file_cache_set_size -status_t -file_cache_set_size(void *_cacheRef, off_t size) -{ - return UserlandFS::HaikuKernelEmu::file_cache_set_size(_cacheRef, size); -} - -// file_cache_sync -status_t -file_cache_sync(void *_cache) -{ - return UserlandFS::HaikuKernelEmu::file_cache_sync(_cache); -} - -// file_cache_invalidate_file_map -status_t -file_cache_invalidate_file_map(void *_cacheRef, off_t offset, off_t size) -{ - return UserlandFS::HaikuKernelEmu::file_cache_invalidate_file_map( - _cacheRef, offset, size); -} - -// file_cache_read_pages -status_t -file_cache_read_pages(void *_cacheRef, off_t offset, const iovec *vecs, - size_t count, size_t *_numBytes) -{ - return UserlandFS::HaikuKernelEmu::file_cache_read_pages(_cacheRef, - offset, vecs, count, _numBytes); -} - -// file_cache_write_pages -status_t -file_cache_write_pages(void *_cacheRef, off_t offset, const iovec *vecs, - size_t count, size_t *_numBytes) -{ - return UserlandFS::HaikuKernelEmu::file_cache_write_pages(_cacheRef, - offset, vecs, count, _numBytes); -} - -// file_cache_read -status_t -file_cache_read(void *_cacheRef, off_t offset, void *bufferBase, size_t *_size) -{ - return UserlandFS::HaikuKernelEmu::file_cache_read(_cacheRef, offset, - bufferBase, _size); -} - -// file_cache_write -status_t -file_cache_write(void *_cacheRef, off_t offset, const void *buffer, - size_t *_size) -{ - return UserlandFS::HaikuKernelEmu::file_cache_write(_cacheRef, offset, - buffer, _size); -} - - // #pragma mark - Misc diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_lock.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_lock.cpp index 91d19fcb43..426dc491bc 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_lock.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_lock.cpp @@ -10,14 +10,7 @@ #include "haiku_lock.h" -#include - -#include "kernel_emu.h" - -using UserlandFS::KernelEmu::panic; - -namespace UserlandFS { -namespace HaikuKernelEmu { +#include sem_id @@ -269,6 +262,3 @@ rw_lock_write_unlock(rw_lock *lock) { return release_sem_etc(lock->sem, RW_MAX_READERS, 0); } - -} // namespace HaikuKernelEmu -} // namespace UserlandFS diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_lock.h b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_lock.h index bba1f1dd6d..4f97ef6919 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_lock.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_lock.h @@ -11,9 +11,6 @@ #include -namespace UserlandFS { -namespace HaikuKernelEmu { - typedef struct recursive_lock { sem_id sem; thread_id holder; @@ -51,6 +48,9 @@ typedef struct rw_lock { { _init_semaphore(RW_MAX_READERS, name) } +extern "C" { + + sem_id _init_semaphore(int32 count, const char* name); // implementation private @@ -93,6 +93,9 @@ extern status_t rw_lock_write_lock(rw_lock* lock); extern status_t rw_lock_write_unlock(rw_lock* lock); +} // extern "C" + + /* C++ Auto Locking */ #include "AutoLocker.h" @@ -132,10 +135,5 @@ public: // RecursiveLocker typedef AutoLocker RecursiveLocker; -} // namespace HaikuKernelEmu -} // namespace UserlandFS - -using UserlandFS::HaikuKernelEmu::MutexLocker; -using UserlandFS::HaikuKernelEmu::RecursiveLocker; #endif /* USERLAND_FS_HAIKU_LOCK_H */ diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_slab.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_slab.cpp index 16c51d93c3..bc1d72704e 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_slab.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_slab.cpp @@ -10,10 +10,6 @@ #include -namespace UserlandFS { -namespace HaikuKernelEmu { - - struct object_cache { object_cache(const char *name, size_t objectSize, size_t alignment, size_t maxByteUsage, uint32 flags, void *cookie, @@ -92,6 +88,3 @@ void object_cache_get_usage(object_cache *cache, size_t *_allocatedMemory) { *_allocatedMemory = 0; } - -} // namespace HaikuKernelEmu -} // namespace UserlandFS diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_slab.h b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_slab.h index 541f0388a0..0b3ab6d04c 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_slab.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/haiku_slab.h @@ -11,10 +11,6 @@ #include -namespace UserlandFS { -namespace HaikuKernelEmu { - - enum { /* create_object_cache_etc flags */ CACHE_NO_DEPOT = 1 << 0, @@ -35,6 +31,8 @@ typedef void (*object_cache_destructor)(void *cookie, void *object); typedef void (*object_cache_reclaimer)(void *cookie, int32 level); +extern "C" { + object_cache *create_object_cache(const char *name, size_t object_size, size_t alignment, void *cookie, object_cache_constructor constructor, object_cache_destructor); @@ -56,7 +54,6 @@ status_t object_cache_reserve(object_cache *cache, size_t object_count, void object_cache_get_usage(object_cache *cache, size_t *_allocatedMemory); -} // namespace HaikuKernelEmu -} // namespace UserlandFS +} // extern "C" #endif // USERLAND_FS_HAIKU_SLAB_SLAB_H