Commits

Yìjíe Zeng committed 1e35924

make ucd work in mac

Comments (0)

Files changed (14)

+SOURCES  =$(shell find . -name '*.cpp' -a ! -name '.\#*')
+OBJECTS  =$(SOURCES:.cpp=.o)
+CXXFLAGS+=-Iinclude -Isrc/mozilla -Isrc/mozilla/pr
+
+all: libucd.a
+
+
+clean:
+	$(RM) libucd.a $(OBJECTS)
+
+
+libucd.a: $(OBJECTS)
+	$(AR) $(ARFLAGS) $@ $^
+
+
+# .cpp.o:
+# 	$(CXX) $(CCFLAGS) $(CXXFLAGS) -c $< -o $@

ucd/include/ucd.h

 #ifndef UCD_H
 #define UCD_H
 
-#include <_export.h>
+/* #include <_export.h> */
 
 
+typedef unsigned char byte;
 
-EXTERN_LINK int detectcharset(char *charset, int *sign, FILE *stream);
 
-EXTERN_LINK int detectstrcharset(char *charset, int *sign, char *str,
-                                 size_t len);
+bool detectcharset(std::string* charsetname,
+                   bool* withsignatuure,
+                   // byte block
+                   byte* block, size_t blocksize);
 
-#ifdef WINDOWS
+/* EXTERN_LINK int detectcharset(char *charset, int *sign, FILE *stream); */
 
-// / \note Windows Only
-EXTERN_LINK int LookupCodePage(const char *cpName);
+/* EXTERN_LINK int detectstrcharset(char *charset, int *sign, char *str, */
+/*                                  size_t len); */
 
-#endif
+/* #ifdef WINDOWS */
+
+/* // / \note Windows Only */
+/* EXTERN_LINK int LookupCodePage(const char *cpName); */
+
+/* #endif */
 
 #endif // UCD_H

ucd/src/mozilla/CharDistribution.cpp

  *
  * ***** END LICENSE BLOCK ***** */
 
+#include <nscore.h>
+
 #include "CharDistribution.h"
 
 #include "JISFreq.tab"
 
 //return confidence base on received _data
 float CharDistributionAnalysis::GetConfidence()
