blob: af205863ae6c7d075d344030b143ca0e8ae4ee34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/** BEGIN COPYRIGHT BLOCK
* Copyright 2001 Sun Microsystems, Inc.
* Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
* All rights reserved.
* END COPYRIGHT BLOCK **/
#ifndef __nslock_h
#define __nslock_h
/*
* Description (nslock.h)
*
* This file defines to interface for a locking facility that
* provides exclusive access to a resource across multiple
* server processes.
*/
#include "nserror.h"
#include "base/crit.h"
#ifdef __PRIVATE_NSLOCK
/*
* Description (NSLock_t)
*
* This type represents a lock. It includes a name which
* uniquely identifies the lock, and a handle for referencing
* the lock once it has been initialized.
*/
typedef struct NSLock_s NSLock_t;
struct NSLock_s {
NSLock_t * nl_next; /* next lock on NSLock_List */
char * nl_name; /* name associate with lock */
#if defined(FILE_UNIX)
CRITICAL nl_crit; /* critical section for threads */
SYS_FILE nl_fd; /* file descriptor */
int nl_cnt; /* nsLockAcquire() count */
#elif defined(XP_WIN32)
#else
#error "nslock.h needs work for this platform"
#endif
};
#endif /* __PRIVATE_NSLOCK */
/* Define error identifiers */
/* nsLockOpen() */
#define NSLERR1000 1000 /* insufficient dynamic memory */
#define NSLERR1020 1020 /* error creating lock */
#define NSLERR1040 1040 /* error accessing lock */
/* nsLockAcquire() */
#define NSLERR1100 1100 /* error acquiring lock */
/* Define error return codes */
#define NSLERRNOMEM -1 /* insufficient dynamic memory */
#define NSLERRCREATE -2 /* error creating lock */
#define NSLERROPEN -3 /* error accessing lock */
#define NSLERRLOCK -4 /* error acquiring lock */
NSPR_BEGIN_EXTERN_C
/* Functions in nslock.c */
extern NSAPI_PUBLIC int nsLockOpen(NSErr_t * errp,
char * lockname, void **plock);
extern NSAPI_PUBLIC int nsLockAcquire(NSErr_t * errp, void * lock);
extern NSAPI_PUBLIC void nsLockRelease(void * lock);
extern NSAPI_PUBLIC void nsLockClose(void * lock);
NSPR_END_EXTERN_C
#endif __nslock_h
|