From 106350525e3f5b71a8b19c02e5aa97abfc6d4203 Mon Sep 17 00:00:00 2001 From: PHO Date: Sun, 8 Aug 2010 19:32:10 +0900 Subject: [PATCH] more bindings --- Bindings/APR/Allocator.hsc | 20 +++---- Bindings/APR/Allocator/Types.hsc | 17 ++++++ Bindings/APR/Pools.hsc | 95 ++++++++++++++++++++++++++++++++ bindings-apr.cabal | 3 + cbits/helper_apr_pools.c | 23 ++++++++ 5 files changed, 146 insertions(+), 12 deletions(-) create mode 100644 Bindings/APR/Allocator/Types.hsc create mode 100644 Bindings/APR/Pools.hsc create mode 100644 cbits/helper_apr_pools.c diff --git a/Bindings/APR/Allocator.hsc b/Bindings/APR/Allocator.hsc index 454ff16..0ee0f97 100644 --- a/Bindings/APR/Allocator.hsc +++ b/Bindings/APR/Allocator.hsc @@ -4,18 +4,9 @@ module Bindings.APR.Allocator where #strict_import import Bindings.APR +import Bindings.APR.Allocator.Types import Bindings.APR.Errno - -#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 -#stoptype +import Bindings.APR.Pools #num APR_MEMNODE_T_SIZE #num APR_ALLOCATOR_MAX_FREE_UNLIMITED @@ -25,4 +16,9 @@ import Bindings.APR.Errno #ccall apr_allocator_alloc , Ptr -> -> IO (Ptr ) #ccall apr_allocator_free , Ptr -> Ptr -> IO () --- FIXME: incomplete +#ccall apr_allocator_owner_set, Ptr -> Ptr -> IO () +#ccall apr_allocator_owner_get, Ptr -> IO (Ptr ) + +#ccall apr_allocator_max_free_set, Ptr -> -> IO () + +-- FIXME: incomplete \ No newline at end of file diff --git a/Bindings/APR/Allocator/Types.hsc b/Bindings/APR/Allocator/Types.hsc new file mode 100644 index 0000000..088d6f6 --- /dev/null +++ b/Bindings/APR/Allocator/Types.hsc @@ -0,0 +1,17 @@ +#include +#include + +module Bindings.APR.Allocator.Types where +#strict_import +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 +#stoptype diff --git a/Bindings/APR/Pools.hsc b/Bindings/APR/Pools.hsc new file mode 100644 index 0000000..46c4790 --- /dev/null +++ b/Bindings/APR/Pools.hsc @@ -0,0 +1,95 @@ +#include +#include + +module Bindings.APR.Pools where +#strict_import +import Bindings.APR +import Bindings.APR.Allocator.Types +import Bindings.APR.Errno + +#opaque_t apr_pool_t + +#num APR_POOL_DEBUG + +#callback apr_abortfunc_t, CInt -> IO CInt + +#ccall apr_pool_initialize, IO +#ccall apr_pool_terminate , IO () + +#if APR_POOL_DEBUG + +# cinline apr_pool_create_ex, Ptr (Ptr ) -> Ptr -> -> Ptr -> IO +# cinline apr_pool_create_core_ex, Ptr (Ptr ) -> -> Ptr -> IO +# cinline apr_pool_create_unmanaged_ex, Ptr (Ptr ) -> -> Ptr -> IO + +# ccall apr_pool_create_ex_debug, Ptr (Ptr ) -> Ptr -> -> Ptr -> Ptr CChar -> IO +# ccall apr_pool_create_core_ex_debug, Ptr (Ptr ) -> -> Ptr -> Ptr CChar -> IO +# ccall apr_pool_create_unmanaged_ex_debug, Ptr (Ptr ) -> -> Ptr -> Ptr CChar -> IO + +#else + +# ccall apr_pool_create_ex, Ptr (Ptr ) -> Ptr -> -> Ptr -> IO +# ccall apr_pool_create_core_ex, Ptr (Ptr ) -> -> Ptr -> IO +# ccall apr_pool_create_unmanaged_ex, Ptr (Ptr ) -> -> Ptr -> IO + +#endif + +#cinline apr_pool_create, Ptr (Ptr ) -> Ptr -> IO +#cinline apr_pool_create_core, Ptr (Ptr ) -> IO +#cinline apr_pool_create_unmanaged, Ptr (Ptr ) -> IO + +#ccall apr_pool_allocator_get, Ptr -> IO (Ptr ) + +#if APR_POOL_DEBUG +# cinline apr_pool_clear, Ptr -> IO () +# ccall apr_pool_clear_debug, Ptr -> Ptr CChar -> IO () +#else +# ccall apr_pool_clear, Ptr -> IO () +#endif + +#if APR_POOL_DEBUG +# cinline apr_pool_destroy, Ptr -> IO () +# ccall apr_pool_destroy_debug, Ptr -> Ptr CChar -> IO () +#else +# ccall apr_pool_destroy, Ptr -> IO () +#endif + +#if APR_POOL_DEBUG +# cinline apr_palloc, Ptr -> -> IO (Ptr ()) +# ccall apr_palloc_debug, Ptr -> -> Ptr CChar -> IO (Ptr ()) +#else +# ccall apr_palloc, Ptr -> -> IO (Ptr ()) +#endif + +#cinline apr_pcalloc, Ptr -> -> IO (Ptr ()) +#if APR_POOL_DEBUG +# ccall apr_pcalloc_debug, Ptr -> -> Ptr CChar -> IO (Ptr ()) +#endif + +#ccall apr_pool_abort_set , -> Ptr -> IO () +#ccall apr_pool_abort_get , Ptr -> IO +#ccall apr_pool_parent_get , Ptr -> IO (Ptr ) +#ccall apr_pool_is_ancestor, Ptr -> Ptr -> IO CInt +#ccall apr_pool_tag , Ptr -> Ptr CChar -> IO () + +#ccall apr_pool_userdata_set , Ptr () -> Ptr CChar -> FunPtr (Ptr () -> IO ) -> Ptr -> IO +#ccall apr_pool_userdata_setn, Ptr () -> Ptr CChar -> FunPtr (Ptr () -> IO ) -> Ptr -> IO +#ccall apr_pool_userdata_get , Ptr (Ptr ()) -> Ptr CChar -> Ptr -> IO + +#ccall apr_pool_cleanup_register , Ptr -> Ptr () -> FunPtr (Ptr () -> IO ) -> FunPtr (Ptr () -> IO ) -> IO () +#ccall apr_pool_pre_cleanup_register, Ptr -> Ptr () -> FunPtr (Ptr () -> IO ) -> IO () +#ccall apr_pool_cleanup_kill , Ptr -> Ptr () -> FunPtr (Ptr () -> IO ) -> IO () +#ccall apr_pool_child_cleanup_set , Ptr -> Ptr () -> FunPtr (Ptr () -> IO ) -> FunPtr (Ptr () -> IO ) -> IO () +#ccall apr_pool_cleanup_run , Ptr -> Ptr () -> FunPtr (Ptr () -> IO ) -> IO +#ccall apr_pool_cleanup_null , Ptr () -> IO +#ccall apr_pool_cleanup_for_exec , Ptr () -> IO () + +#if APR_POOL_DEBUG +# ccall apr_pool_join , Ptr -> Ptr -> IO () +# ccall apr_pool_find , Ptr () -> IO (Ptr ) +# ccall apr_pool_num_bytes, Ptr -> CInt -> IO +# ccall apr_pool_lock , Ptr -> CInt -> IO () +#else +# cinline apr_pool_join, Ptr -> Ptr -> IO () +# cinline apr_pool_lock, Ptr -> CInt -> IO () +#endif diff --git a/bindings-apr.cabal b/bindings-apr.cabal index 1c8947c..af4b80e 100644 --- a/bindings-apr.cabal +++ b/bindings-apr.cabal @@ -30,10 +30,13 @@ Library Exposed-Modules: Bindings.APR Bindings.APR.Allocator + Bindings.APR.Allocator.Types Bindings.APR.Errno + Bindings.APR.Pools C-Sources: cbits/helper_apr_errno.c + cbits/helper_apr_pools.c Extensions: ForeignFunctionInterface diff --git a/cbits/helper_apr_pools.c b/cbits/helper_apr_pools.c new file mode 100644 index 0000000..3544f6d --- /dev/null +++ b/cbits/helper_apr_pools.c @@ -0,0 +1,23 @@ +#include +#include + +#if APR_POOL_DEBUG +BC_INLINE4(apr_pool_create_ex, apr_pool_t**, apr_pool_t*, apr_abortfunc_t, apr_allocator_t*, apr_status_t) +BC_INLINE3(apr_pool_create_core_ex, apr_pool_t**, apr_abortfunc_t, apr_allocator_t*, apr_status_t) +BC_INLINE3(apr_pool_create_unmanaged_ex, apr_pool_t**, apr_abortfunc_t, apr_allocator_t*, apr_status_t) +#endif + +BC_INLINE2(apr_pool_create, apr_pool_t**, apr_pool_t*, apr_status_t) +BC_INLINE1(apr_pool_create_core, apr_pool_t**, apr_status_t) +BC_INLINE1(apr_pool_create_unmanaged, apr_pool_t**, apr_status_t) + +#if APR_POOL_DEBUG +BC_INLINE1VOID(apr_pool_clear , apr_pool_t*) +BC_INLINE1VOID(apr_pool_destroy, apr_pool_t*) +BC_INLINE3(apr_palloc, apr_pool_t*, apr_size_t, const char*, void*) +#endif + +BC_INLINE2(apr_pcalloc, apr_pool_t*, apr_size_t, void*) + +BC_INLINE2VOID(apr_pool_join, apr_pool_t*, apr_pool_t*) +BC_INLINE2VOID(apr_pool_lock, apr_pool_t*, int) -- 2.40.0