michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef BASET_H michael@0: #define BASET_H michael@0: michael@0: /* michael@0: * baset.h michael@0: * michael@0: * This file contains definitions for the basic types used throughout michael@0: * nss but not available publicly. michael@0: */ michael@0: michael@0: #ifndef NSSBASET_H michael@0: #include "nssbaset.h" michael@0: #endif /* NSSBASET_H */ michael@0: michael@0: #include "plhash.h" michael@0: michael@0: PR_BEGIN_EXTERN_C michael@0: michael@0: /* michael@0: * nssArenaMark michael@0: * michael@0: * This type is used to mark the current state of an NSSArena. michael@0: */ michael@0: michael@0: struct nssArenaMarkStr; michael@0: typedef struct nssArenaMarkStr nssArenaMark; michael@0: michael@0: #ifdef DEBUG michael@0: /* michael@0: * ARENA_THREADMARK michael@0: * michael@0: * Optionally, this arena implementation can be compiled with some michael@0: * runtime checking enabled, which will catch the situation where michael@0: * one thread "marks" the arena, another thread allocates memory, michael@0: * and then the mark is released. Usually this is a surprise to michael@0: * the second thread, and this leads to weird runtime errors. michael@0: * Define ARENA_THREADMARK to catch these cases; we define it for all michael@0: * (internal and external) debug builds. michael@0: */ michael@0: #define ARENA_THREADMARK michael@0: michael@0: /* michael@0: * ARENA_DESTRUCTOR_LIST michael@0: * michael@0: * Unfortunately, our pointer-tracker facility, used in debug michael@0: * builds to agressively fight invalid pointers, requries that michael@0: * pointers be deregistered when objects are destroyed. This michael@0: * conflicts with the standard arena usage where "memory-only" michael@0: * objects (that don't hold onto resources outside the arena) michael@0: * can be allocated in an arena, and never destroyed other than michael@0: * when the arena is destroyed. Therefore we have added a michael@0: * destructor-registratio facility to our arenas. This was not michael@0: * a simple decision, since we're getting ever-further away from michael@0: * the original arena philosophy. However, it was felt that michael@0: * adding this in debug builds wouldn't be so bad; as it would michael@0: * discourage them from being used for "serious" purposes. michael@0: * This facility requires ARENA_THREADMARK to be defined. michael@0: */ michael@0: #ifdef ARENA_THREADMARK michael@0: #define ARENA_DESTRUCTOR_LIST michael@0: #endif /* ARENA_THREADMARK */ michael@0: michael@0: #endif /* DEBUG */ michael@0: michael@0: typedef struct nssListStr nssList; michael@0: typedef struct nssListIteratorStr nssListIterator; michael@0: typedef PRBool (* nssListCompareFunc)(void *a, void *b); michael@0: typedef PRIntn (* nssListSortFunc)(void *a, void *b); michael@0: typedef void (* nssListElementDestructorFunc)(void *el); michael@0: michael@0: typedef struct nssHashStr nssHash; michael@0: typedef void (PR_CALLBACK *nssHashIterator)(const void *key, michael@0: void *value, michael@0: void *arg); michael@0: michael@0: /* michael@0: * nssPointerTracker michael@0: * michael@0: * This type is used in debug builds (both external and internal) to michael@0: * track our object pointers. Objects of this type must be statically michael@0: * allocated, which means the structure size must be available to the michael@0: * compiler. Therefore we must expose the contents of this structure. michael@0: * But please don't access elements directly; use the accessors. michael@0: */ michael@0: michael@0: #ifdef DEBUG michael@0: struct nssPointerTrackerStr { michael@0: PRCallOnceType once; michael@0: PZLock *lock; michael@0: PLHashTable *table; michael@0: }; michael@0: typedef struct nssPointerTrackerStr nssPointerTracker; michael@0: #endif /* DEBUG */ michael@0: michael@0: /* michael@0: * nssStringType michael@0: * michael@0: * There are several types of strings in the real world. We try to michael@0: * use only UTF8 and avoid the rest, but that's not always possible. michael@0: * So we have a couple converter routines to go to and from the other michael@0: * string types. We have to be able to specify those string types, michael@0: * so we have this enumeration. michael@0: */ michael@0: michael@0: enum nssStringTypeEnum { michael@0: nssStringType_DirectoryString, michael@0: nssStringType_TeletexString, /* Not "teletext" with trailing 't' */ michael@0: nssStringType_PrintableString, michael@0: nssStringType_UniversalString, michael@0: nssStringType_BMPString, michael@0: nssStringType_UTF8String, michael@0: nssStringType_PHGString, michael@0: nssStringType_GeneralString, michael@0: michael@0: nssStringType_Unknown = -1 michael@0: }; michael@0: typedef enum nssStringTypeEnum nssStringType; michael@0: michael@0: PR_END_EXTERN_C michael@0: michael@0: #endif /* BASET_H */