diff options
Diffstat (limited to 'sys/dev/raidframe/rf_mcpair.c')
-rw-r--r-- | sys/dev/raidframe/rf_mcpair.c | 100 |
1 files changed, 53 insertions, 47 deletions
diff --git a/sys/dev/raidframe/rf_mcpair.c b/sys/dev/raidframe/rf_mcpair.c index 5b39b182332..d189c1d1127 100644 --- a/sys/dev/raidframe/rf_mcpair.c +++ b/sys/dev/raidframe/rf_mcpair.c @@ -1,5 +1,6 @@ -/* $OpenBSD: rf_mcpair.c,v 1.2 1999/02/16 00:02:56 niklas Exp $ */ +/* $OpenBSD: rf_mcpair.c,v 1.3 2002/12/16 07:01:04 tdeval Exp $ */ /* $NetBSD: rf_mcpair.c,v 1.3 1999/02/05 00:06:13 oster Exp $ */ + /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -27,9 +28,10 @@ * rights to redistribute these changes. */ -/* rf_mcpair.c - * an mcpair is a structure containing a mutex and a condition variable. - * it's used to block the current thread until some event occurs. +/* + * rf_mcpair.c + * An mcpair is a structure containing a mutex and a condition variable. + * It's used to block the current thread until some event occurs. */ #include "rf_types.h" @@ -43,78 +45,76 @@ static RF_FreeList_t *rf_mcpair_freelist; -#define RF_MAX_FREE_MCPAIR 128 -#define RF_MCPAIR_INC 16 -#define RF_MCPAIR_INITIAL 24 +#define RF_MAX_FREE_MCPAIR 128 +#define RF_MCPAIR_INC 16 +#define RF_MCPAIR_INITIAL 24 -static int init_mcpair(RF_MCPair_t *); -static void clean_mcpair(RF_MCPair_t *); -static void rf_ShutdownMCPair(void *); +int rf_init_mcpair(RF_MCPair_t *); +void rf_clean_mcpair(RF_MCPair_t *); +void rf_ShutdownMCPair(void *); -static int -init_mcpair(t) - RF_MCPair_t *t; +int +rf_init_mcpair(RF_MCPair_t *t) { - int rc; + int rc; rc = rf_mutex_init(&t->mutex); if (rc) { - RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); + RF_ERRORMSG3("Unable to init mutex file %s line %d rc=%d\n", + __FILE__, __LINE__, rc); return (rc); } rc = rf_cond_init(&t->cond); if (rc) { - RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", __FILE__, - __LINE__, rc); + RF_ERRORMSG3("Unable to init cond file %s line %d rc=%d\n", + __FILE__, __LINE__, rc); rf_mutex_destroy(&t->mutex); return (rc); } return (0); } -static void -clean_mcpair(t) - RF_MCPair_t *t; +void +rf_clean_mcpair(RF_MCPair_t *t) { rf_mutex_destroy(&t->mutex); rf_cond_destroy(&t->cond); } -static void -rf_ShutdownMCPair(ignored) - void *ignored; +void +rf_ShutdownMCPair(void *ignored) { - RF_FREELIST_DESTROY_CLEAN(rf_mcpair_freelist, next, (RF_MCPair_t *), clean_mcpair); + RF_FREELIST_DESTROY_CLEAN(rf_mcpair_freelist, next, (RF_MCPair_t *), + rf_clean_mcpair); } -int -rf_ConfigureMCPair(listp) - RF_ShutdownList_t **listp; +int +rf_ConfigureMCPair(RF_ShutdownList_t **listp) { - int rc; + int rc; RF_FREELIST_CREATE(rf_mcpair_freelist, RF_MAX_FREE_MCPAIR, RF_MCPAIR_INC, sizeof(RF_MCPair_t)); rc = rf_ShutdownCreate(listp, rf_ShutdownMCPair, NULL); if (rc) { - RF_ERRORMSG3("Unable to add to shutdown list file %s line %d rc=%d\n", - __FILE__, __LINE__, rc); + RF_ERRORMSG3("Unable to add to shutdown list file %s line %d" + " rc=%d\n", __FILE__, __LINE__, rc); rf_ShutdownMCPair(NULL); return (rc); } RF_FREELIST_PRIME_INIT(rf_mcpair_freelist, RF_MCPAIR_INITIAL, next, - (RF_MCPair_t *), init_mcpair); + (RF_MCPair_t *), rf_init_mcpair); return (0); } RF_MCPair_t * -rf_AllocMCPair() +rf_AllocMCPair(void) { RF_MCPair_t *t; - RF_FREELIST_GET_INIT(rf_mcpair_freelist, t, next, (RF_MCPair_t *), init_mcpair); + RF_FREELIST_GET_INIT(rf_mcpair_freelist, t, next, (RF_MCPair_t *), + rf_init_mcpair); if (t) { t->flag = 0; t->next = NULL; @@ -122,27 +122,33 @@ rf_AllocMCPair() return (t); } -void -rf_FreeMCPair(t) - RF_MCPair_t *t; +void +rf_FreeMCPair(RF_MCPair_t *t) { - RF_FREELIST_FREE_CLEAN(rf_mcpair_freelist, t, next, clean_mcpair); + RF_FREELIST_FREE_CLEAN(rf_mcpair_freelist, t, next, rf_clean_mcpair); } -/* the callback function used to wake you up when you use an mcpair to wait for something */ -void -rf_MCPairWakeupFunc(mcpair) - RF_MCPair_t *mcpair; + +/* + * The callback function used to wake you up when you use an mcpair to wait + * for something. + */ +void +rf_MCPairWakeupFunc(RF_MCPair_t *mcpair) { RF_LOCK_MUTEX(mcpair->mutex); mcpair->flag = 1; #if 0 printf("MCPairWakeupFunc called!\n"); #endif - wakeup(&(mcpair->flag));/* XXX Does this do anything useful!! GO */ - /* XXX Looks like the following is needed to truly get the - * functionality they were looking for here... This could be a + wakeup(&(mcpair->flag)); /* XXX Does this do anything useful !!! GO */ + /* + * XXX + * Looks like the following is needed to truly get the + * functionality they were looking for here... This could be a * side-effect of my using a tsleep in the Net- and OpenBSD port - * though... XXX */ - wakeup(&(mcpair->cond));/* XXX XXX XXX GO */ + * though... + * XXX + */ + wakeup(&(mcpair->cond)); /* XXX XXX XXX GO */ RF_UNLOCK_MUTEX(mcpair->mutex); } |