1
/*--------------------------------------------------------------------*/
4
/* Part of BinkD project */
5
/* Semaphore support (OS/2) for bsy.c module */
6
/*--------------------------------------------------------------------*/
8
/*--------------------------------------------------------------------*/
9
/* Copyright (c) 1996 by Fydodor Ustinov */
10
/* FIDONet 2:5020/79 */
12
/* This program is free software; you can redistribute it and/or */
13
/* modify it under the terms of the GNU General Public License as */
14
/* published by the Free Software Foundation; either version 2 of */
15
/* the License, or (at your option) any later version. See COPYING. */
16
/*--------------------------------------------------------------------*/
18
/*--------------------------------------------------------------------*/
20
/*--------------------------------------------------------------------*/
23
* $Id: sem.c,v 2.0 2001/01/10 12:12:40 gul Exp $
27
* Revision 2.0 2001/01/10 12:12:40 gul
28
* Binkd is under CVS again
30
* Revision 1.2 1996/11/05 04:06:06 mff
31
* Added support for multiple semaphores
33
* Revision 0.01 1996/12/04 14:52:58 ufm
38
/*--------------------------------------------------------------------*/
39
/* System include files */
40
/*--------------------------------------------------------------------*/
50
/*--------------------------------------------------------------------*/
51
/* Local include files */
52
/*--------------------------------------------------------------------*/
54
/*--------------------------------------------------------------------*/
55
/* Global definitions */
56
/*--------------------------------------------------------------------*/
58
#define hmtx (*(HMTX*)vpSem)
60
/*--------------------------------------------------------------------*/
61
/* Global variables */
62
/*--------------------------------------------------------------------*/
64
/*--------------------------------------------------------------------*/
66
/*--------------------------------------------------------------------*/
68
/*--------------------------------------------------------------------*/
69
/* Global functions prototypes */
70
/*--------------------------------------------------------------------*/
72
extern void Log (int lev, char *s,...);
74
/*--------------------------------------------------------------------*/
75
/* int InitSem(void) */
77
/* Initialise Semaphores. */
78
/*--------------------------------------------------------------------*/
80
int init_sem(void *vpSem) {
82
if (DosCreateMutexSem (0, &hmtx, 0, FALSE)) {
83
Log (0, "DosCreateMutexSem: error");
89
/*--------------------------------------------------------------------*/
90
/* int CleanSem(void) */
92
/* Clean Semaphores. */
93
/*--------------------------------------------------------------------*/
95
int clean_sem(void *vpSem) {
96
DosCloseMutexSem (hmtx);
100
/*--------------------------------------------------------------------*/
101
/* int LockSem(void) */
103
/* Wait & lock semaphore */
104
/*--------------------------------------------------------------------*/
106
int lock_sem(void *vpSem) {
107
DosRequestMutexSem (hmtx, SEM_INDEFINITE_WAIT);
111
/*--------------------------------------------------------------------*/
112
/* int ReleaseSem(void) */
114
/* Release Semaphore. */
115
/*--------------------------------------------------------------------*/
117
int release_sem(void *vpSem) {
118
DosReleaseMutexSem (hmtx);