Merge branch 'master' of oss:/var/local/git/avian into powerpc

This commit is contained in:
Joel Dice 2008-06-23 17:38:16 -06:00
commit 8512d6c74c
9 changed files with 92 additions and 49 deletions

View File

@ -27,6 +27,8 @@
# include "winbase.h"
# include "io.h"
# include "tchar.h"
# include "sys/types.h"
# include "sys/timeb.h"
# define SO_PREFIX ""
#else
# define SO_PREFIX "lib"
@ -388,24 +390,9 @@ extern "C" JNIEXPORT jlong JNICALL
Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass)
{
#ifdef WIN32
static LARGE_INTEGER frequency;
static LARGE_INTEGER time;
static bool init = true;
if (init) {
QueryPerformanceFrequency(&frequency);
if (frequency.QuadPart == 0) {
return 0;
}
init = false;
}
QueryPerformanceCounter(&time);
return static_cast<int64_t>
(((static_cast<double>(time.QuadPart)) * 1000.0) /
(static_cast<double>(frequency.QuadPart)));
_timeb tb;
_ftime(&tb);
return (static_cast<jlong>(tb.time) * 1000) + static_cast<jlong>(tb.millitm);
#else
timeval tv = { 0, 0 };
gettimeofday(&tv, 0);

48
classpath/java-util.cpp Normal file
View File

@ -0,0 +1,48 @@
/* Copyright (c) 2008, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
#include "time.h"
#include "jni.h"
#include "jni-util.h"
namespace {
void
removeNewline(char* s)
{
for (; s; ++s) {
if (*s == '\n') {
*s = 0;
break;
}
}
}
} // namespace
extern "C" JNIEXPORT jstring JNICALL
Java_java_util_Date_toString(JNIEnv* e, jclass c UNUSED, jlong when)
{
time_t time = when / 1000;
#ifdef WIN32
e->MonitorEnter(c);
char* s = ctime(&time);
removeNewline(s);
jstring r = e->NewStringUTF(s);
e->MonitorExit(c);
return r;
#else
char buffer[27];
ctime_r(&time, buffer);
removeNewline(buffer);
return e->NewStringUTF(buffer);
#endif
}

View File

@ -24,4 +24,10 @@ public class Date {
public long getTime() {
return when;
}
public String toString() {
return toString(when);
}
private static native String toString(long when);
}

View File

@ -18,6 +18,8 @@
# define JNIEXPORT __attribute__ ((visibility("default")))
#endif
#define UNUSED __attribute__((unused))
namespace {
inline void

View File

@ -1,7 +1,7 @@
MAKEFLAGS = -s
name = avian
version = 0.1
version = 0.1.1
build-arch = "$(shell uname -m)"
ifeq ($(build-arch),"Power Macintosh")

View File

@ -1212,7 +1212,7 @@ findInterfaceMethodFromInstance(MyThread* t, object method, object instance)
}
}
intptr_t
intptr_t FORCE_ALIGN
compareDoublesG(uint64_t bi, uint64_t ai)
{
double a = bitsToDouble(ai);
@ -1229,7 +1229,7 @@ compareDoublesG(uint64_t bi, uint64_t ai)
}
}
intptr_t
intptr_t FORCE_ALIGN
compareDoublesL(uint64_t bi, uint64_t ai)
{
double a = bitsToDouble(ai);
@ -1246,7 +1246,7 @@ compareDoublesL(uint64_t bi, uint64_t ai)
}
}
intptr_t
intptr_t FORCE_ALIGN
compareFloatsG(uint32_t bi, uint32_t ai)
{
float a = bitsToFloat(ai);
@ -1263,7 +1263,7 @@ compareFloatsG(uint32_t bi, uint32_t ai)
}
}
intptr_t
intptr_t FORCE_ALIGN
compareFloatsL(uint32_t bi, uint32_t ai)
{
float a = bitsToFloat(ai);
@ -1280,79 +1280,79 @@ compareFloatsL(uint32_t bi, uint32_t ai)
}
}
uint64_t
uint64_t FORCE_ALIGN
addDouble(uint64_t b, uint64_t a)
{
return doubleToBits(bitsToDouble(a) + bitsToDouble(b));
}
uint64_t
uint64_t FORCE_ALIGN
subtractDouble(uint64_t b, uint64_t a)
{
return doubleToBits(bitsToDouble(a) - bitsToDouble(b));
}
uint64_t
uint64_t FORCE_ALIGN
multiplyDouble(uint64_t b, uint64_t a)
{
return doubleToBits(bitsToDouble(a) * bitsToDouble(b));
}
uint64_t
uint64_t FORCE_ALIGN
divideDouble(uint64_t b, uint64_t a)
{
return doubleToBits(bitsToDouble(a) / bitsToDouble(b));
}
uint64_t
uint64_t FORCE_ALIGN
moduloDouble(uint64_t b, uint64_t a)
{
return doubleToBits(fmod(bitsToDouble(a), bitsToDouble(b)));
}
uint64_t
uint64_t FORCE_ALIGN
negateDouble(uint64_t a)
{
return doubleToBits(- bitsToDouble(a));
}
uint32_t
uint32_t FORCE_ALIGN
doubleToFloat(int64_t a)
{
return floatToBits(static_cast<float>(bitsToDouble(a)));
}
int32_t
int32_t FORCE_ALIGN
doubleToInt(int64_t a)
{
return static_cast<int32_t>(bitsToDouble(a));
}
int64_t
int64_t FORCE_ALIGN
doubleToLong(int64_t a)
{
return static_cast<int64_t>(bitsToDouble(a));
}
uint32_t
uint32_t FORCE_ALIGN
addFloat(uint32_t b, uint32_t a)
{
return floatToBits(bitsToFloat(a) + bitsToFloat(b));
}
uint32_t
uint32_t FORCE_ALIGN
subtractFloat(uint32_t b, uint32_t a)
{
return floatToBits(bitsToFloat(a) - bitsToFloat(b));
}
uint32_t
uint32_t FORCE_ALIGN
multiplyFloat(uint32_t b, uint32_t a)
{
return floatToBits(bitsToFloat(a) * bitsToFloat(b));
}
uint32_t
uint32_t FORCE_ALIGN
divideFloat(uint32_t b, uint32_t a)
{
return floatToBits(bitsToFloat(a) / bitsToFloat(b));
@ -1364,7 +1364,7 @@ moduloFloat(uint32_t b, uint32_t a)
return floatToBits(fmod(bitsToFloat(a), bitsToFloat(b)));
}
uint32_t
uint32_t FORCE_ALIGN
negateFloat(uint32_t a)
{
return floatToBits(- bitsToFloat(a));
@ -1382,43 +1382,43 @@ moduloLong(int64_t b, int64_t a)
return a % b;
}
uint64_t
uint64_t FORCE_ALIGN
floatToDouble(int32_t a)
{
return doubleToBits(static_cast<double>(bitsToFloat(a)));
}
int32_t
int32_t FORCE_ALIGN
floatToInt(int32_t a)
{
return static_cast<int32_t>(bitsToFloat(a));
}
int64_t
int64_t FORCE_ALIGN
floatToLong(int32_t a)
{
return static_cast<int64_t>(bitsToFloat(a));
}
uint64_t
uint64_t FORCE_ALIGN
intToDouble(int32_t a)
{
return doubleToBits(static_cast<double>(a));
}
uint32_t
uint32_t FORCE_ALIGN
intToFloat(int32_t a)
{
return floatToBits(static_cast<float>(a));
}
uint64_t
uint64_t FORCE_ALIGN
longToDouble(int64_t a)
{
return doubleToBits(static_cast<double>(a));
}
uint32_t
uint32_t FORCE_ALIGN
longToFloat(int64_t a)
{
return floatToBits(static_cast<float>(a));
@ -1449,7 +1449,7 @@ makeBlankArray(MyThread* t, object (*constructor)(Thread*, uintptr_t, bool),
}
}
uintptr_t
uintptr_t FORCE_ALIGN
lookUpAddress(int32_t key, uintptr_t* start, int32_t count,
uintptr_t default_)
{

View File

@ -2221,7 +2221,7 @@ isAssignableFrom(Thread* t, object a, object b)
return false;
}
bool
bool FORCE_ALIGN
instanceOf(Thread* t, object class_, object o)
{
if (o == 0) {

View File

@ -1507,7 +1507,7 @@ mark(Thread* t, object o, unsigned offset)
}
}
inline void
inline void FORCE_ALIGN
set(Thread* t, object target, unsigned offset, object value)
{
cast<object>(target, offset) = value;

View File

@ -1825,10 +1825,10 @@ longCompareCR(Context* c, unsigned size UNUSED, Assembler::Constant* a,
int64_t v = a->value->value();
ResolvedPromise low(v & 0xFFFFFFFF);
ResolvedPromise low(v & ~static_cast<uintptr_t>(0));
Assembler::Constant al(&low);
ResolvedPromise high((v >> 32) & 0xFFFFFFFF);
ResolvedPromise high((v >> 32) & ~static_cast<uintptr_t>(0));
Assembler::Constant ah(&high);
Assembler::Register bh(b->high);