📄 prtypes.h
字号:
// // Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.// // This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 3 of the License, or// (at your option) any later version.// // This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.// // You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA///*** 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 <cstddef>using namespace std;/************************************************************************* 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 __declspec(dllexport) __type#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type#define PR_IMPORT(__type) __declspec(dllimport) __type#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type#define PR_EXTERN(__type) extern __declspec(dllexport) __type#define PR_IMPLEMENT(__type) __declspec(dllexport) __type#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type#define PR_CALLBACK#define PR_CALLBACK_DECL#define PR_STATIC_CALLBACK(__x) static __x#elif defined(XP_BEOS)#define PR_EXPORT(__type) extern __declspec(dllexport) __type#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type#define PR_IMPORT(__type) extern __declspec(dllexport) __type#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type#define PR_EXTERN(__type) extern __declspec(dllexport) __type#define PR_IMPLEMENT(__type) __declspec(dllexport) __type#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type#define PR_CALLBACK#define PR_CALLBACK_DECL#define PR_STATIC_CALLBACK(__x) static __x#elif defined(WIN16)#define PR_CALLBACK_DECL __cdecl#if defined(_WINDLL)#define PR_EXPORT(__type) extern __type _cdecl _export _loadds#define PR_IMPORT(__type) extern __type _cdecl _export _loadds#define PR_EXPORT_DATA(__type) extern __type _export#define PR_IMPORT_DATA(__type) extern __type _export#define PR_EXTERN(__type) extern __type _cdecl _export _loadds#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds#define PR_EXTERN_DATA(__type) extern __type _export#define PR_IMPLEMENT_DATA(__type) __type _export#define PR_CALLBACK __cdecl __loadds#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK#else /* this must be .EXE */#define PR_EXPORT(__type) extern __type _cdecl _export#define PR_IMPORT(__type) extern __type _cdecl _export#define PR_EXPORT_DATA(__type) extern __type _export#define PR_IMPORT_DATA(__type) extern __type _export#define PR_EXTERN(__type) extern __type _cdecl _export#define PR_IMPLEMENT(__type) __type _cdecl _export#define PR_EXTERN_DATA(__type) extern __type _export#define PR_IMPLEMENT_DATA(__type) __type _export#define PR_CALLBACK __cdecl __loadds#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK#endif /* _WINDLL */#elif defined(XP_MAC)#define PR_EXPORT(__type) extern __declspec(export) __type#define PR_EXPORT_DATA(__type) extern __declspec(export) __type#define PR_IMPORT(__type) extern __declspec(export) __type#define PR_IMPORT_DATA(__type) extern __declspec(export) __type#define PR_EXTERN(__type) extern __declspec(export) __type#define PR_IMPLEMENT(__type) __declspec(export) __type#define PR_EXTERN_DATA(__type) extern __declspec(export) __type#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type#define PR_CALLBACK#define PR_CALLBACK_DECL#define PR_STATIC_CALLBACK(__x) static __x#elif defined(XP_OS2_VACPP) #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 _Optlink#define PR_CALLBACK_DECL#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK#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 == 1typedef 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;#elsetypedef signed char PRInt8;#endif#else#error No suitable type for PRInt8/PRUint8#endif/************************************************************************ * MACROS: PR_INT8_MAX
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -