Bug 795507: Remove usage of PR_BEGIN_EXTERN_C and PR_END_EXTERN_C; r=ehsan
authorIsaac Aggrey <isaac.aggrey@gmail.com>
Sun, 30 Sep 2012 21:10:22 -0500
changeset 108752 2d1a365a332043ac3cc4bbc0cc2c216610004ce8
parent 108751 144db3479fe37c80e9c92fbd6e1d3471010a7782
child 108753 b16fb4f4ad481335da9d58e233dffc8f4ae35918
push idunknown
push userunknown
push dateunknown
reviewersehsan
bugs795507
milestone18.0a1
Bug 795507: Remove usage of PR_BEGIN_EXTERN_C and PR_END_EXTERN_C; r=ehsan
dbm/include/mcom_db.h
modules/libpref/src/prefapi.h
modules/libpref/src/prefread.h
tools/testy/TestySupport.h
tools/testy/sample/SimpleTest.cpp
tools/trace-malloc/lib/nsTraceMalloc.h
tools/trace-malloc/lib/nsTraceMallocCallbacks.h
tools/trace-malloc/lib/nsTypeInfo.h
tools/trace-malloc/tmreader.h
widget/os2/nsPrintdOS2.h
xpcom/base/nsStackWalk.cpp
xpcom/base/nsStackWalk.h
xpcom/glue/nsQuickSort.cpp
xpcom/glue/nsQuickSort.h
xpcom/glue/pldhash.h
xpcom/typelib/xpt/public/xpt_arena.h
xpcom/typelib/xpt/public/xpt_struct.h
xpcom/typelib/xpt/public/xpt_xdr.h
--- a/dbm/include/mcom_db.h
+++ b/dbm/include/mcom_db.h
@@ -201,19 +201,23 @@
 #endif
 #endif
 
 #ifdef macintosh
 #include <stdio.h>
 #include "xp_mcom.h"
 #define O_ACCMODE       3       /* Mask for file access modes */
 #define EFTYPE 2000
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 int mkstemp(const char *path);
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 #endif	/* MACINTOSH */
 
 #if !defined(_WINDOWS) && !defined(macintosh)
 #include <sys/stat.h>
 #include <errno.h>
 #endif
 
 /* define EFTYPE since most don't */
@@ -386,28 +390,32 @@ typedef struct {
 	((char *)a)[1] = ((char *)&_tmp)[0];				\
 }
 #define	P_16_COPY(a, b) {						\
 	((char *)&(b))[0] = ((char *)&(a))[1];				\
 	((char *)&(b))[1] = ((char *)&(a))[0];				\
 }
 #endif
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 extern DB *
 dbopen (const char *, int, int, DBTYPE, const void *);
 
 /* set or unset a global lock flag to disable the
  * opening of any DBM file
  */
 void dbSetOrClearDBLock(DBLockFlagEnum type);
 
 #ifdef __DBINTERFACE_PRIVATE
 DB	*__bt_open (const char *, int, int, const BTREEINFO *, int);
 DB	*__hash_open (const char *, int, int, const HASHINFO *, int);
 DB	*__rec_open (const char *, int, int, const RECNOINFO *, int);
 void	 __dbpanic (DB *dbp);
 #endif
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* !_DB_H_ */
--- a/modules/libpref/src/prefapi.h
+++ b/modules/libpref/src/prefapi.h
@@ -7,17 +7,19 @@
 // <pre>
 */
 #ifndef PREFAPI_H
 #define PREFAPI_H
 
 #include "nscore.h"
 #include "pldhash.h"
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef union
 {
     char*       stringVal;
     int32_t     intVal;
     bool        boolVal;
 } PrefValue;
 
