]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /* $NetBSD: fileext.h,v 1.5 2003/07/18 21:46:41 nathanw Exp $ */\r |
2 | \r | |
3 | /*-\r | |
4 | * Copyright (c)2001 Citrus Project,\r | |
5 | * All rights reserved.\r | |
6 | *\r | |
7 | * Redistribution and use in source and binary forms, with or without\r | |
8 | * modification, are permitted provided that the following conditions\r | |
9 | * are met:\r | |
10 | * 1. Redistributions of source code must retain the above copyright\r | |
11 | * notice, this list of conditions and the following disclaimer.\r | |
12 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
13 | * notice, this list of conditions and the following disclaimer in the\r | |
14 | * documentation and/or other materials provided with the distribution.\r | |
15 | *\r | |
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r | |
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r | |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
26 | * SUCH DAMAGE.\r | |
27 | *\r | |
28 | * $Citrus$\r | |
29 | */\r | |
30 | \r | |
31 | /*\r | |
32 | * file extension\r | |
33 | */\r | |
34 | struct __sfileext {\r | |
35 | struct __sbuf _ub; /* ungetc buffer */\r | |
36 | struct wchar_io_data _wcio; /* wide char i/o status */\r | |
37 | #ifdef _REENTRANT\r | |
38 | mutex_t _lock; /* Lock for FLOCKFILE/FUNLOCKFILE */\r | |
39 | cond_t _lockcond; /* Condition variable for signalling lock releases */\r | |
40 | thr_t _lockowner; /* The thread currently holding the lock */\r | |
41 | int _lockcount; /* Count of recursive locks */\r | |
42 | int _lockinternal; /* Flag of whether the lock is held inside stdio */\r | |
43 | int _lockcancelstate; /* Stashed cancellation state on internal lock */\r | |
44 | #endif \r | |
45 | };\r | |
46 | \r | |
47 | #define _EXT(fp) ((struct __sfileext *)(void *)((fp)->_ext._base))\r | |
48 | #define _UB(fp) _EXT(fp)->_ub\r | |
49 | #ifdef _REENTRANT\r | |
50 | #define _LOCK(fp) (_EXT(fp)->_lock)\r | |
51 | #define _LOCKCOND(fp) (_EXT(fp)->_lockcond)\r | |
52 | #define _LOCKOWNER(fp) (_EXT(fp)->_lockowner)\r | |
53 | #define _LOCKCOUNT(fp) (_EXT(fp)->_lockcount)\r | |
54 | #define _LOCKINTERNAL(fp) (_EXT(fp)->_lockinternal)\r | |
55 | #define _LOCKCANCELSTATE(fp) (_EXT(fp)->_lockcancelstate)\r | |
56 | #define _FILEEXT_SETUP(f, fext) do { \\r | |
57 | /* LINTED */(f)->_ext._base = (unsigned char *)(fext); \\r | |
58 | mutex_init(&_LOCK(f), NULL); \\r | |
59 | cond_init(&_LOCKCOND(f), 0, NULL); \\r | |
60 | _LOCKOWNER(f) = NULL; \\r | |
61 | _LOCKCOUNT(f) = 0; \\r | |
62 | _LOCKINTERNAL(f) = 0; \\r | |
63 | } while (/* LINTED */ 0)\r | |
64 | #else\r | |
65 | #define _FILEEXT_SETUP(f, fext) /* LINTED */(f)->_ext._base = (unsigned char *)(fext)\r | |
66 | #endif\r |