source: trunk/essentials/dev-lang/perl/NetWare/nw5thread.h@ 3951

Last change on this file since 3951 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 5.0 KB
Line 
1
2/*
3 * Copyright © 2001 Novell, Inc. All Rights Reserved.
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
8 */
9
10/*
11 * FILENAME : nw5thread.h
12 * DESCRIPTION : Thread related functions.
13 * Author : SGP
14 * Date : January 2001.
15 *
16 */
17
18
19
20#ifndef _NW5THREAD_H
21#define _NW5THREAD_H
22
23
24#include <nwthread.h>
25
26#include "netware.h"
27
28typedef long perl_key;
29
30// The line below is just a definition to avoid compilation error.
31// It is not being used anywhere.
32// Ananth, 3 Sept 2001
33typedef struct nw_cond { long waiters; unsigned int sem; } perl_cond;
34
35#if (defined (USE_ITHREADS) || defined (USE_5005THREADS)) && defined(MPK_ON)
36#ifdef __cplusplus
37extern "C"
38{
39#endif
40 #include <mpktypes.h>
41 #include <mpkapis.h>
42 #define kSUCCESS (0)
43 #define ERROR_INVALID_MUTEX (0x1010)
44
45#ifdef __cplusplus
46}
47#endif
48#undef WORD
49//On NetWare, since the NLM will be resident, only once the MUTEX_INIT gets called and
50//this will be freed when the script terminates. But when a new script is executed,
51//then MUTEX_LOCK will fail since it is already freed. Even if this problem is fixed
52//by not freeing the mutex when script terminates but when the NLM unloads, there will
53//still be problems when multiple scripts are running simultaneously in a multi-processor
54//machine - sgp
55typedef MUTEX perl_mutex;
56# define MUTEX_INIT(m) \
57 STMT_START { \
58 /*if ((*(m) = kMutexAlloc("NetWarePerlMutex")) == NULL) */\
59 /*Perl_croak_nocontext("panic: MUTEX_ALLOC"); */\
60 /*ConsolePrintf("Mutex Init %d\n",*(m)); */\
61 } STMT_END
62
63# define MUTEX_LOCK(m) \
64 STMT_START { \
65 /*ConsolePrintf("Mutex lock %d\n",*(m)); */\
66 /*if (kMutexLock(*(m)) == ERROR_INVALID_MUTEX) */\
67 /*Perl_croak_nocontext("panic: MUTEX_LOCK"); */\
68 } STMT_END
69
70# define MUTEX_UNLOCK(m) \
71 STMT_START { \
72 /*ConsolePrintf("Mutex unlock %d\n",*(m)); */\
73 /*if (kMutexUnlock(*(m)) != kSUCCESS) \
74 Perl_croak_nocontext("panic: MUTEX_UNLOCK"); */\
75 } STMT_END
76
77# define MUTEX_DESTROY(m) \
78 STMT_START { \
79 /*ConsolePrintf("Mutex Destroy %d\n",*(m)); */\
80 /*if (kMutexWaitCount(*(m)) == 0 ) */\
81 /*{ */\
82 /*PERL_SET_INTERP(NULL); *//*newly added CHKSGP???*/ \
83 /*if (kMutexFree(*(m)) != kSUCCESS) */ \
84 /*Perl_croak_nocontext("panic: MUTEX_FREE"); */\
85 /*} */\
86 } STMT_END
87
88#else
89typedef unsigned long perl_mutex;
90# define MUTEX_INIT(m)
91# define MUTEX_LOCK(m)
92# define MUTEX_UNLOCK(m)
93# define MUTEX_DESTROY(m)
94#endif