@@ -173,10 +175,12 @@ nsresult PREF_UnregisterCallback( const 
  * Used by nsPrefService as the callback function of the 'pref' parser
  */
 void PREF_ReaderCallback( void *closure,
                           const char *pref,
                           PrefValue   value,
                           PrefType    type,
                           bool        isDefault);
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
 #endif
+#endif
--- a/modules/libpref/src/prefread.h
+++ b/modules/libpref/src/prefread.h
@@ -3,17 +3,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef prefread_h__
 #define prefread_h__
 
 #include "prtypes.h"
 #include "prefapi.h"
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /**
  * Callback function used to notify consumer of preference name value pairs.
  * The pref name and value must be copied by the implementor of the callback
  * if they are needed beyond the scope of the callback function.
  *
  * @param closure
  *        user data passed to PREF_InitParseState
@@ -92,10 +94,12 @@ void PREF_FinalizeParseState(PrefParseSt
  *        Raw buffer containing data to be parsed.
  * @param bufLen
  *        Length of buffer.
  *
  * @return false if buffer contains malformed content.
  */
 bool PREF_ParseBuf(PrefParseState *ps, const char *buf, int bufLen);
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 #endif /* prefread_h__ */
--- a/tools/testy/TestySupport.h
+++ b/tools/testy/TestySupport.h
@@ -1,14 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 PR_EXPORT(int)  Testy_LogInit(const char* fileName);
 PR_EXPORT(void) Testy_LogShutdown();
 
 PR_EXPORT(void) Testy_LogStart(const char* name);
 PR_EXPORT(void) Testy_LogComment(const char* name, const char* comment);
 PR_EXPORT(void) Testy_LogEnd(const char* name, bool passed);
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
--- a/tools/testy/sample/SimpleTest.cpp
+++ b/tools/testy/sample/SimpleTest.cpp
@@ -1,21 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "nspr.h"
 #include "TestySupport.h"
 
-PR_BEGIN_EXTERN_C
+extern "C" {
 PR_EXPORT(int) Testy_Init();
 PR_EXPORT(int) Testy_RunTest();
 PR_EXPORT(int) Testy_Shutdown();
-PR_END_EXTERN_C
+}
 
 
 int Testy_Init() 
 {
   return 0;
 }
 
 
--- a/tools/trace-malloc/lib/nsTraceMalloc.h
+++ b/tools/trace-malloc/lib/nsTraceMalloc.h
@@ -10,17 +10,19 @@
 
 #include <stdio.h> /* for FILE */
 #include "prtypes.h"
 
 #ifdef XP_WIN
 #define setlinebuf(stream) setvbuf((stream), (char *)NULL, _IOLBF, 0)
 #endif
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /**
  * Magic "number" at start of a trace-malloc log file.  Inspired by the PNG
  * magic string, which inspired XPCOM's typelib (.xpt) file magic.  See the
  * NS_TraceMallocStartup comment (below) for magic number differences in log
  * file structure.
  */
 #define NS_TRACE_MALLOC_MAGIC           "XPCOM\nTMLog08\r\n\032"
@@ -213,11 +215,13 @@ PR_EXTERN(nsTMStackTraceID)
 NS_TraceMallocGetStackTrace(void);
 
 /**
  * Print the stack trace identified.
  */
 PR_EXTERN(void)
 NS_TraceMallocPrintStackTrace(FILE *ofp, nsTMStackTraceID id);
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* nsTraceMalloc_h___ */
--- a/tools/trace-malloc/lib/nsTraceMallocCallbacks.h
+++ b/tools/trace-malloc/lib/nsTraceMallocCallbacks.h
@@ -6,17 +6,19 @@
 
 /* declarations needed by both nsTraceMalloc.c and nsWinTraceMalloc.cpp */
 
 #ifndef NSTRACEMALLOCCALLBACKS_H
 #define NSTRACEMALLOCCALLBACKS_H
 
 #include <stdlib.h>
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* Used by backtrace. */
 typedef struct stack_buffer_info {
     void **buffer;
     size_t size;
     size_t entries;
 } stack_buffer_info;
 
@@ -49,11 +51,13 @@ PR_EXTERN(void) ShutdownHooker();
 /* implemented in nsWinTraceMalloc.cpp */
 void* dhw_orig_malloc(size_t);
 void* dhw_orig_calloc(size_t, size_t);
 void* dhw_orig_realloc(void*, size_t);
 void dhw_orig_free(void*);
 
 #endif /* defined(XP_WIN32) */
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* !defined(NSTRACEMALLOCCALLBACKS_H) */
--- a/tools/trace-malloc/lib/nsTypeInfo.h
+++ b/tools/trace-malloc/lib/nsTypeInfo.h
@@ -4,17 +4,21 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef trace_malloc_nsTypeInfo_h_
 #define trace_malloc_nsTypeInfo_h_
 
 #include "prtypes.h"
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 extern const char* nsGetTypeName(void* ptr);
 
 extern void RegisterTraceMallocShutdown();
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* trace_malloc_nsTypeInfo_h_ */
--- a/tools/trace-malloc/tmreader.h
+++ b/tools/trace-malloc/tmreader.h
@@ -6,17 +6,19 @@
 #ifndef tmreader_h___
 #define tmreader_h___
 
 #include "prtypes.h"
 #include "plhash.h"
 #include "nsTraceMalloc.h"
 #include "plarena.h"
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef struct tmreader     tmreader;
 typedef struct tmevent      tmevent;
 typedef struct tmcounts     tmcounts;
 typedef struct tmallcounts  tmallcounts;
 typedef struct tmgraphlink  tmgraphlink;
 typedef struct tmgraphedge  tmgraphedge;
 typedef struct tmgraphnode  tmgraphnode;
@@ -178,11 +180,13 @@ extern tmcallsite   *tmreader_callsite(t
  * only if zero (the root is at level 0).  A low watermark should be cleared
  * when the tree walk unwinds past the level at which it was set non-zero.
  *
  * Return 0 on error (malloc failure) and 1 on success.
  */
 extern int tmgraphnode_connect(tmgraphnode *from, tmgraphnode *to,
                                tmcallsite *site);
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* tmreader_h___ */
--- a/widget/os2/nsPrintdOS2.h
+++ b/widget/os2/nsPrintdOS2.h
@@ -6,17 +6,19 @@
 
 /* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
 
 #ifndef nsPrintdOS2_h___
 #define nsPrintdOS2_h___
 
 #include <limits.h>
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* stolen from nsPostScriptObj.h. needs to be put somewhere else that
    both ps and gtk can see easily */
  
 #ifndef PATH_MAX
 #ifdef _POSIX_PATH_MAX
 #define PATH_MAX	_POSIX_PATH_MAX
 #else
@@ -34,11 +36,13 @@ typedef enum
 typedef struct OS2prdata {
         printDest destination;     /* print to file, printer or print preview */
         int copies;                /* number of copies to print   0 < n < 999 */
         char printer[ PATH_MAX ];  /* Printer selected - name*/
         char path[ PATH_MAX ];     /* If destination = printToFile, dest file */
         bool cancel;		     /* If true, user cancelled */
 } OS2PrData;
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* nsPrintdOS2_h___ */
--- a/xpcom/base/nsStackWalk.cpp
+++ b/xpcom/base/nsStackWalk.cpp
@@ -193,17 +193,17 @@ StackWalkInitCriticalAddress()
 #endif
 
 // Define these as static pointers so that we can load the DLL on the
 // fly (and not introduce a link-time dependency on it). Tip o' the
 // hat to Matt Pietrick for this idea. See:
 //
 //   http://msdn.microsoft.com/library/periodic/period97/F1/D3/S245C6.htm
 //
-PR_BEGIN_EXTERN_C
+extern "C" {
 
 extern HANDLE hStackWalkMutex; 
 
 bool EnsureSymInitialized();
 
 bool EnsureImageHlpInitialized();
 
 struct WalkStackData {
@@ -224,17 +224,17 @@ struct WalkStackData {
 void PrintError(char *prefix, WalkStackData* data);
 unsigned int WINAPI WalkStackThread(void* data);
 void WalkStackMain64(struct WalkStackData* data);
 
 
 DWORD gStackWalkThread;
 CRITICAL_SECTION gDbgHelpCS;
 
-PR_END_EXTERN_C
+}
 
 // Routine to print an error message to standard error.
 // Will also call callback with error, if data supplied.
 void PrintError(char *prefix)
 {
     LPVOID lpMsgBuf;
     DWORD lastErr = GetLastError();
     FormatMessageA(
--- a/xpcom/base/nsStackWalk.h
+++ b/xpcom/base/nsStackWalk.h
@@ -9,17 +9,19 @@
 #define nsStackWalk_h_
 
 /* WARNING: This file is intended to be included from C or C++ files. */
 
 #include "nscore.h"
 #include <mozilla/StandardInteger.h>
 #include "prtypes.h"
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 // aSP will be the best approximation possible of what the stack pointer will be
 // pointing to when the execution returns to executing that at that PC.
 // If no approximation can be made it will be NULL.
 typedef void
 (* NS_WalkStackCallback)(void *aPC, void *aSP, void *aClosure);
 
 /**
@@ -98,11 +100,13 @@ NS_DescribeCodeAddress(void *aPC, nsCode
  *                    to be printed would be larger than aBuffer, it
  *                    will be truncated so that aBuffer[aBufferSize-1]
  *                    is the terminating null.
  */
 XPCOM_API(nsresult)
 NS_FormatCodeAddressDetails(void *aPC, const nsCodeAddressDetails *aDetails,
                             char *aBuffer, uint32_t aBufferSize);
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* !defined(nsStackWalk_h_) */
--- a/xpcom/glue/nsQuickSort.cpp
+++ b/xpcom/glue/nsQuickSort.cpp
@@ -33,17 +33,17 @@
  * causes array bounds reads.
  */
 
 #include <stdlib.h>
 #include "prtypes.h"
 #include "nsAlgorithm.h"
 #include "nsQuickSort.h"
 
-PR_BEGIN_EXTERN_C
+extern "C" {
 
 #if !defined(DEBUG) && (defined(__cplusplus) || defined(__gcc))
 # ifndef INLINE
 #  define INLINE inline
 # endif
 #else
 # define INLINE
 #endif
@@ -175,9 +175,9 @@ loop:	SWAPINIT(a, es);
 		/* Iterate rather than recurse to save stack space */
 		a = pn - r;
 		n = r / es;
 		goto loop;
 	}
 /*		NS_QuickSort(pn - r, r / es, es, cmp, data);*/
 }
 
-PR_END_EXTERN_C
+}
--- a/xpcom/glue/nsQuickSort.h
+++ b/xpcom/glue/nsQuickSort.h
@@ -9,17 +9,19 @@
  */
 
 #ifndef nsQuickSort_h___
 #define nsQuickSort_h___
 
 #include "prtypes.h"
 #include "nscore.h"
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /**
  * Parameters:
  *  1. the array to sort
  *  2. the number of elements in the array
  *  3. the size of each array element
  *  4. comparison function taking two elements and parameter #5 and
  *     returning an integer:
@@ -27,11 +29,13 @@ PR_BEGIN_EXTERN_C
  *      + 0 if the order of the elements does not matter
  *      + greater than zero if the second element should be before the first
  *  5. extra data to pass to comparison function
  */
 NS_COM_GLUE void NS_QuickSort(void *, unsigned int, unsigned int,
                               int (*)(const void *, const void *, void *), 
                               void *);
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* nsQuickSort_h___ */
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -7,17 +7,19 @@
 #define pldhash_h___
 /*
  * Double hashing, a la Knuth 6.
  *
  * Try to keep this file in sync with js/src/jsdhash.h.
  */
 #include "nscore.h"
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #if defined(__GNUC__) && defined(__i386__) && (__GNUC__ >= 3) && !defined(XP_OS2)
 #define PL_DHASH_FASTCALL __attribute__ ((regparm (3),stdcall))
 #elif defined(XP_WIN)
 #define PL_DHASH_FASTCALL __fastcall
 #else
 #define PL_DHASH_FASTCALL
 #endif
@@ -592,11 +594,13 @@ PL_DHashMarkTableImmutable(PLDHashTable 
 
 #ifdef PL_DHASHMETER
 #include <stdio.h>
 
 NS_COM_GLUE void
 PL_DHashTableDumpMeter(PLDHashTable *table, PLDHashEnumerator dump, FILE *fp);
 #endif
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* pldhash_h___ */
--- a/xpcom/typelib/xpt/public/xpt_arena.h
+++ b/xpcom/typelib/xpt/public/xpt_arena.h
@@ -17,17 +17,19 @@
 
 /*
  * The XPT library is statically linked: no functions are exported from
  * shared libraries.
  */
 #define XPT_PUBLIC_API(t)    t
 #define XPT_PUBLIC_DATA(t)   t
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*
  * Simple Arena support. Use with caution!
  */ 
 
 typedef struct XPTArena XPTArena;
 
 XPT_PUBLIC_API(XPTArena *)
@@ -85,11 +87,13 @@ XPT_SizeOfArena(XPTArena *arena, xptMall
 XPT_PUBLIC_API(void)
 XPT_AssertFailed(const char *s, const char *file, uint32_t lineno);
 #define XPT_ASSERT(_expr) \
     ((_expr)?((void)0):XPT_AssertFailed(# _expr, __FILE__, __LINE__))
 #else
 #define XPT_ASSERT(_expr) ((void)0)
 #endif
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* __xpt_arena_h__ */
--- a/xpcom/typelib/xpt/public/xpt_struct.h
+++ b/xpcom/typelib/xpt/public/xpt_struct.h
@@ -9,17 +9,19 @@
  */
 
 #ifndef __xpt_struct_h__
 #define __xpt_struct_h__
 
 #include "xpt_arena.h"
 #include "mozilla/StandardInteger.h"
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*
  * Originally, I was going to have structures that exactly matched the on-disk
  * representation, but that proved difficult: different compilers can pack
  * their structs differently, and that makes overlaying them atop a
  * read-from-disk byte buffer troublesome.  So now I just have some structures
  * that are used in memory, and we're going to write a nice XDR library to
  * write them to disk and stuff.  It is pure joy. -- shaver
@@ -506,11 +508,13 @@ struct XPTAnnotation {
 #define XPT_ANN_IS_LAST(flags)          (flags & XPT_ANN_LAST)
 #define XPT_ANN_PRIVATE                 0x40
 #define XPT_ANN_IS_PRIVATE(flags)       (flags & XPT_ANN_PRIVATE)
 
 extern XPT_PUBLIC_API(XPTAnnotation *)
 XPT_NewAnnotation(XPTArena *arena, uint8_t flags, XPTString *creator, 
                   XPTString *private_data);
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* __xpt_struct_h__ */
--- a/xpcom/typelib/xpt/public/xpt_xdr.h
+++ b/xpcom/typelib/xpt/public/xpt_xdr.h
@@ -7,17 +7,19 @@
  * Basic APIs for streaming typelib structures to/from disk.
  */
 
 #ifndef __xpt_xdr_h__
 #define __xpt_xdr_h__
 
 #include "xpt_struct.h"
 
-PR_BEGIN_EXTERN_C
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 typedef struct XPTState         XPTState;
 typedef struct XPTDatapool      XPTDatapool;
 typedef struct XPTCursor        XPTCursor;
 
 /* Opaque type, for internal use */
 typedef struct XPTHashTable     XPTHashTable;
 
@@ -169,11 +171,13 @@ XPT_GetAddrForOffset(XPTCursor *cursor, 
 
 #define XPT_ERROR_HANDLE(arena, free_it)                                      \
  error:                                                                       \
     if (cursor->state->mode == XPT_DECODE)                                    \
     XPT_FREEIF(arena, free_it);                                               \
     return PR_FALSE;
 
 
-PR_END_EXTERN_C
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* __xpt_xdr_h__ */