lock.h

Go to the documentation of this file.
00001 /*
00002  * $Id: lock.h 5003 2008-09-26 11:01:51Z henningw $
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License 
00019  * along with this program; if not, write to the Free Software 
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  * History:
00023  * --------
00024  *  2003-03-17  converted to locking.h (andrei)
00025  *  2004-07-28  s/lock_set_t/gen_lock_set_t/ because of a type conflict
00026  *              on darwin (andrei)
00027  */
00028 
00029 /*! \file
00030  * \brief TM :: Locking functions
00031  *
00032  * \ingroup tm
00033  * - Module: \ref tm
00034  * - \ref lock.c
00035  */
00036 
00037 
00038 #ifndef __lock_h
00039 #define __lock_h
00040 
00041 #include "../../dprint.h"
00042 #include "../../locking.h"
00043 
00044 
00045 
00046 #ifdef GEN_LOCK_T_PREFERED
00047 #define ser_lock_t gen_lock_t
00048 #else
00049 /* typedef to structure we use for mutexing;
00050    currently, index to a semaphore set identifier now */
00051 typedef struct {
00052    gen_lock_set_t* semaphore_set;
00053    int semaphore_index;
00054 } ser_lock_t;
00055 #endif
00056 
00057 
00058 enum timer_groups {
00059    TG_FR,
00060    TG_WT,
00061    TG_DEL,
00062    TG_RT,
00063    TG_NR
00064 };
00065 
00066 
00067 /* extern ser_lock_t timer_group_lock[TG_NR]; */
00068 
00069 #include "h_table.h"
00070 #include "timer.h" 
00071 
00072 #define IPC_PERMISSIONS 0666     /*!< Uni*x permissions for IPC */
00073 
00074 
00075 int lock_initialize(void);
00076 void lock_cleanup(void);
00077 
00078 #ifdef DBG_LOCK
00079 #define lock(_s) _lock( (_s), __FILE__, __FUNCTION__, __LINE__ )
00080 #define unlock(_s) _unlock( (_s), __FILE__, __FUNCTION__, __LINE__ )
00081 #else
00082 #define lock(_s) _lock( (_s) )
00083 #define unlock(_s) _unlock( (_s) )
00084 #endif
00085 
00086 
00087 int init_cell_lock( struct cell *cell );
00088 int init_entry_lock( struct s_table* ht, struct entry *entry );
00089 
00090 
00091 
00092 /* lock semaphore s */
00093 #ifdef DBG_LOCK
00094 static inline void _lock( ser_lock_t* s , char *file, char *function, unsigned int line )
00095 #else
00096 static inline void _lock( ser_lock_t* s )
00097 #endif
00098 {
00099 #ifdef DBG_LOCK
00100    LM_DBG("lock : entered from %s , %s(%d)\n", function, file, line );
00101 #endif
00102 #ifdef GEN_LOCK_T_PREFERED 
00103    lock_get(s);
00104 #else
00105    lock_set_get(s->semaphore_set, s->semaphore_index);
00106 #endif
00107 }
00108 
00109 
00110 
00111 #ifdef DBG_LOCK
00112 static inline void _unlock( ser_lock_t* s, char *file, char *function,
00113       unsigned int line )
00114 #else
00115 static inline void _unlock( ser_lock_t* s )
00116 #endif
00117 {
00118 #ifdef DBG_LOCK
00119    LM_DBG("unlock : entered from %s, %s:%d\n", file, function, line );
00120 #endif
00121 #ifdef GEN_LOCK_T_PREFERED
00122    lock_release(s);
00123 #else
00124    lock_set_release( s->semaphore_set, s->semaphore_index );
00125 #endif
00126 }
00127 
00128 int init_timerlist_lock(  enum lists timerlist_id);
00129 
00130 
00131 #endif
00132 

Generated on Wed May 23 18:00:28 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6