Bug 1080998 - Build libjsctypes-test without a dependency on mozalloc or mozglue. r=jorendorff
--- a/toolkit/components/ctypes/tests/Makefile.in
+++ b/toolkit/components/ctypes/tests/Makefile.in
@@ -4,8 +4,10 @@
LIB_1_FILES = $(SHARED_LIBRARY)
LIB_1_DEST = $(DEPTH)/_tests/xpcshell/$(relativesrcdir)/unit
INSTALL_TARGETS += LIB_1
LIB_3_FILES = $(SHARED_LIBRARY)
LIB_3_DEST = $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)/chrome
INSTALL_TARGETS += LIB_3
+
+MOZ_GLUE_LDFLAGS =
--- a/toolkit/components/ctypes/tests/jsctypes-test-errno.h
+++ b/toolkit/components/ctypes/tests/jsctypes-test-errno.h
@@ -1,20 +1,21 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/* 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 "nscore.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Types.h"
-#define EXPORT_CDECL(type) NS_EXPORT type
-#define EXPORT_STDCALL(type) NS_EXPORT type NS_STDCALL
+#define EXPORT_CDECL(type) MOZ_EXPORT type
-NS_EXTERN_C
-{
+MOZ_BEGIN_EXTERN_C
+
EXPORT_CDECL(void) set_errno(int status);
EXPORT_CDECL(int) get_errno();
#if defined(XP_WIN)
EXPORT_CDECL(void) set_last_error(int status);
EXPORT_CDECL(int) get_last_error();
#endif // defined(XP_WIN)
-}
+
+MOZ_END_EXTERN_C
--- a/toolkit/components/ctypes/tests/jsctypes-test-finalizer.h
+++ b/toolkit/components/ctypes/tests/jsctypes-test-finalizer.h
@@ -1,16 +1,19 @@
/* 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/. */
-#define EXPORT_CDECL(type) NS_EXPORT type
+#include "mozilla/Attributes.h"
+#include "mozilla/Types.h"
-NS_EXTERN_C
-{
+#define EXPORT_CDECL(type) MOZ_EXPORT type
+
+MOZ_BEGIN_EXTERN_C
+
EXPORT_CDECL(void) test_finalizer_start(size_t size);
EXPORT_CDECL(void) test_finalizer_stop();
EXPORT_CDECL(bool) test_finalizer_resource_is_acquired(size_t i);
EXPORT_CDECL(size_t) test_finalizer_acq_size_t(size_t i);
EXPORT_CDECL(void) test_finalizer_rel_size_t(size_t i);
EXPORT_CDECL(size_t) test_finalizer_rel_size_t_return_size_t(size_t i);
EXPORT_CDECL(myRECT) test_finalizer_rel_size_t_return_struct_t(size_t i);
@@ -46,9 +49,9 @@ NS_EXTERN_C
EXPORT_CDECL(bool) test_finalizer_cmp_struct_t(myRECT a, myRECT b);
typedef void (*afun)(size_t);
EXPORT_CDECL(afun*) test_finalizer_rel_null_function();
EXPORT_CDECL(void) test_finalizer_rel_size_t_set_errno(size_t i);
EXPORT_CDECL(void) reset_errno();
-}
+MOZ_END_EXTERN_C
--- a/toolkit/components/ctypes/tests/jsctypes-test.cpp
+++ b/toolkit/components/ctypes/tests/jsctypes-test.cpp
@@ -1,15 +1,14 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/* 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 "jsctypes-test.h"
-#include "nsCRTGlue.h"
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#if defined(XP_WIN)
#define snprintf _snprintf
#endif // defined(XP_WIN)
--- a/toolkit/components/ctypes/tests/jsctypes-test.h
+++ b/toolkit/components/ctypes/tests/jsctypes-test.h
@@ -1,24 +1,32 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/* 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/. */
#ifndef jsctypes_test_h
#define jsctypes_test_h
-#include "nscore.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/Types.h"
#include "jspubtd.h"
-#define EXPORT_CDECL(type) NS_EXPORT type
-#define EXPORT_STDCALL(type) NS_EXPORT type NS_STDCALL
+#define EXPORT_CDECL(type) MOZ_EXPORT type
+#if defined(_WIN32)
+#if defined(_WIN64)
+#define NS_STDCALL
+#else
+#define NS_STDCALL __stdcall
+#endif
+#define EXPORT_STDCALL(type) MOZ_EXPORT type NS_STDCALL
+#endif
-NS_EXTERN_C
-{
+MOZ_BEGIN_EXTERN_C
+
EXPORT_CDECL(void) test_void_t_cdecl();
EXPORT_CDECL(void*) get_voidptr_t_cdecl();
EXPORT_CDECL(void*) set_voidptr_t_cdecl(void*);
#define DEFINE_TYPE(name, type, ffiType) \
EXPORT_CDECL(type) get_##name##_cdecl(); \
EXPORT_CDECL(type) set_##name##_cdecl(type); \
@@ -53,21 +61,21 @@ NS_EXTERN_C
EXPORT_STDCALL(type) sum_many_##name##_stdcall( \
type, type, type, type, type, type, type, type, type, \
type, type, type, type, type, type, type, type, type);
#include "typedefs.h"
#endif /* defined(_WIN32) */
- NS_EXPORT int32_t test_ansi_len(const char*);
- NS_EXPORT int32_t test_wide_len(const char16_t*);
- NS_EXPORT const char* test_ansi_ret();
- NS_EXPORT const char16_t* test_wide_ret();
- NS_EXPORT char* test_ansi_echo(const char*);
+ MOZ_EXPORT int32_t test_ansi_len(const char*);
+ MOZ_EXPORT int32_t test_wide_len(const char16_t*);
+ MOZ_EXPORT const char* test_ansi_ret();
+ MOZ_EXPORT const char16_t* test_wide_ret();
+ MOZ_EXPORT char* test_ansi_echo(const char*);
struct ONE_BYTE {
char a;
};
struct TWO_BYTE {
char a;
char b;
@@ -134,45 +142,46 @@ NS_EXTERN_C
struct NESTED {
int32_t n1;
int16_t n2;
INNER inner;
int64_t n3;
int32_t n4;
};
- NS_EXPORT int32_t test_pt_in_rect(myRECT, myPOINT);
- NS_EXPORT void test_init_pt(myPOINT* pt, int32_t x, int32_t y);
+ MOZ_EXPORT int32_t test_pt_in_rect(myRECT, myPOINT);
+ MOZ_EXPORT void test_init_pt(myPOINT* pt, int32_t x, int32_t y);
- NS_EXPORT int32_t test_nested_struct(NESTED);
- NS_EXPORT myPOINT test_struct_return(myRECT);
- NS_EXPORT myRECT test_large_struct_return(myRECT, myRECT);
- NS_EXPORT ONE_BYTE test_1_byte_struct_return(myRECT);
- NS_EXPORT TWO_BYTE test_2_byte_struct_return(myRECT);
- NS_EXPORT THREE_BYTE test_3_byte_struct_return(myRECT);
- NS_EXPORT FOUR_BYTE test_4_byte_struct_return(myRECT);
- NS_EXPORT FIVE_BYTE test_5_byte_struct_return(myRECT);
- NS_EXPORT SIX_BYTE test_6_byte_struct_return(myRECT);
- NS_EXPORT SEVEN_BYTE test_7_byte_struct_return(myRECT);
+ MOZ_EXPORT int32_t test_nested_struct(NESTED);
+ MOZ_EXPORT myPOINT test_struct_return(myRECT);
+ MOZ_EXPORT myRECT test_large_struct_return(myRECT, myRECT);
+ MOZ_EXPORT ONE_BYTE test_1_byte_struct_return(myRECT);
+ MOZ_EXPORT TWO_BYTE test_2_byte_struct_return(myRECT);
+ MOZ_EXPORT THREE_BYTE test_3_byte_struct_return(myRECT);
+ MOZ_EXPORT FOUR_BYTE test_4_byte_struct_return(myRECT);
+ MOZ_EXPORT FIVE_BYTE test_5_byte_struct_return(myRECT);
+ MOZ_EXPORT SIX_BYTE test_6_byte_struct_return(myRECT);
+ MOZ_EXPORT SEVEN_BYTE test_7_byte_struct_return(myRECT);
- NS_EXPORT void * test_fnptr();
+ MOZ_EXPORT void * test_fnptr();
typedef int32_t (* test_func_ptr)(int8_t);
- NS_EXPORT int32_t test_closure_cdecl(int8_t, test_func_ptr);
+ MOZ_EXPORT int32_t test_closure_cdecl(int8_t, test_func_ptr);
#if defined(_WIN32)
typedef int32_t (NS_STDCALL * test_func_ptr_stdcall)(int8_t);
- NS_EXPORT int32_t test_closure_stdcall(int8_t, test_func_ptr_stdcall);
+ MOZ_EXPORT int32_t test_closure_stdcall(int8_t, test_func_ptr_stdcall);
#endif /* defined(_WIN32) */
- NS_EXPORT int32_t test_callme(int8_t);
- NS_EXPORT void* test_getfn();
+ MOZ_EXPORT int32_t test_callme(int8_t);
+ MOZ_EXPORT void* test_getfn();
EXPORT_CDECL(int32_t) test_sum_va_cdecl(uint8_t n, ...);
EXPORT_CDECL(uint8_t) test_count_true_va_cdecl(uint8_t n, ...);
EXPORT_CDECL(void) test_add_char_short_int_va_cdecl(uint32_t* result, ...);
EXPORT_CDECL(int32_t*) test_vector_add_va_cdecl(uint8_t num_vecs,
uint8_t vec_len,
int32_t* result, ...);
- NS_EXPORT extern myRECT data_rect;
-}
+ MOZ_EXPORT extern myRECT data_rect;
+
+MOZ_END_EXTERN_C
#endif
--- a/toolkit/components/ctypes/tests/moz.build
+++ b/toolkit/components/ctypes/tests/moz.build
@@ -14,12 +14,8 @@ UNIFIED_SOURCES += [
'jsctypes-test.cpp',
]
SharedLibrary('jsctypes-test')
LOCAL_INCLUDES += [
'/js/src/ctypes',
]
-
-USE_LIBS += [
- 'mozalloc',
-]