diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-10 23:25:31 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-10 23:25:57 +0200 |
commit | 7692b5734a8e508d99c7a6c77f3c0fb482166353 (patch) | |
tree | 129ca1ca19fea316b5648d8181f80c24f4a91da5 /lib/locks.c | |
parent | d0a081ec1b276a80a4b1ca1dc5109fd27ad0abc2 (diff) | |
download | gnutls-7692b5734a8e508d99c7a6c77f3c0fb482166353.tar.gz |
system specific functions were moved to system.c
Diffstat (limited to 'lib/locks.c')
-rw-r--r-- | lib/locks.c | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/lib/locks.c b/lib/locks.c index 30ffd5302e..ea967334ce 100644 --- a/lib/locks.c +++ b/lib/locks.c @@ -31,147 +31,6 @@ #include <locks.h> -#ifdef HAVE_WIN32_LOCKS - -# include <windows.h> - -/* FIXME: win32 locks are untested */ -static int gnutls_system_mutex_init (void **priv) -{ - CRITICAL_SECTION *lock = malloc (sizeof (CRITICAL_SECTION)); - int ret; - - if (lock==NULL) - return GNUTLS_E_MEMORY_ERROR; - - InitializeCriticalSection(lock); - - *priv = lock; - - return 0; -} - -static int gnutls_system_mutex_deinit (void **priv) -{ - DeleteCriticalSection((CRITICAL_SECTION*)*priv); - free(*priv); - - return 0; -} - -static int gnutls_system_mutex_lock (void **priv) -{ - EnterCriticalSection((CRITICAL_SECTION*)*priv); - return 0; -} - -static int gnutls_system_mutex_unlock (void **priv) -{ - LeaveCriticalSection((CRITICAL_SECTION*)*priv); - return 0; -} - -int _gnutls_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) -{ - return 0; -} - - -#endif /* WIN32_LOCKS */ - -#ifdef HAVE_PTHREAD_LOCKS -# include <pthread.h> - -static int gnutls_system_mutex_init (void **priv) -{ - pthread_mutex_t *lock = malloc (sizeof (pthread_mutex_t)); - int ret; - - if (lock==NULL) - return GNUTLS_E_MEMORY_ERROR; - - ret = pthread_mutex_init (lock, NULL); - if (ret) - { - free(lock); - gnutls_assert(); - return GNUTLS_E_LOCKING_ERROR; - } - - *priv = lock; - - return 0; -} - -static int gnutls_system_mutex_deinit (void **priv) -{ - pthread_mutex_destroy((pthread_mutex_t*)*priv); - free(*priv); - return 0; -} - -static int gnutls_system_mutex_lock (void **priv) -{ - if (pthread_mutex_lock((pthread_mutex_t*)*priv)) - { - gnutls_assert(); - return GNUTLS_E_LOCKING_ERROR; - } - - return 0; -} - -static int gnutls_system_mutex_unlock (void **priv) -{ - if (pthread_mutex_unlock((pthread_mutex_t*)*priv)) - { - gnutls_assert(); - return GNUTLS_E_LOCKING_ERROR; - } - - return 0; -} - -int _gnutls_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) -{ - return pthread_atfork(prepare, parent, child); -} - -#endif /* PTHREAD_LOCKS */ - -#ifdef HAVE_NO_LOCKS - -static int gnutls_system_mutex_init (void **priv) -{ - return 0; -} - -static int gnutls_system_mutex_deinit (void **priv) -{ - return 0; -} - -static int gnutls_system_mutex_lock (void **priv) -{ - return 0; -} - -static int gnutls_system_mutex_unlock (void **priv) -{ - return 0; -} - -int _gnutls_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) -{ - return 0; -} - -#endif /* NO_LOCKS */ - -mutex_init_func gnutls_mutex_init = gnutls_system_mutex_init; -mutex_deinit_func gnutls_mutex_deinit = gnutls_system_mutex_deinit; -mutex_lock_func gnutls_mutex_lock = gnutls_system_mutex_lock; -mutex_unlock_func gnutls_mutex_unlock = gnutls_system_mutex_unlock; /** * gnutls_global_set_mutex: |