OLD | NEW |
| (Empty) |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
4 | |
5 #ifndef BASET_H | |
6 #define BASET_H | |
7 | |
8 #ifdef DEBUG | |
9 static const char BASET_CVS_ID[] = "@(#) $RCSfile: baset.h,v $ $Revision: 1.9 $
$Date: 2012/04/25 14:49:26 $"; | |
10 #endif /* DEBUG */ | |
11 | |
12 /* | |
13 * baset.h | |
14 * | |
15 * This file contains definitions for the basic types used throughout | |
16 * nss but not available publicly. | |
17 */ | |
18 | |
19 #ifndef NSSBASET_H | |
20 #include "nssbaset.h" | |
21 #endif /* NSSBASET_H */ | |
22 | |
23 #include "plhash.h" | |
24 | |
25 PR_BEGIN_EXTERN_C | |
26 | |
27 /* | |
28 * nssArenaMark | |
29 * | |
30 * This type is used to mark the current state of an NSSArena. | |
31 */ | |
32 | |
33 struct nssArenaMarkStr; | |
34 typedef struct nssArenaMarkStr nssArenaMark; | |
35 | |
36 #ifdef DEBUG | |
37 /* | |
38 * ARENA_THREADMARK | |
39 * | |
40 * Optionally, this arena implementation can be compiled with some | |
41 * runtime checking enabled, which will catch the situation where | |
42 * one thread "marks" the arena, another thread allocates memory, | |
43 * and then the mark is released. Usually this is a surprise to | |
44 * the second thread, and this leads to weird runtime errors. | |
45 * Define ARENA_THREADMARK to catch these cases; we define it for all | |
46 * (internal and external) debug builds. | |
47 */ | |
48 #define ARENA_THREADMARK | |
49 | |
50 /* | |
51 * ARENA_DESTRUCTOR_LIST | |
52 * | |
53 * Unfortunately, our pointer-tracker facility, used in debug | |
54 * builds to agressively fight invalid pointers, requries that | |
55 * pointers be deregistered when objects are destroyed. This | |
56 * conflicts with the standard arena usage where "memory-only" | |
57 * objects (that don't hold onto resources outside the arena) | |
58 * can be allocated in an arena, and never destroyed other than | |
59 * when the arena is destroyed. Therefore we have added a | |
60 * destructor-registratio facility to our arenas. This was not | |
61 * a simple decision, since we're getting ever-further away from | |
62 * the original arena philosophy. However, it was felt that | |
63 * adding this in debug builds wouldn't be so bad; as it would | |
64 * discourage them from being used for "serious" purposes. | |
65 * This facility requires ARENA_THREADMARK to be defined. | |
66 */ | |
67 #ifdef ARENA_THREADMARK | |
68 #define ARENA_DESTRUCTOR_LIST | |
69 #endif /* ARENA_THREADMARK */ | |
70 | |
71 #endif /* DEBUG */ | |
72 | |
73 typedef struct nssListStr nssList; | |
74 typedef struct nssListIteratorStr nssListIterator; | |
75 typedef PRBool (* nssListCompareFunc)(void *a, void *b); | |
76 typedef PRIntn (* nssListSortFunc)(void *a, void *b); | |
77 typedef void (* nssListElementDestructorFunc)(void *el); | |
78 | |
79 typedef struct nssHashStr nssHash; | |
80 typedef void (PR_CALLBACK *nssHashIterator)(const void *key, | |
81 void *value, | |
82 void *arg); | |
83 | |
84 /* | |
85 * nssPointerTracker | |
86 * | |
87 * This type is used in debug builds (both external and internal) to | |
88 * track our object pointers. Objects of this type must be statically | |
89 * allocated, which means the structure size must be available to the | |
90 * compiler. Therefore we must expose the contents of this structure. | |
91 * But please don't access elements directly; use the accessors. | |
92 */ | |
93 | |
94 #ifdef DEBUG | |
95 struct nssPointerTrackerStr { | |
96 PRCallOnceType once; | |
97 PZLock *lock; | |
98 PLHashTable *table; | |
99 }; | |
100 typedef struct nssPointerTrackerStr nssPointerTracker; | |
101 #endif /* DEBUG */ | |
102 | |
103 /* | |
104 * nssStringType | |
105 * | |
106 * There are several types of strings in the real world. We try to | |
107 * use only UTF8 and avoid the rest, but that's not always possible. | |
108 * So we have a couple converter routines to go to and from the other | |
109 * string types. We have to be able to specify those string types, | |
110 * so we have this enumeration. | |
111 */ | |
112 | |
113 enum nssStringTypeEnum { | |
114 nssStringType_DirectoryString, | |
115 nssStringType_TeletexString, /* Not "teletext" with trailing 't' */ | |
116 nssStringType_PrintableString, | |
117 nssStringType_UniversalString, | |
118 nssStringType_BMPString, | |
119 nssStringType_UTF8String, | |
120 nssStringType_PHGString, | |
121 nssStringType_GeneralString, | |
122 | |
123 nssStringType_Unknown = -1 | |
124 }; | |
125 typedef enum nssStringTypeEnum nssStringType; | |
126 | |
127 PR_END_EXTERN_C | |
128 | |
129 #endif /* BASET_H */ | |
OLD | NEW |