security/nss/lib/base/baset.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial