From 50443d0b64ecea256ddbb63c8a0135f7bb99c25c Mon Sep 17 00:00:00 2001 From: PHO Date: Sun, 8 Aug 2010 21:00:54 +0900 Subject: [PATCH] more bindings --- Bindings/APR/Allocator.hsc | 2 +- Bindings/APR/Allocator/Types.hsc | 12 +++++----- Bindings/APR/AnyLock.hsc | 32 +++++++++++++++++++++++++++ Bindings/APR/{Errno.hsc => ErrNo.hsc} | 2 +- Bindings/APR/Pools.hsc | 2 +- Bindings/APR/Proc/Mutex.hsc | 30 +++++++++++++++++++++++++ Bindings/APR/Thread/Mutex.hsc | 2 +- Bindings/APR/Thread/RWLock.hsc | 18 +++++++++++++++ bindings-apr.cabal | 6 ++++- cbits/helper_apr_anylock.c | 6 +++++ 10 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 Bindings/APR/AnyLock.hsc rename Bindings/APR/{Errno.hsc => ErrNo.hsc} (99%) create mode 100644 Bindings/APR/Proc/Mutex.hsc create mode 100644 Bindings/APR/Thread/RWLock.hsc create mode 100644 cbits/helper_apr_anylock.c diff --git a/Bindings/APR/Allocator.hsc b/Bindings/APR/Allocator.hsc index 236fff9..b2dcfa6 100644 --- a/Bindings/APR/Allocator.hsc +++ b/Bindings/APR/Allocator.hsc @@ -5,7 +5,7 @@ module Bindings.APR.Allocator where #strict_import import Bindings.APR import Bindings.APR.Allocator.Types -import Bindings.APR.Errno +import Bindings.APR.ErrNo import Bindings.APR.Thread.Mutex import Bindings.APR.Pools diff --git a/Bindings/APR/Allocator/Types.hsc b/Bindings/APR/Allocator/Types.hsc index 088d6f6..3f16522 100644 --- a/Bindings/APR/Allocator/Types.hsc +++ b/Bindings/APR/Allocator/Types.hsc @@ -8,10 +8,10 @@ import Bindings.APR #opaque_t apr_allocator_t #starttype struct apr_memnode_t -#field next , Ptr -#field ref , Ptr (Ptr ) -#field index , -#field free_index , -#field first_avail, Ptr CChar -#field endp , Ptr CChar +# field next , Ptr +# field ref , Ptr (Ptr ) +# field index , +# field free_index , +# field first_avail, Ptr CChar +# field endp , Ptr CChar #stoptype diff --git a/Bindings/APR/AnyLock.hsc b/Bindings/APR/AnyLock.hsc new file mode 100644 index 0000000..acfc483 --- /dev/null +++ b/Bindings/APR/AnyLock.hsc @@ -0,0 +1,32 @@ +#include +#include + +module Bindings.APR.AnyLock where +#strict_import +import Bindings.APR.ErrNo +import Bindings.APR.Proc.Mutex +import Bindings.APR.Thread.Mutex +import Bindings.APR.Thread.RWLock + +#synonym_t tm_lock, CInt +#num apr_anylock_none +#num apr_anylock_procmutex +#num apr_anylock_readlock +#num apr_anylock_writelock + +#starttype union apr_anylock_u_t +# union_field pm, Ptr +# if APR_HAS_THREADS +# union_field tm, Ptr +# union_field rw, Ptr +# endif +#stoptype + +#starttype struct apr_anylock_t +#field type, +#field lock, +#stoptype + +#cinline APR_ANYLOCK_LOCK , Ptr -> IO +#cinline APR_ANYLOCK_TRYLOCK, Ptr -> IO +#cinline APR_ANYLOCK_UNLOCK , Ptr -> IO diff --git a/Bindings/APR/Errno.hsc b/Bindings/APR/ErrNo.hsc similarity index 99% rename from Bindings/APR/Errno.hsc rename to Bindings/APR/ErrNo.hsc index a18a2c8..8cd11d9 100644 --- a/Bindings/APR/Errno.hsc +++ b/Bindings/APR/ErrNo.hsc @@ -1,7 +1,7 @@ #include #include -module Bindings.APR.Errno where +module Bindings.APR.ErrNo where #strict_import import Bindings.APR diff --git a/Bindings/APR/Pools.hsc b/Bindings/APR/Pools.hsc index 46c4790..87979e4 100644 --- a/Bindings/APR/Pools.hsc +++ b/Bindings/APR/Pools.hsc @@ -5,7 +5,7 @@ module Bindings.APR.Pools where #strict_import import Bindings.APR import Bindings.APR.Allocator.Types -import Bindings.APR.Errno +import Bindings.APR.ErrNo #opaque_t apr_pool_t diff --git a/Bindings/APR/Proc/Mutex.hsc b/Bindings/APR/Proc/Mutex.hsc new file mode 100644 index 0000000..69d8f7f --- /dev/null +++ b/Bindings/APR/Proc/Mutex.hsc @@ -0,0 +1,30 @@ +#include +#include + +module Bindings.APR.Proc.Mutex where +#strict_import +import Bindings.APR.ErrNo +import Bindings.APR.Pools + +#integral_t apr_lockmech_e +#num APR_LOCK_FCNTL +#num APR_LOCK_FLOCK +#num APR_LOCK_SYSVSEM +#num APR_LOCK_PROC_PTHREAD +#num APR_LOCK_POSIXSEM +#num APR_LOCK_DEFAULT + +#opaque_t apr_proc_mutex_t + +#ccall apr_proc_mutex_create , Ptr (Ptr ) -> Ptr CChar -> -> Ptr -> IO +#ccall apr_proc_mutex_child_init, Ptr (Ptr ) -> Ptr CChar -> Ptr -> IO +#ccall apr_proc_mutex_lock , Ptr -> IO +#ccall apr_proc_mutex_trylock , Ptr -> IO +#ccall apr_proc_mutex_unlock , Ptr -> IO +#ccall apr_proc_mutex_destroy , Ptr -> IO +#ccall apr_proc_mutex_cleanup , Ptr () -> IO +#ccall apr_proc_mutex_lockfile , Ptr -> IO (Ptr CChar) +#ccall apr_proc_mutex_name , Ptr -> IO (Ptr CChar) +#ccall apr_proc_mutex_defname , IO (Ptr CChar) + +#ccall apr_proc_mutex_pool_get , Ptr -> IO (Ptr ) diff --git a/Bindings/APR/Thread/Mutex.hsc b/Bindings/APR/Thread/Mutex.hsc index 07c7ddd..8efd2e0 100644 --- a/Bindings/APR/Thread/Mutex.hsc +++ b/Bindings/APR/Thread/Mutex.hsc @@ -3,7 +3,7 @@ module Bindings.APR.Thread.Mutex where #strict_import -import Bindings.APR.Errno +import Bindings.APR.ErrNo import Bindings.APR.Pools #opaque_t apr_thread_mutex_t diff --git a/Bindings/APR/Thread/RWLock.hsc b/Bindings/APR/Thread/RWLock.hsc new file mode 100644 index 0000000..28cccbf --- /dev/null +++ b/Bindings/APR/Thread/RWLock.hsc @@ -0,0 +1,18 @@ +#include +#include + +module Bindings.APR.Thread.RWLock where +#strict_import +import Bindings.APR.ErrNo +import Bindings.APR.Pools + +#opaque_t apr_thread_rwlock_t + +#ccall apr_thread_rwlock_create , Ptr (Ptr ) -> Ptr -> IO +#ccall apr_thread_rwlock_rdlock , Ptr -> IO +#ccall apr_thread_rwlock_tryrdlock, Ptr -> IO +#ccall apr_thread_rwlock_wrlock , Ptr -> IO +#ccall apr_thread_rwlock_trywrlock, Ptr -> IO +#ccall apr_thread_rwlock_destroy , Ptr -> IO + +#ccall apr_thread_rwlock_pool_get , Ptr -> IO (Ptr ) diff --git a/bindings-apr.cabal b/bindings-apr.cabal index 4e70373..cec13ca 100644 --- a/bindings-apr.cabal +++ b/bindings-apr.cabal @@ -31,11 +31,15 @@ Library Bindings.APR Bindings.APR.Allocator Bindings.APR.Allocator.Types - Bindings.APR.Errno + Bindings.APR.AnyLock + Bindings.APR.ErrNo Bindings.APR.Pools + Bindings.APR.Proc.Mutex Bindings.APR.Thread.Mutex + Bindings.APR.Thread.RWLock C-Sources: + cbits/helper_apr_anylock.c cbits/helper_apr_errno.c cbits/helper_apr_pools.c diff --git a/cbits/helper_apr_anylock.c b/cbits/helper_apr_anylock.c new file mode 100644 index 0000000..a874008 --- /dev/null +++ b/cbits/helper_apr_anylock.c @@ -0,0 +1,6 @@ +#include +#include + +BC_INLINE1(APR_ANYLOCK_LOCK , apr_anylock_t*, apr_status_t) +BC_INLINE1(APR_ANYLOCK_TRYLOCK, apr_anylock_t*, apr_status_t) +BC_INLINE1(APR_ANYLOCK_UNLOCK , apr_anylock_t*, apr_status_t) -- 2.40.0