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