From fc58b42fbfa0f0381efc68e5dd0f5e83f75500c1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2001 20:13:17 -0500 Subject: Portability and bug fixes for Innobase. Add --with-innobase-db to configure. acconfig.h: HAVE_INNOBASE_DB acinclude.m4: add MYSQL_CHECK_INNOBASE configure.in: use MYSQL_CHECK_INNOBASE and configure innobase directory innobase/configure.in: add AM_MAINTAINER_MODE innobase/include/lock0types.h: define lock_t innobase/include/os0file.h: define S_IRWX[UGO] if needed innobase/include/os0sync.h: use pthread_cond_t instead of mutex innobase/include/sync0types.h: define mutex_t innobase/os/os0sync.c: use pthread_cond_t instead of mutex sql/Makefile.am: add @innobase_{includes,libs}@ sql/ha_innobase.cc: fix casts --- innobase/configure.in | 3 ++- innobase/include/lock0types.h | 1 + innobase/include/os0file.h | 6 ++++++ innobase/include/os0sync.h | 4 ++-- innobase/include/sync0types.h | 1 + innobase/os/os0sync.c | 27 ++++++++++++++++++++------- 6 files changed, 32 insertions(+), 10 deletions(-) (limited to 'innobase') diff --git a/innobase/configure.in b/innobase/configure.in index 1289f881344..ba95df0cc8c 100644 --- a/innobase/configure.in +++ b/innobase/configure.in @@ -1,5 +1,6 @@ # Process this file with autoconf to produce a configure script -AC_INIT(./os/os0file.c) +AC_INIT +AM_MAINTAINER_MODE AM_CONFIG_HEADER(ib_config.h) AM_INIT_AUTOMAKE(ib, 0.90) AC_PROG_CC diff --git a/innobase/include/lock0types.h b/innobase/include/lock0types.h index 705e64f6581..6c3e54ee1fc 100644 --- a/innobase/include/lock0types.h +++ b/innobase/include/lock0types.h @@ -9,6 +9,7 @@ Created 5/7/1996 Heikki Tuuri #ifndef lock0types_h #define lock0types_h +#define lock_t ib_lock_t typedef struct lock_struct lock_t; typedef struct lock_sys_struct lock_sys_t; diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 5b90f24f12e..a02cd947c28 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -28,6 +28,12 @@ Created 10/21/1995 Heikki Tuuri #define POSIX_ASYNC_IO #endif +#ifndef S_IRWXU +#define S_IRWXU 00700 +#define S_IRWXG 00070 +#define S_IRWXO 00007 +#endif + #endif #ifdef __WIN__ diff --git a/innobase/include/os0sync.h b/innobase/include/os0sync.h index dcf519fdb9d..a45f738f22b 100644 --- a/innobase/include/os0sync.h +++ b/innobase/include/os0sync.h @@ -25,8 +25,8 @@ struct os_event_struct { fields */ ibool is_set; /* this is TRUE if the next mutex is not reserved */ - os_fast_mutex_t wait_mutex; /* this mutex is used in waiting for - the event */ + pthread_cond_t cond_var; /* condition variable is used in + waiting for the event */ }; typedef struct os_event_struct os_event_struct_t; typedef os_event_struct_t* os_event_t; diff --git a/innobase/include/sync0types.h b/innobase/include/sync0types.h index 2c31f80cca3..57478426f25 100644 --- a/innobase/include/sync0types.h +++ b/innobase/include/sync0types.h @@ -9,6 +9,7 @@ Created 9/5/1995 Heikki Tuuri #ifndef sync0types_h #define sync0types_h +#define mutex_t ib_mutex_t typedef struct mutex_struct mutex_t; diff --git a/innobase/os/os0sync.c b/innobase/os/os0sync.c index 1647dd982f3..4c283431575 100644 --- a/innobase/os/os0sync.c +++ b/innobase/os/os0sync.c @@ -60,9 +60,9 @@ os_event_create( event = ut_malloc(sizeof(struct os_event_struct)); os_fast_mutex_init(&(event->os_mutex)); - os_fast_mutex_init(&(event->wait_mutex)); + pthread_cond_init(&(event->cond_var), NULL); - event->is_set = TRUE; + event->is_set = FALSE; return(event); #endif @@ -119,8 +119,8 @@ os_event_set( if (event->is_set) { /* Do nothing */ } else { - os_fast_mutex_unlock(&(event->wait_mutex)); event->is_set = TRUE; + pthread_cond_broadcast(&(event->cond_var)); } os_fast_mutex_unlock(&(event->os_mutex)); @@ -148,7 +148,6 @@ os_event_reset( if (!event->is_set) { /* Do nothing */ } else { - os_fast_mutex_lock(&(event->wait_mutex)); event->is_set = FALSE; } @@ -173,7 +172,7 @@ os_event_free( ut_a(event); os_fast_mutex_free(&(event->os_mutex)); - os_fast_mutex_free(&(event->wait_mutex)); + pthread_cond_destroy(&(event->cond_var)); ut_free(event); #endif @@ -197,8 +196,22 @@ os_event_wait( ut_a(err == WAIT_OBJECT_0); #else - os_fast_mutex_lock(&(event->wait_mutex)); - os_fast_mutex_unlock(&(event->wait_mutex)); + os_fast_mutex_lock(&(event->os_mutex)); +loop: + if (event->is_set == TRUE) { + os_fast_mutex_unlock(&(event->os_mutex)); + + /* Ok, we may return */ + + return; + } + + pthread_cond_wait(&(event->cond_var), &(event->os_mutex)); + + /* Solaris manual said that spurious wakeups may occur: we have + to check the 'is_set' variable again */ + + goto loop; #endif } -- cgit v1.2.1