JavaScriptCore:
Reviewed by Darin.
- Set up new prototype macros and avoid using #if without defined() in JSC
Added new PLATFORM macros and related, to make sure #if's all check if relevant macros
are defined, and to separate core OS-level dependencies from operating environment
dependencies so you can, e.g., build KDE on Mac or Windows.
* kxmlcore/Platform.h: Added.
- deploy them everywhere in JavaScriptCore
* JavaScriptCore.xcodeproj/project.pbxproj:
* bindings/jni/jni_utility.cpp:
(KJS::Bindings::convertValueToJValue):
* bindings/objc/WebScriptObject.mm:
* bindings/objc/objc_instance.mm:
(ObjcInstance::end):
* bindings/softlinking.h:
* bindings/testbindings.mm:
(main):
* kjs/JSLock.cpp:
* kjs/collector.cpp:
(KJS::Collector::markCurrentThreadConservatively):
(KJS::Collector::markOtherThreadConservatively):
(KJS::Collector::markStackObjectsConservatively):
* kjs/config.h:
* kjs/date_object.cpp:
(gmtoffset):
(KJS::formatTime):
(KJS::DateProtoFunc::callAsFunction):
(KJS::DateObjectImp::construct):
(KJS::makeTime):
* kjs/dtoa.cpp:
* kjs/fpconst.cpp:
(KJS::sizeof):
(KJS::):
* kjs/grammar.y:
* kjs/identifier.cpp:
* kjs/internal.cpp:
* kjs/interpreter.cpp:
(KJS::Interpreter::evaluate):
(KJS::Interpreter::createLanguageInstanceForValue):
* kjs/interpreter.h:
* kjs/lookup.cpp:
* kjs/lookup.h:
* kjs/math_object.cpp:
* kjs/object.cpp:
* kjs/object.h:
* kjs/operations.cpp:
(KJS::isNaN):
(KJS::isInf):
(KJS::isPosInf):
(KJS::isNegInf):
* kjs/operations.h:
* kjs/regexp.cpp:
(KJS::RegExp::RegExp):
(KJS::RegExp::~RegExp):
(KJS::RegExp::match):
* kjs/regexp.h:
* kjs/testkjs.cpp:
(StopWatch::start):
(StopWatch::stop):
(StopWatch::getElapsedMS):
* kjs/ustring.cpp:
* kjs/ustring.h:
* kxmlcore/AlwaysInline.h:
* kxmlcore/Assertions.cpp:
* kxmlcore/Assertions.h:
* kxmlcore/FastMalloc.cpp:
(KXMLCore::):
* kxmlcore/FastMalloc.h:
* kxmlcore/FastMallocInternal.h:
* kxmlcore/HashTable.h:
* kxmlcore/TCPageMap.h:
* kxmlcore/TCSpinLock.h:
(TCMalloc_SpinLock::Lock):
(TCMalloc_SpinLock::Unlock):
(TCMalloc_SlowLock):
* kxmlcore/TCSystemAlloc.cpp:
(TCMalloc_SystemAlloc):
* os-win32/stdint.h:
JavaScriptGlue:
Not reviewed, but I noticed these trivial extra changes were needed to avoid
breaking the build with my reviewed patch for:
http://bugzilla.opendarwin.org/show_bug.cgi?id=7387
Add config.h, includes of it, and Platform.h forwarding header.
* JSBase.cpp:
* JSObject.cpp:
* JSRun.cpp:
* JSUtils.cpp:
* JSValueWrapper.cpp:
* JavaScriptGlue.cpp:
* UserObjectImp.cpp:
* config.h: Added.
* kxmlcore/Platform.h: Added.
WebCore:
Reviewed by Darin.
- WebCore updates for "Set up new prototype macros and avoid using #if without defined() in JSC"
http://bugzilla.opendarwin.org/show_bug.cgi?id=7387
Add Platform.h
* ForwardingHeaders/kxmlcore/Platform.h: Added.
* bridge/mac/WebCoreFrameNamespaces.m:
* bridge/mac/WebCoreViewFactory.m:
* bridge/mac/WebDashboardRegion.m:
* config.h:
* platform/Logging.cpp:
* platform/mac/ScrollViewMac.mm:
(WebCore::ScrollView::addChild):
* platform/mac/WebCoreCookieAdapter.m:
* platform/mac/WebCoreGraphicsBridge.m:
* platform/mac/WebCoreHistory.m:
* platform/mac/WebCoreImageRendererFactory.m:
* platform/mac/WebCoreKeyGenerator.m:
* platform/mac/WebCoreView.m:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@13089 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 2884d9d..f3bca67 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,88 @@
+2006-03-01 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Darin.
+
+ - Set up new prototype macros and avoid using #if without defined() in JSC
+
+ Added new PLATFORM macros and related, to make sure #if's all check if relevant macros
+ are defined, and to separate core OS-level dependencies from operating environment
+ dependencies so you can, e.g., build KDE on Mac or Windows.
+
+ * kxmlcore/Platform.h: Added.
+
+ - deploy them everywhere in JavaScriptCore
+
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * bindings/jni/jni_utility.cpp:
+ (KJS::Bindings::convertValueToJValue):
+ * bindings/objc/WebScriptObject.mm:
+ * bindings/objc/objc_instance.mm:
+ (ObjcInstance::end):
+ * bindings/softlinking.h:
+ * bindings/testbindings.mm:
+ (main):
+ * kjs/JSLock.cpp:
+ * kjs/collector.cpp:
+ (KJS::Collector::markCurrentThreadConservatively):
+ (KJS::Collector::markOtherThreadConservatively):
+ (KJS::Collector::markStackObjectsConservatively):
+ * kjs/config.h:
+ * kjs/date_object.cpp:
+ (gmtoffset):
+ (KJS::formatTime):
+ (KJS::DateProtoFunc::callAsFunction):
+ (KJS::DateObjectImp::construct):
+ (KJS::makeTime):
+ * kjs/dtoa.cpp:
+ * kjs/fpconst.cpp:
+ (KJS::sizeof):
+ (KJS::):
+ * kjs/grammar.y:
+ * kjs/identifier.cpp:
+ * kjs/internal.cpp:
+ * kjs/interpreter.cpp:
+ (KJS::Interpreter::evaluate):
+ (KJS::Interpreter::createLanguageInstanceForValue):
+ * kjs/interpreter.h:
+ * kjs/lookup.cpp:
+ * kjs/lookup.h:
+ * kjs/math_object.cpp:
+ * kjs/object.cpp:
+ * kjs/object.h:
+ * kjs/operations.cpp:
+ (KJS::isNaN):
+ (KJS::isInf):
+ (KJS::isPosInf):
+ (KJS::isNegInf):
+ * kjs/operations.h:
+ * kjs/regexp.cpp:
+ (KJS::RegExp::RegExp):
+ (KJS::RegExp::~RegExp):
+ (KJS::RegExp::match):
+ * kjs/regexp.h:
+ * kjs/testkjs.cpp:
+ (StopWatch::start):
+ (StopWatch::stop):
+ (StopWatch::getElapsedMS):
+ * kjs/ustring.cpp:
+ * kjs/ustring.h:
+ * kxmlcore/AlwaysInline.h:
+ * kxmlcore/Assertions.cpp:
+ * kxmlcore/Assertions.h:
+ * kxmlcore/FastMalloc.cpp:
+ (KXMLCore::):
+ * kxmlcore/FastMalloc.h:
+ * kxmlcore/FastMallocInternal.h:
+ * kxmlcore/HashTable.h:
+ * kxmlcore/TCPageMap.h:
+ * kxmlcore/TCSpinLock.h:
+ (TCMalloc_SpinLock::Lock):
+ (TCMalloc_SpinLock::Unlock):
+ (TCMalloc_SlowLock):
+ * kxmlcore/TCSystemAlloc.cpp:
+ (TCMalloc_SystemAlloc):
+ * os-win32/stdint.h:
+
2006-02-28 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin.
diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index 4d76360..a7db5ad 100644
--- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -43,6 +43,7 @@
6592C318098B7DE10003D4F6 /* Vector.h in Headers */ = {isa = PBXBuildFile; fileRef = 6592C316098B7DE10003D4F6 /* Vector.h */; settings = {ATTRIBUTES = (Private, ); }; };
6592C319098B7DE10003D4F6 /* VectorTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 6592C317098B7DE10003D4F6 /* VectorTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
65C647B4093EF8D60022C380 /* RefPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C647B3093EF8D60022C380 /* RefPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 65D6D87F09B5A32E0002E4D7 /* Platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 65D6D87E09B5A32E0002E4D7 /* Platform.h */; settings = {ATTRIBUTES = (Private, ); }; };
65D7D19C08F10B5B0015ABD8 /* FastMallocInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */; };
65DFC93008EA173A00F7300B /* HashFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92A08EA173A00F7300B /* HashFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
65DFC93108EA173A00F7300B /* HashMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92B08EA173A00F7300B /* HashMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -353,6 +354,7 @@
6592C317098B7DE10003D4F6 /* VectorTraits.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = VectorTraits.h; sourceTree = "<group>"; };
65C02FBB0637462A003E7EE6 /* protect.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = protect.h; sourceTree = "<group>"; tabWidth = 8; };
65C647B3093EF8D60022C380 /* RefPtr.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = RefPtr.h; sourceTree = "<group>"; tabWidth = 8; };
+ 65D6D87E09B5A32E0002E4D7 /* Platform.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Platform.h; sourceTree = "<group>"; };
65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = FastMallocInternal.h; sourceTree = "<group>"; tabWidth = 8; };
65DFC92A08EA173A00F7300B /* HashFunctions.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HashFunctions.h; sourceTree = "<group>"; tabWidth = 8; };
65DFC92B08EA173A00F7300B /* HashMap.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HashMap.h; sourceTree = "<group>"; tabWidth = 8; };
@@ -596,6 +598,7 @@
65162EF108E6A21C007556CD /* kxmlcore */ = {
isa = PBXGroup;
children = (
+ 65D6D87E09B5A32E0002E4D7 /* Platform.h */,
93AA4F770957251F0084B3A7 /* AlwaysInline.h */,
65E217B708E7EECC0023E5F6 /* Assertions.h */,
65E217B808E7EECC0023E5F6 /* Assertions.cpp */,
@@ -860,6 +863,7 @@
1483B58A099BC1950016E4F0 /* JSImmediate.h in Headers */,
14ABB36F099C076400E2A24F /* value.h in Headers */,
14ABB455099C2A0F00E2A24F /* JSType.h in Headers */,
+ 65D6D87F09B5A32E0002E4D7 /* Platform.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/JavaScriptCore/bindings/jni/jni_utility.cpp b/JavaScriptCore/bindings/jni/jni_utility.cpp
index c6bd2da..094f973 100644
--- a/JavaScriptCore/bindings/jni/jni_utility.cpp
+++ b/JavaScriptCore/bindings/jni/jni_utility.cpp
@@ -737,7 +737,7 @@
// Now convert value to a string if the target type is a java.lang.string, and we're not
// converting from a Null.
if (result.l == 0 && strcmp(javaClassName, "java.lang.String") == 0) {
-#if CONVERT_NULL_TO_EMPTY_STRING
+#ifdef CONVERT_NULL_TO_EMPTY_STRING
if (value->isNull()) {
JNIEnv *env = getJNIEnv();
jchar buf[2];
diff --git a/JavaScriptCore/bindings/objc/WebScriptObject.mm b/JavaScriptCore/bindings/objc/WebScriptObject.mm
index 3fb858b..efb43836 100644
--- a/JavaScriptCore/bindings/objc/WebScriptObject.mm
+++ b/JavaScriptCore/bindings/objc/WebScriptObject.mm
@@ -38,14 +38,6 @@
#import <kxmlcore/UnusedParam.h>
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3
-
-@interface NSObject (WebExtras)
-- (void)finalize;
-@end
-
-#endif
-
using namespace KJS;
using namespace KJS::Bindings;
diff --git a/JavaScriptCore/bindings/objc/objc_instance.mm b/JavaScriptCore/bindings/objc/objc_instance.mm
index f1ed84a..a021875 100644
--- a/JavaScriptCore/bindings/objc/objc_instance.mm
+++ b/JavaScriptCore/bindings/objc/objc_instance.mm
@@ -103,11 +103,7 @@
_beginCount--;
assert (_beginCount >= 0);
if (_beginCount == 0) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3
- [_pool release];
-#else
[_pool drain];
-#endif
}
_pool = 0;
}
diff --git a/JavaScriptCore/bindings/softlinking.h b/JavaScriptCore/bindings/softlinking.h
index adac418..59d0d0e 100644
--- a/JavaScriptCore/bindings/softlinking.h
+++ b/JavaScriptCore/bindings/softlinking.h
@@ -25,7 +25,7 @@
#include <JavaVM/jni.h>
-#if __cplusplus
+#ifdef __cplusplus
extern "C"
#endif
jint KJS_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs);
diff --git a/JavaScriptCore/bindings/testbindings.mm b/JavaScriptCore/bindings/testbindings.mm
index be27c1b..b481124 100644
--- a/JavaScriptCore/bindings/testbindings.mm
+++ b/JavaScriptCore/bindings/testbindings.mm
@@ -281,12 +281,7 @@
}
[myInterface release];
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3
- [pool release];
-#else
[pool drain];
-#endif
} // end block, so that Interpreter and global get deleted
return ret ? 0 : 3;
diff --git a/JavaScriptCore/kjs/JSLock.cpp b/JavaScriptCore/kjs/JSLock.cpp
index 123ddfa..7e854a4 100644
--- a/JavaScriptCore/kjs/JSLock.cpp
+++ b/JavaScriptCore/kjs/JSLock.cpp
@@ -27,7 +27,7 @@
namespace KJS {
-#if KJS_MULTIPLE_THREADS
+#if USE(MULTIPLE_THREADS)
static pthread_once_t interpreterLockOnce = PTHREAD_ONCE_INIT;
static pthread_mutex_t interpreterLock;
diff --git a/JavaScriptCore/kjs/collector.cpp b/JavaScriptCore/kjs/collector.cpp
index 32eb203..edfb191 100644
--- a/JavaScriptCore/kjs/collector.cpp
+++ b/JavaScriptCore/kjs/collector.cpp
@@ -32,29 +32,29 @@
#include <setjmp.h>
#include <algorithm>
-#if __APPLE__
+#if PLATFORM(DARWIN)
#include <pthread.h>
#include <mach/mach_port.h>
#include <mach/task.h>
#include <mach/thread_act.h>
-#elif WIN32
+#elif PLATFORM(WIN_OS)
#include <windows.h>
-#else
+#elif PLATFORM(UNIX)
#include <pthread.h>
-#ifdef HAVE_PTHREAD_NP_H
-
+#if HAVE(PTHREAD_NP_H)
#include <pthread_np.h>
-
#endif
#endif
+#define DEBUG_COLLECTOR 0
+
using std::max;
namespace KJS {
@@ -191,7 +191,7 @@
return newCell;
}
-#if KJS_MULTIPLE_THREADS
+#if USE(MULTIPLE_THREADS)
struct Collector::Thread {
Thread(pthread_t pthread, mach_port_t mthread) : posixThread(pthread), machThread(mthread) {}
@@ -300,23 +300,23 @@
jmp_buf registers;
setjmp(registers);
-#if __APPLE__
+#if PLATFORM(DARWIN)
pthread_t thread = pthread_self();
void *stackBase = pthread_get_stackaddr_np(thread);
-#elif WIN32
+#elif PLATFORM(WIN_OS) && PLATFORM(X86) && COMPILER(MSVC)
NT_TIB *pTib;
__asm {
MOV EAX, FS:[18h]
MOV pTib, EAX
}
void *stackBase = (void *)pTib->StackBase;
-#else
+#elif PLATFORM(UNIX)
static void *stackBase = 0;
static pthread_t stackThread;
pthread_t thread = pthread_self();
if (stackBase == 0 || thread != stackThread) {
pthread_attr_t sattr;
-#ifdef HAVE_PTHREAD_NP_H
+#if HAVE(PTHREAD_NP_H)
// e.g. on FreeBSD 5.4, neundorf@kde.org
pthread_attr_get_np(thread, &sattr);
#else
@@ -329,6 +329,8 @@
assert(stackBase);
stackThread = thread;
}
+#else
+#error Need a way to get the stack base on this platform
#endif
int dummy;
@@ -337,7 +339,7 @@
markStackObjectsConservatively(stackPointer, stackBase);
}
-#if KJS_MULTIPLE_THREADS
+#if USE(MULTIPLE_THREADS)
typedef unsigned long usword_t; // word size, assumed to be either 32 or 64 bit
@@ -345,15 +347,15 @@
{
thread_suspend(thread->machThread);
-#if KJS_CPU_X86
+#if PLATFORM(X86)
i386_thread_state_t regs;
unsigned user_count = sizeof(regs)/sizeof(int);
thread_state_flavor_t flavor = i386_THREAD_STATE;
-#elif KJS_CPU_PPC
+#elif PLATFORM(PPC)
ppc_thread_state_t regs;
unsigned user_count = PPC_THREAD_STATE_COUNT;
thread_state_flavor_t flavor = PPC_THREAD_STATE;
-#elif KJS_CPU_PPC64
+#elif PLATFORM(PPC64)
ppc_thread_state64_t regs;
unsigned user_count = PPC_THREAD_STATE64_COUNT;
thread_state_flavor_t flavor = PPC_THREAD_STATE64;
@@ -367,9 +369,9 @@
markStackObjectsConservatively((void *)®s, (void *)((char *)®s + (user_count * sizeof(usword_t))));
// scan the stack
-#if KJS_CPU_X86
+#if PLATFORM(X86)
markStackObjectsConservatively((void *)regs.esp, pthread_get_stackaddr_np(thread->posixThread));
-#elif KJS_CPU_PPC || KJS_CPU_PPC64
+#elif PLATFORM(PPC) || PLATFORM(PPC64)
markStackObjectsConservatively((void *)regs.r1, pthread_get_stackaddr_np(thread->posixThread));
#else
#error Unknown Architecture
@@ -384,7 +386,7 @@
{
markCurrentThreadConservatively();
-#if KJS_MULTIPLE_THREADS
+#if USE(MULTIPLE_THREADS)
for (Thread *thread = registeredThreads; thread != NULL; thread = thread->next) {
if (thread->posixThread != pthread_self()) {
markOtherThreadConservatively(thread);
diff --git a/JavaScriptCore/kjs/config.h b/JavaScriptCore/kjs/config.h
index 465ca83..7d70b7e 100644
--- a/JavaScriptCore/kjs/config.h
+++ b/JavaScriptCore/kjs/config.h
@@ -1,4 +1,6 @@
-#if __APPLE__
+#include <kxmlcore/Platform.h>
+
+#if PLATFORM(DARWIN)
#define HAVE_ERRNO_H 1
#define HAVE_FUNC_ISINF 1
@@ -10,17 +12,20 @@
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIMEB_H 1
-#define KJS_MULTIPLE_THREADS 1
-
-#elif WIN32
+#elif PLATFORM(WIN_OS)
#define HAVE_FLOAT_H 1
#define HAVE_FUNC__FINITE 1
#define HAVE_SYS_TIMEB_H 1
+
+
#define USE_SYSTEM_MALLOC 1
#else
+// FIXME: is this actually used or do other platforms generate their
+// own config.h?
+
#define HAVE_ERRNO_H 1
#define HAVE_FUNC_ISINF 1
#define HAVE_FUNC_ISNAN 1
@@ -32,22 +37,13 @@
#endif
-#define HAVE_FUNC_STRTOLL 1
#define HAVE_ICU 1
#define HAVE_PCREPOSIX 1
+
+// FIXME: if all platforms have these, do they really need #defines?
#define HAVE_STDINT_H 1
#define HAVE_STRING_H 1
-#if __ppc__ || __PPC__ || __powerpc__
-#define KJS_CPU_PPC 1
-#define WORDS_BIGENDIAN 1
-#elif __ppc64__ || __PPC64__
-#define KJS_CPU_PPC64 1
-#define WORDS_BIGENDIAN 1
-#elif __i386__
-#define KJS_CPU_X86 1
-#endif
-
#define KXC_CHANGES 1
#ifdef __cplusplus
diff --git a/JavaScriptCore/kjs/date_object.cpp b/JavaScriptCore/kjs/date_object.cpp
index 204557a..2a9d953 100644
--- a/JavaScriptCore/kjs/date_object.cpp
+++ b/JavaScriptCore/kjs/date_object.cpp
@@ -22,19 +22,19 @@
#include "config.h"
#include "date_object.h"
-#if HAVE_ERRNO_H
+#if HAVE(ERRNO_H)
#include <errno.h>
#endif
-#if HAVE_SYS_PARAM_H
+#if HAVE(SYS_PARAM_H)
#include <sys/param.h>
#endif
-#if HAVE_SYS_TIME_H
+#if HAVE(SYS_TIME_H)
#include <sys/time.h>
#endif
-#if HAVE_SYS_TIMEB_H
+#if HAVE(SYS_TIMEB_H)
#include <sys/timeb.h>
#endif
@@ -51,11 +51,11 @@
#include "error_object.h"
#include "operations.h"
-#if __APPLE__
+#if PLATFORM(MAC)
#include <CoreFoundation/CoreFoundation.h>
#endif
-#if WIN32
+#if PLATFORM(WIN_OS)
#define copysign(x, y) _copysign(x, y)
#define isfinite(x) _finite(x)
#define strncasecmp(x, y, z) strnicmp(x, y, z)
@@ -64,7 +64,7 @@
inline int gmtoffset(const tm& t)
{
-#if WIN32
+#if PLATFORM(WIN_OS)
// Time is supposed to be in the current timezone.
// FIXME: Use undocumented _dstbias?
return -(_timezone / 60 - (t.tm_isdst > 0 ? 60 : 0 )) * 60;
@@ -141,7 +141,7 @@
static double timeClip(double);
static void millisecondsToTM(double milli, bool utc, tm *t);
-#if __APPLE__
+#if PLATFORM(MAC)
static CFDateFormatterStyle styleFromArgString(const UString& string, CFDateFormatterStyle defaultStyle)
{
@@ -206,7 +206,7 @@
return UString(buffer, length);
}
-#endif // __APPLE__
+#endif // PLATFORM(MAC)
static UString formatDate(const tm &t)
{
@@ -230,7 +230,8 @@
{
char buffer[100];
if (utc) {
-#if !WIN32
+ // FIXME: why not on windows?
+#if !PLATFORM(WIN_OS)
ASSERT(t.tm_gmtoff == 0);
#endif
snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d GMT", t.tm_hour, t.tm_min, t.tm_sec);
@@ -553,7 +554,7 @@
JSValue *result = 0;
UString s;
-#if !__APPLE__
+#if !PLATFORM(DARWIN)
const int bufsize=100;
char timebuffer[bufsize];
CString oldlocale = setlocale(LC_TIME, 0);
@@ -609,7 +610,7 @@
case ToUTCString:
return jsString(formatDateUTCVariant(t) + " " + formatTime(t, utc));
break;
-#if __APPLE__
+#if PLATFORM(MAC)
case ToLocaleString:
return jsString(formatLocaleDate(exec, secs, true, true, args));
break;
@@ -734,19 +735,19 @@
double value;
if (numArgs == 0) { // new Date() ECMA 15.9.3.3
-#if !WIN32
+#if PLATFORM(WIN_OS)
+#if COMPILER(BORLAND)
+ struct timeb timebuffer;
+ ftime(&timebuffer);
+#else
+ struct _timeb timebuffer;
+ _ftime(&timebuffer);
+#endif
+ double utc = timebuffer.time * msPerSecond + timebuffer.millitm;
+#else
struct timeval tv;
gettimeofday(&tv, 0);
double utc = floor(tv.tv_sec * msPerSecond + tv.tv_usec / 1000);
-#else
-# if __BORLANDC__
- struct timeb timebuffer;
- ftime(&timebuffer);
-# else
- struct _timeb timebuffer;
- _ftime(&timebuffer);
-# endif
- double utc = timebuffer.time * msPerSecond + timebuffer.millitm;
#endif
value = utc;
} else if (numArgs == 1) {
@@ -854,7 +855,7 @@
// We follow the recommendation of RFC 2822 to consider all
// obsolete time zones not listed here equivalent to "-0000".
static const struct KnownZone {
-#if !WIN32
+#if !PLATFORM(WIN_OS)
const
#endif
char tzName[4];
@@ -877,20 +878,20 @@
int utcOffset;
if (utc) {
time_t zero = 0;
-#if !WIN32
+#if PLATFORM(WIN_OS)
+ // FIXME: not thread safe
+ (void)localtime(&zero);
+#if COMPILER(BORLAND) || COMPILER(CYGWIN)
+ utcOffset = - _timezone;
+#else
+ utcOffset = - timezone;
+#endif
+ t->tm_isdst = 0;
+#else
tm t3;
localtime_r(&zero, &t3);
utcOffset = t3.tm_gmtoff;
t->tm_isdst = t3.tm_isdst;
-#else
- // FIXME: not thread safe
- (void)localtime(&zero);
-# if __BORLANDC__ || __CYGWIN__
- utcOffset = - _timezone;
-# else
- utcOffset = - timezone;
-# endif
- t->tm_isdst = 0;
#endif
} else {
utcOffset = 0;
diff --git a/JavaScriptCore/kjs/dtoa.cpp b/JavaScriptCore/kjs/dtoa.cpp
index 79f1c8b..0370e5e 100644
--- a/JavaScriptCore/kjs/dtoa.cpp
+++ b/JavaScriptCore/kjs/dtoa.cpp
@@ -172,7 +172,7 @@
#include "config.h"
#include "dtoa.h"
-#ifdef WORDS_BIGENDIAN
+#if PLATFORM(BIG_ENDIAN)
#define IEEE_MC68k
#else
#define IEEE_8087
diff --git a/JavaScriptCore/kjs/fpconst.cpp b/JavaScriptCore/kjs/fpconst.cpp
index 05993ae..04dc708 100644
--- a/JavaScriptCore/kjs/fpconst.cpp
+++ b/JavaScriptCore/kjs/fpconst.cpp
@@ -31,16 +31,37 @@
// characters don't necessarily need the same alignment doubles do, but for now it seems to work.
// It would be good to figure out a 100% clean way that still avoids code that runs at init time.
-#if __APPLE__
+#if PLATFORM(DARWIN)
-#ifdef WORDS_BIGENDIAN
- extern const unsigned char NaN[sizeof(double)] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
- extern const unsigned char Inf[sizeof(double)] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
+#if PLATFORM(BIG_ENDIAN)
+ extern const unsigned char NaN[sizeof(double)] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
+ extern const unsigned char Inf[sizeof(double)] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
+#elif PLATFORM(MIDDLE_ENDIAN)
+ extern const unsigned char NaN[] = { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 };
+ extern const unsigned char Inf[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 };
#else
- extern const unsigned char NaN[sizeof(double)] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
- extern const unsigned char Inf[sizeof(double)] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
-#endif
+ extern const unsigned char NaN[sizeof(double)] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
+ extern const unsigned char Inf[sizeof(double)] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
+#endif // PLATFORM(MIDDLE_ENDIAN)
-#endif
+#else // !PLATFORM(DARWIN)
-}
+#include "value.h"
+
+#if PLATFORM(BIG_ENDIAN)
+ const unsigned char NaN_Bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
+ const unsigned char Inf_Bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
+#elif PLATFORM(MIDDLE_ENDIAN)
+ const unsigned char NaN_Bytes[] = { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 };
+ const unsigned char Inf_Bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 };
+#else
+ const unsigned char NaN_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
+ const unsigned char Inf_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
+#endif
+ const double NaN = *(const double*) NaN_Bytes;
+ const double Inf = *(const double*) Inf_Bytes;
+
+#endif // !PLATFORM(DARWIN)
+
+
+} // namespace KJS
diff --git a/JavaScriptCore/kjs/grammar.y b/JavaScriptCore/kjs/grammar.y
index 0ca67fe..94ab1c4 100644
--- a/JavaScriptCore/kjs/grammar.y
+++ b/JavaScriptCore/kjs/grammar.y
@@ -3,6 +3,7 @@
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
+ * Copyright (C) 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -37,7 +38,8 @@
/* default values for bison */
#define YYDEBUG 0
-#if !__APPLE__ /* work around the fact that YYERROR_VERBOSE causes a compiler warning in bison code */
+#if !PLATFORM(DARWIN)
+ // avoid triggering warnings in older bison
#define YYERROR_VERBOSE
#endif
diff --git a/JavaScriptCore/kjs/identifier.cpp b/JavaScriptCore/kjs/identifier.cpp
index fc1e958..999fdc7 100644
--- a/JavaScriptCore/kjs/identifier.cpp
+++ b/JavaScriptCore/kjs/identifier.cpp
@@ -25,7 +25,7 @@
// portable, and it would be good to figure out a 100% clean way that still avoids code that
// runs at init time.
-#if !defined(WIN32) // can't get this to compile on Visual C++ yet
+#if !PLATFORM(WIN_OS) // can't get this to compile on Visual C++ yet
#define AVOID_STATIC_CONSTRUCTORS 1
#endif
diff --git a/JavaScriptCore/kjs/internal.cpp b/JavaScriptCore/kjs/internal.cpp
index d851335..e375557 100644
--- a/JavaScriptCore/kjs/internal.cpp
+++ b/JavaScriptCore/kjs/internal.cpp
@@ -52,25 +52,7 @@
namespace KJS {
-#if !__APPLE__
-
-#ifdef WORDS_BIGENDIAN
- const unsigned char NaN_Bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
- const unsigned char Inf_Bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
-#elif defined(arm)
- const unsigned char NaN_Bytes[] = { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 };
- const unsigned char Inf_Bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 };
-#else
- const unsigned char NaN_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
- const unsigned char Inf_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
-#endif
-
- const double NaN = *(const double*) NaN_Bytes;
- const double Inf = *(const double*) Inf_Bytes;
-
-#endif
-
-#if WIN32
+#if PLATFORM(WIN_OS)
#define copysign _copysign
#endif
diff --git a/JavaScriptCore/kjs/interpreter.cpp b/JavaScriptCore/kjs/interpreter.cpp
index a7251e7..640d635 100644
--- a/JavaScriptCore/kjs/interpreter.cpp
+++ b/JavaScriptCore/kjs/interpreter.cpp
@@ -36,12 +36,13 @@
#include "nodes.h"
#include "object.h"
#include "operations.h"
-#if __APPLE__
-#include "runtime.h"
-#endif
#include "types.h"
#include "value.h"
+#if PLATFORM(MAC)
+#include "runtime.h"
+#endif
+
namespace KJS {
// ------------------------------ Context --------------------------------------
@@ -124,7 +125,7 @@
CString f = sourceURL.UTF8String();
CString message = comp.value()->toObject(exec)->toString(exec).UTF8String();
int line = comp.value()->toObject(exec)->get(exec, "line")->toUInt32(exec);
-#ifdef WIN32
+#if PLATFORM(WIN_OS)
printf("%s line %d: %s\n", f.c_str(), line, message.c_str());
#else
printf("[%d] %s line %d: %s\n", getpid(), f.c_str(), line, message.c_str());
@@ -325,12 +326,12 @@
printExceptions = print;
}
-#if __APPLE__
+// bindings are OS X WebKit-only for now
+#if PLATFORM(MAC)
void *Interpreter::createLanguageInstanceForValue(ExecState *exec, int language, JSObject *value, const Bindings::RootObject *origin, const Bindings::RootObject *current)
{
return Bindings::Instance::createLanguageInstanceForValue (exec, (Bindings::Instance::BindingLanguage)language, value, origin, current);
}
-
#endif
void Interpreter::saveBuiltins (SavedBuiltins &builtins) const
diff --git a/JavaScriptCore/kjs/interpreter.h b/JavaScriptCore/kjs/interpreter.h
index a230e38..09cb35e 100644
--- a/JavaScriptCore/kjs/interpreter.h
+++ b/JavaScriptCore/kjs/interpreter.h
@@ -395,7 +395,7 @@
*/
virtual bool isSafeScript(const Interpreter*) { return true; }
-#if __APPLE__
+#if PLATFORM(MAC)
virtual void *createLanguageInstanceForValue(ExecState*, int language, JSObject* value, const Bindings::RootObject* origin, const Bindings::RootObject* current);
#endif
diff --git a/JavaScriptCore/kjs/lookup.cpp b/JavaScriptCore/kjs/lookup.cpp
index 1d9df8c..52f2160 100644
--- a/JavaScriptCore/kjs/lookup.cpp
+++ b/JavaScriptCore/kjs/lookup.cpp
@@ -26,9 +26,6 @@
#include "lookup.h"
-#ifdef HAVE_CONFIG_H
-#endif
-
using namespace KJS;
static inline bool keysMatch(const UChar *c, unsigned len, const char *s)
diff --git a/JavaScriptCore/kjs/lookup.h b/JavaScriptCore/kjs/lookup.h
index aa17a58..d550ea4 100644
--- a/JavaScriptCore/kjs/lookup.h
+++ b/JavaScriptCore/kjs/lookup.h
@@ -299,7 +299,7 @@
*/
// Work around a bug in GCC 4.1
-#if !__GNUC__
+#if !COMPILER(GCC)
#define KJS_GCC_ROOT_NS_HACK ::
#else
#define KJS_GCC_ROOT_NS_HACK
diff --git a/JavaScriptCore/kjs/math_object.cpp b/JavaScriptCore/kjs/math_object.cpp
index dbe6fa3..7a16a44 100644
--- a/JavaScriptCore/kjs/math_object.cpp
+++ b/JavaScriptCore/kjs/math_object.cpp
@@ -34,7 +34,7 @@
#include "math_object.lut.h"
-#if WIN32
+#if PLATFORM(WIN_OS)
#include <float.h>
static int signbit(double d)
diff --git a/JavaScriptCore/kjs/object.cpp b/JavaScriptCore/kjs/object.cpp
index 0caf0fc..30733d1 100644
--- a/JavaScriptCore/kjs/object.cpp
+++ b/JavaScriptCore/kjs/object.cpp
@@ -40,9 +40,7 @@
#include "error_object.h"
#include "nodes.h"
-#ifndef NDEBUG
-//#define JAVASCRIPT_CALL_TRACING 1
-#endif
+#define JAVASCRIPT_CALL_TRACING 0
#if JAVASCRIPT_CALL_TRACING
static bool _traceJavaScript = false;
diff --git a/JavaScriptCore/kjs/object.h b/JavaScriptCore/kjs/object.h
index 6b1d3e8..c37b4e5 100644
--- a/JavaScriptCore/kjs/object.h
+++ b/JavaScriptCore/kjs/object.h
@@ -29,7 +29,7 @@
// maximum global call stack size. Protects against accidental or
// malicious infinite recursions. Define to -1 if you want no limit.
-#if __APPLE__
+#if PLATFORM(DARWIN)
// Given OS X stack sizes we run out of stack at about 350 levels.
// If we improve our stack usage, we can bump this number.
#define KJS_MAX_STACK 100
diff --git a/JavaScriptCore/kjs/operations.cpp b/JavaScriptCore/kjs/operations.cpp
index ca3fd07..d92d813 100644
--- a/JavaScriptCore/kjs/operations.cpp
+++ b/JavaScriptCore/kjs/operations.cpp
@@ -30,13 +30,11 @@
#include <stdio.h>
#include <stdlib.h>
-#ifndef HAVE_FUNC_ISINF
-#ifdef HAVE_IEEEFP_H
+#if HAVE(FUNC_ISINF) && HAVE(IEEEFP_H)
#include <ieeefp.h>
#endif
-#endif /* HAVE_FUNC_ISINF */
-#if HAVE_FLOAT_H
+#if HAVE(FLOAT_H)
#include <float.h>
#endif
@@ -44,13 +42,16 @@
namespace KJS {
-#if !__APPLE__
+#if !PLATFORM(DARWIN)
+ // FIXME: should probably be inlined on other platforms too, and controlled exclusively
+ // by HAVE macros
+
bool isNaN(double d)
{
-#ifdef HAVE_FUNC_ISNAN
+#if HAVE(FUNC_ISNAN)
return isnan(d);
-#elif defined HAVE_FLOAT_H
+#elif HAVE(FLOAT_H)
return _isnan(d) != 0;
#else
return !(d == d);
@@ -59,14 +60,15 @@
bool isInf(double d)
{
-#if WIN32
+ // FIXME: should be HAVE(_FPCLASS)
+#if PLATFORM(WIN_OS)
int fpClass = _fpclass(d);
return _FPCLASS_PINF == fpClass || _FPCLASS_NINF == fpClass;
-#elif defined(HAVE_FUNC_ISINF)
+#elif HAVE(FUNC_ISINF)
return isinf(d);
-#elif HAVE_FUNC_FINITE
+#elif HAVE(FUNC_FINITE)
return finite(d) == 0 && d == d;
-#elif HAVE_FUNC__FINITE
+#elif HAVE(FUNC__FINITE)
return _finite(d) == 0 && d == d;
#else
return false;
@@ -75,14 +77,15 @@
bool isPosInf(double d)
{
-#if WIN32
+ // FIXME: should be HAVE(_FPCLASS)
+#if PLATFORM(WIN_OS)
return _FPCLASS_PINF == _fpclass(d);
-#elif defined(HAVE_FUNC_ISINF)
+#elif HAVE(FUNC_ISINF)
return (isinf(d) == 1);
-#elif HAVE_FUNC_FINITE
- return finite(d) == 0 && d == d; // ### can we distinguish between + and - ?
-#elif HAVE_FUNC__FINITE
- return _finite(d) == 0 && d == d; // ###
+#elif HAVE(FUNC_FINITE)
+ return !finite(d) && d == d; // ### can we distinguish between + and - ?
+#elif HAVE(FUNC__FINITE)
+ return !_finite(d) && d == d; // ###
#else
return false;
#endif
@@ -90,13 +93,14 @@
bool isNegInf(double d)
{
-#if WIN32
+ // FIXME: should be HAVE(_FPCLASS)
+#if PLATFORM(WIN_OS)
return _FPCLASS_NINF == _fpclass(d);
-#elif defined(HAVE_FUNC_ISINF)
+#elif HAVE(FUNC_ISINF)
return (isinf(d) == -1);
-#elif HAVE_FUNC_FINITE
+#elif HAVE(FUNC_FINITE)
return finite(d) == 0 && d == d; // ###
-#elif HAVE_FUNC__FINITE
+#elif HAVE(FUNC__FINITE)
return _finite(d) == 0 && d == d; // ###
#else
return false;
diff --git a/JavaScriptCore/kjs/operations.h b/JavaScriptCore/kjs/operations.h
index 680f6be..5c11d9f 100644
--- a/JavaScriptCore/kjs/operations.h
+++ b/JavaScriptCore/kjs/operations.h
@@ -28,19 +28,13 @@
class ExecState;
class JSValue;
-#if __APPLE__
+#if PLATFORM(DARWIN)
inline bool isNaN(double d) { return isnan(d); }
inline bool isInf(double d) { return isinf(d); }
inline bool isPosInf(double d) { return isinf(d) && d > 0; }
inline bool isNegInf(double d) { return isinf(d) && d < 0; }
#else
- /**
- * @return True if d is not a number (platform support required).
- */
bool isNaN(double d);
- /**
- * @return True if d is infinite (platform support required).
- */
bool isInf(double d);
bool isPosInf(double d);
bool isNegInf(double d);
diff --git a/JavaScriptCore/kjs/regexp.cpp b/JavaScriptCore/kjs/regexp.cpp
index dc1c4ca..bb8ce8f 100644
--- a/JavaScriptCore/kjs/regexp.cpp
+++ b/JavaScriptCore/kjs/regexp.cpp
@@ -32,7 +32,7 @@
RegExp::RegExp(const UString &p, int flags)
: _flags(flags), _numSubPatterns(0)
{
-#ifdef HAVE_PCREPOSIX
+#if HAVE(PCREPOSIX)
int options = PCRE_UTF8;
// Note: the Global flag is already handled by RegExpProtoFunc::execute.
@@ -60,7 +60,7 @@
pcre_fullinfo(_regex, NULL, PCRE_INFO_CAPTURECOUNT, &_numSubPatterns);
#endif
-#else /* HAVE_PCREPOSIX */
+#else /* HAVE(PCREPOSIX) */
int regflags = 0;
#ifdef REG_EXTENDED
@@ -84,7 +84,7 @@
RegExp::~RegExp()
{
-#ifdef HAVE_PCREPOSIX
+#if HAVE(PCREPOSIX)
pcre_free(_regex);
#else
/* TODO: is this really okay after an error ? */
@@ -106,7 +106,7 @@
if (i > s.size() || s.isNull())
return UString::null();
-#ifdef HAVE_PCREPOSIX
+#if HAVE(PCREPOSIX)
if (!_regex)
return UString::null();
diff --git a/JavaScriptCore/kjs/regexp.h b/JavaScriptCore/kjs/regexp.h
index 178b283..88674ae 100644
--- a/JavaScriptCore/kjs/regexp.h
+++ b/JavaScriptCore/kjs/regexp.h
@@ -26,13 +26,13 @@
#include "config.h"
-#ifdef HAVE_PCREPOSIX
+#if HAVE(PCREPOSIX)
#include <pcre.h>
#else // POSIX regex - not so good...
extern "C" { // bug with some libc5 distributions
#include <regex.h>
}
-#endif //HAVE_PCREPOSIX
+#endif // HAVE(PCREPOSIX)
#include "ustring.h"
@@ -51,7 +51,7 @@
unsigned subPatterns() const { return _numSubPatterns; }
private:
-#ifdef HAVE_PCREPOSIX
+#if HAVE(PCREPOSIX)
pcre *_regex;
#else
regex_t _regex;
diff --git a/JavaScriptCore/kjs/testkjs.cpp b/JavaScriptCore/kjs/testkjs.cpp
index 014f38d..e6bd0eb 100644
--- a/JavaScriptCore/kjs/testkjs.cpp
+++ b/JavaScriptCore/kjs/testkjs.cpp
@@ -34,7 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#if HAVE_SYS_TIME_H
+#if HAVE(SYS_TIME_H)
#include <sys/time.h>
#endif
@@ -52,7 +52,7 @@
long getElapsedMS(); // call stop() first
private:
-#if !WIN32
+#if !PLATFORM(WIN_OS)
// Windows does not have timeval, disabling this class for now (bug 7399)
timeval m_startTime;
timeval m_stopTime;
@@ -61,21 +61,21 @@
void StopWatch::start()
{
-#if !WIN32
+#if !PLATFORM(WIN_OS)
gettimeofday(&m_startTime, 0);
#endif
}
void StopWatch::stop()
{
-#if !WIN32
+#if !PLATFORM(WIN_OS)
gettimeofday(&m_stopTime, 0);
#endif
}
long StopWatch::getElapsedMS()
{
-#if !WIN32
+#if !PLATFORM(WIN_OS)
timeval elapsedTime;
timersub(&m_stopTime, &m_startTime, &elapsedTime);
diff --git a/JavaScriptCore/kjs/ustring.cpp b/JavaScriptCore/kjs/ustring.cpp
index 92250d3..6b231c7 100644
--- a/JavaScriptCore/kjs/ustring.cpp
+++ b/JavaScriptCore/kjs/ustring.cpp
@@ -28,10 +28,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
-#ifdef HAVE_STRING_H
+#if HAVE(STRING_H)
#include <string.h>
#endif
-#ifdef HAVE_STRINGS_H
+#if HAVE(STRINGS_H)
#include <strings.h>
#endif
diff --git a/JavaScriptCore/kjs/ustring.h b/JavaScriptCore/kjs/ustring.h
index e2e311d..12e61e8 100644
--- a/JavaScriptCore/kjs/ustring.h
+++ b/JavaScriptCore/kjs/ustring.h
@@ -28,15 +28,6 @@
#include <kxmlcore/RefPtr.h>
#include <kxmlcore/PassRefPtr.h>
-#if __APPLE__
-#include <sys/types.h>
-#ifndef KWQ_UNSIGNED_TYPES_DEFINED
-#define KWQ_UNSIGNED_TYPES_DEFINED
-typedef unsigned char uchar;
-typedef unsigned long ulong;
-#endif
-#endif
-
#include <stdint.h>
/**
diff --git a/JavaScriptCore/kxmlcore/AlwaysInline.h b/JavaScriptCore/kxmlcore/AlwaysInline.h
index f449590..621168e 100644
--- a/JavaScriptCore/kxmlcore/AlwaysInline.h
+++ b/JavaScriptCore/kxmlcore/AlwaysInline.h
@@ -20,7 +20,7 @@
*/
#ifndef ALWAYS_INLINE
-#if defined(__GNUC__) && (__GNUC__ > 3)
+#if COMPILER(GCC)
#define ALWAYS_INLINE inline __attribute__ ((__always_inline__))
#else
#define ALWAYS_INLINE inline
diff --git a/JavaScriptCore/kxmlcore/Assertions.cpp b/JavaScriptCore/kxmlcore/Assertions.cpp
index 410beb8..d2f3d2e 100644
--- a/JavaScriptCore/kxmlcore/Assertions.cpp
+++ b/JavaScriptCore/kxmlcore/Assertions.cpp
@@ -29,7 +29,7 @@
#include "stdio.h"
#include "stdarg.h"
-#if __APPLE__
+#if PLATFORM(MAC)
#include <CoreFoundation/CFString.h>
#endif
@@ -41,7 +41,7 @@
static void vprintf_stderr_common(const char *format, va_list args)
{
-#if __APPLE__
+#if PLATFORM(MAC)
if (!strstr(format, "%@")) {
CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8);
CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args);
diff --git a/JavaScriptCore/kxmlcore/Assertions.h b/JavaScriptCore/kxmlcore/Assertions.h
index 7c74d1d..0b45020 100644
--- a/JavaScriptCore/kxmlcore/Assertions.h
+++ b/JavaScriptCore/kxmlcore/Assertions.h
@@ -35,15 +35,11 @@
// For non-debug builds, everything is disabled by default.
// Defining any of the symbols explicitly prevents this from having any effect.
-#if !__APPLE__
-#define ASSERT_DISABLED 1 // FIXME: We have to undo all the assert macros, since they are currently in a .mm file and use obj-c.
-#else
#ifdef NDEBUG
#define ASSERTIONS_DISABLED_DEFAULT 1
#else
#define ASSERTIONS_DISABLED_DEFAULT 0
#endif
-#endif
#ifndef ASSERT_DISABLED
#define ASSERT_DISABLED ASSERTIONS_DISABLED_DEFAULT
@@ -65,7 +61,7 @@
#define LOG_DISABLED ASSERTIONS_DISABLED_DEFAULT
#endif
-#ifdef __GNUC__
+#if COMPILER(GCC)
#define KXMLCORE_PRETTY_FUNCTION __PRETTY_FUNCTION__
#else
#define KXMLCORE_PRETTY_FUNCTION __FUNCTION__
diff --git a/JavaScriptCore/kxmlcore/FastMalloc.cpp b/JavaScriptCore/kxmlcore/FastMalloc.cpp
index 13f8f04..74434fa 100644
--- a/JavaScriptCore/kxmlcore/FastMalloc.cpp
+++ b/JavaScriptCore/kxmlcore/FastMalloc.cpp
@@ -67,6 +67,8 @@
#ifndef NDEBUG
#define USE_SYSTEM_MALLOC 1
+#else
+#define USE_SYSTEM_MALLOC 0
#endif
#if USE_SYSTEM_MALLOC
@@ -95,7 +97,7 @@
return realloc(p, n);
}
-#if !WIN32
+#if PLATFORM(WIN_OS)
void fastMallocRegisterThread(pthread_t)
{
}
@@ -105,9 +107,9 @@
#else
-#if HAVE_STDINT_H
+#if HAVE(STDINT_H)
#include <stdint.h>
-#elif HAVE_INTTYPES_H
+#elif HAVE(INTTYPES_H)
#include <inttypes.h>
#else
#include <sys/types.h>
@@ -140,7 +142,7 @@
#endif
-#if defined HAVE_INTTYPES_H
+#if HAVE(INTTYPES_H)
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#define LLU PRIu64
@@ -220,7 +222,7 @@
static size_t class_to_pages[kNumClasses];
// Return floor(log2(n)) for n > 0.
-#if defined __i386__ && defined __GNUC__
+#if PLATFORM(X86) && COMPILER(GCC)
static inline int LgFloor(size_t n) {
// "ro" for the input spec means the input can come from either a
// register ("r") or offsetable memory ("o").
@@ -233,7 +235,7 @@
return result;
}
-#elif defined __ppc__ && defined __GNUC__
+#elif PLATFORM(PPC) && COMPILER(GCC)
static inline int LgFloor(size_t n) {
// "r" for the input spec means the input must come from a
// register ("r")
@@ -2280,7 +2282,7 @@
//-------------------------------------------------------------------
extern "C" {
-#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__)
+#if COMPILER(GCC) && HAVE(__ATTRIBUTE__)
// Potentially faster variants that use the gcc alias extension
#define ALIAS(x) __attribute__ ((weak, alias (x)))
void* __libc_malloc(size_t size) ALIAS("malloc");
diff --git a/JavaScriptCore/kxmlcore/FastMalloc.h b/JavaScriptCore/kxmlcore/FastMalloc.h
index 3a33244..04ffec8 100644
--- a/JavaScriptCore/kxmlcore/FastMalloc.h
+++ b/JavaScriptCore/kxmlcore/FastMalloc.h
@@ -40,14 +40,10 @@
using KXMLCore::fastRealloc;
using KXMLCore::fastFree;
-#if __GNUC__
-
-#if __APPLE__
+#if PLATFORM(GCC) && PLATFORM(DARWIN)
#define KXMLCORE_PRIVATE_INLINE __private_extern__ inline __attribute__((always_inline))
-#else
+#elif PLATFORM(GCC)
#define KXMLCORE_PRIVATE_INLINE inline __attribute__((always_inline))
-#endif
-
#else
#define KXMLCORE_PRIVATE_INLINE inline
#endif
@@ -57,5 +53,4 @@
KXMLCORE_PRIVATE_INLINE void* operator new[](size_t s) { return fastMalloc(s); }
KXMLCORE_PRIVATE_INLINE void operator delete[](void* p) { fastFree(p); }
-
#endif /* KXMLCORE_FAST_MALLOC_H */
diff --git a/JavaScriptCore/kxmlcore/FastMallocInternal.h b/JavaScriptCore/kxmlcore/FastMallocInternal.h
index 168f4b4..e94b3f6 100644
--- a/JavaScriptCore/kxmlcore/FastMallocInternal.h
+++ b/JavaScriptCore/kxmlcore/FastMallocInternal.h
@@ -23,7 +23,7 @@
#ifndef KXMLCORE_FAST_MALLOC_INTERNAL_H
#define KXMLCORE_FAST_MALLOC_INTERNAL_H
-#ifndef WIN32
+#if !PLATFORM(WIN_OS)
#include <pthread.h>
diff --git a/JavaScriptCore/kxmlcore/HashTable.h b/JavaScriptCore/kxmlcore/HashTable.h
index 2244803..f205428 100644
--- a/JavaScriptCore/kxmlcore/HashTable.h
+++ b/JavaScriptCore/kxmlcore/HashTable.h
@@ -33,7 +33,7 @@
#define DUMP_HASHTABLE_STATS 0
#define CHECK_HASHTABLE_CONSISTENCY 0
-#if NDEBUG
+#ifdef NDEBUG
#define CHECK_HASHTABLE_ITERATORS 0
#else
#define CHECK_HASHTABLE_ITERATORS 1
@@ -235,7 +235,7 @@
using std::swap;
-#if !WIN32
+#if !COMPILER(MSVC)
// Visual C++ has a swap for pairs defined.
// swap pairs by component, in case of pair members that specialize swap
diff --git a/JavaScriptCore/kxmlcore/Platform.h b/JavaScriptCore/kxmlcore/Platform.h
new file mode 100644
index 0000000..15c05ad
--- /dev/null
+++ b/JavaScriptCore/kxmlcore/Platform.h
@@ -0,0 +1,154 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef KXMLCORE_PLATFORM_H
+#define KXMLCORE_PLATFORM_H
+
+// PLATFORM handles OS, operating environment, graphics API, and CPU
+#define PLATFORM(FEATURE) (defined(KXMLCORE_PLATFORM_##FEATURE) && KXMLCORE_PLATFORM_##FEATURE)
+#define COMPILER(FEATURE) (defined(KXMLCORE_COMPILER_##FEATURE) && KXMLCORE_COMPILER_##FEATURE)
+#define HAVE(FEATURE) (defined(HAVE_##FEATURE) && HAVE_##FEATURE)
+#define USE(FEATURE) (defined(KXMLCORE_USE_##FEATURE) && KXMLCORE_USE_##FEATURE)
+
+// Operating systems - low-level dependencies
+
+// PLATFORM(DARWIN)
+// Operating system level dependencies for Mac OS X / Darwin that should
+// be used regardless of operating environment
+#ifdef __APPLE__
+#define KXMLCORE_PLATFORM_DARWIN 1
+#endif
+
+// PLATFORM(WIN_OS)
+// Operating system level dependencies for Windows that should be used
+// regardless of operating environment
+#if defined(WIN32) || defined(_WIN32)
+#define KXMLCORE_PLATFORM_WIN_OS 1
+#endif
+
+// PLATFORM(UNIX)
+// Operating system level dependencies for Unix-like systems that
+// should be used regardless of operating environment
+// (includes PLATFORM(DARWIN))
+#if defined(__APPLE__) \
+ || defined(unix) \
+ || defined(__unix) \
+ || defined(__unix__) \
+ || defined (__NetBSD__) \
+ || defined(_AIX)
+#define KXMLCORE_PLATFORM_UNIX 1
+#endif
+
+// Operating environments
+
+#define KXMLCORE_HAVE_OPERATING_ENVIRONMENT 0
+
+// PLATFORM(KDE)
+// Operating environment dependencies for KDE
+// I made this macro up for the KDE build system to define
+#if defined(BUILDING_KDE__)
+#define KXMLCORE_PLATFORM_KDE 1
+#undef KXMLCORE_HAVE_OPERATING_ENVIRONMENT
+#define KXMLCORE_HAVE_OPERATING_ENVIRONMENT 1
+#endif
+
+#if !KXMLCORE_HAVE_OPERATING_ENVIRONMENT && PLATFORM(DARWIN)
+#define KXMLCORE_PLATFORM_MAC 1
+#undef KXMLCORE_HAVE_OPERATING_ENVIRONMENT
+#define KXMLCORE_HAVE_OPERATING_ENVIRONMENT 1
+#endif
+
+#if !KXMLCORE_HAVE_OPERATING_ENVIRONMENT && PLATFORM(WIN_OS)
+#define KXMLCORE_PLATFORM_WIN 1
+#undef KXMLCORE_HAVE_OPERATING_ENVIRONMENT
+#define KXMLCORE_HAVE_OPERATING_ENVIRONMENT 1
+#endif
+
+// CPU
+
+// PLATFORM(PPC)
+#if defined(__ppc__) \
+ || defined(__PPC__) \
+ || defined(__powerpc__) \
+ || defined(__powerpc) \
+ || defined(__POWERPC__) \
+ || defined(_M_PPC) \
+ || defined(__PPC)
+#define KXMLCORE_PLATFORM_PPC 1
+#define KXMLCORE_PLATFORM_BIG_ENDIAN 1
+#endif
+
+// PLATFORM(PPC64)
+#if defined(__ppc64__) \
+ || defined(__PPC64__)
+#define KXMLCORE_PLATFORM_PPC64 1
+#define KXMLCORE_PLATFORM_BIG_ENDIAN 1
+#endif
+
+#if defined(arm)
+#define KXMLCORE_PLATFORM_ARM 1
+#define KXMLCORE_PLATFORM_MIDDLE_ENDIAN 1
+#endif
+
+// PLATFORM(X86)
+#if defined(__i386__) \
+ || defined(i386) \
+ || defined(_M_IX86) \
+ || defined(_X86_) \
+ || defined(__THW_INTEL)
+#define KXMLCORE_PLATFORM_X86 1
+#endif
+
+// Compiler
+
+// COMPILER(MSVC)
+#if defined(_MSC_Ver)
+#define KXMLCORE_COMPILER_MSVC 1
+#endif
+
+// COMPILER(GCC)
+#if defined(__GNUC__)
+#define KXMLCORE_COMPILER_GCC 1
+#endif
+
+// COMPILER(BORLAND)
+// not really fully supported - is this relevant any more?
+#if defined(__BORLANDC__)
+#define KXMLCORE_COMPILER_BORLAND 1
+#endif
+
+// COMPILER(CYGWIN)
+// not really fully supported - is this relevant any more?
+#if defined(__CYGWIN__)
+#define KXMLCORE_COMPILER_CYGWIN 1
+#endif
+
+// multiple threads only supported on OS X WebKit for now
+#if PLATFORM(MAC)
+#define USE_MULTIPLE_THREADS 1
+#endif
+
+#endif // KXMLCORE_PLATFORM_H
diff --git a/JavaScriptCore/kxmlcore/TCPageMap.h b/JavaScriptCore/kxmlcore/TCPageMap.h
index a7c6a3c..d26d148 100644
--- a/JavaScriptCore/kxmlcore/TCPageMap.h
+++ b/JavaScriptCore/kxmlcore/TCPageMap.h
@@ -47,9 +47,9 @@
#include "config.h"
-#if defined HAVE_STDINT_H
+#if HAVE(STDINT_H)
#include <stdint.h>
-#elif defined HAVE_INTTYPES_H
+#elif HAVE(INTTYPES_H)
#include <inttypes.h>
#else
#include <sys/types.h>
diff --git a/JavaScriptCore/kxmlcore/TCSpinLock.h b/JavaScriptCore/kxmlcore/TCSpinLock.h
index 65fe267..71ec94a 100644
--- a/JavaScriptCore/kxmlcore/TCSpinLock.h
+++ b/JavaScriptCore/kxmlcore/TCSpinLock.h
@@ -36,16 +36,16 @@
#include "config.h"
#include <time.h> /* For nanosleep() */
#include <sched.h> /* For sched_yield() */
-#if defined HAVE_STDINT_H
+#if HAVE(STDINT_H)
#include <stdint.h>
-#elif defined HAVE_INTTYPES_H
+#elif HAVE(INTTYPES_H)
#include <inttypes.h>
#else
#include <sys/types.h>
#endif
#include <stdlib.h> /* for abort() */
-#if (defined __i386__ || defined __ppc__) && defined __GNUC__
+#if (PLATFORM(X86) || PLATFORM(PPC)) && COMPILER(GCC)
static void TCMalloc_SlowLock(volatile unsigned int* lockword);
// The following is a struct so that it can be initialized at compile time
@@ -57,7 +57,7 @@
inline void Lock() {
int r;
-#if __i386__
+#if PLATFORM(X86)
__asm__ __volatile__
("xchgl %0, %1"
: "=r"(r), "=m"(private_lockword_)
@@ -78,7 +78,7 @@
}
inline void Unlock() {
-#if __i386__
+#if PLATFORM(X86)
__asm__ __volatile__
("movl $0, %0"
: "=m"(private_lockword_)
@@ -102,7 +102,7 @@
sched_yield(); // Yield immediately since fast path failed
while (true) {
int r;
-#if __i386__
+#if PLATFORM(X86)
__asm__ __volatile__
("xchgl %0, %1"
: "=r"(r), "=m"(*lockword)
diff --git a/JavaScriptCore/kxmlcore/TCSystemAlloc.cpp b/JavaScriptCore/kxmlcore/TCSystemAlloc.cpp
index d4b3fec..4c787fa 100644
--- a/JavaScriptCore/kxmlcore/TCSystemAlloc.cpp
+++ b/JavaScriptCore/kxmlcore/TCSystemAlloc.cpp
@@ -31,14 +31,14 @@
// Author: Sanjay Ghemawat
#include "config.h"
-#if defined HAVE_STDINT_H
+#if HAVE(STDINT_H)
#include <stdint.h>
-#elif defined HAVE_INTTYPES_H
+#elif HAVE(INTTYPES_H)
#include <inttypes.h>
#else
#include <sys/types.h>
#endif
-#ifndef WIN32
+#if !PLATFORM(WIN_OS)
#include <unistd.h>
#include <sys/mman.h>
#endif
@@ -91,7 +91,7 @@
static const int32_t FLAGS_malloc_devmem_limit = 0;
#endif
-#ifdef HAVE_SBRK
+#if HAVE(SBRK)
static void* TrySbrk(size_t size, size_t alignment) {
size = ((size + alignment - 1) / alignment) * alignment;
@@ -127,9 +127,9 @@
return reinterpret_cast<void*>(ptr);
}
-#endif /* HAVE_SBRK */
+#endif /* HAVE(SBRK) */
-#ifdef HAVE_MMAP
+#if HAVE(MMAP)
static void* TryMmap(size_t size, size_t alignment) {
// Enforce page alignment
@@ -170,7 +170,7 @@
return reinterpret_cast<void*>(ptr);
}
-#endif /* HAVE_MMAP */
+#endif /* HAVE(MMAP) */
#ifndef KXC_CHANGES
static void* TryDevMem(size_t size, size_t alignment) {
@@ -268,14 +268,14 @@
}
#endif
-#ifdef HAVE_SBRK
+#if HAVE(SBRK)
if (use_sbrk && !sbrk_failure) {
void* result = TrySbrk(size, alignment);
if (result != NULL) return result;
}
#endif
-#ifdef HAVE_MMAP
+#if HAVE(MMAP)
if (use_mmap && !mmap_failure) {
void* result = TryMmap(size, alignment);
if (result != NULL) return result;
diff --git a/JavaScriptCore/os-win32/stdint.h b/JavaScriptCore/os-win32/stdint.h
index 285b276..f55860c 100644
--- a/JavaScriptCore/os-win32/stdint.h
+++ b/JavaScriptCore/os-win32/stdint.h
@@ -4,7 +4,7 @@
/* This file emulates enough of unix's stdint.h on Windows
to make WebCore compile */
-#ifndef WIN32
+#if !PLATFORM(WIN_OS)
#error "This stdint.h file should only be compiled under Windows"
#endif
typedef unsigned short uint16_t;