Browse Source

MoonchildProductions#1251 - Part 1: Restore initial Solaris support, fixed up.

Compared with what Pale Moon had for Solaris originally, this is mostly the same zero point I started patching from, but I've made the following changes here after reviewing all this initial code I never looked at closely before.

1. In package-manifest.in for both Basilisk and Pale Moon, I've made the SPARC code for libfreebl not interefere with the x86 code, use the proper build flags, and also updated it to allow a SPARC64 build which is more likely to be used than the 32-bit SPARC code we had there.

2. See Mozilla bug #832272 and the old rules.mk patch from around Firefox 30 in oracle/solaris-userland. I believe they screwed up NSINSTALL on Solaris when they were trying to streamline the NSS buildsystem, because they started having unexplained issues with it around that time after Firefox 22 that they never properly resolved until Mozilla began building NSS with gyp files. I'm actually not even sure how relevant the thing they broke actually is to Solaris at this point, bug 665509 is so old it predates Firefox itself and goes back to the Mozilla suite days. I believe $(INSTALL) -t was wrong, and they meant $(NSINSTALL) -t because that makes more sense and is closer to what was there originally. It's what they have for WINNT, and it's possible a fix more like that could serve for Solaris as well. Alternatively, we could get rid of all these half-broken Makefiles and start building NSS with gyp files like Mozilla did.

3. I've completely cut out support for the Sun compiler and taken into account the reality that everyone builds Firefox (and therefore its forks) with GCC now on Solaris. This alone helped clean up a lot of the uglier parts of the code.

4. I've updated all remaining SOLARIS build flags to the newer XP_SOLARIS, because the SOLARIS flag is no longer set when building Solaris.

5. I've confirmed the workaround in gtxFontconfigFonts.cpp is no longer necessary. The Solaris people got impatient about implementing a half-baked patch for a fontconfig feature that wasn't ready yet back in 2009, and somehow convinced Mozilla to patch their software to work around it when really they should have just fixed or removed their broken fontconfig patch. The feature they wanted has since been implemented properly, and no version of Solaris still uses the broken patch that required this fix. If anyone had ever properly audited this code, it would have been removed a long time ago.
pull/24/head
athenian200 3 years ago committed by Roy Tam
parent
commit
6de8a0f12d
  1. 2
      Makefile.in
  2. 1
      accessible/tests/mochitest/common.js
  3. 2
      accessible/tests/mochitest/elm/test_nsApplicationAcc.html
  4. 6
      accessible/tests/mochitest/treeupdate/test_contextmenu.xul
  5. 4
      accessible/tests/mochitest/treeupdate/test_menu.xul
  6. 7
      application/basilisk/installer/package-manifest.in
  7. 7
      application/palemoon/installer/package-manifest.in
  8. 1
      build/gyp.mozbuild
  9. 20
      config/external/nss/Makefile.in
  10. 4
      dom/base/nsContentUtils.h
  11. 13
      dom/plugins/base/nptypes.h
  12. 16
      dom/plugins/base/nsPluginsDirUnix.cpp
  13. 2
      editor/libeditor/tests/test_htmleditor_keyevent_handling.html
  14. 2
      editor/reftests/xul/platform.js
  15. 11
      js/src/Makefile.in
  16. 5
      js/src/builtin/TestingFunctions.cpp
  17. 4
      js/src/ctypes/CTypes.cpp
  18. 13
      js/src/jsnativestack.cpp
  19. 8
      js/src/moz.build
  20. 12
      js/src/vm/Time.cpp
  21. 2
      js/xpconnect/src/XPCShellImpl.cpp
  22. 3
      layout/style/nsRuleNode.cpp
  23. 21
      memory/mozjemalloc/jemalloc.c
  24. 16
      toolkit/components/osfile/modules/osfile_unix_back.jsm
  25. 6
      toolkit/library/moz.build
  26. 4
      toolkit/mozapps/update/common/updatedefines.h
  27. 82
      toolkit/mozapps/update/updater/updater.cpp
  28. 57
      toolkit/xre/nsSigHandlers.cpp
  29. 8
      xpcom/base/nsDebugImpl.cpp
  30. 83
      xpcom/base/nsMemoryReporterManager.cpp
  31. 4
      xpcom/ds/nsMathUtils.h
  32. 17
      xpcom/io/nsLocalFileUnix.cpp
  33. 32
      xpcom/reflect/xptcall/md/unix/moz.build
  34. 52
      xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_sparc_solaris_GCC3.s
  35. 122
      xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_x86_64_unix.S
  36. 4
      xpcom/reflect/xptcall/md/unix/xptcinvoke_sparc64_openbsd.cpp
  37. 131
      xpcom/reflect/xptcall/md/unix/xptcinvoke_sparc_solaris.cpp
  38. 49
      xpcom/reflect/xptcall/md/unix/xptcstubs_asm_sparc_solaris.s
  39. 7
      xpcom/reflect/xptcall/md/unix/xptcstubs_sparc64_openbsd.cpp
  40. 112
      xpcom/reflect/xptcall/md/unix/xptcstubs_sparc_solaris.cpp
  41. 14
      xpcom/reflect/xptcall/status.html

2
Makefile.in

@ -290,7 +290,7 @@ MAKE_SYM_STORE_PATH := $(DIST)/bin
endif
DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms
endif
ifeq (,$(filter-out Linux,$(OS_ARCH)))
ifeq (,$(filter-out Linux SunOS,$(OS_ARCH)))
MAKE_SYM_STORE_ARGS := -c --vcs-info
DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms
MAKE_SYM_STORE_PATH := $(DIST)/bin

