Land patch to add Solaris platform support.
authorager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 25 Jan 2010 12:37:31 +0000 (12:37 +0000)
committerager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 25 Jan 2010 12:37:31 +0000 (12:37 +0000)
Patch by Erich Ocean and Ryan Dahl.

Review URL: http://codereview.chromium.org/545125

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3688 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

12 files changed:
AUTHORS
SConstruct
src/SConscript
src/dtoa-config.c
src/platform-freebsd.cc
src/platform-linux.cc
src/platform-macos.cc
src/platform-openbsd.cc
src/platform-posix.cc
src/platform.h
test/cctest/test-compiler.cc
tools/utils.py

diff --git a/AUTHORS b/AUTHORS
index af0ecded71450ee2a2d0655b520d025a2e09f964..5d712fc271e08f9dc5a5c530b862bc354b0ae33a 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,6 +10,7 @@ Alexandre Vassalotti <avassalotti@gmail.com>
 Craig Schlenter <craig.schlenter@gmail.com>
 Daniel Andersson <kodandersson@gmail.com>
 Daniel James <dnljms@gmail.com>
+Erich Ocean <erich.ocean@me.com>
 Jan de Mooij <jandemooij@gmail.com>
 Jay Freeman <saurik@saurik.com>
 Joel Stanley <joel.stan@gmail.com>
index 739e3445caa9f3bd7a1864ea1f7f6f05b167a64a..2967d92e0e88d6e183cc71960780a0d48ef0b93a 100644 (file)
@@ -35,7 +35,6 @@ root_dir = dirname(File('SConstruct').rfile().abspath)
 sys.path.append(join(root_dir, 'tools'))
 import js2c, utils
 
-
 # ANDROID_TOP is the top of the Android checkout, fetched from the environment
 # variable 'TOP'.   You will also need to set the CXX, CC, AR and RANLIB
 # environment variables to the cross-compiling tools.
@@ -157,6 +156,11 @@ LIBRARY_FLAGS = {
       'LIBPATH' : ['/usr/local/lib'],
       'CCFLAGS':      ['-ansi'],
     },
