Bug 1438257, part 1 - Get rid of useless XPT_PUBLIC_* macros. r=froydnj draft
authorAndrew McCreight <continuation@gmail.com>
Wed, 14 Feb 2018 09:52:08 -0800
changeset 754979 901be461cb31e63355c9374e84b1a92be814fd82
parent 754399 38b3c1d03a594664c6b32c35533734283c258f43
child 754980 aa9ab3bb9b298fffc09dfe9cb9299af2b27717b7
push id99082
push userbmo:continuation@gmail.com
push dateWed, 14 Feb 2018 19:47:59 +0000
reviewersfroydnj
bugs1438257
milestone60.0a1
Bug 1438257, part 1 - Get rid of useless XPT_PUBLIC_* macros. r=froydnj These macros haven't done anything since 2006, so get rid of them. MozReview-Commit-ID: GOakDBIt1Mf
xpcom/typelib/xpt/xpt_arena.cpp
xpcom/typelib/xpt/xpt_arena.h
xpcom/typelib/xpt/xpt_struct.cpp
xpcom/typelib/xpt/xpt_xdr.cpp
xpcom/typelib/xpt/xpt_xdr.h
--- a/xpcom/typelib/xpt/xpt_arena.cpp
+++ b/xpcom/typelib/xpt/xpt_arena.cpp
@@ -41,17 +41,17 @@ struct XPTArena
 {
     // We have one sub-arena with 8-byte alignment for most allocations, and
     // one with 1-byte alignment for C string allocations. The latter sub-arena
     // avoids significant amounts of unnecessary padding between C strings.
     XPTSubArena subarena8;
     XPTSubArena subarena1;
 };
 
