2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:21:17 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-05-19 01:43:13 +04:00
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* 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/
|
1999-05-19 01:43:13 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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.
|
1999-05-19 01:43:13 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:21:17 +04:00
|
|
|
* 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"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:21:17 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:21:17 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-05-19 01:43:13 +04:00
|
|
|
#ifndef nscore_h___
|
|
|
|
#define nscore_h___
|
|
|
|
|
2003-04-04 08:50:58 +04:00
|
|
|
/**
|
|
|
|
* Make sure that we have the proper platform specific
|
|
|
|
* c++ definitions needed by nscore.h
|
|
|
|
*/
|
2003-06-27 08:12:16 +04:00
|
|
|
#ifndef _XPCOM_CONFIG_H_
|
|
|
|
#include "xpcom-config.h"
|
2003-04-04 08:50:58 +04:00
|
|
|
#endif
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* Incorporate the core NSPR data types which XPCOM uses.
|
|
|
|
*/
|
|
|
|
#include "prtypes.h"
|
|
|
|
|
|
|
|
/* Core XPCOM declarations. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Macros defining the target platform...
|
|
|
|
*/
|
1999-05-19 01:43:13 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define NS_WIN32 1
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
#elif defined(__unix)
|
1999-05-19 01:43:13 +04:00
|
|
|
#define NS_UNIX 1
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
#elif defined(XP_OS2)
|
2000-02-29 18:50:48 +03:00
|
|
|
#define NS_OS2 1
|
|
|
|
#endif
|
1999-05-19 01:43:13 +04:00
|
|
|
/*----------------------------------------------------------------------*/
|
|
|
|
/* Import/export defines */
|
|
|
|
|
2004-02-03 11:32:33 +03:00
|
|
|
/**
|
|
|
|
* 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
|
2004-02-04 07:55:57 +03:00
|
|
|
* #define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
|
|
|
|
*
|
2004-02-03 11:32:33 +03:00
|
|
|
* class Foo {
|
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* #undef IMETHOD_VISIBILITY
|
2004-02-04 07:55:57 +03:00
|
|
|
* #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
|
2004-02-03 11:32:33 +03:00
|
|
|
*
|
|
|
|
* Don't forget to change the visibility back to hidden before the end
|
|
|
|
* of a header!
|
2004-02-04 07:55:57 +03:00
|
|
|
*
|
|
|
|
* Other examples:
|
|
|
|
*
|
|
|
|
* NS_HIDDEN_(int) someMethod();
|
|
|
|
* SomeCtor() NS_HIDDEN;
|
2004-02-03 11:32:33 +03:00
|
|
|
*/
|
|
|
|
|
2004-12-15 08:52:44 +03:00
|
|
|
#ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE
|
2004-02-04 07:55:57 +03:00
|
|
|
#define NS_VISIBILITY_HIDDEN __attribute__ ((visibility ("hidden")))
|
2004-02-03 11:32:33 +03:00
|
|
|
#else
|
2004-02-04 07:55:57 +03:00
|
|
|
#define NS_VISIBILITY_HIDDEN
|
2004-12-15 08:52:44 +03:00
|
|
|
#endif
|
2004-02-04 07:55:57 +03:00
|
|
|
|
2005-11-02 17:14:18 +03:00
|
|
|
#if defined(HAVE_VISIBILITY_ATTRIBUTE)
|
2004-12-15 08:52:44 +03:00
|
|
|
#define NS_VISIBILITY_DEFAULT __attribute__ ((visibility ("default")))
|
|
|
|
#else
|
|
|
|
#define NS_VISIBILITY_DEFAULT
|
2004-02-03 11:32:33 +03:00
|
|
|
#endif
|
|
|
|
|
2004-12-15 08:52:44 +03:00
|
|
|
#define NS_HIDDEN_(type) NS_VISIBILITY_HIDDEN type
|
|
|
|
#define NS_EXTERNAL_VIS_(type) NS_VISIBILITY_DEFAULT type
|
|
|
|
|
2004-02-04 07:55:57 +03:00
|
|
|
#define NS_HIDDEN NS_VISIBILITY_HIDDEN
|
2004-12-15 08:52:44 +03:00
|
|
|
#define NS_EXTERNAL_VIS NS_VISIBILITY_DEFAULT
|
2004-02-03 11:32:33 +03:00
|
|
|
|
|
|
|
#undef IMETHOD_VISIBILITY
|
2004-02-04 07:55:57 +03:00
|
|
|
#define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
|
2004-02-03 11:32:33 +03:00
|
|
|
|
2004-07-15 02:14:34 +04:00
|
|
|
/**
|
|
|
|
* 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.
|
2005-11-10 17:43:22 +03:00
|
|
|
* - __fastcall on windows should not be applied to class
|
|
|
|
* constructors/destructors - use the NS_CONSTRUCTOR_FASTCALL macro for
|
|
|
|
* constructors/destructors.
|
2004-07-15 02:14:34 +04:00
|
|
|
*
|
|
|
|
* Examples: int NS_FASTCALL func1(char *foo);
|
|
|
|
* NS_HIDDEN_(int) NS_FASTCALL func2(char *foo);
|
|
|
|
*/
|
|
|
|
|
2006-01-23 23:11:08 +03:00
|
|
|
#if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2)
|
2004-07-15 02:14:34 +04:00
|
|
|
#define NS_FASTCALL __attribute__ ((regparm (3), stdcall))
|
2005-11-10 17:43:22 +03:00
|
|
|
#define NS_CONSTRUCTOR_FASTCALL __attribute__ ((regparm (3), stdcall))
|
|
|
|
#elif defined(XP_WIN)
|
|
|
|
#define NS_FASTCALL __fastcall
|
|
|
|
#define NS_CONSTRUCTOR_FASTCALL
|
2004-07-15 02:14:34 +04:00
|
|
|
#else
|
|
|
|
#define NS_FASTCALL
|
2005-11-10 17:43:22 +03:00
|
|
|
#define NS_CONSTRUCTOR_FASTCALL
|
2004-07-15 02:14:34 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NS_DEFCALL undoes the effect of a global regparm/stdcall setting
|
|
|
|
* so that xptcall works correctly.
|
|
|
|
*/
|
2006-01-23 23:11:08 +03:00
|
|
|
#if defined(__i386__) && defined(__GNUC__) && (__GNUC__ >= 3) && !defined(XP_OS2)
|
2004-07-15 02:14:34 +04:00
|
|
|
#define NS_DEFCALL __attribute__ ((regparm (0), cdecl))
|
|
|
|
#else
|
|
|
|
#define NS_DEFCALL
|
|
|
|
#endif
|
|
|
|
|
1999-05-19 01:43:13 +04:00
|
|
|
#ifdef NS_WIN32
|
2001-09-27 07:43:00 +04:00
|
|
|
|
2003-06-25 02:12:37 +04:00
|
|
|
#define NS_IMPORT __declspec(dllimport)
|
2005-11-08 21:17:49 +03:00
|
|
|
#define NS_IMPORT_(type) __declspec(dllimport) type __stdcall
|
2003-06-25 02:12:37 +04:00
|
|
|
#define NS_EXPORT __declspec(dllexport)
|
2005-11-08 21:17:49 +03:00
|
|
|
#define NS_EXPORT_(type) __declspec(dllexport) type __stdcall
|
2001-09-27 07:43:00 +04:00
|
|
|
#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)
|
2003-03-07 09:07:56 +03:00
|
|
|
#define NS_STDCALL __stdcall
|
2005-11-08 21:17:49 +03:00
|
|
|
#define NS_FROZENCALL __cdecl
|
2001-09-27 07:43:00 +04:00
|
|
|
|
2005-04-29 00:57:42 +04:00
|
|
|
/*
|
|
|
|
These are needed to mark static members in exported classes, due to
|
|
|
|
gcc bug XXX insert bug# here.
|
|
|
|
*/
|
2004-12-15 08:52:44 +03:00
|
|
|
|
|
|
|
#define NS_EXPORT_STATIC_MEMBER_(type) type
|
|
|
|
#define NS_IMPORT_STATIC_MEMBER_(type) type
|
|
|
|
|
2006-03-08 22:56:32 +03:00
|
|
|
#elif defined(XP_OS2) && defined(__declspec)
|
|
|
|
|
|
|
|
#define NS_IMPORT __declspec(dllimport)
|
|
|
|
#define NS_IMPORT_(type) type __declspec(dllimport)
|
|
|
|
#define NS_EXPORT __declspec(dllexport)
|
|
|
|
#define NS_EXPORT_(type) type __declspec(dllexport)
|
|
|
|
#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)
|
|
|
|
|
1999-05-19 01:43:13 +04:00
|
|
|
#else
|
|
|
|
|
2004-12-15 08:52:44 +03:00
|
|
|
#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)
|
2004-07-15 02:14:34 +04:00
|
|
|
#define NS_IMETHOD_(type) virtual IMETHOD_VISIBILITY type NS_DEFCALL
|
2001-09-27 07:43:00 +04:00
|
|
|
#define NS_IMETHODIMP_(type) type
|
|
|
|
#define NS_METHOD_(type) type
|
|
|
|
#define NS_CALLBACK_(_type, _name) _type (* _name)
|
2003-03-07 09:07:56 +03:00
|
|
|
#define NS_STDCALL
|
2005-11-08 21:17:49 +03:00
|
|
|
#define NS_FROZENCALL
|
2004-12-15 08:52:44 +03:00
|
|
|
#define NS_EXPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
|
|
|
|
#define NS_IMPORT_STATIC_MEMBER_(type) NS_EXTERNAL_VIS_(type)
|
|
|
|
|
2003-03-07 09:07:56 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2003-09-15 08:20:20 +04:00
|
|
|
* 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.
|
2003-03-07 09:07:56 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
2003-09-15 08:20:20 +04:00
|
|
|
#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
|
|
|
|
typeof(&class::func) name
|
2003-03-07 09:07:56 +03:00
|
|
|
#else
|
2003-09-15 08:20:20 +04:00
|
|
|
#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \
|
|
|
|
ret (NS_STDCALL class::*name) args
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* 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)
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* Import/Export macros for XPCOM APIs
|
|
|
|
*/
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2006-02-10 18:00:36 +03:00
|
|
|
#ifdef __cplusplus
|
2006-03-06 04:49:10 +03:00
|
|
|
#define NS_EXTERN_C extern "C"
|
2006-02-10 18:00:36 +03:00
|
|
|
#else
|
2006-03-06 04:49:10 +03:00
|
|
|
#define NS_EXTERN_C
|
2006-02-10 18:00:36 +03:00
|
|
|
#endif
|
|
|
|
|
2006-03-06 04:49:10 +03:00
|
|
|
#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
|
2005-11-08 21:17:49 +03:00
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
#ifdef _IMPL_NS_COM
|
2005-11-08 21:17:49 +03:00
|
|
|
#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
|
|
|
|
|
2006-08-02 22:27:25 +04:00
|
|
|
#ifdef MOZ_ENABLE_LIBXUL
|
2002-03-22 02:43:21 +03:00
|
|
|
#define NS_COM
|
2005-11-08 21:17:49 +03:00
|
|
|
#elif defined(_IMPL_NS_COM)
|
|
|
|
#define NS_COM NS_EXPORT
|
|
|
|
#elif defined(XPCOM_GLUE)
|
2002-06-21 23:58:54 +04:00
|
|
|
#define NS_COM
|
1999-05-19 01:43:13 +04:00
|
|
|
#else
|
2001-09-27 07:43:00 +04:00
|
|
|
#define NS_COM NS_IMPORT
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif
|
|
|
|
|
2005-04-06 07:35:24 +04:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2005-07-01 16:24:07 +04:00
|
|
|
# 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
|
2005-04-06 07:35:24 +04:00
|
|
|
#else
|
2006-05-03 20:11:14 +04:00
|
|
|
# ifdef HAVE_VISIBILITY_ATTRIBUTE
|
|
|
|
# define NS_COM_GLUE NS_VISIBILITY_HIDDEN
|
|
|
|
# else
|
|
|
|
# define NS_COM_GLUE
|
|
|
|
# endif
|
2004-10-29 23:43:51 +04:00
|
|
|
#endif
|
|
|
|
|
2004-07-15 02:14:34 +04:00
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* 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
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif
|
2001-09-27 07:43:00 +04:00
|
|
|
#if defined(_MSC_VER) && _MSC_VER >= 1100
|
|
|
|
#define NS_NO_VTABLE __declspec(novtable)
|
1999-05-19 01:43:13 +04:00
|
|
|
#else
|
2001-09-27 07:43:00 +04:00
|
|
|
#define NS_NO_VTABLE
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* Generic XPCOM result data type
|
|
|
|
*/
|
|
|
|
typedef PRUint32 nsresult;
|
|
|
|
|
2006-02-10 18:00:36 +03:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
2001-09-27 07:43:00 +04:00
|
|
|
/**
|
|
|
|
* The preferred symbol for null.
|
|
|
|
*/
|
|
|
|
#define nsnull 0
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2002-09-07 21:13:19 +04:00
|
|
|
#include "nsError.h"
|
1999-05-19 01:43:13 +04:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
1999-06-04 06:00:19 +04:00
|
|
|
/* Casting macros for hiding C++ features from older compilers */
|
1999-05-19 01:43:13 +04:00
|
|
|
|
2000-01-13 08:48:47 +03:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2000-01-14 02:06:47 +03:00
|
|
|
/* under Metrowerks (Mac), we don't have autoconf yet */
|
2000-01-13 08:48:47 +03:00
|
|
|
#ifdef __MWERKS__
|
2000-04-26 04:55:37 +04:00
|
|
|
#define HAVE_CPP_PARTIAL_SPECIALIZATION
|
2000-01-13 08:48:47 +03:00
|
|
|
#define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
2000-03-18 02:08:29 +03:00
|
|
|
|
2000-06-05 04:46:37 +04:00
|
|
|
#define HAVE_CPP_ACCESS_CHANGING_USING
|
|
|
|
#define HAVE_CPP_AMBIGUITY_RESOLVING_USING
|
2000-03-18 02:08:29 +03:00
|
|
|
#define HAVE_CPP_EXPLICIT
|
2000-06-18 09:00:31 +04:00
|
|
|
#define HAVE_CPP_TYPENAME
|
2000-03-18 02:08:29 +03:00
|
|
|
#define HAVE_CPP_BOOL
|
2000-03-28 11:01:37 +04:00
|
|
|
#define HAVE_CPP_NAMESPACE_STD
|
2000-04-04 10:38:12 +04:00
|
|
|
#define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
|
2000-06-21 05:31:09 +04:00
|
|
|
#define HAVE_CPP_2BYTE_WCHAR_T
|
2000-03-28 11:01:37 +04:00
|
|
|
#endif
|
|
|
|
|
2000-01-14 02:06:47 +03:00
|
|
|
/* under VC++ (Windows), we don't have autoconf yet */
|
2000-01-13 08:48:47 +03:00
|
|
|
#if defined(_MSC_VER) && (_MSC_VER>=1100)
|
2000-01-14 02:06:47 +03:00
|
|
|
/* VC++ 5.0 and greater implement template specialization, 4.2 is unknown */
|
2000-01-13 08:48:47 +03:00
|
|
|
#define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
2000-03-18 02:08:29 +03:00
|
|
|
|
|
|
|
#define HAVE_CPP_EXPLICIT
|
2000-06-18 09:00:31 +04:00
|
|
|
#define HAVE_CPP_TYPENAME
|
2000-06-05 04:46:37 +04:00
|
|
|
#define HAVE_CPP_ACCESS_CHANGING_USING
|
2000-03-18 02:08:29 +03:00
|
|
|
|
2002-07-13 01:08:56 +04:00
|
|
|
#if (_MSC_VER==1100)
|
2000-09-13 16:22:17 +04:00
|
|
|
/* VC++5.0 has an internal compiler error (sometimes) without this */
|
2000-06-05 04:46:37 +04:00
|
|
|
#undef HAVE_CPP_ACCESS_CHANGING_USING
|
2000-03-18 02:08:29 +03:00
|
|
|
#endif
|
2000-03-24 03:38:52 +03:00
|
|
|
|
2000-03-28 11:44:26 +04:00
|
|
|
#define HAVE_CPP_NAMESPACE_STD
|
2000-04-04 10:38:12 +04:00
|
|
|
#define HAVE_CPP_UNAMBIGUOUS_STD_NOTEQUAL
|
2000-09-03 06:24:58 +04:00
|
|
|
#define HAVE_CPP_2BYTE_WCHAR_T
|
2000-06-13 04:05:18 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PRUNICHAR__
|
|
|
|
#define __PRUNICHAR__
|
2001-05-21 20:34:20 +04:00
|
|
|
/* 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
|
2007-07-08 11:08:04 +04:00
|
|
|
* |reinterpret_cast| in nsLiteralString.h either.
|
2001-05-21 20:34:20 +04:00
|
|
|
*/
|
2005-06-24 04:24:42 +04:00
|
|
|
#if defined(HAVE_CPP_2BYTE_WCHAR_T) && defined(NS_WIN32)
|
2001-05-21 20:34:20 +04:00
|
|
|
typedef wchar_t PRUnichar;
|
|
|
|
#else
|
|
|
|
typedef PRUint16 PRUnichar;
|
|
|
|
#endif
|
2000-01-13 08:48:47 +03:00
|
|
|
#endif
|
|
|
|
|
2000-06-10 13:58:15 +04:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
|
2000-06-18 09:00:31 +04:00
|
|
|
#ifndef HAVE_CPP_TYPENAME
|
|
|
|
#define typename
|
|
|
|
#endif
|
|
|
|
|
2000-01-13 08:48:47 +03:00
|
|
|
#ifdef HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
|
|
|
#define NS_SPECIALIZE_TEMPLATE template <>
|
|
|
|
#else
|
|
|
|
#define NS_SPECIALIZE_TEMPLATE
|
|
|
|
#endif
|
|
|
|
|
2001-08-14 08:14:47 +04:00
|
|
|
/*
|
|
|
|
* Use these macros to do 64bit safe pointer conversions.
|
|
|
|
*/
|
|
|
|
|
2005-07-20 17:12:13 +04:00
|
|
|
#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))
|
2001-08-14 08:14:47 +04:00
|
|
|
|
2005-03-28 23:36:24 +04:00
|
|
|
/*
|
2005-04-07 22:11:59 +04:00
|
|
|
* Use NS_STRINGIFY to form a string literal from the value of a macro.
|
2005-03-28 23:36:24 +04:00
|
|
|
*/
|
2005-04-07 22:11:59 +04:00
|
|
|
#define NS_STRINGIFY_HELPER(x_) #x_
|
|
|
|
#define NS_STRINGIFY(x_) NS_STRINGIFY_HELPER(x_)
|
2005-03-28 23:36:24 +04:00
|
|
|
|
2004-03-08 02:32:08 +03:00
|
|
|
/*
|
|
|
|
* 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 ...
|
|
|
|
* }
|
|
|
|
*
|
2006-11-18 03:48:56 +03:00
|
|
|
* These macros are guaranteed to always return 0 or 1.
|
|
|
|
* The NS_FAILED/NS_SUCCEEDED macros depends on this.
|
|
|
|
* @return 0 or 1
|
2004-03-08 02:32:08 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(__GNUC__) && (__GNUC__ > 2)
|
2006-11-18 03:48:56 +03:00
|
|
|
#define NS_LIKELY(x) (__builtin_expect(!!(x), 1))
|
|
|
|
#define NS_UNLIKELY(x) (__builtin_expect(!!(x), 0))
|
2004-03-08 02:32:08 +03:00
|
|
|
#else
|
2006-11-18 03:48:56 +03:00
|
|
|
#define NS_LIKELY(x) (!!(x))
|
|
|
|
#define NS_UNLIKELY(x) (!!(x))
|
2007-09-29 00:33:32 +04:00
|
|
|
#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
|
2004-03-08 02:32:08 +03:00
|
|
|
#endif
|
|
|
|
|
1999-05-19 01:43:13 +04:00
|
|
|
#endif /* nscore_h___ */
|