~ubuntu-branches/ubuntu/utopic/binkd/utopic-proposed

« back to all changes in this revision

Viewing changes to os2/sem.c

  • Committer: Bazaar Package Importer
  • Author(s): Marco d'Itri
  • Date: 2002-03-24 22:52:25 UTC
  • Revision ID: james.westby@ubuntu.com-20020324225225-7ru6itlapn03nl35
Tags: upstream-0.9.5a
ImportĀ upstreamĀ versionĀ 0.9.5a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*--------------------------------------------------------------------*/
 
2
/*       S e m . c                                                    */
 
3
/*                                                                    */
 
4
/*       Part of BinkD project                                        */
 
5
/*       Semaphore support (OS/2) for bsy.c module                    */
 
6
/*--------------------------------------------------------------------*/
 
7
 
 
8
/*--------------------------------------------------------------------*/
 
9
/*       Copyright (c) 1996 by Fydodor Ustinov                        */
 
10
/*                             FIDONet 2:5020/79                      */
 
11
/*                                                                    */
 
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
/*--------------------------------------------------------------------*/
 
17
 
 
18
/*--------------------------------------------------------------------*/
 
19
/*                          RCS Information                           */
 
20
/*--------------------------------------------------------------------*/
 
21
 
 
22
/*
 
23
 * $Id: sem.c,v 2.0 2001/01/10 12:12:40 gul Exp $
 
24
 *
 
25
 * Revision history:
 
26
 * $Log: sem.c,v $
 
27
 * Revision 2.0  2001/01/10 12:12:40  gul
 
28
 * Binkd is under CVS again
 
29
 *
 
30
 * Revision 1.2  1996/11/05 04:06:06  mff
 
31
 *      Added support for multiple semaphores
 
32
 *
 
33
 * Revision 0.01  1996/12/04  14:52:58  ufm
 
34
 *      First revision
 
35
 *
 
36
 */
 
37
 
 
38
/*--------------------------------------------------------------------*/
 
39
/*                        System include files                        */
 
40
/*--------------------------------------------------------------------*/
 
41
 
 
42
#ifdef __WATCOMC__
 
43
  #define __IBMC__ 0
 
44
  #define __IBMCPP__ 0
 
45
#endif
 
46
 
 
47
#define INCL_DOS
 
48
#include <os2.h>
 
49
 
 
50
/*--------------------------------------------------------------------*/
 
51
/*                        Local include files                         */
 
52
/*--------------------------------------------------------------------*/
 
53
 
 
54
/*--------------------------------------------------------------------*/
 
55
/*                         Global definitions                         */
 
56
/*--------------------------------------------------------------------*/
 
57
 
 
58
#define hmtx (*(HMTX*)vpSem)
 
59
 
 
60
/*--------------------------------------------------------------------*/
 
61
/*                          Global variables                          */
 
62
/*--------------------------------------------------------------------*/
 
63
 
 
64
/*--------------------------------------------------------------------*/
 
65
/*                           Local variables                          */
 
66
/*--------------------------------------------------------------------*/
 
67
 
 
68
/*--------------------------------------------------------------------*/
 
69
/*                   Global functions prototypes                      */
 
70
/*--------------------------------------------------------------------*/
 
71
 
 
72
extern void Log (int lev, char *s,...);
 
73
 
 
74
/*--------------------------------------------------------------------*/
 
75
/*    int InitSem(void)                                               */
 
76
/*                                                                    */
 
77
/*    Initialise Semaphores.                                          */
 
78
/*--------------------------------------------------------------------*/
 
79
 
 
80
int init_sem(void *vpSem) {
 
81
 
 
82
  if (DosCreateMutexSem (0, &hmtx, 0, FALSE)) {
 
83
     Log (0, "DosCreateMutexSem: error");
 
84
     return(-1);
 
85
   }
 
86
   return(0);
 
87
}
 
88
 
 
89
/*--------------------------------------------------------------------*/
 
90
/*    int CleanSem(void)                                              */
 
91
/*                                                                    */
 
92
/*    Clean Semaphores.                                               */
 
93
/*--------------------------------------------------------------------*/
 
94
 
 
95
int clean_sem(void *vpSem) {
 
96
  DosCloseMutexSem (hmtx);
 
97
  return (0);
 
98
}
 
99
 
 
100
/*--------------------------------------------------------------------*/
 
101
/*    int LockSem(void)                                               */
 
102
/*                                                                    */
 
103
/*    Wait & lock semaphore                                           */
 
104
/*--------------------------------------------------------------------*/
 
105
 
 
106
int lock_sem(void *vpSem) {
 
107
  DosRequestMutexSem (hmtx, SEM_INDEFINITE_WAIT);
 
108
  return (0);
 
109
}
 
110
 
 
111
/*--------------------------------------------------------------------*/
 
112
/*    int ReleaseSem(void)                                            */
 
113
/*                                                                    */
 
114
/*    Release Semaphore.                                              */
 
115
/*--------------------------------------------------------------------*/
 
116
 
 
117
int release_sem(void *vpSem) {
 
118
  DosReleaseMutexSem (hmtx);
 
119
  return (0);
 
120
}
 
121