-XPT_PUBLIC_API(XPTArena *)
+XPTArena*
 XPT_NewArena(size_t block_size8, size_t block_size1)
 {
     XPTArena *arena = static_cast<XPTArena*>(calloc(1, sizeof(XPTArena)));
     if (arena) {
         if (block_size8 < XPT_MIN_BLOCK_SIZE)
             block_size8 = XPT_MIN_BLOCK_SIZE;
         arena->subarena8.block_size = ALIGN_RND(block_size8, 8);
 
@@ -68,30 +68,30 @@ DestroySubArena(XPTSubArena *subarena)
     BLK_HDR* cur = subarena->first;
     while (cur) {
         BLK_HDR* next = cur->next;
         free(cur);
         cur = next;
     }
 }
 
-XPT_PUBLIC_API(void)
+void
 XPT_DestroyArena(XPTArena *arena)
 {
     DestroySubArena(&arena->subarena8);
     DestroySubArena(&arena->subarena1);
     free(arena);
 }
 
 /*
 * Our alignment rule is that we always round up the size of each allocation
 * so that the 'arena->next' pointer one will point to properly aligned space.
 */
 
-XPT_PUBLIC_API(void *)
+void*
 XPT_ArenaCalloc(XPTArena *arena, size_t size, size_t alignment)
 {
     if (!size)
         return NULL;
 
     if (!arena) {
         XPT_ASSERT(0);
         return NULL;
@@ -157,17 +157,17 @@ XPT_ArenaCalloc(XPTArena *arena, size_t 
     subarena->space -= bytes;
 
     return p;
 }
 
 /***************************************************************************/
 
 #ifdef DEBUG
-XPT_PUBLIC_API(void)
+void
 XPT_AssertFailed(const char *s, const char *file, uint32_t lineno)
 {
     fprintf(stderr, "Assertion failed: %s, file %s, line %d\n",
             s, file, lineno);
     abort();
 }
 #endif
 
@@ -181,16 +181,16 @@ SizeOfSubArenaExcludingThis(XPTSubArena 
         BLK_HDR* next = cur->next;
         n += mallocSizeOf(cur);
         cur = next;
     }
 
     return n;
 }
 
-XPT_PUBLIC_API(size_t)
+size_t
 XPT_SizeOfArenaIncludingThis(XPTArena *arena, MozMallocSizeOf mallocSizeOf)
 {
     size_t n = mallocSizeOf(arena);
     n += SizeOfSubArenaExcludingThis(&arena->subarena8, mallocSizeOf);
     n += SizeOfSubArenaExcludingThis(&arena->subarena1, mallocSizeOf);
     return n;
 }
--- a/xpcom/typelib/xpt/xpt_arena.h
+++ b/xpcom/typelib/xpt/xpt_arena.h
@@ -10,56 +10,48 @@
 #ifndef __xpt_arena_h__
 #define __xpt_arena_h__
 
 #include <stdlib.h>
 #include "mozilla/Attributes.h"
 #include "mozilla/MemoryReporting.h"
 #include <stdint.h>
 
-
-/*
- * 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
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /*
  * Simple Arena support. Use with caution!
  */
 
 typedef struct XPTArena XPTArena;
 
-XPT_PUBLIC_API(XPTArena *)
+XPTArena*
 XPT_NewArena(size_t block_size8, size_t block_size1);
 
-XPT_PUBLIC_API(void)
+void
 XPT_DestroyArena(XPTArena *arena);
 
-XPT_PUBLIC_API(void *)
+void*
 XPT_ArenaCalloc(XPTArena *arena, size_t size, size_t alignment);
 
-XPT_PUBLIC_API(size_t)
+size_t
 XPT_SizeOfArenaIncludingThis(XPTArena *arena, MozMallocSizeOf mallocSizeOf);
 
 /* --------------------------------------------------------- */
 
 #define XPT_CALLOC8(_arena, _bytes) XPT_ArenaCalloc((_arena), (_bytes), 8)
 #define XPT_CALLOC1(_arena, _bytes) XPT_ArenaCalloc((_arena), (_bytes), 1)
 #define XPT_NEWZAP(_arena, _struct) ((_struct *) XPT_CALLOC8((_arena), sizeof(_struct)))
 
 /* --------------------------------------------------------- */
 
 #ifdef DEBUG
-XPT_PUBLIC_API(void)
+void
 XPT_AssertFailed(const char *s, const char *file, uint32_t lineno)
   MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS;
 #define XPT_ASSERT(_expr) \
     ((_expr)?((void)0):XPT_AssertFailed(# _expr, __FILE__, __LINE__))
 #else
 #define XPT_ASSERT(_expr) ((void)0)
 #endif
 
--- a/xpcom/typelib/xpt/xpt_struct.cpp
+++ b/xpcom/typelib/xpt/xpt_struct.cpp
@@ -43,17 +43,17 @@ DoTypeDescriptor(XPTArena *arena, NotNul
                  XPTTypeDescriptor *td, XPTInterfaceDescriptor *id);
 
 static bool
 DoParamDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
                   XPTParamDescriptor *pd, XPTInterfaceDescriptor *id);
 
 /***************************************************************************/
 
-XPT_PUBLIC_API(bool)
+bool
 XPT_DoHeader(XPTArena *arena, NotNull<XPTCursor*> cursor, XPTHeader **headerp)
 {
     unsigned int i;
     uint32_t file_length = 0;
     uint32_t ide_offset;
 
     XPTHeader* header = XPT_NEWZAP(arena, XPTHeader);
     if (!header)
--- a/xpcom/typelib/xpt/xpt_xdr.cpp
+++ b/xpcom/typelib/xpt/xpt_xdr.cpp
@@ -33,32 +33,32 @@ CHECK_COUNT(NotNull<XPTCursor*> cursor, 
         XPT_ASSERT(0);
         fprintf(stderr, "FATAL: no room for %u in cursor\n", space);
         return false;
     }
 
     return true;
 }
 
-XPT_PUBLIC_API(void)
+void
 XPT_InitXDRState(XPTState* state, char *data, uint32_t len)
 {
     state->next_cursor[0] = state->next_cursor[1] = 1;
     state->pool_data = data;
     state->pool_allocated = len;
 }
 
 /* All offsets are 1-based */
-XPT_PUBLIC_API(void)
+void
 XPT_SetDataOffset(XPTState *state, uint32_t data_offset)
 {
    state->data_offset = data_offset;
 }
 
-XPT_PUBLIC_API(bool)
+bool
 XPT_MakeCursor(XPTState *state, XPTPool pool, uint32_t len,
                NotNull<XPTCursor*> cursor)
 {
     cursor->state = state;
     cursor->pool = pool;
     cursor->bits = 0;
     cursor->offset = state->next_cursor[pool];
 
@@ -71,40 +71,40 @@ XPT_MakeCursor(XPTState *state, XPTPool 
         return false;
     }
 
     state->next_cursor[pool] += len;
 
     return true;
 }
 
-XPT_PUBLIC_API(bool)
+bool
 XPT_SeekTo(NotNull<XPTCursor*> cursor, uint32_t offset)
 {
     /* XXX do some real checking and update len and stuff */
     cursor->offset = offset;
     return true;
 }
 
-XPT_PUBLIC_API(bool)
+bool
 XPT_SkipStringInline(NotNull<XPTCursor*> cursor)
 {
     uint16_t length;
     if (!XPT_Do16(cursor, &length))
         return false;
 
     uint8_t byte;
     for (uint16_t i = 0; i < length; i++)
         if (!XPT_Do8(cursor, &byte))
             return false;
 
     return true;
 }
 
-XPT_PUBLIC_API(bool)
+bool
 XPT_DoCString(XPTArena *arena, NotNull<XPTCursor*> cursor, char **identp,
               bool ignore)
 {
     uint32_t offset = 0;
     if (!XPT_Do32(cursor, &offset))
         return false;
 
     if (!offset) {
@@ -147,17 +147,17 @@ XPT_DoCString(XPTArena *arena, NotNull<X
  *     {00112233-4455-6677-8899-aabbccddeeff}
  *   is converted to the 128-bit value
  *     0x00112233445566778899aabbccddeeff
  *   Note that the byte storage order corresponds to the layout of the nsIID
  *   C-struct on a big-endian architecture."
  *
  * (http://www.mozilla.org/scriptable/typelib_file.html#iid)
  */
-XPT_PUBLIC_API(bool)
+bool
 XPT_DoIID(NotNull<XPTCursor*> cursor, nsID *iidp)
 {
     int i;
 
     if (!XPT_Do32(cursor, &iidp->m0) ||
         !XPT_Do16(cursor, &iidp->m1) ||
         !XPT_Do16(cursor, &iidp->m2))
         return false;
@@ -180,43 +180,43 @@ XPT_DoIID(NotNull<XPTCursor*> cursor, ns
             return false;                         \
         }                                         \
                                                   \
         *valuep = func(&CURS_POINT(cursor));      \
         cursor->offset += sz;                     \
         return true;                              \
     } while(0)
 
-XPT_PUBLIC_API(bool)
+bool
 XPT_Do64(NotNull<XPTCursor*> cursor, int64_t *u64p)
 {
     XPT_DOINT(int64_t, mozilla::BigEndian::readInt64, u64p);
 }
 
 /*
  * When we're handling 32- or 16-bit quantities, we handle a byte at a time to
  * avoid alignment issues.  Someone could come and optimize this to detect
  * well-aligned cases and do a single store, if they cared.  I might care
  * later.
  */
-XPT_PUBLIC_API(bool)
+bool
 XPT_Do32(NotNull<XPTCursor*> cursor, uint32_t *u32p)
 {
     XPT_DOINT(uint32_t, mozilla::BigEndian::readUint32, u32p);
 }
 
-XPT_PUBLIC_API(bool)
+bool
 XPT_Do16(NotNull<XPTCursor*> cursor, uint16_t *u16p)
 {
     XPT_DOINT(uint16_t, mozilla::BigEndian::readUint16, u16p);
 }
 
 #undef XPT_DOINT
 
-XPT_PUBLIC_API(bool)
+bool
 XPT_Do8(NotNull<XPTCursor*> cursor, uint8_t *u8p)
 {
     if (!CHECK_COUNT(cursor, 1))
         return false;
 
     *u8p = CURS_POINT(cursor);
 
     cursor->offset++;
--- a/xpcom/typelib/xpt/xpt_xdr.h
+++ b/xpcom/typelib/xpt/xpt_xdr.h
@@ -17,39 +17,39 @@ using mozilla::NotNull;
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 typedef struct XPTState         XPTState;
 typedef struct XPTCursor        XPTCursor;
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_SkipStringInline(NotNull<XPTCursor*> cursor);
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_DoCString(XPTArena *arena, NotNull<XPTCursor*> cursor, char **strp,
               bool ignore = false);
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_DoIID(NotNull<XPTCursor*> cursor, nsID *iidp);
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_Do64(NotNull<XPTCursor*> cursor, int64_t *u64p);
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_Do32(NotNull<XPTCursor*> cursor, uint32_t *u32p);
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_Do16(NotNull<XPTCursor*> cursor, uint16_t *u16p);
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_Do8(NotNull<XPTCursor*> cursor, uint8_t *u8p);
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_DoHeader(XPTArena *arena, NotNull<XPTCursor*> cursor, XPTHeader **headerp);
 
 typedef enum {
     XPT_HEADER = 0,
     XPT_DATA = 1
 } XPTPool;
 
 struct XPTState {
@@ -61,26 +61,26 @@ struct XPTState {
 
 struct XPTCursor {
     XPTState    *state;
     XPTPool     pool;
     uint32_t    offset;
     uint8_t     bits;
 };
 
-extern XPT_PUBLIC_API(void)
+extern void
 XPT_InitXDRState(XPTState* state, char* data, uint32_t len);
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_MakeCursor(XPTState *state, XPTPool pool, uint32_t len,
                NotNull<XPTCursor*> cursor);
 
-extern XPT_PUBLIC_API(bool)
+extern bool
 XPT_SeekTo(NotNull<XPTCursor*> cursor, uint32_t offset);
 
-extern XPT_PUBLIC_API(void)
+extern void
 XPT_SetDataOffset(XPTState *state, uint32_t data_offset);
 
 #ifdef __cplusplus
 }
 #endif
 
 #endif /* __xpt_xdr_h__ */