Sprinkle some copyrights (use the oldest timestamp to
[p5sagit/p5-mst-13.2.git] / sharedsv.h
1 /*    sharedsv.h
2  *
3  *    Copyright (c) 2001-2002, Larry Wall
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 #ifdef USE_ITHREADS
11
12 typedef struct {
13     SV                 *sv;             /* The actual SV */
14     perl_mutex          mutex;          /* Our mutex */
15     perl_cond           cond;           /* Our condition variable */
16     perl_cond           user_cond;      /* For user-level conditions */
17     IV                  locks;          /* Number of locks held */
18     PerlInterpreter    *owner;          /* Who owns the lock? */
19     U16                 index;          /* Update index */
20 } shared_sv;
21
22 #define SHAREDSvGET(a)      (a->sv)
23 #define SHAREDSvLOCK(a)     Perl_sharedsv_lock(aTHX_ a)
24 #define SHAREDSvUNLOCK(a)   Perl_sharedsv_unlock(aTHX_ a)
25
26 #define SHAREDSvEDIT(a)     STMT_START {                                \
27                                 MUTEX_LOCK(&PL_sharedsv_space_mutex);   \
28                                 SHAREDSvLOCK((a));                      \
29                                 PERL_SET_CONTEXT(PL_sharedsv_space);    \
30                             } STMT_END
31
32 #define SHAREDSvRELEASE(a)  STMT_START {                                \
33                                 PERL_SET_CONTEXT((a)->owner);           \
34                                 SHAREDSvUNLOCK((a));                    \
35                                 MUTEX_UNLOCK(&PL_sharedsv_space_mutex); \
36                             } STMT_END
37
38 #endif /* USE_ITHREADS */