- Main Page
- Modules
- Data Structures
- Files

# hpgsmutex.h

    00001 /***********************************************************************
    00002  *                                                                     *
    00003  * $Id: hpgsmutex.h 489 2009-02-11 14:10:30Z softadm $
    00004  *                                                                     *
    00005  * hpgs - HPGl Script, a hpgl/2 interpreter, which uses a Postscript   *
    00006  *        API for rendering a scene and thus renders to a variety of   *
    00007  *        devices and fileformats.                                     *
    00008  *                                                                     *
    00009  * (C) 2004-2009 ev-i Informationstechnologie GmbH  http://www.ev-i.at *
    00010  *                                                                     *
    00011  * Author: Wolfgang Glas                                               *
    00012  *                                                                     *
    00013  *  hpgs is free software; you can redistribute it and/or              *
    00014  * modify it under the terms of the GNU Lesser General Public          *
    00015  * License as published by the Free Software Foundation; either        *
    00016  * version 2.1 of the License, or (at your option) any later version.  *
    00017  *                                                                     *
    00018  * hpgs is distributed in the hope that it will be useful,             *
    00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of      *
    00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   *
    00021  * Lesser General Public License for more details.                     *
    00022  *                                                                     *
    00023  * You should have received a copy of the GNU Lesser General Public    *
    00024  * License along with this library; if not, write to the               *
    00025  * Free Software  Foundation, Inc., 59 Temple Place, Suite 330,        *
    00026  * Boston, MA  02111-1307  USA                                         *
    00027  *                                                                     *
    00028  ***********************************************************************
    00029  *                                                                     *
    00030  * Private header file for thread mutex support.                       *
    00031  *                                                                     *
    00032  ***********************************************************************/
    00033
    00034 #ifndef __HPGS_MUTEX_H__
    00035 #define __HPGS_MUTEX_H__
    00036
    00037 #ifndef __HPGS_H
    00038 #include <hpgs.h>
    00039 #endif
    00040
    00041 #ifdef WIN32
    00042 #include <windows.h>
    00043 typedef CRITICAL_SECTION hpgs_mutex_t;
    00044 #else
    00045 #include <pthread.h>
    00046 typedef pthread_mutex_t hpgs_mutex_t;
    00047 #endif
    00048
    00049 static void hpgs_mutex_init(hpgs_mutex_t *m);
    00050 static void hpgs_mutex_destroy(hpgs_mutex_t *m);
    00051 static void hpgs_mutex_lock(hpgs_mutex_t *m);
    00052 static void hpgs_mutex_unlock(hpgs_mutex_t *m);
    00053
    00054 #ifdef WIN32
    00055
    00056 __inline__ void hpgs_mutex_init(hpgs_mutex_t *m)
    00057 { InitializeCriticalSection(m); }
    00058
    00059 __inline__ void hpgs_mutex_destroy(hpgs_mutex_t *m)
    00060 { DeleteCriticalSection(m); }
    00061
    00062 __inline__ void hpgs_mutex_lock(hpgs_mutex_t *m)
    00063 { EnterCriticalSection(m); }
    00064
    00065 __inline__ void hpgs_mutex_unlock(hpgs_mutex_t *m)
    00066 { LeaveCriticalSection(m); }
    00067
    00068 #else
    00069
    00070 __inline__ void hpgs_mutex_init(hpgs_mutex_t *m)
    00071 { pthread_mutex_init(m,0); }
    00072
    00073 __inline__ void hpgs_mutex_destroy(hpgs_mutex_t *m)
    00074 { pthread_mutex_destroy(m); }
    00075
    00076 __inline__ void hpgs_mutex_lock(hpgs_mutex_t *m)
    00077 { pthread_mutex_lock(m); }
    00078
    00079 __inline__ void hpgs_mutex_unlock(hpgs_mutex_t *m)
    00080 { pthread_mutex_unlock(m); }
    00081
    00082 #endif
    00083
    00084 #endif