+    'os:solaris': {
+      'CPPPATH' : ['/usr/local/include'],
+      'LIBPATH' : ['/usr/local/lib'],
+      'CCFLAGS':      ['-ansi'],
+    },
     'os:win32': {
       'CCFLAGS':      ['-DWIN32'],
       'CXXFLAGS':     ['-DWIN32'],
@@ -313,6 +317,10 @@ MKSNAPSHOT_EXTRA_FLAGS = {
     'os:freebsd': {
       'LIBS': ['execinfo', 'pthread']
     },
+    'os:solaris': {
+      'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
+      'LINKFLAGS': ['-mt']
+    },
     'os:openbsd': {
       'LIBS': ['execinfo', 'pthread']
     },
@@ -362,6 +370,10 @@ CCTEST_EXTRA_FLAGS = {
     'os:freebsd': {
       'LIBS':         ['execinfo', 'pthread']
     },
+    'os:solaris': {
+      'LIBS':         ['m', 'pthread', 'socket', 'nsl', 'rt'],
+      'LINKFLAGS':    ['-mt']
+    },
     'os:openbsd': {
       'LIBS':         ['execinfo', 'pthread']
     },
@@ -420,6 +432,11 @@ SAMPLE_FLAGS = {
       'LIBPATH' : ['/usr/local/lib'],
       'LIBS':     ['execinfo', 'pthread']
     },
+    'os:solaris': {
+      'LIBPATH' : ['/usr/local/lib'],
+      'LIBS':     ['m', 'pthread', 'socket', 'nsl', 'rt'],
+      'LINKFLAGS': ['-mt']
+    },
     'os:openbsd': {
       'LIBPATH' : ['/usr/local/lib'],
       'LIBS':     ['execinfo', 'pthread']
@@ -529,6 +546,10 @@ D8_FLAGS = {
     'os:freebsd': {
       'LIBS': ['pthread'],
     },
+    'os:solaris': {
+      'LIBS': ['m', 'pthread', 'socket', 'nsl', 'rt'],
+      'LINKFLAGS': ['-mt']
+    },
     'os:openbsd': {
       'LIBS': ['pthread'],
     },
@@ -582,7 +603,7 @@ SIMPLE_OPTIONS = {
     'help': 'the toolchain to use (' + TOOLCHAIN_GUESS + ')'
   },
   'os': {
-    'values': ['freebsd', 'linux', 'macos', 'win32', 'android', 'openbsd'],
+    'values': ['freebsd', 'linux', 'macos', 'win32', 'android', 'openbsd', 'solaris'],
     'default': OS_GUESS,
     'help': 'the os to build for (' + OS_GUESS + ')'
   },
@@ -936,6 +957,7 @@ def BuildSpecific(env, mode, env_overrides):
 
   # Link the object files into a library.
   env.Replace(**context.flags['v8'])
+
   context.ApplyEnvOverrides(env)
   if context.options['library'] == 'static':
     library = env.StaticLibrary(library_name, object_files)
index 3000b421fd81ab4c8e41a8679df200ba7d4703e5..7950ab33aafecf36d2917819cbacee378664007e 100755 (executable)
@@ -168,6 +168,7 @@ SOURCES = {
   'os:linux':   ['platform-linux.cc', 'platform-posix.cc'],
   'os:android': ['platform-linux.cc', 'platform-posix.cc'],
   'os:macos':   ['platform-macos.cc', 'platform-posix.cc'],
+  'os:solaris': ['platform-solaris.cc', 'platform-posix.cc'],
   'os:nullos':  ['platform-nullos.cc'],
   'os:win32':   ['platform-win32.cc'],
   'mode:release': [],
@@ -196,6 +197,9 @@ D8_FILES = {
   'os:openbsd': [
     'd8-posix.cc'
   ],
+  'os:solaris': [
+    'd8-posix.cc'
+  ],
   'os:win32': [
     'd8-windows.cc'
   ],
index a1acd2dd440ab645bbde4418cca91119c697983a..9c5ee331943a5001a2172356cb3e818accdfd811 100644 (file)
@@ -38,7 +38,8 @@
  */
 
 #if !(defined(__APPLE__) && defined(__MACH__)) && \
-    !defined(WIN32) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
+    !defined(WIN32) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && \
+    !defined(__sun)
 #include <endian.h>
 #endif
 #include <math.h>
@@ -47,7 +48,7 @@
 /* The floating point word order on ARM is big endian when floating point
  * emulation is used, even if the byte order is little endian */
 #if !(defined(__APPLE__) && defined(__MACH__)) && !defined(WIN32) && \
-    !defined(__FreeBSD__) && !defined(__OpenBSD__) && \
+    !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__sun) && \
     __FLOAT_WORD_ORDER == __BIG_ENDIAN
 #define  IEEE_MC68k
 #else
@@ -56,7 +57,7 @@
 
 #define __MATH_H__
 #if defined(__APPLE__) && defined(__MACH__) || defined(__FreeBSD__) || \
-    defined(__OpenBSD__)
+    defined(__OpenBSD__) || defined(__sun)
 /* stdlib.h on FreeBSD and Apple's 10.5 and later SDKs will mangle the
  * name of strtod.  If it's included after strtod is redefined as
  * gay_strtod, it will mangle the name of gay_strtod, which is
index 7141483901fad69d7601fd9001c1ad74a196630c..ff75776856466c5ec47fabb6b550c718d0b3eba8 100644 (file)
@@ -95,6 +95,24 @@ int OS::ActivationFrameAlignment() {
 }
 
 
+const char* OS::LocalTimezone(double time) {
+  if (isnan(time)) return "";
+  time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+  struct tm* t = localtime(&tv);
+  if (NULL == t) return "";
+  return t->tm_zone;
+}
+
+
+double OS::LocalTimeOffset() {
+  time_t tv = time(NULL);
+  struct tm* t = localtime(&tv);
+  // tm_gmtoff includes any daylight savings offset, so subtract it.
+  return static_cast<double>(t->tm_gmtoff * msPerSecond -
+                             (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
+}
+
+
 // We keep the lowest and highest addresses mapped as a quick way of
 // determining that pointers are outside the heap (used mostly in assertions
 // and verification).  The estimate is conservative, ie, not all addresses in
index 93f23f33cc7d47d6e9b50bf6ae4ea9f45624c9c6..005b1deb6b88ebdd884ecff54bdbad5f9cfd4435 100644 (file)
@@ -159,6 +159,24 @@ int OS::ActivationFrameAlignment() {
 }
 
 
+const char* OS::LocalTimezone(double time) {
+  if (isnan(time)) return "";
+  time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+  struct tm* t = localtime(&tv);
+  if (NULL == t) return "";
+  return t->tm_zone;
+}
+
+
+double OS::LocalTimeOffset() {
+  time_t tv = time(NULL);
+  struct tm* t = localtime(&tv);
+  // tm_gmtoff includes any daylight savings offset, so subtract it.
+  return static_cast<double>(t->tm_gmtoff * msPerSecond -
+                             (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
+}
+
+
 // We keep the lowest and highest addresses mapped as a quick way of
 // determining that pointers are outside the heap (used mostly in assertions
 // and verification).  The estimate is conservative, ie, not all addresses in
index aeb69b2a6e748927f2c1e264a8c752d269d87e48..e379ae22671b52846cacaed7dc412b8a5da060f0 100644 (file)
@@ -259,6 +259,24 @@ int OS::ActivationFrameAlignment() {
 }
 
 
+const char* OS::LocalTimezone(double time) {
+  if (isnan(time)) return "";
+  time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+  struct tm* t = localtime(&tv);
+  if (NULL == t) return "";
+  return t->tm_zone;
+}
+
+
+double OS::LocalTimeOffset() {
+  time_t tv = time(NULL);
+  struct tm* t = localtime(&tv);
+  // tm_gmtoff includes any daylight savings offset, so subtract it.
+  return static_cast<double>(t->tm_gmtoff * msPerSecond -
+                             (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
+}
+
+
 int OS::StackWalk(Vector<StackFrame> frames) {
   // If weak link to execinfo lib has failed, ie because we are on 10.4, abort.
   if (backtrace == NULL)
index 6d273047dae763b3dab8a7ce4101f2d27b8b6ce9..62e60044112299d1f8f6c2204767d179d51270af 100644 (file)
@@ -94,6 +94,24 @@ int OS::ActivationFrameAlignment() {
 }
 
 
+const char* OS::LocalTimezone(double time) {
+  if (isnan(time)) return "";
+  time_t tv = static_cast<time_t>(floor(time/msPerSecond));
+  struct tm* t = localtime(&tv);
+  if (NULL == t) return "";
+  return t->tm_zone;
+}
+
+
+double OS::LocalTimeOffset() {
+  time_t tv = time(NULL);
+  struct tm* t = localtime(&tv);
+  // tm_gmtoff includes any daylight savings offset, so subtract it.
+  return static_cast<double>(t->tm_gmtoff * msPerSecond -
+                             (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
+}
+
+
 // We keep the lowest and highest addresses mapped as a quick way of
 // determining that pointers are outside the heap (used mostly in assertions
 // and verification).  The estimate is conservative, ie, not all addresses in
index 41e0e64f3b017eecd694303d983db9a19f691db1..89f4d983df0a0388f47937c1f607d0de2866d40d 100644 (file)
@@ -99,15 +99,6 @@ int64_t OS::Ticks() {
 }
 
 
-const char* OS::LocalTimezone(double time) {
-  if (isnan(time)) return "";
-  time_t tv = static_cast<time_t>(floor(time/msPerSecond));
-  struct tm* t = localtime(&tv);
-  if (NULL == t) return "";
-  return t->tm_zone;
-}
-
-
 double OS::DaylightSavingsOffset(double time) {
   if (isnan(time)) return nan_value();
   time_t tv = static_cast<time_t>(floor(time/msPerSecond));
@@ -117,15 +108,6 @@ double OS::DaylightSavingsOffset(double time) {
 }
 
 
-double OS::LocalTimeOffset() {
-  time_t tv = time(NULL);
-  struct tm* t = localtime(&tv);
-  // tm_gmtoff includes any daylight savings offset, so subtract it.
-  return static_cast<double>(t->tm_gmtoff * msPerSecond -
-                             (t->tm_isdst > 0 ? 3600 * msPerSecond : 0));
-}
-
-
 // ----------------------------------------------------------------------------
 // POSIX stdio support.
 //
index d17540796aeb52d354609df0d8c7e02ff24642ed..bc2e9d64f3e0af65946987a8b510ebff2f247779 100644 (file)
 #ifndef V8_PLATFORM_H_
 #define V8_PLATFORM_H_
 
+#ifdef __sun
+// On Solaris, to get isinf, INFINITY, fpclassify and other macros one needs
+// to define this symbol
+#define __C99FEATURES__ 1
+#endif
+
 #define V8_INFINITY INFINITY
 
 // Windows specific stuff.
index 08037b3779f260d466ccbaad19b815f16ea9fb51..05c29d7107eed6ad4ceea59d1b91de396ec2b1cc 100644 (file)
@@ -26,6 +26,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <stdlib.h>
+#include <wchar.h>  // wint_t
 
 #include "v8.h"
 
@@ -73,7 +74,7 @@ v8::Handle<v8::Value> PrintExtension::Print(const v8::Arguments& args) {
     uint16_t* string = NewArray<uint16_t>(length + 1);
     string_obj->Write(string);
     for (int j = 0; j < length; j++)
-      printf("%lc", string[j]);
+      printf("%lc", static_cast<wint_t>(string[j]));
     DeleteArray(string);
   }
   printf("\n");
index 196bb055559bf45de94b3261732b25c289cba8bf..435c12dee6c52adb599e5e3cd8744a483563db61 100644 (file)
@@ -57,6 +57,8 @@ def GuessOS():
     return 'freebsd'
   elif id == 'OpenBSD':
     return 'openbsd'
+  elif id == 'SunOS':
+    return 'solaris'
   else:
     return None
 
@@ -67,6 +69,8 @@ def GuessArchitecture():
     return 'arm'
   elif (not id) or (not re.match('(x|i[3-6])86', id) is None):
     return 'ia32'
+  elif id == 'i86pc':
+    return 'ia32'
   else:
     return None