-{ 
+{
   //if we didn't receive any character in our consideration range, or the
   // number of frequent characters is below the minimum threshold, return
   // negative answer

ucd/src/mozilla/CharDistribution.h

 #ifndef CharDistribution_h__
 #define CharDistribution_h__
 
-#include "nscore.h"
+// #include "nscore.h"
 
 #define ENOUGH_DATA_THRESHOLD 1024
- 
+
 class CharDistributionAnalysis
 {
 public:
 
   //feed a block of _data and do distribution analysis
   void HandleData(const char* aBuf, PRUint32 aLen) {}
-  
+
   //Feed a character with known length
   void HandleOneChar(const char* aStr, PRUint32 aCharLen)
   {
   //return confidence base on existing _data
   float GetConfidence();
 
-  //Reset analyser, clear any state 
-  void      Reset(void) 
+  //Reset analyser, clear any state
+  void      Reset(void)
   {
     mDone = PR_FALSE;
     mTotalChars = 0;
   PRBool GotEnoughData() {return mTotalChars > ENOUGH_DATA_THRESHOLD;}
 
 protected:
-  //we do not handle character base on its original encoding string, but 
+  //we do not handle character base on its original encoding string, but
   //convert this encoding string to a number, here called order.
-  //This allow multiple encoding of a language to share one frequency table 
+  //This allow multiple encoding of a language to share one frequency table
   virtual PRInt32 GetOrder(const char* str) {return -1;}
-  
+
   //If this flag is set to PR_TRUE, detection is done and conclusion has been made
   PRBool   mDone;
 
   //Size of above table
   PRUint32 mTableSize;
 
-  //This is a constant value varies from language to language, it is used in 
+  //This is a constant value varies from language to language, it is used in
   //calculating confidence. See my paper for further detail.
   float    mTypicalDistributionRatio;
 };
   EUCTWDistributionAnalysis();
 protected:
 
-  //for euc-TW encoding, we are interested 
+  //for euc-TW encoding, we are interested
   //  first  byte range: 0xc4 -- 0xfe
   //  second byte range: 0xa1 -- 0xfe
   //no validation needed here. State machine has done that
-  PRInt32 GetOrder(const char* str) 
-  { if ((unsigned char)*str >= (unsigned char)0xc4)  
+  PRInt32 GetOrder(const char* str)
+  { if ((unsigned char)*str >= (unsigned char)0xc4)
       return 94*((unsigned char)str[0]-(unsigned char)0xc4) + (unsigned char)str[1] - (unsigned char)0xa1;
     else
       return -1;
 public:
   EUCKRDistributionAnalysis();
 protected:
-  //for euc-KR encoding, we are interested 
+  //for euc-KR encoding, we are interested
   //  first  byte range: 0xb0 -- 0xfe
   //  second byte range: 0xa1 -- 0xfe
   //no validation needed here. State machine has done that
-  PRInt32 GetOrder(const char* str) 
-  { if ((unsigned char)*str >= (unsigned char)0xb0)  
+  PRInt32 GetOrder(const char* str)
+  { if ((unsigned char)*str >= (unsigned char)0xb0)
       return 94*((unsigned char)str[0]-(unsigned char)0xb0) + (unsigned char)str[1] - (unsigned char)0xa1;
     else
       return -1;
 public:
   GB2312DistributionAnalysis();
 protected:
-  //for GB2312 encoding, we are interested 
+  //for GB2312 encoding, we are interested
   //  first  byte range: 0xb0 -- 0xfe
   //  second byte range: 0xa1 -- 0xfe
   //no validation needed here. State machine has done that
-  PRInt32 GetOrder(const char* str) 
-  { if ((unsigned char)*str >= (unsigned char)0xb0 && (unsigned char)str[1] >= (unsigned char)0xa1)  
+  PRInt32 GetOrder(const char* str)
+  { if ((unsigned char)*str >= (unsigned char)0xb0 && (unsigned char)str[1] >= (unsigned char)0xa1)
       return 94*((unsigned char)str[0]-(unsigned char)0xb0) + (unsigned char)str[1] - (unsigned char)0xa1;
     else
       return -1;
 public:
   Big5DistributionAnalysis();
 protected:
-  //for big5 encoding, we are interested 
+  //for big5 encoding, we are interested
   //  first  byte range: 0xa4 -- 0xfe
   //  second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe
   //no validation needed here. State machine has done that
-  PRInt32 GetOrder(const char* str) 
-  { if ((unsigned char)*str >= (unsigned char)0xa4)  
+  PRInt32 GetOrder(const char* str)
+  { if ((unsigned char)*str >= (unsigned char)0xa4)
       if ((unsigned char)str[1] >= (unsigned char)0xa1)
         return 157*((unsigned char)str[0]-(unsigned char)0xa4) + (unsigned char)str[1] - (unsigned char)0xa1 +63;
       else
 public:
   SJISDistributionAnalysis();
 protected:
-  //for sjis encoding, we are interested 
+  //for sjis encoding, we are interested
   //  first  byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe
   //  second byte range: 0x40 -- 0x7e,  0x81 -- oxfe
   //no validation needed here. State machine has done that
-  PRInt32 GetOrder(const char* str) 
-  { 
+  PRInt32 GetOrder(const char* str)
+  {
     PRInt32 order;
-    if ((unsigned char)*str >= (unsigned char)0x81 && (unsigned char)*str <= (unsigned char)0x9f)  
+    if ((unsigned char)*str >= (unsigned char)0x81 && (unsigned char)*str <= (unsigned char)0x9f)
       order = 188 * ((unsigned char)str[0]-(unsigned char)0x81);
-    else if ((unsigned char)*str >= (unsigned char)0xe0 && (unsigned char)*str <= (unsigned char)0xef)  
+    else if ((unsigned char)*str >= (unsigned char)0xe0 && (unsigned char)*str <= (unsigned char)0xef)
       order = 188 * ((unsigned char)str[0]-(unsigned char)0xe0 + 31);
     else
       return -1;
 public:
   EUCJPDistributionAnalysis();
 protected:
-  //for euc-JP encoding, we are interested 
+  //for euc-JP encoding, we are interested
   //  first  byte range: 0xa0 -- 0xfe
   //  second byte range: 0xa1 -- 0xfe
   //no validation needed here. State machine has done that
-  PRInt32 GetOrder(const char* str) 
-  { if ((unsigned char)*str >= (unsigned char)0xa0)  
+  PRInt32 GetOrder(const char* str)
+  { if ((unsigned char)*str >= (unsigned char)0xa0)
       return 94*((unsigned char)str[0]-(unsigned char)0xa1) + (unsigned char)str[1] - (unsigned char)0xa1;
     else
       return -1;

ucd/src/mozilla/nscore.h

-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#ifndef nscore_h___
-#define nscore_h___
-
-/**
- * Make sure that we have the proper platform specific
- * c++ definitions needed by nscore.h
- */
-#ifndef _XPCOM_CONFIG_H_
-#include "xpcom-config.h"
-#endif
-
-/**
- * Incorporate the core NSPR _data types which XPCOM uses.
- */
-#include "prtypes.h"
-
-/* Core XPCOM declarations. */
-
-/**
- * Macros defining the target platform...
- */
-#ifdef _WIN32
-#define NS_WIN32 1
-
-#elif defined(__unix)
-#define NS_UNIX 1
-
-#elif defined(XP_OS2)
-#define NS_OS2 1
-#endif
-/*----------------------------------------------------------------------*/
-/* Import/export defines */
-
-/**
- * Using the visibility("hidden") attribute allows the compiler to use
- * PC-relative addressing to call this function.  If a function does not
- * access any global _data, and does not call any methods which are not either
- * file-local or hidden, then on ELF systems we avoid loading the address of
- * the PLT into a register at the start of the function, which reduces code
- * size and frees up a register for general use.
- *
- * As a general rule, this should be used for any non-exported symbol
- * (including virtual method implementations).  NS_IMETHOD uses this by
- * default; if you need to have your NS_IMETHOD functions exported, you can
- * wrap your class as follows:
- *
- * #undef  IMETHOD_VISIBILITY
- * #define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
- *
- * class Foo {
- * ...
- * };
- *
- * #undef  IMETHOD_VISIBILITY
- * #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
- *
- * Don't forget to change the visibility back to hidden before the end
- * of a header!
- *
- * Other examples:
- *
- * NS_HIDDEN_(int) someMethod();
- * SomeCtor() NS_HIDDEN;
- */
-
-#ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE
-#define NS_VISIBILITY_HIDDEN   __attribute__ ((visibility ("hidden")))
-#else
-#define NS_VISIBILITY_HIDDEN
-#endif
-
-#if defined(HAVE_VISIBILITY_ATTRIBUTE)
-#define NS_VISIBILITY_DEFAULT __attribute__ ((visibility ("default")))
-#else
-#define NS_VISIBILITY_DEFAULT
-#endif
-
-#define NS_HIDDEN_(type)   NS_VISIBILITY_HIDDEN type
-#define NS_EXTERNAL_VIS_(type) NS_VISIBILITY_DEFAULT type
-
-#define NS_HIDDEN           NS_VISIBILITY_HIDDEN
-#define NS_EXTERNAL_VIS     NS_VISIBILITY_DEFAULT
-
-#undef  IMETHOD_VISIBILITY
-#define IMETHOD_VISIBILITY  NS_VISIBILITY_HIDDEN
-
-/**
- * Mark a function as using a potentially non-standard function calling
- * convention.  This can be used on functions that are called very
- * frequently, to reduce the overhead of the function call.  It is still worth
- * using the macro for C++ functions which take no parameters since it allows
- * passing |this| in a register.
- *
- *  - Do not use this on any scriptable interface method since xptcall won't be
- *    aware of the different calling convention.
- *  - This must appear on the declaration, not the definition.
- *  - Adding this to a public function _will_ break binary compatibility.
- *  - This may be used on virtual functions but you must ensure it is applied
- *    to all implementations - the compiler will _not_ warn but it will crash.
- *  - This has no effect for inline functions or functions which take a
- *    variable number of arguments.
- *  - __fastcall on windows should not be applied to class
- *    constructors/destructors - use the NS_CONSTRUCTOR_FASTCALL macro for
- *    constructors/destructors.
- *
- * Examples: int NS_FASTCALL func1(char *foo);
- *           NS_HIDDEN_(int) NS_FASTCALL func2(char *foo);
- */
-
-#if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2)
-#define NS_FASTCALL __attribute__ ((regparm (3), stdcall))
-#define NS_CONSTRUCTOR_FASTCALL __attribute__ ((regparm (3), stdcall))
-#elif defined(XP_WIN)
-#define NS_FASTCALL __fastcall
-#define NS_CONSTRUCTOR_FASTCALL
-#else
-#define NS_FASTCALL
-#define NS_CONSTRUCTOR_FASTCALL
-#endif
-
-/*
- * NS_DEFCALL undoes the effect of a global regparm/stdcall setting
- * so that xptcall works correctly.
- */
-#if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2)
-#define NS_DEFCALL __attribute__ ((regparm (0), cdecl))
-#else
-#define NS_DEFCALL
-#endif
-
-#ifdef NS_WIN32
-
-#define NS_IMPORT
-#define NS_IMPORT_(type) type __stdcall
-#define NS_EXPORT
-#define NS_EXPORT_(type) type __stdcall
-#define NS_IMETHOD_(type) virtual type __stdcall
-#define NS_IMETHODIMP_(type) type __stdcall
-#define NS_METHOD_(type) type __stdcall
-#define NS_CALLBACK_(_type, _name) _type (__stdcall * _name)
-#define NS_STDCALL __stdcall
-#define NS_FROZENCALL __cdecl
-
-/*
-  These are needed to mark static members in exported classes, due to
-  gcc bug XXX insert bug# here.
- */
-
-#define NS_EXPORT_STATIC_MEMBER_(type) type
-#define NS_IMPORT_STATIC_MEMBER_(type) type
-
-#elif defined(XP_OS2) && defined(__declspec)
-
-#define NS_IMPORT
-#define NS_IMPORT_(type) type
-#define NS_EXPORT
-#define NS_EXPORT_(type) type
-#define NS_IMETHOD_(type) virtual type
-#define NS_IMETHODIMP_(type) type
-#define NS_METHOD_(type) type
-#define NS_CALLBACK_(_type, _name) _type (* _name)
-#define NS_STDCALL
-#define NS_FROZENCALL
-#define NS_EXPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
-#define NS_IMPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
-
-#else
-
-#define NS_IMPORT NS_EXTERNAL_VIS
-#define NS_IMPORT_(type) NS_EXTERNAL_VIS_(type)
-#define NS_EXPORT NS_EXTERNAL_VIS
-#define NS_EXPORT_(type) NS_EXTERNAL_VIS_(type)
-#define NS_IMETHOD_(type) virtual IMETHOD_VISIBILITY type NS_DEFCALL
-#define NS_IMETHODIMP_(type) type
-#define NS_METHOD_(type) type
-#define NS_CALLBACK_(_type, _name) _type (* _name)
-#define NS_STDCALL
-#define NS_FROZENCALL
-#define NS_EXPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
-#define NS_IMPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
-
-#endif
-
-/**
- * Macro for creating typedefs for pointer-to-member types which are
- * declared with stdcall.  It is important to use this for any type which is
- * declared as stdcall (i.e. NS_IMETHOD).  For example, instead of writing:
- *
- *  typedef nsresult (nsIFoo::*someType)(nsISupports* arg);
- *
- *  you should write:
- *
- *  typedef
- *  NS_STDCALL_FUNCPROTO(nsresult, someType, nsIFoo, typeFunc, (nsISupports*));
- *
- *  where nsIFoo::typeFunc is any method declared as
- *  NS_IMETHOD typeFunc(nsISupports*);
- *
- *  XXX this can be simplified to always use the non-typeof implementation
- *  when http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11893 is fixed.
- */
-
-#ifdef __GNUC__
-#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
-  typeof(&class::func) name
-#else
-#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
-  ret (NS_STDCALL class::*name) args
-#endif
-
-/**
- * Deprecated declarations.
- */
-#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-# define NS_DEPRECATED __attribute__((deprecated))
-#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
-# define NS_DEPRECATED __declspec(deprecated)
-#else
-# define NS_DEPRECATED
-#endif
-
-/**
- * Attributes defined to help Dehydra GCC analysis.
- */
-#ifdef DEHYDRA_GCC
-# define NS_SCRIPTABLE __attribute__((user("script")))
-#else
-# define NS_SCRIPTABLE
-#endif
-
-/**
- * Generic API modifiers which return the standard XPCOM nsresult type
- */
-#define NS_IMETHOD          NS_IMETHOD_(nsresult)
-#define NS_IMETHODIMP       NS_IMETHODIMP_(nsresult)
-#define NS_METHOD           NS_METHOD_(nsresult)
-#define NS_CALLBACK(_name)  NS_CALLBACK_(nsresult, _name)
-
-/**
- * Import/Export macros for XPCOM APIs
- */
-
-#ifdef __cplusplus
-#define NS_EXTERN_C extern "C"
-#else
-#define NS_EXTERN_C
-#endif
-
-#define EXPORT_XPCOM_API(type) NS_EXTERN_C NS_EXPORT type NS_FROZENCALL
-#define IMPORT_XPCOM_API(type) NS_EXTERN_C NS_IMPORT type NS_FROZENCALL
-#define GLUE_XPCOM_API(type) NS_EXTERN_C NS_HIDDEN_(type) NS_FROZENCALL
-
-#ifdef _IMPL_NS_COM
-#define XPCOM_API(type) EXPORT_XPCOM_API(type)
-#elif defined(XPCOM_GLUE)
-#define XPCOM_API(type) GLUE_XPCOM_API(type)
-#else
-#define XPCOM_API(type) IMPORT_XPCOM_API(type)
-#endif
-
-#ifdef MOZ_ENABLE_LIBXUL
-#define NS_COM
-#elif defined(_IMPL_NS_COM)
-#define NS_COM NS_EXPORT
-#elif defined(XPCOM_GLUE)
-#define NS_COM
-#else
-#define NS_COM NS_IMPORT
-#endif
-
-#ifdef MOZILLA_INTERNAL_API
-#  define NS_COM_GLUE NS_COM
-   /*
-     The frozen string API has different definitions of nsAC?String
-     classes than the internal API. On systems that explicitly declare
-     dllexport symbols this is not a problem, but on ELF systems
-     internal symbols can accidentally "shine through"; we rename the
-     internal classes to avoid symbol conflicts.
-   */
-#  define nsAString nsAString_internal
-#  define nsACString nsACString_internal
-#else
-#  ifdef HAVE_VISIBILITY_ATTRIBUTE
-#    define NS_COM_GLUE NS_VISIBILITY_HIDDEN
-#  else
-#    define NS_COM_GLUE
-#  endif
-#endif
-
-
-/**
- * NS_NO_VTABLE is emitted by xpidl in interface declarations whenever
- * xpidl can determine that the interface can't contain a constructor.
- * This results in some space savings and possible runtime savings -
- * see bug 49416.  We undefine it first, as xpidl-generated headers
- * define it for IDL uses that don't include this file.
- */
-#ifdef NS_NO_VTABLE
-#undef NS_NO_VTABLE
-#endif
-#if defined(_MSC_VER) && _MSC_VER >= 1100
-#define NS_NO_VTABLE __declspec(novtable)
-#else
-#define NS_NO_VTABLE
-#endif
-
-
-/**
- * Generic XPCOM result _data type
- */
-typedef PRUint32 nsresult;
-
-/**
- * Reference count values
- *
- * This is the return type for AddRef() and Release() in nsISupports.
- * IUnknown of COM returns an unsigned long from equivalent functions.
- * The following ifdef exists to maintain binary compatibility with
- * IUnknown.
- */
-#if defined(XP_WIN) && PR_BYTES_PER_LONG == 4
-typedef unsigned long nsrefcnt;
-#else
-typedef PRUint32 nsrefcnt;
-#endif
-
-/**
- * The preferred symbol for null.
- */
-#define nsnull 0
-
-#include "nsError.h"
-
-/* ------------------------------------------------------------------------ */
-/* Casting macros for hiding C++ features from older compilers */
-
-  /*
-    All our compiler support template specialization, but not all support the
-    |template <>| notation.  The compiler that don't understand this notation
-    just omit it for specialization.
-
-    Need to add an autoconf test for this.
-  */
-
-  /* under Metrowerks (Mac), we don't have autoconf yet */
-#ifdef __MWERKS__
-  #define HAVE_CPP_PARTIAL_SPECIALIZATION
-  #define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
-
-  #define HAVE_CPP_ACCESS_CHANGING_USING
-  #define HAVE_CPP_AMBIGUITY_RESOLVING_USING
-  #define HAVE_CPP_EXPLICIT
-  #define HAVE_CPP_TYPENAME
-  #define HAVE_CPP_BOOL
-  #define HAVE_CPP_NAMESPACE_STD
-  #define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
-  #define HAVE_CPP_2BYTE_WCHAR_T
-#endif
-
-  /* under VC++ (Windows), we don't have autoconf yet */
-#if defined(_MSC_VER) && (_MSC_VER>=1100)
-  /* VC++ 5.0 and greater implement template specialization, 4.2 is unknown */
-  #define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
-
-  #define HAVE_CPP_EXPLICIT
-  #define HAVE_CPP_TYPENAME
-  #define HAVE_CPP_ACCESS_CHANGING_USING
-
-  #if (_MSC_VER==1100)
-      /* VC++5.0 has an internal compiler error (sometimes) without this */
-    #undef HAVE_CPP_ACCESS_CHANGING_USING
-  #endif
-
-  #define HAVE_CPP_NAMESPACE_STD
-  #define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
-  #define HAVE_CPP_2BYTE_WCHAR_T
-#endif
-
-#ifndef __PRUNICHAR__
-#define __PRUNICHAR__
-  /* For now, don't use wchar_t on Unix because it breaks the Netscape
-   * commercial build.  When this is fixed there will be no need for the
-   * |reinterpret_cast| in nsLiteralString.h either.
-   */
-  #if defined(HAVE_CPP_2BYTE_WCHAR_T) && defined(NS_WIN32)
-    typedef wchar_t PRUnichar;
-  #else
-    typedef PRUint16 PRUnichar;
-  #endif
-#endif
-
-  /*
-    If the compiler doesn't support |explicit|, we'll just make it go away, trusting
-    that the builds under compilers that do have it will keep us on the straight and narrow.
-  */
-#ifndef HAVE_CPP_EXPLICIT
-  #define explicit
-#endif
-
-#ifndef HAVE_CPP_TYPENAME
-  #define typename
-#endif
-
-#ifdef HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
-  #define NS_SPECIALIZE_TEMPLATE  template <>
-#else
-  #define NS_SPECIALIZE_TEMPLATE
-#endif
-
-/*
- * Use these macros to do 64bit safe pointer conversions.
- */
-
-#define NS_PTR_TO_INT32(x)  ((PRInt32)  (PRWord) (x))
-#define NS_PTR_TO_UINT32(x) ((PRUint32) (PRWord) (x))
-#define NS_INT32_TO_PTR(x)  ((void *)   (PRWord) (x))
-
-/*
- * Use NS_STRINGIFY to form a string literal from the value of a macro.
- */
-#define NS_STRINGIFY_HELPER(x_) #x_
-#define NS_STRINGIFY(x_) NS_STRINGIFY_HELPER(x_)
-
-/*
- * These macros allow you to give a hint to the compiler about branch
- * probability so that it can better optimize.  Use them like this:
- *
- *  if (NS_LIKELY(v == 1)) {
- *    ... expected code path ...
- *  }
- *
- *  if (NS_UNLIKELY(v == 0)) {
- *    ... non-expected code path ...
- *  }
- *
- * These macros are guaranteed to always return 0 or 1.
- * The NS_FAILED/NS_SUCCEEDED macros depends on this.
- * @return 0 or 1
- */
-
-#if defined(__GNUC__) && (__GNUC__ > 2)
-#define NS_LIKELY(x)    (__builtin_expect(!!(x), 1))
-#define NS_UNLIKELY(x)  (__builtin_expect(!!(x), 0))
-#else
-#define NS_LIKELY(x)    (!!(x))
-#define NS_UNLIKELY(x)  (!!(x))
-#endif
-
- /*
-  * If we're being linked as standalone glue, we don't want a dynamic dependency
-  * on NSPR libs, so we skip the debug thread-safety checks, and we cannot use
-  * the THREADSAFE_ISUPPORTS macros.
-  */
-#if defined(XPCOM_GLUE) && !defined(XPCOM_GLUE_USE_NSPR)
-#define XPCOM_GLUE_AVOID_NSPR
-#endif
-
-#endif /* nscore_h___ */

ucd/src/mozilla/pr/nscore.h

+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+#ifndef nscore_h___
+#define nscore_h___
+
+/**
+ * Make sure that we have the proper platform specific
+ * c++ definitions needed by nscore.h
+ */
+#ifndef _XPCOM_CONFIG_H_
+#include "xpcom-config.h"
+#endif
+
+/**
+ * Incorporate the core NSPR _data types which XPCOM uses.
+ */
+#include "prtypes.h"
+
+/* Core XPCOM declarations. */
+
+/**
+ * Macros defining the target platform...
+ */
+#ifdef _WIN32
+#define NS_WIN32 1
+
+#elif defined(__unix)
+#define NS_UNIX 1
+
+#elif defined(XP_OS2)
+#define NS_OS2 1
+#endif
+/*----------------------------------------------------------------------*/
+/* Import/export defines */
+
+/**
+ * Using the visibility("hidden") attribute allows the compiler to use
+ * PC-relative addressing to call this function.  If a function does not
+ * access any global _data, and does not call any methods which are not either
+ * file-local or hidden, then on ELF systems we avoid loading the address of
+ * the PLT into a register at the start of the function, which reduces code
+ * size and frees up a register for general use.
+ *
+ * As a general rule, this should be used for any non-exported symbol
+ * (including virtual method implementations).  NS_IMETHOD uses this by
+ * default; if you need to have your NS_IMETHOD functions exported, you can
+ * wrap your class as follows:
+ *
+ * #undef  IMETHOD_VISIBILITY
+ * #define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
+ *
+ * class Foo {
+ * ...
+ * };
+ *
+ * #undef  IMETHOD_VISIBILITY
+ * #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
+ *
+ * Don't forget to change the visibility back to hidden before the end
+ * of a header!
+ *
+ * Other examples:
+ *
+ * NS_HIDDEN_(int) someMethod();
+ * SomeCtor() NS_HIDDEN;
+ */
+
+#ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE
+#define NS_VISIBILITY_HIDDEN   __attribute__ ((visibility ("hidden")))
+#else
+#define NS_VISIBILITY_HIDDEN
+#endif
+
+#if defined(HAVE_VISIBILITY_ATTRIBUTE)
+#define NS_VISIBILITY_DEFAULT __attribute__ ((visibility ("default")))
+#else
+#define NS_VISIBILITY_DEFAULT
+#endif
+
+#define NS_HIDDEN_(type)   NS_VISIBILITY_HIDDEN type
+#define NS_EXTERNAL_VIS_(type) NS_VISIBILITY_DEFAULT type
+
+#define NS_HIDDEN           NS_VISIBILITY_HIDDEN
+#define NS_EXTERNAL_VIS     NS_VISIBILITY_DEFAULT
+
+#undef  IMETHOD_VISIBILITY
+#define IMETHOD_VISIBILITY  NS_VISIBILITY_HIDDEN
+
+/**
+ * Mark a function as using a potentially non-standard function calling
+ * convention.  This can be used on functions that are called very
+ * frequently, to reduce the overhead of the function call.  It is still worth
+ * using the macro for C++ functions which take no parameters since it allows
+ * passing |this| in a register.
+ *
+ *  - Do not use this on any scriptable interface method since xptcall won't be
+ *    aware of the different calling convention.
+ *  - This must appear on the declaration, not the definition.
+ *  - Adding this to a public function _will_ break binary compatibility.
+ *  - This may be used on virtual functions but you must ensure it is applied
+ *    to all implementations - the compiler will _not_ warn but it will crash.
+ *  - This has no effect for inline functions or functions which take a
+ *    variable number of arguments.
+ *  - __fastcall on windows should not be applied to class
+ *    constructors/destructors - use the NS_CONSTRUCTOR_FASTCALL macro for
+ *    constructors/destructors.
+ *
+ * Examples: int NS_FASTCALL func1(char *foo);
+ *           NS_HIDDEN_(int) NS_FASTCALL func2(char *foo);
+ */
+
+#if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2)
+#define NS_FASTCALL __attribute__ ((regparm (3), stdcall))
+#define NS_CONSTRUCTOR_FASTCALL __attribute__ ((regparm (3), stdcall))
+#elif defined(XP_WIN)
+#define NS_FASTCALL __fastcall
+#define NS_CONSTRUCTOR_FASTCALL
+#else
+#define NS_FASTCALL
+#define NS_CONSTRUCTOR_FASTCALL
+#endif
+
+/*
+ * NS_DEFCALL undoes the effect of a global regparm/stdcall setting
+ * so that xptcall works correctly.
+ */
+#if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2)
+#define NS_DEFCALL __attribute__ ((regparm (0), cdecl))
+#else
+#define NS_DEFCALL
+#endif
+
+#ifdef NS_WIN32
+
+#define NS_IMPORT
+#define NS_IMPORT_(type) type __stdcall
+#define NS_EXPORT
+#define NS_EXPORT_(type) type __stdcall
+#define NS_IMETHOD_(type) virtual type __stdcall
+#define NS_IMETHODIMP_(type) type __stdcall
+#define NS_METHOD_(type) type __stdcall
+#define NS_CALLBACK_(_type, _name) _type (__stdcall * _name)
+#define NS_STDCALL __stdcall
+#define NS_FROZENCALL __cdecl
+
+/*
+  These are needed to mark static members in exported classes, due to
+  gcc bug XXX insert bug# here.
+ */
+
+#define NS_EXPORT_STATIC_MEMBER_(type) type
+#define NS_IMPORT_STATIC_MEMBER_(type) type
+
+#elif defined(XP_OS2) && defined(__declspec)
+
+#define NS_IMPORT
+#define NS_IMPORT_(type) type
+#define NS_EXPORT
+#define NS_EXPORT_(type) type
+#define NS_IMETHOD_(type) virtual type
+#define NS_IMETHODIMP_(type) type
+#define NS_METHOD_(type) type
+#define NS_CALLBACK_(_type, _name) _type (* _name)
+#define NS_STDCALL
+#define NS_FROZENCALL
+#define NS_EXPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
+#define NS_IMPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
+
+#else
+
+#define NS_IMPORT NS_EXTERNAL_VIS
+#define NS_IMPORT_(type) NS_EXTERNAL_VIS_(type)
+#define NS_EXPORT NS_EXTERNAL_VIS
+#define NS_EXPORT_(type) NS_EXTERNAL_VIS_(type)
+#define NS_IMETHOD_(type) virtual IMETHOD_VISIBILITY type NS_DEFCALL
+#define NS_IMETHODIMP_(type) type
+#define NS_METHOD_(type) type
+#define NS_CALLBACK_(_type, _name) _type (* _name)
+#define NS_STDCALL
+#define NS_FROZENCALL
+#define NS_EXPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
+#define NS_IMPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
+
+#endif
+
+/**
+ * Macro for creating typedefs for pointer-to-member types which are
+ * declared with stdcall.  It is important to use this for any type which is
+ * declared as stdcall (i.e. NS_IMETHOD).  For example, instead of writing:
+ *
+ *  typedef nsresult (nsIFoo::*someType)(nsISupports* arg);
+ *
+ *  you should write:
+ *
+ *  typedef
+ *  NS_STDCALL_FUNCPROTO(nsresult, someType, nsIFoo, typeFunc, (nsISupports*));
+ *
+ *  where nsIFoo::typeFunc is any method declared as
+ *  NS_IMETHOD typeFunc(nsISupports*);
+ *
+ *  XXX this can be simplified to always use the non-typeof implementation
+ *  when http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11893 is fixed.
+ */
+
+#ifdef __GNUC__
+#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
+  typeof(&class::func) name
+#else
+#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
+  ret (NS_STDCALL class::*name) args
+#endif
+
+/**
+ * Deprecated declarations.
+ */
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+# define NS_DEPRECATED __attribute__((deprecated))
+#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
+# define NS_DEPRECATED __declspec(deprecated)
+#else
+# define NS_DEPRECATED
+#endif
+
+/**
+ * Attributes defined to help Dehydra GCC analysis.
+ */
+#ifdef DEHYDRA_GCC
+# define NS_SCRIPTABLE __attribute__((user("script")))
+#else
+# define NS_SCRIPTABLE
+#endif
+
+/**
+ * Generic API modifiers which return the standard XPCOM nsresult type
+ */
+#define NS_IMETHOD          NS_IMETHOD_(nsresult)
+#define NS_IMETHODIMP       NS_IMETHODIMP_(nsresult)
+#define NS_METHOD           NS_METHOD_(nsresult)
+#define NS_CALLBACK(_name)  NS_CALLBACK_(nsresult, _name)
+
+/**
+ * Import/Export macros for XPCOM APIs
+ */
+
+#ifdef __cplusplus
+#define NS_EXTERN_C extern "C"
+#else
+#define NS_EXTERN_C
+#endif
+
+#define EXPORT_XPCOM_API(type) NS_EXTERN_C NS_EXPORT type NS_FROZENCALL
+#define IMPORT_XPCOM_API(type) NS_EXTERN_C NS_IMPORT type NS_FROZENCALL
+#define GLUE_XPCOM_API(type) NS_EXTERN_C NS_HIDDEN_(type) NS_FROZENCALL
+
+#ifdef _IMPL_NS_COM
+#define XPCOM_API(type) EXPORT_XPCOM_API(type)
+#elif defined(XPCOM_GLUE)
+#define XPCOM_API(type) GLUE_XPCOM_API(type)
+#else
+#define XPCOM_API(type) IMPORT_XPCOM_API(type)
+#endif
+
+#ifdef MOZ_ENABLE_LIBXUL
+#define NS_COM
+#elif defined(_IMPL_NS_COM)
+#define NS_COM NS_EXPORT
+#elif defined(XPCOM_GLUE)
+#define NS_COM
+#else
+#define NS_COM NS_IMPORT
+#endif
+
+#ifdef MOZILLA_INTERNAL_API
+#  define NS_COM_GLUE NS_COM
+   /*
+     The frozen string API has different definitions of nsAC?String
+     classes than the internal API. On systems that explicitly declare
+     dllexport symbols this is not a problem, but on ELF systems
+     internal symbols can accidentally "shine through"; we rename the
+     internal classes to avoid symbol conflicts.
+   */
+#  define nsAString nsAString_internal
+#  define nsACString nsACString_internal
+#else
+#  ifdef HAVE_VISIBILITY_ATTRIBUTE
+#    define NS_COM_GLUE NS_VISIBILITY_HIDDEN
+#  else
+#    define NS_COM_GLUE
+#  endif
+#endif
+
+
+/**
+ * NS_NO_VTABLE is emitted by xpidl in interface declarations whenever
+ * xpidl can determine that the interface can't contain a constructor.
+ * This results in some space savings and possible runtime savings -
+ * see bug 49416.  We undefine it first, as xpidl-generated headers
+ * define it for IDL uses that don't include this file.
+ */
+#ifdef NS_NO_VTABLE
+#undef NS_NO_VTABLE
+#endif
+#if defined(_MSC_VER) && _MSC_VER >= 1100
+#define NS_NO_VTABLE __declspec(novtable)
+#else
+#define NS_NO_VTABLE
+#endif
+
+
+/**
+ * Generic XPCOM result _data type
+ */
+typedef PRUint32 nsresult;
+
+/**
+ * Reference count values
+ *
+ * This is the return type for AddRef() and Release() in nsISupports.
+ * IUnknown of COM returns an unsigned long from equivalent functions.
+ * The following ifdef exists to maintain binary compatibility with
+ * IUnknown.
+ */
+#if defined(XP_WIN) && PR_BYTES_PER_LONG == 4
+typedef unsigned long nsrefcnt;
+#else
+typedef PRUint32 nsrefcnt;
+#endif
+
+/**
+ * The preferred symbol for null.
+ */
+#define nsnull 0
+
+#include "nsError.h"
+
+/* ------------------------------------------------------------------------ */
+/* Casting macros for hiding C++ features from older compilers */
+
+  /*
+    All our compiler support template specialization, but not all support the
+    |template <>| notation.  The compiler that don't understand this notation
+    just omit it for specialization.
+
+    Need to add an autoconf test for this.
+  */
+
+  /* under Metrowerks (Mac), we don't have autoconf yet */
+#ifdef __MWERKS__
+  #define HAVE_CPP_PARTIAL_SPECIALIZATION
+  #define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
+
+  #define HAVE_CPP_ACCESS_CHANGING_USING
+  #define HAVE_CPP_AMBIGUITY_RESOLVING_USING
+  #define HAVE_CPP_EXPLICIT
+  #define HAVE_CPP_TYPENAME
+  #define HAVE_CPP_BOOL
+  #define HAVE_CPP_NAMESPACE_STD
+  #define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
+  #define HAVE_CPP_2BYTE_WCHAR_T
+#endif
+
+  /* under VC++ (Windows), we don't have autoconf yet */
+#if defined(_MSC_VER) && (_MSC_VER>=1100)
+  /* VC++ 5.0 and greater implement template specialization, 4.2 is unknown */
+  #define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
+
+  #define HAVE_CPP_EXPLICIT
+  #define HAVE_CPP_TYPENAME
+  #define HAVE_CPP_ACCESS_CHANGING_USING
+
+  #if (_MSC_VER==1100)
+      /* VC++5.0 has an internal compiler error (sometimes) without this */
+    #undef HAVE_CPP_ACCESS_CHANGING_USING
+  #endif
+
+  #define HAVE_CPP_NAMESPACE_STD
+  #define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
+  #define HAVE_CPP_2BYTE_WCHAR_T
+#endif
+
+#ifndef __PRUNICHAR__
+#define __PRUNICHAR__
+  /* For now, don't use wchar_t on Unix because it breaks the Netscape
+   * commercial build.  When this is fixed there will be no need for the
+   * |reinterpret_cast| in nsLiteralString.h either.
+   */
+  #if defined(HAVE_CPP_2BYTE_WCHAR_T) && defined(NS_WIN32)
+    typedef wchar_t PRUnichar;
+  #else
+    typedef PRUint16 PRUnichar;
+  #endif
+#endif
+
+  /*
+    If the compiler doesn't support |explicit|, we'll just make it go away, trusting
+    that the builds under compilers that do have it will keep us on the straight and narrow.
+  */
+#ifndef HAVE_CPP_EXPLICIT
+  #define explicit
+#endif
+
+#ifndef HAVE_CPP_TYPENAME
+  #define typename
+#endif
+
+#ifdef HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
+  #define NS_SPECIALIZE_TEMPLATE  template <>
+#else
+  #define NS_SPECIALIZE_TEMPLATE
+#endif
+
+/*
+ * Use these macros to do 64bit safe pointer conversions.
+ */
+
+#define NS_PTR_TO_INT32(x)  ((PRInt32)  (PRWord) (x))
+#define NS_PTR_TO_UINT32(x) ((PRUint32) (PRWord) (x))
+#define NS_INT32_TO_PTR(x)  ((void *)   (PRWord) (x))
+
+/*
+ * Use NS_STRINGIFY to form a string literal from the value of a macro.
+ */
+#define NS_STRINGIFY_HELPER(x_) #x_
+#define NS_STRINGIFY(x_) NS_STRINGIFY_HELPER(x_)
+
+/*
+ * These macros allow you to give a hint to the compiler about branch
+ * probability so that it can better optimize.  Use them like this:
+ *
+ *  if (NS_LIKELY(v == 1)) {
+ *    ... expected code path ...
+ *  }
+ *
+ *  if (NS_UNLIKELY(v == 0)) {
+ *    ... non-expected code path ...
+ *  }
+ *
+ * These macros are guaranteed to always return 0 or 1.
+ * The NS_FAILED/NS_SUCCEEDED macros depends on this.
+ * @return 0 or 1
+ */
+
+#if defined(__GNUC__) && (__GNUC__ > 2)
+#define NS_LIKELY(x)    (__builtin_expect(!!(x), 1))
+#define NS_UNLIKELY(x)  (__builtin_expect(!!(x), 0))
+#else
+#define NS_LIKELY(x)    (!!(x))
+#define NS_UNLIKELY(x)  (!!(x))
+#endif
+
+ /*
+  * If we're being linked as standalone glue, we don't want a dynamic dependency
+  * on NSPR libs, so we skip the debug thread-safety checks, and we cannot use
+  * the THREADSAFE_ISUPPORTS macros.
+  */
+#if defined(XPCOM_GLUE) && !defined(XPCOM_GLUE_USE_NSPR)
+#define XPCOM_GLUE_AVOID_NSPR
+#endif
+
+#endif /* nscore_h___ */

ucd/src/mozilla/pr/prcpucfg.h

+////----

ucd/src/mozilla/pr/prmem.h

+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Netscape Portable Runtime (NSPR).
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998-2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+** File: prmem.h
+** Description: API to NSPR memory management functions
+**
+*/
+#ifndef prmem_h___
+#define prmem_h___
+
+#include "prtypes.h"
+#include <stdlib.h>
+
+PR_BEGIN_EXTERN_C
+
+/*
+** Thread safe memory allocation.
+**
+** NOTE: pr wraps up malloc, free, calloc, realloc so they are already
+** thread safe (and are not declared here - look in stdlib.h).
+*/
+
+/*
+** PR_Malloc, PR_Calloc, PR_Realloc, and PR_Free have the same signatures
+** as their libc equivalent malloc, calloc, realloc, and free, and have
+** the same semantics.  (Note that the argument type size_t is replaced
+** by PRUint32.)  Memory allocated by PR_Malloc, PR_Calloc, or PR_Realloc
+** must be freed by PR_Free.
+*/
+
+NSPR_API(void *) PR_Malloc(size_t size); ////----
+
+NSPR_API(void *) PR_Calloc(PRUint32 nelem, PRUint32 elsize);
+
+NSPR_API(void *) PR_Realloc(void *ptr, PRUint32 size);
+
+NSPR_API(void) PR_Free(void *ptr);
+
+/*
+** The following are some convenience macros defined in terms of
+** PR_Malloc, PR_Calloc, PR_Realloc, and PR_Free.
+*/
+
+/***********************************************************************
+** FUNCTION:	PR_MALLOC()
+** DESCRIPTION:
+**   PR_NEW() allocates an untyped item of size _size from the heap.
+** INPUTS:  _size: size in bytes of item to be allocated
+** OUTPUTS:	untyped pointer to the node allocated
+** RETURN:	pointer to node or error returned from malloc().
+***********************************************************************/
+#define PR_MALLOC(_bytes) (PR_Malloc((_bytes)))
+
+/***********************************************************************
+** FUNCTION:	PR_NEW()
+** DESCRIPTION:
+**   PR_NEW() allocates an item of type _struct from the heap.
+** INPUTS:  _struct: a _data type
+** OUTPUTS:	pointer to _struct
+** RETURN:	pointer to _struct or error returns from malloc().
+***********************************************************************/
+#define PR_NEW(_struct) ((_struct *) PR_MALLOC(sizeof(_struct)))
+
+/***********************************************************************
+** FUNCTION:	PR_REALLOC()
+** DESCRIPTION:
+**   PR_REALLOC() re-allocates _ptr bytes from the heap as a _size
+**   untyped item.
+** INPUTS:	_ptr: pointer to node to reallocate
+**          _size: size of node to allocate
+** OUTPUTS:	pointer to node allocated
+** RETURN:	pointer to node allocated
+***********************************************************************/
+#define PR_REALLOC(_ptr, _size) (PR_Realloc((_ptr), (_size)))
+
+/***********************************************************************
+** FUNCTION:	PR_CALLOC()
+** DESCRIPTION:
+**   PR_CALLOC() allocates a _size bytes untyped item from the heap
+**   and sets the allocated memory to all 0x00.
+** INPUTS:	_size: size of node to allocate
+** OUTPUTS:	pointer to node allocated
+** RETURN:	pointer to node allocated
+***********************************************************************/
+#define PR_CALLOC(_size) (PR_Calloc(1, (_size)))
+
+/***********************************************************************
+** FUNCTION:	PR_NEWZAP()
+** DESCRIPTION:
+**   PR_NEWZAP() allocates an item of type _struct from the heap
+**   and sets the allocated memory to all 0x00.
+** INPUTS:	_struct: a _data type
+** OUTPUTS:	pointer to _struct
+** RETURN:	pointer to _struct
+***********************************************************************/
+#define PR_NEWZAP(_struct) ((_struct*)PR_Calloc(1, sizeof(_struct)))
+
+/***********************************************************************
+** FUNCTION:	PR_DELETE()
+** DESCRIPTION:
+**   PR_DELETE() unallocates an object previosly allocated via PR_NEW()
+**   or PR_NEWZAP() to the heap.
+** INPUTS:	pointer to previously allocated object
+** OUTPUTS:	the referenced object is returned to the heap
+** RETURN:	void
+***********************************************************************/
+#define PR_DELETE(_ptr) { PR_Free(_ptr); (_ptr) = NULL; }
+
+/***********************************************************************
+** FUNCTION:	PR_FREEIF()
+** DESCRIPTION:
+**   PR_FREEIF() conditionally unallocates an object previously allocated
+**   vial PR_NEW() or PR_NEWZAP(). If the pointer to the object is
+**   equal to zero (0), the object is not released.
+** INPUTS:	pointer to previously allocated object
+** OUTPUTS:	the referenced object is conditionally returned to the heap
+** RETURN:	void
+***********************************************************************/
+#define PR_FREEIF(_ptr)	if (_ptr) PR_DELETE(_ptr)
+
+PR_END_EXTERN_C
+
+#endif /* prmem_h___ */

ucd/src/mozilla/pr/prtypes.h

+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Netscape Portable Runtime (NSPR).
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998-2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+** File:                prtypes.h
+** Description: Definitions of NSPR's basic types
+**
+** Prototypes and macros used to make up for deficiencies that we have found
+** in ANSI environments.
+**
+** Since we do not wrap <stdlib.h> and all the other standard headers, authors
+** of portable code will not know in general that they need these definitions.
+** Instead of requiring these authors to find the dependent uses in their code
+** and take the following steps only in those C files, we take steps once here
+** for all C files.
+**/
+
+#ifndef prtypes_h___
+#define prtypes_h___
+
+#ifdef MDCPUCFG
+#include MDCPUCFG
+#else
+#include "prcpucfg.h"
+#endif
+
+#include <stddef.h>
+
+/***********************************************************************
+** MACROS:      PR_EXTERN
+**              PR_IMPLEMENT
+** DESCRIPTION:
+**      These are only for externally visible routines and globals.  For
+**      internal routines, just use "extern" for type checking and that
+**      will not export internal cross-file or forward-declared symbols.
+**      Define a macro for declaring procedures return types. We use this to
+**      deal with windoze specific type hackery for DLL definitions. Use
+**      PR_EXTERN when the prototype for the method is declared. Use
+**      PR_IMPLEMENT for the implementation of the method.
+**
+** Example:
+**   in dowhim.h
+**     PR_EXTERN( void ) DoWhatIMean( void );
+**   in dowhim.c
+**     PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
+**
+**
+***********************************************************************/
+#if defined(WIN32)
+
+#define PR_EXPORT(__type) extern __type
+#define PR_EXPORT_DATA(__type) extern __type
+#define PR_IMPORT(__type) __type
+#define PR_IMPORT_DATA(__type) __type
+
+#define PR_EXTERN(__type) extern __type
+#define PR_IMPLEMENT(__type) __type
+#define PR_EXTERN_DATA(__type) extern __type
+#define PR_IMPLEMENT_DATA(__type) __type
+
+#define PR_CALLBACK
+#define PR_CALLBACK_DECL
+#define PR_STATIC_CALLBACK(__x) static __x
+
+#elif defined(XP_BEOS)
+
+#define PR_EXPORT(__type) extern __type
+#define PR_EXPORT_DATA(__type) extern __type
+#define PR_IMPORT(__type) extern __type
+#define PR_IMPORT_DATA(__type) extern __type
+
+#define PR_EXTERN(__type) extern __type
+#define PR_IMPLEMENT(__type) __type
+#define PR_EXTERN_DATA(__type) extern __type
+#define PR_IMPLEMENT_DATA(__type) __type
+
+#define PR_CALLBACK
+#define PR_CALLBACK_DECL
+#define PR_STATIC_CALLBACK(__x) static __x
+
+#elif defined(XP_OS2) && defined(__declspec)
+
+#define PR_EXPORT(__type) extern __type
+#define PR_EXPORT_DATA(__type) extern __type
+#define PR_IMPORT(__type) extern  __type
+#define PR_IMPORT_DATA(__type) extern __type
+
+#define PR_EXTERN(__type) extern __type
+#define PR_IMPLEMENT(__type) __type
+#define PR_EXTERN_DATA(__type) extern __type
+#define PR_IMPLEMENT_DATA(__type) __type
+
+#define PR_CALLBACK
+#define PR_CALLBACK_DECL
+#define PR_STATIC_CALLBACK(__x) static __x
+
+#elif defined(SYMBIAN)
+
+#define PR_EXPORT(__type) extern __type
+#define PR_EXPORT_DATA(__type) extern __type
+#ifdef __WINS__
+#define PR_IMPORT(__type) extern __type
+#define PR_IMPORT_DATA(__type) extern __type
+#else
+#define PR_IMPORT(__type) extern __type
+#define PR_IMPORT_DATA(__type) extern __type
+#endif
+
+#define PR_EXTERN(__type) extern __type
+#define PR_IMPLEMENT(__type) __type
+#define PR_EXTERN_DATA(__type) extern __type
+#define PR_IMPLEMENT_DATA(__type) __type
+
+#define PR_CALLBACK
+#define PR_CALLBACK_DECL
+#define PR_STATIC_CALLBACK(__x) static __x
+
+#else /* Unix */
+
+/* GCC 3.3 and later support the visibility attribute. */
+#if (__GNUC__ >= 4) || \
+    (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
+#define PR_VISIBILITY_DEFAULT __attribute__((visibility("default")))
+#else
+#define PR_VISIBILITY_DEFAULT
+#endif
+
+#define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
+
+#define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type
+#define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
+#define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type
+#define PR_CALLBACK
+#define PR_CALLBACK_DECL
+#define PR_STATIC_CALLBACK(__x) static __x
+
+#endif
+
+#if defined(_NSPR_BUILD_)
+#define NSPR_API(__type) PR_EXPORT(__type)
+#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
+#else
+#define NSPR_API(__type) PR_IMPORT(__type)
+#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
+#endif
+
+/***********************************************************************
+** MACROS:      PR_BEGIN_MACRO
+**              PR_END_MACRO
+** DESCRIPTION:
+**      Macro body brackets so that macros with compound statement definitions
+**      behave syntactically more like functions when called.
+***********************************************************************/
+#define PR_BEGIN_MACRO  do {
+#define PR_END_MACRO    } while (0)
+
+/***********************************************************************
+** MACROS:      PR_BEGIN_EXTERN_C
+**              PR_END_EXTERN_C
+** DESCRIPTION:
+**      Macro shorthands for conditional C++ extern block delimiters.
+***********************************************************************/
+#ifdef __cplusplus
+#define PR_BEGIN_EXTERN_C       extern "C" {
+#define PR_END_EXTERN_C         }
+#else
+#define PR_BEGIN_EXTERN_C
+#define PR_END_EXTERN_C
+#endif
+
+/***********************************************************************
+** MACROS:      PR_BIT
+**              PR_BITMASK
+** DESCRIPTION:
+** Bit masking macros.  XXX n must be <= 31 to be portable
+***********************************************************************/
+#define PR_BIT(n)       ((PRUint32)1 << (n))
+#define PR_BITMASK(n)   (PR_BIT(n) - 1)
+
+/***********************************************************************
+** MACROS:      PR_ROUNDUP
+**              PR_MIN
+**              PR_MAX
+**              PR_ABS
+** DESCRIPTION:
+**      Commonly used macros for operations on compatible types.
+***********************************************************************/
+#define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
+#define PR_MIN(x,y)     ((x)<(y)?(x):(y))
+#define PR_MAX(x,y)     ((x)>(y)?(x):(y))
+#define PR_ABS(x)       ((x)<0?-(x):(x))
+
+PR_BEGIN_EXTERN_C
+
+/************************************************************************
+** TYPES:       PRUint8
+**              PRInt8
+** DESCRIPTION:
+**  The int8 types are known to be 8 bits each. There is no type that
+**      is equivalent to a plain "char".
+************************************************************************/
+#if PR_BYTES_PER_BYTE == 1
+typedef unsigned char PRUint8;
+/*
+** Some cfront-based C++ compilers do not like 'signed char' and
+** issue the warning message:
+**     warning: "signed" not implemented (ignored)
+** For these compilers, we have to define PRInt8 as plain 'char'.
+** Make sure that plain 'char' is indeed signed under these compilers.
+*/
+#if (defined(HPUX) && defined(__cplusplus) \
+        && !defined(__GNUC__) && __cplusplus < 199707L) \
+    || (defined(SCO) && defined(__cplusplus) \
+        && !defined(__GNUC__) && __cplusplus == 1L)
+typedef char PRInt8;
+#else
+typedef signed char PRInt8;
+#endif
+#else
+#error No suitable type for PRInt8/PRUint8
+#endif
+
+/************************************************************************
+ * MACROS:      PR_INT8_MAX
+ *              PR_INT8_MIN
+ *              PR_UINT8_MAX
+ * DESCRIPTION:
+ *  The maximum and minimum values of a PRInt8 or PRUint8.
+************************************************************************/
+
+#define PR_INT8_MAX 127
+#define PR_INT8_MIN (-128)
+#define PR_UINT8_MAX 255U
+
+/************************************************************************
+** TYPES:       PRUint16
+**              PRInt16
+** DESCRIPTION:
+**  The int16 types are known to be 16 bits each.
+************************************************************************/
+#if PR_BYTES_PER_SHORT == 2
+typedef unsigned short PRUint16;
+typedef short PRInt16;
+#else
+#error No suitable type for PRInt16/PRUint16
+#endif
+
+/************************************************************************
+ * MACROS:      PR_INT16_MAX
+ *              PR_INT16_MIN
+ *              PR_UINT16_MAX
+ * DESCRIPTION:
+ *  The maximum and minimum values of a PRInt16 or PRUint16.
+************************************************************************/
+
+#define PR_INT16_MAX 32767
+#define PR_INT16_MIN (-32768)
+#define PR_UINT16_MAX 65535U
+
+/************************************************************************
+** TYPES:       PRUint32
+**              PRInt32
+** DESCRIPTION:
+**  The int32 types are known to be 32 bits each.
+************************************************************************/
+#if PR_BYTES_PER_INT == 4
+typedef unsigned int PRUint32;
+typedef int PRInt32;
+#define PR_INT32(x)  x
+#define PR_UINT32(x) x ## U
+#elif PR_BYTES_PER_LONG == 4
+typedef unsigned long PRUint32;
+typedef long PRInt32;
+#define PR_INT32(x)  x ## L
+#define PR_UINT32(x) x ## UL
+#else
+#error No suitable type for PRInt32/PRUint32
+#endif
+
+/************************************************************************
+ * MACROS:      PR_INT32_MAX
+ *              PR_INT32_MIN
+ *              PR_UINT32_MAX
+ * DESCRIPTION:
+ *  The maximum and minimum values of a PRInt32 or PRUint32.
+************************************************************************/
+
+#define PR_INT32_MAX PR_INT32(2147483647)
+#define PR_INT32_MIN (-PR_INT32_MAX - 1)
+#define PR_UINT32_MAX PR_UINT32(4294967295)
+
+/************************************************************************
+** TYPES:       PRUint64
+**              PRInt64
+** DESCRIPTION:
+**  The int64 types are known to be 64 bits each. Care must be used when
+**      declaring variables of type PRUint64 or PRInt64. Different hardware
+**      architectures and even different compilers have varying support for
+**      64 bit values. The only guaranteed portability requires the use of
+**      the LL_ macros (see prlong.h).
+************************************************************************/
+#ifdef HAVE_LONG_LONG
+/* Keep this in sync with prlong.h. */
+/*
+ * On 64-bit Mac OS X, uint64 needs to be defined as unsigned long long to
+ * match uint64_t, otherwise our uint64 typedef conflicts with the uint64
+ * typedef in cssmconfig.h, which CoreServices.h includes indirectly.
+ */
+#if PR_BYTES_PER_LONG == 8 && !defined(__APPLE__)
+typedef long PRInt64;
+typedef unsigned long PRUint64;
+#elif defined(WIN32) && !defined(__GNUC__)
+typedef __int64  PRInt64;
+typedef unsigned __int64 PRUint64;
+#else
+typedef long long PRInt64;
+typedef unsigned long long PRUint64;
+#endif /* PR_BYTES_PER_LONG == 8 */
+#else  /* !HAVE_LONG_LONG */
+typedef struct {
+#ifdef IS_LITTLE_ENDIAN
+    PRUint32 lo, hi;
+#else
+    PRUint32 hi, lo;
+#endif
+} PRInt64;
+typedef PRInt64 PRUint64;
+#endif /* !HAVE_LONG_LONG */
+
+/************************************************************************
+** TYPES:       PRUintn
+**              PRIntn
+** DESCRIPTION:
+**  The PRIntn types are most appropriate for automatic variables. They are
+**      guaranteed to be at least 16 bits, though various architectures may
+**      define them to be wider (e.g., 32 or even 64 bits). These types are
+**      never valid for fields of a structure.
+************************************************************************/
+#if PR_BYTES_PER_INT >= 2
+typedef int PRIntn;
+typedef unsigned int PRUintn;
+#else
+#error 'sizeof(int)' not sufficient for platform use
+#endif
+
+/************************************************************************
+** TYPES:       PRFloat64
+** DESCRIPTION:
+**  NSPR's floating point type is always 64 bits.
+************************************************************************/
+typedef double          PRFloat64;
+
+/************************************************************************
+** TYPES:       PRSize
+** DESCRIPTION:
+**  A type for representing the size of objects.
+************************************************************************/
+typedef size_t PRSize;
+
+
+/************************************************************************
+** TYPES:       PROffset32, PROffset64
+** DESCRIPTION:
+**  A type for representing byte offsets from some location.
+************************************************************************/
+typedef PRInt32 PROffset32;
+typedef PRInt64 PROffset64;
+
+/************************************************************************
+** TYPES:       PRPtrDiff
+** DESCRIPTION:
+**  A type for pointer difference. Variables of this type are suitable
+**      for storing a pointer or pointer subtraction.
+************************************************************************/
+typedef ptrdiff_t PRPtrdiff;
+
+/************************************************************************
+** TYPES:       PRUptrdiff
+** DESCRIPTION:
+**  A type for pointer difference. Variables of this type are suitable
+**      for storing a pointer or pointer sutraction.
+************************************************************************/
+#ifdef _WIN64
+typedef unsigned __int64 PRUptrdiff;
+#else
+typedef unsigned long PRUptrdiff;
+#endif
+
+/************************************************************************
+** TYPES:       PRBool
+** DESCRIPTION:
+**  Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
+**      for clarity of target type in assignments and actual arguments. Use
+**      'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
+**      just as you would C int-valued conditions.
+************************************************************************/
+typedef PRIntn PRBool;
+#define PR_TRUE 1
+#define PR_FALSE 0
+
+/************************************************************************
+** TYPES:       PRPackedBool
+** DESCRIPTION:
+**  Use PRPackedBool within structs where bitfields are not desirable
+**      but minimum and consistant overhead matters.
+************************************************************************/
+typedef PRUint8 PRPackedBool;
+
+/*
+** Status code used by some routines that have a single point of failure or
+** special status return.
+*/
+typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
+
+#ifndef __PRUNICHAR__
+#define __PRUNICHAR__
+#ifdef WIN32
+typedef wchar_t PRUnichar;
+#else
+typedef PRUint16 PRUnichar;
+#endif
+#endif
+
+/*
+** WARNING: The undocumented _data types PRWord and PRUword are
+** only used in the garbage collection and arena code.  Do not
+** use PRWord and PRUword in new code.
+**
+** A PRWord is an integer that is the same size as a void*.
+** It implements the notion of a "word" in the Java Virtual
+** Machine.  (See Sec. 3.4 "Words", The Java Virtual Machine
+** Specification, Addison-Wesley, September 1996.
+** http://java.sun.com/docs/books/vmspec/index.html.)
+*/
+#ifdef _WIN64
+typedef __int64 PRWord;
+typedef unsigned __int64 PRUword;
+#else
+typedef long PRWord;
+typedef unsigned long PRUword;
+#endif
+
+#if defined(NO_NSPR_10_SUPPORT)
+#else
+/********* ???????????????? FIX ME       ??????????????????????????? *****/
+/********************** Some old definitions until pr=>ds transition is done ***/
+/********************** Also, we are still using NSPR 1.0. GC ******************/
+/*
+** Fundamental NSPR macros, used nearly everywhere.
+*/
+
+#define PR_PUBLIC_API		PR_IMPLEMENT
+
+/*
+** Macro body brackets so that macros with compound statement definitions
+** behave syntactically more like functions when called.
+*/
+#define NSPR_BEGIN_MACRO        do {
+#define NSPR_END_MACRO          } while (0)
+
+/*
+** Macro shorthands for conditional C++ extern block delimiters.
+*/
+#ifdef NSPR_BEGIN_EXTERN_C
+#undef NSPR_BEGIN_EXTERN_C
+#endif
+#ifdef NSPR_END_EXTERN_C
+#undef NSPR_END_EXTERN_C
+#endif
+
+#ifdef __cplusplus
+#define NSPR_BEGIN_EXTERN_C     extern "C" {
+#define NSPR_END_EXTERN_C       }
+#else
+#define NSPR_BEGIN_EXTERN_C
+#define NSPR_END_EXTERN_C
+#endif
+
+//#include "obsolete/protypes.h"
+
+/********* ????????????? End Fix me ?????????????????????????????? *****/
+#endif /* NO_NSPR_10_SUPPORT */
+
+/*
+** Compile-time assert. "condition" must be a constant expression.
+** The macro can be used only in places where an "extern" declaration is
+** allowed.
+*/
+#define PR_STATIC_ASSERT(condition) \
+    extern void pr_static_assert(int arg[(condition) ? 1 : -1])
+
+PR_END_EXTERN_C
+
+#endif /* prtypes_h___ */
+

ucd/src/mozilla/prcpucfg.h

-////----

ucd/src/mozilla/prmem.h

-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Netscape Portable Runtime (NSPR).
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998-2000
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
-** File: prmem.h
-** Description: API to NSPR memory management functions
-**
-*/
-#ifndef prmem_h___
-#define prmem_h___
-
-#include "prtypes.h"
-#include <stdlib.h>
-
-PR_BEGIN_EXTERN_C
-
-/*
-** Thread safe memory allocation.
-**
-** NOTE: pr wraps up malloc, free, calloc, realloc so they are already
-** thread safe (and are not declared here - look in stdlib.h).
-*/
-
-/*
-** PR_Malloc, PR_Calloc, PR_Realloc, and PR_Free have the same signatures
-** as their libc equivalent malloc, calloc, realloc, and free, and have
-** the same semantics.  (Note that the argument type size_t is replaced
-** by PRUint32.)  Memory allocated by PR_Malloc, PR_Calloc, or PR_Realloc
-** must be freed by PR_Free.
-*/
-
-NSPR_API(void *) PR_Malloc(PRUint32 size);
-
-NSPR_API(void *) PR_Calloc(PRUint32 nelem, PRUint32 elsize);
-
-NSPR_API(void *) PR_Realloc(void *ptr, PRUint32 size);
-
-NSPR_API(void) PR_Free(void *ptr);
-
-/*
-** The following are some convenience macros defined in terms of
-** PR_Malloc, PR_Calloc, PR_Realloc, and PR_Free.
-*/
-
-/***********************************************************************
-** FUNCTION:	PR_MALLOC()
-** DESCRIPTION:
-**   PR_NEW() allocates an untyped item of size _size from the heap.
-** INPUTS:  _size: size in bytes of item to be allocated
-** OUTPUTS:	untyped pointer to the node allocated
-** RETURN:	pointer to node or error returned from malloc().
-***********************************************************************/
-#define PR_MALLOC(_bytes) (PR_Malloc((_bytes)))
-
-/***********************************************************************
-** FUNCTION:	PR_NEW()
-** DESCRIPTION:
-**   PR_NEW() allocates an item of type _struct from the heap.
-** INPUTS:  _struct: a _data type
-** OUTPUTS:	pointer to _struct
-** RETURN:	pointer to _struct or error returns from malloc().
-***********************************************************************/
-#define PR_NEW(_struct) ((_struct *) PR_MALLOC(sizeof(_struct)))
-
-/***********************************************************************
-** FUNCTION:	PR_REALLOC()
-** DESCRIPTION:
-**   PR_REALLOC() re-allocates _ptr bytes from the heap as a _size
-**   untyped item.
-** INPUTS:	_ptr: pointer to node to reallocate
-**          _size: size of node to allocate
-** OUTPUTS:	pointer to node allocated
-** RETURN:	pointer to node allocated
-***********************************************************************/
-#define PR_REALLOC(_ptr, _size) (PR_Realloc((_ptr), (_size)))
-
-/***********************************************************************
-** FUNCTION:	PR_CALLOC()
-** DESCRIPTION:
-**   PR_CALLOC() allocates a _size bytes untyped item from the heap
-**   and sets the allocated memory to all 0x00.
-** INPUTS:	_size: size of node to allocate
-** OUTPUTS:	pointer to node allocated
-** RETURN:	pointer to node allocated
-***********************************************************************/
-#define PR_CALLOC(_size) (PR_Calloc(1, (_size)))
-
-/***********************************************************************
-** FUNCTION:	PR_NEWZAP()
-** DESCRIPTION:
-**   PR_NEWZAP() allocates an item of type _struct from the heap
-**   and sets the allocated memory to all 0x00.
-** INPUTS:	_struct: a _data type
-** OUTPUTS:	pointer to _struct
-** RETURN:	pointer to _struct
-***********************************************************************/
-#define PR_NEWZAP(_struct) ((_struct*)PR_Calloc(1, sizeof(_struct)))
-
-/***********************************************************************
-** FUNCTION:	PR_DELETE()
-** DESCRIPTION:
-**   PR_DELETE() unallocates an object previosly allocated via PR_NEW()
-**   or PR_NEWZAP() to the heap.
-** INPUTS:	pointer to previously allocated object
-** OUTPUTS:	the referenced object is returned to the heap
-** RETURN:	void
-***********************************************************************/
-#define PR_DELETE(_ptr) { PR_Free(_ptr); (_ptr) = NULL; }
-
-/***********************************************************************
-** FUNCTION:	PR_FREEIF()
-** DESCRIPTION:
-**   PR_FREEIF() conditionally unallocates an object previously allocated
-**   vial PR_NEW() or PR_NEWZAP(). If the pointer to the object is
-**   equal to zero (0), the object is not released.
-** INPUTS:	pointer to previously allocated object
-** OUTPUTS:	the referenced object is conditionally returned to the heap
-** RETURN:	void
-***********************************************************************/
-#define PR_FREEIF(_ptr)	if (_ptr) PR_DELETE(_ptr)
-
-PR_END_EXTERN_C
-
-#endif /* prmem_h___ */

ucd/src/mozilla/prtypes.h

-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Netscape Portable Runtime (NSPR).
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998-2000
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
-** File:                prtypes.h
-** Description: Definitions of NSPR's basic types
-**
-** Prototypes and macros used to make up for deficiencies that we have found
-** in ANSI environments.
-**
-** Since we do not wrap <stdlib.h> and all the other standard headers, authors
-** of portable code will not know in general that they need these definitions.
-** Instead of requiring these authors to find the dependent uses in their code
-** and take the following steps only in those C files, we take steps once here
-** for all C files.
-**/
-
-#ifndef prtypes_h___
-#define prtypes_h___
-
-#ifdef MDCPUCFG
-#include MDCPUCFG
-#else
-#include "prcpucfg.h"
-#endif
-
-#include <stddef.h>
-
-/***********************************************************************
-** MACROS:      PR_EXTERN
-**              PR_IMPLEMENT
-** DESCRIPTION:
-**      These are only for externally visible routines and globals.  For
-**      internal routines, just use "extern" for type checking and that
-**      will not export internal cross-file or forward-declared symbols.
-**      Define a macro for declaring procedures return types. We use this to
-**      deal with windoze specific type hackery for DLL definitions. Use
-**      PR_EXTERN when the prototype for the method is declared. Use
-**      PR_IMPLEMENT for the implementation of the method.
-**
-** Example:
-**   in dowhim.h
-**     PR_EXTERN( void ) DoWhatIMean( void );
-**   in dowhim.c
-**     PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
-**
-**
-***********************************************************************/
-#if defined(WIN32)
-
-#define PR_EXPORT(__type) extern __type
-#define PR_EXPORT_DATA(__type) extern __type
-#define PR_IMPORT(__type) __type