typedef pthread_rwlock_t ldap_int_thread_rdwr_t;
#endif
-#ifndef LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL ,PTHREAD_MUTEX_INITIALIZER
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL PTHREAD_MUTEX_INITIALIZER
+#define LDAP_INT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
LDAP_END_DECL
typedef struct condition ldap_int_thread_cond_t;
typedef cthread_key_t ldap_int_thread_key_t;
-#ifndef LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL ,MUTEX_INITIALIZER
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL MUTEX_INITIALIZER
+#define LDAP_INT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
LDAP_END_DECL
typedef pth_rwlock_t ldap_int_thread_rdwr_t;
#endif
-#ifndef LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL ,PTH_MUTEX_INIT
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL PTH_MUTEX_INIT
+#define LDAP_INT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
LDAP_END_DECL
#define LDAP_THREAD_HAVE_SETCONCURRENCY 1
#endif
-#ifndef LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL ,DEFAULTMUTEX
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL DEFAULTMUTEX
+#define LDAP_INT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
#elif defined(HAVE_NT_THREADS)
typedef HANDLE ldap_int_thread_cond_t;
typedef DWORD ldap_int_thread_key_t;
-#ifndef LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL ,(HANDLE)0
-#define MUTEX_FIRSTCREATE(m) (!m ? 0 : ldap_pvt_thread_mutex_init(&m) )
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL ((HANDLE)0)
+#define LDAP_INT_MUTEX_FIRSTCREATE(m) \
+ ((void) ((m) && ldap_int_thread_mutex_init(&(m))))
#endif
LDAP_END_DECL
#define LDAP_THREAD_HAVE_TPOOL 1
typedef int ldap_int_thread_pool_t;
-#ifndef LDO_MUTEX_NULL
-#define LDO_MUTEX_NULL
-#define MUTEX_FIRSTCREATE(m)
+#ifndef LDAP_INT_MUTEX_NULL
+#define LDAP_INT_MUTEX_NULL 0
+#define LDAP_INT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
LDAP_END_DECL
ldap_int_thread_t owner;
} ldap_debug_thread_mutex_t;
+#define LDAP_DEBUG_MUTEX_NULL {LDAP_INT_MUTEX_NULL, {0,0,{0},0} /*,owner*/}
+#define LDAP_DEBUG_MUTEX_FIRSTCREATE(m) \
+ ((void) ((m).usage.state || ldap_pvt_thread_mutex_init(&(m))))
+
typedef struct {
ldap_int_thread_cond_t wrapped;
ldap_debug_usage_info_t usage;
typedef ldap_debug_thread_mutex_t ldap_pvt_thread_mutex_t;
typedef ldap_debug_thread_cond_t ldap_pvt_thread_cond_t;
typedef ldap_debug_thread_rdwr_t ldap_pvt_thread_rdwr_t;
+#define LDAP_PVT_MUTEX_FIRSTCREATE LDAP_DEBUG_MUTEX_FIRSTCREATE
+#define LDAP_PVT_MUTEX_NULL LDAP_DEBUG_MUTEX_NULL
#else
typedef ldap_int_thread_mutex_t ldap_pvt_thread_mutex_t;
typedef ldap_int_thread_cond_t ldap_pvt_thread_cond_t;
typedef ldap_int_thread_rdwr_t ldap_pvt_thread_rdwr_t;
+#define LDAP_PVT_MUTEX_FIRSTCREATE LDAP_INT_MUTEX_FIRSTCREATE
+#define LDAP_PVT_MUTEX_NULL LDAP_INT_MUTEX_NULL
#endif
typedef ldap_int_thread_rmutex_t ldap_pvt_thread_rmutex_t;
typedef ldap_int_thread_key_t ldap_pvt_thread_key_t;
#include "lutil.h"
struct ldapoptions ldap_int_global_options =
- { LDAP_UNINITIALIZED, LDAP_DEBUG_NONE LDO_MUTEX_NULL };
+ { LDAP_UNINITIALIZED, LDAP_DEBUG_NONE LDAP_LDO_MUTEX_NULLARG };
#define ATTR_NONE 0
#define ATTR_BOOL 1
*/
void ldap_int_initialize_global_options( struct ldapoptions *gopts, int *dbglvl )
{
- MUTEX_FIRSTCREATE(gopts->ldo_mutex);
+ LDAP_PVT_MUTEX_FIRSTCREATE(gopts->ldo_mutex);
LDAP_MUTEX_LOCK( &gopts->ldo_mutex );
if (gopts->ldo_valid == LDAP_INITIALIZED) {
/* someone else got here first */
#define LDAP_VALID_SESSION 0x2
#define LDAP_TRASHED_SESSION 0xFF
int ldo_debug;
+
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_t ldo_mutex;
+#define LDAP_LDO_MUTEX_NULLARG , LDAP_PVT_MUTEX_NULL
#else
-#define LDO_MUTEX_NULL
-#define MUTEX_FIRSTCREATE(m)
+#define LDAP_LDO_MUTEX_NULLARG
+#define LDAP_PVT_MUTEX_FIRSTCREATE(m) ((void) 0)
#endif
+
#ifdef LDAP_CONNECTIONLESS
#define LDAP_IS_UDP(ld) ((ld)->ld_options.ldo_is_udp)
void* ldo_peer; /* struct sockaddr* */
#define LDAP_ASSERT_MUTEX_OWNER(mutex) \
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER(mutex)
#else
-#define LDAP_MUTEX_LOCK(mutex)
-#define LDAP_MUTEX_UNLOCK(mutex)
-#define LDAP_ASSERT_MUTEX_OWNER(mutex)
+#define LDAP_MUTEX_LOCK(mutex) ((void) 0)
+#define LDAP_MUTEX_UNLOCK(mutex) ((void) 0)
+#define LDAP_ASSERT_MUTEX_OWNER(mutex) ((void) 0)
#endif
-#ifdef LDAP_R_COMPILE
-#define LDAP_NEXT_MSGID(ld, id) \
+#define LDAP_NEXT_MSGID(ld, id) do { \
LDAP_MUTEX_LOCK( &(ld)->ld_msgid_mutex ); \
- id = ++(ld)->ld_msgid; \
- LDAP_MUTEX_UNLOCK( &(ld)->ld_msgid_mutex )
-#else
-#define LDAP_NEXT_MSGID(ld, id) id = ++(ld)->ld_msgid
-#endif
+ (id) = ++(ld)->ld_msgid; \
+ LDAP_MUTEX_UNLOCK( &(ld)->ld_msgid_mutex ); \
+} while (0)
/*
* in abandon.c