Use bc_lock_t to hide type of locking.
authorjbj <devnull@localhost>
Mon, 12 May 2003 00:36:05 +0000 (00:36 +0000)
committerjbj <devnull@localhost>
Mon, 12 May 2003 00:36:05 +0000 (00:36 +0000)
CVS patchset: 6835
CVS date: 2003/05/12 00:36:05

beecrypt/configure.ac
beecrypt/fips186.h
beecrypt/mtprng.h
beecrypt/types.h.in

index 4e58cde..e1fd1f6 100644 (file)
@@ -357,14 +357,17 @@ fi
 
 # Checks for libraries.
 # XXX Insert "typedef foo bc_lock_t" into types.h.
+include_pthread_h=
 typedef_bc_lock_t=
 if test "$ac_enable_threads" = yes; then
   if test "$ac_cv_header_thread_h" = yes; then
     AC_SEARCH_LIBS([mutex_lock],[thread],[
       AC_DEFINE([ENABLE_THREADS],1)
       if test "$ac_cv_header_sync_h" = yes; then
+       include_pthread_h='#include <sync.h>'
        typedef_bc_lock_t='typedef mutex_t bc_lock_t;'
       else
+       include_pthread_h='#include <pthread.h>'
        typedef_bc_lock_t='typedef pthread_mutex_t bc_lock_t;'
       fi
       ])
@@ -372,6 +375,7 @@ if test "$ac_enable_threads" = yes; then
     AC_SEARCH_LIBS([pthread_mutex_lock],[pthread],[
       AC_DEFINE([ENABLE_THREADS],1)
       if test "$ac_cv_header_pthread_h" = yes; then
+       include_pthread_h='#include <pthread.h>'
        typedef_bc_lock_t='typedef pthread_mutex_t bc_lock_t;'
       fi
       ])
@@ -379,6 +383,7 @@ if test "$ac_enable_threads" = yes; then
     AC_MSG_WARN([Don't know which thread library to check for])
   fi
 fi
+AC_SUBST(include_pthread_h)
 AC_SUBST(typedef_bc_lock_t)
 
 if test "$ac_enable_aio" = yes; then
index 5295864..974d665 100644 (file)
 #define _FIPS186_H
 
 #include "beecrypt.h"
-
-#ifdef _REENTRANT
-# if WIN32
-#  include <windows.h>
-#  include <winbase.h>
-# else
-#  if HAVE_THREAD_H && HAVE_SYNCH_H
-#   include <synch.h>
-#  elif HAVE_PTHREAD_H
-#   include <pthread.h>
-#  else
-#   error need locking mechanism
-#  endif
-# endif
-#endif
-
 #include "sha1.h"
 
 #if (MP_WBITS == 64)
@@ -59,21 +43,14 @@ typedef struct
 {
        #ifdef _REENTRANT
        # if WIN32
-       HANDLE                  lock;
+       HANDLE          lock;
        # else
-       #  if HAVE_THREAD_H && HAVE_SYNCH_H
-       mutex_t                 lock;
-       #  elif HAVE_PTHREAD_H
-       pthread_mutex_t lock;
-       #  else
-       #   error need locking mechanism
-       #  endif
-       # endif
+       bc_lock_t       lock;
        #endif
        sha1Param       param;
-       mpw                     state[FIPS186_STATE_SIZE];
+       mpw             state[FIPS186_STATE_SIZE];
        byte            digest[20];
-       int                     digestremain;
+       int             digestremain;
 } fips186Param;
 
 #ifdef __cplusplus
index baf3dc8..25a84d4 100644 (file)
@@ -38,16 +38,9 @@ typedef struct
 {
        #ifdef _REENTRANT
        # if WIN32
-       HANDLE                  lock;
+       HANDLE  lock;
        # else
-       #  if HAVE_THREAD_H && HAVE_SYNCH_H
-       mutex_t                 lock;
-       #  elif HAVE_PTHREAD_H
-       pthread_mutex_t lock;
-       #  else
-       #   error need locking mechanism
-       #  endif
-       # endif
+       bc_lock_t lock;
        #endif
        uint32_t  state[N+1];
        uint32_t  left;
index 05f53a0..61574b0 100644 (file)
@@ -95,6 +95,9 @@ typedef uint16_t mphw;
 # error
 #endif
 
+#if defined(_REENTRANT)
+@include_pthread_h@
 @typedef_bc_lock_t@
+#endif
 
 #endif /* _TYPES_H */