1
accessible/tests/mochitest/common.js

@ -59,6 +59,7 @@ const nsIPropertyElement = Components.interfaces.nsIPropertyElement;
const MAC = (navigator.platform.indexOf("Mac") != -1);
const LINUX = (navigator.platform.indexOf("Linux") != -1);
const SOLARIS = (navigator.platform.indexOf("SunOS") != -1);
const WIN = (navigator.platform.indexOf("Win") != -1);
////////////////////////////////////////////////////////////////////////////////

2
accessible/tests/mochitest/elm/test_nsApplicationAcc.html

@ -32,7 +32,7 @@
// nsIAccessible::name
var applicationName = "";
if (LINUX) {
if (LINUX || SOLARIS) {
applicationName = appInfo.name;
} else {
try {

6
accessible/tests/mochitest/treeupdate/test_contextmenu.xul

@ -130,7 +130,7 @@
*/
function getMenuTree1()
{
if (LINUX) {
if (LINUX || SOLARIS) {
var tree = {
role: ROLE_MENUPOPUP,
children: [
@ -190,7 +190,7 @@
function getMenuTree2()
{
var tree = getMenuTree1();
if (LINUX) {
if (LINUX || SOLARIS) {
var submenuTree =
{
name: "item2.0",
@ -232,7 +232,7 @@
children: []
};
if (LINUX)
if (LINUX || SOLARIS)
tree.children[2].children[0].children.push(subsubmenuTree);
else
tree.children[2].children[0].children[0].children[0].children.push(subsubmenuTree);

4
accessible/tests/mochitest/treeupdate/test_menu.xul

@ -32,7 +32,7 @@
this.invoke = function openMenu_invoke()
{
var tree;
if (LINUX) {
if (LINUX || SOLARIS) {
tree =
{ PARENT_MENUITEM: [ ] };
@ -51,7 +51,7 @@
this.finalCheck = function openMenu_finalCheck()
{
var tree;
if (LINUX) {
if (LINUX || SOLARIS) {
tree =
{ PARENT_MENUITEM: [
{ MENUITEM: [ ] },

7
application/basilisk/installer/package-manifest.in

@ -701,6 +701,13 @@
#ifndef MOZ_SYSTEM_NSS
#if defined(XP_LINUX) && !defined(ANDROID)
@BINPATH@/@DLL_PREFIX@freeblpriv3@DLL_SUFFIX@
#elif defined(XP_SOLARIS) && defined(SPARC64)
@BINPATH@/@DLL_PREFIX@freebl_64fpu_3@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@freebl_64int_3@DLL_SUFFIX@
#elif defined(XP_SOLARIS) && defined(SPARC)
@BINPATH@/@DLL_PREFIX@freebl_32fpu_3@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@freebl_32int64_3@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@freebl3@DLL_SUFFIX@
#else
@BINPATH@/@DLL_PREFIX@freebl3@DLL_SUFFIX@
#endif

7
application/palemoon/installer/package-manifest.in

@ -296,6 +296,13 @@
#ifndef MOZ_SYSTEM_NSS
#if defined(XP_LINUX) && !defined(ANDROID)
@BINPATH@/@DLL_PREFIX@freeblpriv3@DLL_SUFFIX@
#elif defined(XP_SOLARIS) && defined(SPARC64)
@BINPATH@/@DLL_PREFIX@freebl_64fpu_3@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@freebl_64int_3@DLL_SUFFIX@
#elif defined(XP_SOLARIS) && defined(SPARC)
@BINPATH@/@DLL_PREFIX@freebl_32fpu_3@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@freebl_32int64_3@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@freebl3@DLL_SUFFIX@
#else
@BINPATH@/@DLL_PREFIX@freebl3@DLL_SUFFIX@
#endif

1
build/gyp.mozbuild

@ -89,6 +89,7 @@ flavors = {
'Android': 'android',
'Linux': 'linux',
'Darwin': 'mac' if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa' else 'ios',
'SunOS': 'solaris',
'GNU/kFreeBSD': 'freebsd',
'DragonFly': 'dragonfly',
'FreeBSD': 'freebsd',

20
config/external/nss/Makefile.in vendored

@ -43,6 +43,21 @@ endif
# Default
HAVE_FREEBL_LIBS = 1
# SunOS SPARC
ifeq ($(OS_ARCH), SunOS)
ifneq (86,$(findstring 86,$(OS_TEST)))
ifdef HAVE_64BIT_BUILD
HAVE_FREEBL_LIBS =
HAVE_FREEBL_LIBS_64 = 1
else
HAVE_FREEBL_LIBS =
HAVE_FREEBL_LIBS_32FPU = 1
HAVE_FREEBL_LIBS_32INT64 = 1
endif
endif
endif
ifeq ($(OS_TARGET),Linux)
HAVE_FREEBL_LIBS =
HAVE_FREEBL_LIBS_PRIV = 1
@ -317,6 +332,11 @@ NSS_DIST_DLL_DEST := $(DIST)/bin
NSS_DIST_DLL_TARGET := target
INSTALL_TARGETS += NSS_DIST_DLL
ifeq ($(OS_ARCH)_$(1), SunOS_softokn3)
# has to use copy mode on Solaris, see #665509
$(DIST)/bin/$(DLL_PREFIX)softokn3$(DLL_SUFFIX): INSTALL := $(NSINSTALL) -t
endif
NSS_SDK_LIB_FILES := \
$(addprefix $(DIST)/lib/$(LIB_PREFIX),$(addsuffix .$(LIB_SUFFIX),$(SDK_LIBS))) \
$(addprefix $(DIST)/bin/$(DLL_PREFIX),$(addsuffix $(DLL_SUFFIX),$(NSS_DLLS))) \

4
dom/base/nsContentUtils.h

@ -13,6 +13,10 @@
#include <float.h>
#endif
#if defined(XP_SOLARIS)
#include <ieeefp.h>
#endif
#include "js/TypeDecls.h"
#include "js/Value.h"
#include "js/RootingAPI.h"

13
dom/plugins/base/nptypes.h

@ -22,6 +22,19 @@
typedef unsigned int uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
#elif defined(__sun)
/*
* SunOS ships an inttypes.h header that defines [u]int32_t,
* but not bool for C.
*/
#include <inttypes.h>
#ifndef __cplusplus
typedef int bool;
#define true 1
#define false 0
#endif
#elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD)
/*
* BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and

16
dom/plugins/base/nsPluginsDirUnix.cpp

@ -19,7 +19,9 @@
#include "nsIPrefService.h"
#define LOCAL_PLUGIN_DLL_SUFFIX ".so"
#if defined(LINUX)
#if defined(XP_SOLARIS)
#define DEFAULT_X11_PATH "/usr/openwin/lib"
#elif defined(LINUX)
#define DEFAULT_X11_PATH "/usr/X11R6/lib/"
#elif defined(__APPLE__)
#define DEFAULT_X11_PATH "/usr/X11R6/lib"
@ -92,7 +94,11 @@ static bool LoadExtraSharedLib(const char *name, char **soname, bool tryToGetSon
#define PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS 32
#define PREF_PLUGINS_SONAME "plugin.soname.list"
#if defined (XP_SOLARIS)
#define DEFAULT_EXTRA_LIBS_LIST "libXt" LOCAL_PLUGIN_DLL_SUFFIX ":libXext" LOCAL_PLUGIN_DLL_SUFFIX ":libXm" LOCAL_PLUGIN_DLL_SUFFIX
#else
#define DEFAULT_EXTRA_LIBS_LIST "libXt" LOCAL_PLUGIN_DLL_SUFFIX ":libXext" LOCAL_PLUGIN_DLL_SUFFIX
#endif
/*
this function looks for
user_pref("plugin.soname.list", "/usr/X11R6/lib/libXt.so.6:libXext.so");
@ -264,11 +270,15 @@ nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary)
// at runtime. Explicitly opening Xt/Xext into the global
// namespace before attempting to load the plug-in seems to
// work fine.
#if defined(XP_SOLARIS)
// Acrobat/libXm: Lazy resolving might cause crash later (bug 211587)
*outLibrary = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW);
pLibrary = *outLibrary;
#else
// Some dlopen() doesn't recover from a failed PR_LD_NOW (bug 223744)
*outLibrary = PR_LoadLibraryWithFlags(libSpec, 0);
pLibrary = *outLibrary;
#endif
if (!pLibrary) {
LoadExtraSharedLibs();
// try reload plugin once more

2
editor/libeditor/tests/test_htmleditor_keyevent_handling.html

@ -27,7 +27,7 @@ var htmlEditor = document.getElementById("htmlEditor");
const kIsMac = navigator.platform.indexOf("Mac") == 0;
const kIsWin = navigator.platform.indexOf("Win") == 0;
const kIsLinux = navigator.platform.indexOf("Linux") == 0;
const kIsLinux = navigator.platform.indexOf("Linux") == 0 || navigator.platform.indexOf("SunOS") == 0 ;
function runTests()
{

2
editor/reftests/xul/platform.js

@ -13,6 +13,8 @@ if (/Windows/.test(ua)) {
}
else if (/Linux/.test(ua))
id = "linux";
else if (/SunOS/.test(ua))
id = "linux";
else if (/Mac OS X/.test(ua))
id = "mac";

11
js/src/Makefile.in

@ -138,6 +138,17 @@ distclean::
CFLAGS += $(MOZ_ZLIB_CFLAGS)
ifeq ($(OS_ARCH),SunOS)
ifeq ($(TARGET_CPU),sparc)
ifdef GNU_CC
CFLAGS += -mcpu=v9
CXXFLAGS += -mcpu=v9
endif #GNU_CC
endif
endif
$(LIBRARY_NAME).pc: js.pc
cp $^ $@

5
js/src/builtin/TestingFunctions.cpp

@ -239,8 +239,11 @@ GetBuildConfiguration(JSContext* cx, unsigned argc, Value* vp)
value = BooleanValue(true);
if (!JS_SetProperty(cx, info, "intl-api", value))
return false;
#if defined(XP_SOLARIS)
value = BooleanValue(false);
#else
value = BooleanValue(true);
#endif
if (!JS_SetProperty(cx, info, "mapped-array-buffer", value))
return false;

4
js/src/ctypes/CTypes.cpp

@ -20,6 +20,10 @@
#include <float.h>
#endif
#if defined(XP_SOLARIS)
#include <ieeefp.h>
#endif
#ifdef HAVE_SSIZE_T
#include <sys/types.h>
#endif

13
js/src/jsnativestack.cpp

@ -67,6 +67,19 @@ js::GetNativeStackBaseImpl()
# endif
}
#elif defined(XP_SOLARIS)
#include <ucontext.h>
JS_STATIC_ASSERT(JS_STACK_GROWTH_DIRECTION < 0);
void js::GetNativeStackBaseImpl()
{
stack_t st;
stack_getbounds(&st);
return static_cast<char*>(st.ss_sp) + st.ss_size;
}
#elif defined(XP_LINUX) && !defined(ANDROID) && defined(__GLIBC__)
void*
js::GetNativeStackBaseImpl()

8
js/src/moz.build

@ -720,6 +720,14 @@ if CONFIG['OS_ARCH'] == 'Linux':
'dl',
]
if CONFIG['OS_ARCH'] == 'SunOS':
OS_LIBS += [
'posix4',
'dl',
'nsl',
'socket',
]
OS_LIBS += CONFIG['REALTIME_LIBS']
CFLAGS += CONFIG['MOZ_ICU_CFLAGS']

12
js/src/vm/Time.cpp

@ -11,6 +11,10 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/MathAlgorithms.h"
#ifdef XP_SOLARIS
#define _REENTRANT 1
#endif
#include <string.h>
#include <time.h>
@ -30,6 +34,10 @@
#ifdef XP_UNIX
#ifdef _SVID_GETTOD /* Defined only on Solaris, see Solaris <sys/types.h> */
extern int gettimeofday(struct timeval* tv);
#endif
#include <sys/time.h>
#endif /* XP_UNIX */
@ -42,7 +50,11 @@ PRMJ_Now()
{
struct timeval tv;
#ifdef _SVID_GETTOD /* Defined only on Solaris, see Solaris <sys/types.h> */
gettimeofday(&tv);
#else
gettimeofday(&tv, 0);
#endif /* _SVID_GETTOD */
return int64_t(tv.tv_sec) * PRMJ_USEC_PER_SEC + int64_t(tv.tv_usec);
}

2
js/xpconnect/src/XPCShellImpl.cpp

@ -644,6 +644,7 @@ env_setProperty(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue
ObjectOpResult& result)
{
/* XXX porting may be easy, but these don't seem to supply setenv by default */
#if !defined XP_SOLARIS
RootedString valstr(cx);
RootedString idstr(cx);
int rv;
@ -686,6 +687,7 @@ env_setProperty(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue
return false;
}
vp.setString(valstr);
#endif /* !defined XP_SOLARIS */
return result.succeed();
}

3
layout/style/nsRuleNode.cpp

@ -67,6 +67,9 @@
#define alloca _alloca
#endif
#endif
#ifdef XP_SOLARIS
#include <alloca.h>
#endif
using std::max;
using std::min;

21
memory/mozjemalloc/jemalloc.c

@ -283,7 +283,9 @@ typedef long ssize_t;
#define JEMALLOC_RECYCLE
#ifndef MOZ_MEMORY_WINDOWS
#ifndef MOZ_MEMORY_SOLARIS
#include <sys/cdefs.h>
#endif
#ifndef __DECONST
# define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
#endif
@ -309,7 +311,7 @@ __FBSDID("$FreeBSD: head/lib/libc/stdlib/malloc.c 180599 2008-07-18 19:35:44Z ja
#endif
#include <sys/time.h>
#include <sys/types.h>
#if !defined(MOZ_MEMORY_ANDROID)
#if !defined(MOZ_MEMORY_SOLARIS) && !defined(MOZ_MEMORY_ANDROID)
#include <sys/sysctl.h>
#endif
#include <sys/uio.h>
@ -411,6 +413,10 @@ void *_mmap(void *addr, size_t length, int prot, int flags,
#endif
#endif
#if defined(MOZ_MEMORY_SOLARIS && defined(MAP_ALIGN) && !defined(JEMALLOC_NEVER_USES_MAP_ALIGN)
#define JEMALLOC_USES_MAP_ALIGN /* Required on Solaris 10. Might improve performance elsewhere. */
#endif
#ifndef __DECONST
#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
#endif
@ -5125,6 +5131,13 @@ malloc_ncpus(void)
else
return (n);
}
#elif (defined(MOZ_MEMORY_SOLARIS))
static inline unsigned
malloc_ncpus(void)
{
return sysconf(_SC_NPROCESSORS_ONLN);
}
#elif (defined(MOZ_MEMORY_WINDOWS))
static inline unsigned
malloc_ncpus(void)
@ -5921,9 +5934,15 @@ RETURN:
#define MOZ_MEMORY_ELF
#endif
#ifdef MOZ_MEMORY_SOLARIS
# if (defined(__GNUC__))
__attribute__((noinline))
# endif
#else
#if (defined(MOZ_MEMORY_ELF))
__attribute__((visibility ("hidden")))
#endif
#endif
#endif /* MOZ_REPLACE_MALLOC */
#ifdef MOZ_MEMORY_ELF

16
toolkit/components/osfile/modules/osfile_unix_back.jsm

@ -585,10 +585,18 @@
} else if (Const._STAT_VER != undefined) {
const ver = Const._STAT_VER;
let xstat_name, lxstat_name, fxstat_name;
// Linux, all widths
xstat_name = "__xstat";
lxstat_name = "__lxstat";
fxstat_name = "__fxstat";
if (OS.Constants.Sys.Name == "SunOS") {
// Solaris
xstat_name = "_xstat";
lxstat_name = "_lxstat";
fxstat_name = "_fxstat";
} else {
// Linux, all widths
xstat_name = "__xstat";
lxstat_name = "__lxstat";
fxstat_name = "__fxstat";
}
let Stat = {};
libc.declareLazyFFI(Stat, "xstat",

6
toolkit/library/moz.build

@ -270,6 +270,12 @@ if CONFIG['MOZ_ENABLE_STARTUP_NOTIFICATION']:
if CONFIG['MOZ_ENABLE_LIBPROXY']:
OS_LIBS += CONFIG['MOZ_LIBPROXY_LIBS']
if CONFIG['OS_ARCH'] == 'SunOS':
OS_LIBS += [
'elf',
'demangle',
]
if CONFIG['OS_ARCH'] == 'FreeBSD':
OS_LIBS += [
'util',

4
toolkit/mozapps/update/common/updatedefines.h

@ -96,7 +96,11 @@ static inline int mywcsprintf(WCHAR* dest, size_t count, const WCHAR* fmt, ...)
# include <sys/wait.h>
# include <unistd.h>
#ifdef XP_SOLARIS
# include <sys/stat.h>
#else
# include <fts.h>
#endif
# include <dirent.h>
#ifdef XP_MACOSX

82
toolkit/mozapps/update/updater/updater.cpp

@ -3648,6 +3648,88 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
return rv;
}
#elif defined(XP_SOLARIS)
int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
{
int rv = OK;
NS_tchar foundpath[MAXPATHLEN];
struct {
dirent dent_buffer;
char chars[MAXNAMLEN];
} ent_buf;
struct dirent* ent;
mozilla::UniquePtr<NS_tchar[]> searchpath(get_full_path(dirpath));
DIR* dir = opendir(searchpath.get());
if (!dir) {
LOG(("add_dir_entries error on opendir: " LOG_S ", err: %d", searchpath.get(),
errno));
return UNEXPECTED_FILE_OPERATION_ERROR;
}
while (readdir_r(dir, (dirent *)&ent_buf, &ent) == 0 && ent) {
if ((strcmp(ent->d_name, ".") == 0) ||
(strcmp(ent->d_name, "..") == 0))
continue;
NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]),
NS_T("%s%s"), searchpath.get(), ent->d_name);
struct stat64 st_buf;
int test = stat64(foundpath, &st_buf);
if (test) {
closedir(dir);
return UNEXPECTED_FILE_OPERATION_ERROR;
}
if (S_ISDIR(st_buf.st_mode)) {
NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]),
NS_T("%s/"), foundpath);
// Recurse into the directory.
rv = add_dir_entries(foundpath, list);
if (rv) {
LOG(("add_dir_entries error: " LOG_S ", err: %d", foundpath, rv));
closedir(dir);
return rv;
}
} else {
// Add the file to be removed to the ActionList.
NS_tchar *quotedpath = get_quoted_path(get_relative_path(foundpath));
if (!quotedpath) {
closedir(dir);
return PARSE_ERROR;
}
Action *action = new RemoveFile();
rv = action->Parse(quotedpath);
if (rv) {
LOG(("add_dir_entries Parse error on recurse: " LOG_S ", err: %d",
quotedpath, rv));
closedir(dir);
return rv;
}
list->Append(action);
}
}
closedir(dir);
// Add the directory to be removed to the ActionList.
NS_tchar *quotedpath = get_quoted_path(get_relative_path(dirpath));
if (!quotedpath)
return PARSE_ERROR;
Action *action = new RemoveDir();
rv = action->Parse(quotedpath);
if (rv) {
LOG(("add_dir_entries Parse error on close: " LOG_S ", err: %d",
quotedpath, rv));
}
else {
list->Append(action);
}
return rv;
}
#else
int add_dir_entries(const NS_tchar *dirpath, ActionList *list)

57
toolkit/xre/nsSigHandlers.cpp

@ -32,6 +32,11 @@
#endif
#endif
#if defined(XP_SOLARIS)
#include <sys/resource.h>
#include <ucontext.h>
#endif
static const char* gProgname = "huh?";
// Note: some tests manipulate this value.
@ -193,6 +198,33 @@ static void fpehandler(int signum, siginfo_t *si, void *context)
*mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
#endif
#endif
#ifdef XP_SOLARIS
ucontext_t *uc = (ucontext_t *)context;
#if defined(__i386)
uint32_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[0];
*cw |= FPU_EXCEPTION_MASK;
uint32_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[1];
*sw &= ~FPU_STATUS_FLAGS;
/* address of the instruction that caused the exception */
uint32_t *ip = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.state[3];
uc->uc_mcontext.gregs[REG_PC] = *ip;
#endif
#if defined(__amd64__)
uint16_t *cw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.cw;
*cw |= FPU_EXCEPTION_MASK;
uint16_t *sw = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.sw;
*sw &= ~FPU_STATUS_FLAGS;
uint32_t *mxcsr = &uc->uc_mcontext.fpregs.fp_reg_set.fpchip_state.mxcsr;
*mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
*mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
#endif
#endif
}
}
#endif
@ -255,6 +287,31 @@ void InstallSignalHandlers(const char *aProgname)
}
#endif
#if defined(XP_SOLARIS)
#define NOFILES 512
// Boost Solaris file descriptors
{
struct rlimit rl;
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
if (rl.rlim_cur < NOFILES) {
rl.rlim_cur = NOFILES;
if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
perror("setrlimit(RLIMIT_NOFILE)");
fprintf(stderr, "Cannot exceed hard limit for open files");
}
#if defined(DEBUG)
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
printf("File descriptors set to %d\n", rl.rlim_cur);
#endif //DEBUG
}
}
#endif //XP_SOLARIS
#if defined(MOZ_WIDGET_GTK) && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
const char *assertString = PR_GetEnv("XPCOM_DEBUG_BREAK");
if (assertString &&

8
xpcom/base/nsDebugImpl.cpp

@ -450,6 +450,12 @@ RealBreak()
".object_arch armv4t\n"
#endif
"BKPT #0");
#elif defined(__sun)
#if defined (__i386__) || defined(__i386) || defined(__x86_64__)
asm("int $3");
#else
raise(SIGTRAP);
#endif
#else
#warning do not know how to break on this platform
#endif
@ -524,6 +530,8 @@ Break(const char* aMsg)
RealBreak();
#elif defined(__arm__)
RealBreak();
#elif defined(__sun)
RealBreak();
#else
#warning do not know how to break on this platform
#endif

83
xpcom/base/nsMemoryReporterManager.cpp

@ -317,6 +317,85 @@ VsizeMaxContiguousDistinguishedAmount(int64_t* aN)
}
#endif // FreeBSD
#elif defined(XP_SOLARIS)
#include <procfs.h>
#include <fcntl.h>
#include <unistd.h>
static void
XMappingIter(int64_t& aVsize, int64_t& aResident)
{
aVsize = -1;
aResident = -1;
int mapfd = open("/proc/self/xmap", O_RDONLY);
struct stat st;
prxmap_t* prmapp = nullptr;
if (mapfd >= 0) {
if (!fstat(mapfd, &st)) {
int nmap = st.st_size / sizeof(prxmap_t);
while (1) {
// stat(2) on /proc/<pid>/xmap returns an incorrect value,
// prior to the release of Solaris 11.
// Here is a workaround for it.
nmap *= 2;
prmapp = (prxmap_t*)malloc((nmap + 1) * sizeof(prxmap_t));
if (!prmapp) {
// out of memory
break;
}
int n = pread(mapfd, prmapp, (nmap + 1) * sizeof(prxmap_t), 0);
if (n < 0) {
break;
}
if (nmap >= n / sizeof(prxmap_t)) {
aVsize = 0;
aResident = 0;
for (int i = 0; i < n / sizeof(prxmap_t); i++) {
aVsize += prmapp[i].pr_size;
aResident += prmapp[i].pr_rss * prmapp[i].pr_pagesize;
}
break;
}
free(prmapp);
}
free(prmapp);
}
close(mapfd);
}
}
#define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1
static MOZ_MUST_USE nsresult
VsizeDistinguishedAmount(int64_t* aN)
{
int64_t vsize, resident;
XMappingIter(vsize, resident);
if (vsize == -1) {
return NS_ERROR_FAILURE;
}
*aN = vsize;
return NS_OK;
}
static MOZ_MUST_USE nsresult
ResidentDistinguishedAmount(int64_t* aN)
{
int64_t vsize, resident;
XMappingIter(vsize, resident);
if (resident == -1) {
return NS_ERROR_FAILURE;
}
*aN = resident;
return NS_OK;
}
static MOZ_MUST_USE nsresult
ResidentFastDistinguishedAmount(int64_t* aN)
{
return ResidentDistinguishedAmount(aN);
}
#elif defined(XP_MACOSX)
#include <mach/mach_init.h>
@ -1066,9 +1145,13 @@ ResidentPeakDistinguishedAmount(int64_t* aN)
if (0 == getrusage(RUSAGE_SELF, &usage)) {
// The units for ru_maxrrs:
// - Mac: bytes
// - Solaris: pages? But some sources it actually always returns 0, so
// check for that
// - Linux, {Net/Open/Free}BSD, DragonFly: KiB
#ifdef XP_MACOSX
*aN = usage.ru_maxrss;
#elif defined(XP_SOLARIS)
*aN = usage.ru.maxrss * getpagesize();
#else
*aN = usage.ru_maxrss * 1024;
#endif

4
xpcom/ds/nsMathUtils.h

@ -11,6 +11,10 @@
#include <cmath>
#include <float.h>
#ifdef XP_SOLARIS
#include <ieeefp.h>
#endif
/*
* round
*/

17
xpcom/io/nsLocalFileUnix.cpp

@ -1591,6 +1591,23 @@ nsLocalFile::IsExecutable(bool* aResult)
// Then check the execute bit.
*aResult = (access(mPath.get(), X_OK) == 0);
#ifdef XP_SOLARIS
// On Solaris, access will always return 0 for root user, however
// the file is only executable if S_IXUSR | S_IXGRP | S_IXOTH is set.
// See bug 351950, https://bugzilla.mozilla.org/show_bug.cgi?id=351950
if (*aResult) {
struct STAT buf;
*aResult = (STAT(mPath.get(), &buf) == 0);
if (*aResult || errno == EACCES) {
*aResult = *aResult && (buf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH));
return NS_OK;
}
return NSRESULT_FOR_ERRNO();
}
#endif
if (*aResult || errno == EACCES) {
if (*aResult || errno == EACCES) {
return NS_OK;
}

32
xpcom/reflect/xptcall/md/unix/moz.build

@ -46,6 +46,21 @@ if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD'):
'xptcstubs_ipf64.cpp'
]
# Without the need to accomodate the Sun compiler, Solaris/GCC support is pretty
# standard, actually. Not all that different from Linux.
if CONFIG['OS_ARCH'] == 'SunOS':
if CONFIG['OS_TEST'] == 'x86_64':
SOURCES += [
'xptcinvoke_asm_x86_64_unix.S',
'xptcinvoke_x86_64_unix.cpp',
'xptcstubs_x86_64_linux.cpp'
]
elif CONFIG['OS_TEST'] == 'x86':
SOURCES += [
'xptcinvoke_gcc_x86_unix.cpp',
'xptcstubs_gcc_x86_unix.cpp'
]
if CONFIG['OS_TEST'] == 'alpha':
if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD', 'NetBSD'):
@ -186,7 +201,11 @@ if CONFIG['OS_ARCH'] == 'OpenBSD' and CONFIG['OS_TEST'] == 'sparc':
'xptcstubs_sparc_openbsd.cpp',
]
if CONFIG['OS_ARCH'] in ('OpenBSD', 'FreeBSD') and CONFIG['OS_TEST'] == 'sparc64':
# Mozilla discovered at some point that Solaris and Linux can also use these
# files for 64-bit SPARC with no ill effects, so basically the entire mess that
# was there before is no longer needed.
if CONFIG['OS_ARCH'] in ('OpenBSD', 'FreeBSD', 'SunOS') and CONFIG['OS_TEST'] == 'sparc64':
SOURCES += [
'xptcinvoke_asm_sparc64_openbsd.s',
'xptcinvoke_sparc64_openbsd.cpp',
@ -194,6 +213,17 @@ if CONFIG['OS_ARCH'] in ('OpenBSD', 'FreeBSD') and CONFIG['OS_TEST'] == 'sparc64
'xptcstubs_sparc64_openbsd.cpp',
]
# As for the 32-bit SPARC build? That would look like the Linux version with
# one file changed.
if CONFIG['OS_ARCH'] == 'SunOS' and CONFIG['OS_TEST'] == 'sparc':
SOURCES += [
'xptcinvoke_asm_sparc_solaris_GCC3.s',
'xptcinvoke_sparc_solaris.cpp',
'xptcstubs_asm_sparc_solaris.s',
'xptcstubs_sparc_solaris.cpp',
]
if CONFIG['OS_ARCH'] == 'Linux':
if CONFIG['OS_TEST'] == 's390':
SOURCES += [

52
xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_sparc_solaris_GCC3.s

@ -0,0 +1,52 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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/. */
/*
* Platform specific code to invoke XPCOM methods on native objects for
* solaris/sparc with gcc 3 ABI.
*/
.global NS_InvokeByIndex
/*
* NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
* uint32_t paramCount, nsXPTCVariant* params);
*/
NS_InvokeByIndex:
save %sp,-(64 + 32),%sp ! room for the register window and
! struct pointer, rounded up to 0 % 32
mov %i2,%o0 ! paramCount
call invoke_count_words ! returns the required stack size in %o0
mov %i3,%o1 ! params
sll %o0,2,%l0 ! number of bytes
sub %sp,%l0,%sp ! create the additional stack space
mov %sp,%o0 ! pointer for copied args
add %o0,72,%o0 ! step past the register window, the
! struct result pointer and the 'this' slot
mov %i2,%o1 ! paramCount
call invoke_copy_to_stack
mov %i3,%o2 ! params
!
! calculate the target address from the vtable
!
ld [%i0],%l1 ! *that --> vTable
sll %i1,2,%i1 ! multiply index by 4
add %i1,%l1,%l1 ! l1 now points to vTable entry
ld [%l1],%l0 ! target address
.L5: ld [%sp + 88],%o5
.L4: ld [%sp + 84],%o4
.L3: ld [%sp + 80],%o3
.L2: ld [%sp + 76],%o2
.L1: ld [%sp + 72],%o1
.L0:
jmpl %l0,%o7 ! call the routine
! always have a 'this', from the incoming 'that'
mov %i0,%o0
mov %o0,%i0 ! propagate return value
ret
restore

122
xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_x86_64_unix.S

@ -0,0 +1,122 @@
# 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/.
# Darwin gives a leading '_' to symbols defined in C code.
#ifdef XP_DARWIN
#define SYM(x) _ ## x
#define CFI_STARTPROC
#define CFI_ENDPROC
#define CFI_DEF_CFA_OFFSET(offset)
#define CFI_OFFSET(reg, offset)
#define CFI_DEF_CFA_REGISTER(reg)
#define CFI_DEF_CFA(reg, offset)
#else
#define SYM(x) x
#define CFI_STARTPROC .cfi_startproc
#define CFI_ENDPROC .cfi_endproc
#define CFI_DEF_CFA_OFFSET(offset) .cfi_def_cfa_offset offset
#define CFI_OFFSET(reg, offset) .cfi_offset reg, offset
#define CFI_DEF_CFA_REGISTER(reg) .cfi_def_cfa_register reg
#define CFI_DEF_CFA(reg, offset) .cfi_def_cfa reg, offset
#endif
.intel_syntax noprefix
# nsresult NS_InvokeByIndex(nsISupports* this, uint32_t aVtableIndex,
# uint32_t argc, nsXPTCVariant* argv);
.text
.global SYM(NS_InvokeByIndex)
#ifndef XP_DARWIN
.type NS_InvokeByIndex, @function
#endif
.align 4
SYM(NS_InvokeByIndex):
CFI_STARTPROC
push rbp
CFI_DEF_CFA_OFFSET(16)
CFI_OFFSET(6, -16)
mov rbp, rsp
CFI_DEF_CFA_REGISTER(6)
# save r12 and r13 because we use them and they are callee saved.
push r12
push r13
CFI_OFFSET(12, -24)
CFI_OFFSET(13, -32)
# save this and the vtable index because we need them after setting up the
# stack.
mov r12, rdi
mov r13, rsi
# allocate space for stack arguments, in theory we only need 8 * (argc - 5)
# bytes because at least 5 arguments will go in registers, but for now it is
# just simpler to allocate 8 * argc bytes. Note that we treat the this
# pointer specially.
lea eax, [edx * 8]
sub rsp, rax
# If there is an odd number of args the stack can be misaligned so realign it.
and rsp, 0xfffffffffffffff0
# pass the stack slot area to InvokeCopyToStack.
mov r8, rsp
# setup space for the register slots: there are 5 integer ones and 8 floating
# point ones. So we need 104 bytes of space, but we allocate 112 to keep rsp
# aligned to 16 bytes.
sub rsp, 112
# the first argument to InvokeCopyToStack is the integer register area, and the
# second is the floating point area.
mov rdi, rsp
lea rsi, [rsp + 40]
# The 3rd and 4th arguments to InvokeCopyToStack are already in the right
# registers. So now we can just call InvokeCopyToStack.
call SYM(InvokeCopyToStack)
# setup this
mov rdi, r12
# copy the integer arguments into place.
mov rsi, [rsp]
mov rdx, [rsp + 8]
mov rcx, [rsp + 16]
mov r8, [rsp + 24]
mov r9, [rsp + 32]
# copy the float arguments into place
movsd xmm0, [rsp + 40]
movsd xmm1, [rsp + 48]
movsd xmm2, [rsp + 56]
movsd xmm3, [rsp + 64]
movsd xmm4, [rsp + 72]
movsd xmm5, [rsp + 80]
movsd xmm6, [rsp + 88]
movsd xmm7, [rsp + 96]
# get rid of the scratch space for registers
add rsp, 112
# load the function pointer and call
lea eax, [r13d * 8]
add rax, [rdi]
call [rax]
# r12 and r13 were pushed relative to the old stack pointer which is now the
# frame pointer.
mov r12, [rbp - 0x8]
mov r13, [rbp - 0x10]
mov rsp, rbp
pop rbp
CFI_DEF_CFA(7, 8)
ret
CFI_ENDPROC
#ifndef XP_DARWIN
// Magic indicating no need for an executable stack
.section .note.GNU-stack, "", @progbits ; .previous
#endif

4
xpcom/reflect/xptcall/md/unix/xptcinvoke_sparc64_openbsd.cpp

@ -30,9 +30,9 @@ invoke_copy_to_stack(uint64_t* d, uint32_t paramCount, nsXPTCVariant* s)
{
if (regCount < 5) regCount++;
if (l_s->IsPtrData())
if (l_s->IsIndirect())
{
*l_d = (uint64_t)l_s->ptr;
*l_d = (uint64_t) &l_s->val;
continue;
}
switch (l_s->type)

131
xpcom/reflect/xptcall/md/unix/xptcinvoke_sparc_solaris.cpp

@ -0,0 +1,131 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */
/* Platform specific code to invoke XPCOM methods on native objects */
#include "xptcprivate.h"
/* solaris defines __sparc for workshop compilers and
linux defines __sparc__ */
#if !defined(__sparc) && !defined(__sparc__)
#error "This code is for Sparc only"
#endif
typedef unsigned nsXPCVariant;
extern "C" uint32_t
invoke_count_words(uint32_t paramCount, nsXPTCVariant* s)
{
uint32_t result = 0;
for(uint32_t i = 0; i < paramCount; i++, s++)
{
if(s->IsPtrData())
{
result++;
continue;
}
switch(s->type)
{
case nsXPTType::T_I8 :
case nsXPTType::T_I16 :
case nsXPTType::T_I32 :
result++;
break;
case nsXPTType::T_I64 :
result+=2;
break;
case nsXPTType::T_U8 :
case nsXPTType::T_U16 :
case nsXPTType::T_U32 :
result++;
break;
case nsXPTType::T_U64 :
result+=2;
break;
case nsXPTType::T_FLOAT :
result++;
break;
case nsXPTType::T_DOUBLE :
result+=2;
break;
case nsXPTType::T_BOOL :
case nsXPTType::T_CHAR :
case nsXPTType::T_WCHAR :
result++;
break;
default:
// all the others are plain pointer types
result++;
break;
}
}
// nuts, I know there's a cooler way of doing this, but it's late
// now and it'll probably come to me in the morning.
if (result & 0x3) result += 4 - (result & 0x3); // ensure q-word alignment
return result;
}
extern "C" uint32_t
invoke_copy_to_stack(uint32_t* d, uint32_t paramCount, nsXPTCVariant* s)
{
/*
We need to copy the parameters for this function to locals and use them
from there since the parameters occupy the same stack space as the stack
we're trying to populate.
*/
uint32_t *l_d = d;
nsXPTCVariant *l_s = s;
uint32_t l_paramCount = paramCount;
uint32_t regCount = 0; // return the number of registers to load from the stack
typedef struct {
uint32_t hi;
uint32_t lo;
} DU; // have to move 64 bit entities as 32 bit halves since