Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

tdsthread.h

00001 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
00002  *
00003  * Copyright (C) 2005 Liam Widdowson
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the
00017  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018  * Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #ifndef TDSTHREAD_H
00022 #define TDSTHREAD_H 1
00023 
00024 /* $Id: tdsthread.h,v 1.3 2005/07/06 12:35:37 freddy77 Exp $ */
00025 
00026 #if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX)
00027 
00028 #include <pthread.h>
00029 
00030 #define TDS_MUTEX_DECLARE(name) pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER
00031 #define TDS_MUTEX_LOCK(a) pthread_mutex_lock(a)
00032 #define TDS_MUTEX_UNLOCK(a) pthread_mutex_unlock(a)
00033 #define TDS_MUTEX_T pthread_mutex_t
00034 #define TDS_MUTEX_DECLARE_RECURSIVE(name) pthread_mutex_t name = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
00035 #define TDS_MUTEX_INIT_RECURSIVE(mutex) do { \
00036                 pthread_mutexattr_t _attr; \
00037                 pthread_mutexattr_init(&_attr); \
00038                 pthread_mutexattr_settype(&_attr, PTHREAD_MUTEX_RECURSIVE); \
00039                 pthread_mutex_init(mutex, &_attr); \
00040                 pthread_mutexattr_destroy(&_attr); \
00041         } while(0)
00042 #else
00043 
00044 #define TDS_MUTEX_DECLARE(name) int name
00045 #define TDS_MUTEX_LOCK(a)
00046 #define TDS_MUTEX_UNLOCK(a)
00047 #define TDS_MUTEX_T int
00048 #define TDS_MUTEX_DECLARE_RECURSIVE(name) int name
00049 #define TDS_MUTEX_INIT_RECURSIVE(mutex)
00050 #endif
00051 
00052 #endif

Generated on Wed May 7 19:22:09 2008 for FreeTDS API by  doxygen 1.4.1