Skip to content

Commit

Permalink
Clean up OS/X build. Fix printf formatters.
Browse files Browse the repository at this point in the history
  • Loading branch information
captain5050 committed May 5, 2010
1 parent ec4ccb8 commit 071eb5d
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 114 deletions.
31 changes: 25 additions & 6 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ const char *rvm_target_configuration = "${target.file}";
</condition>

<condition property="classlib.libraries"
value="${lib.specifier}pthread ${lib.specifier}dl ${lib.specifier}rt">
value="${lib.specifier}pthread ${lib.specifier}dl">
<not>
<equals arg1="${classlib.provider}" arg2="Harmony"/>
</not>
Expand Down Expand Up @@ -1698,6 +1698,7 @@ const char *rvm_target_configuration = "${target.file}";
<attribute name="outdir"/>
<attribute name="srcdir"/>
<attribute name="lib" default=""/>
<attribute name="suffix" default="${target.dll-ext}"/>
<element name="ObjectFiles"/>
<sequential>
<if>
Expand Down Expand Up @@ -1729,17 +1730,34 @@ const char *rvm_target_configuration = "${target.file}";
</if>
</sequential>
</if>
<if>
<conditions>
<equals arg1="${target.os}" arg2="OSX"/>
</conditions>
<sequential>
<exec executable="${c.exe}" failonerror="true">
<arg line="${c.args} -dynamiclib"/>
<arg value="-L@{outdir}"/>
<arg line="@{lib}"/>
<arg line="-o @{outdir}/${target.dll-prefix}@{dllname}@{suffix}"/>
<ObjectFiles/>
</exec>
</sequential>
</if>
<if>
<conditions>
<not>
<equals arg1="${target.os}" arg2="Windows"/>
<or>
<equals arg1="${target.os}" arg2="Windows"/>
<equals arg1="${target.os}" arg2="OSX"/>
</or>
</not>
</conditions>
<sequential>
<exec executable="${c.exe}" failonerror="true">
<arg line="${c.args} -shared"/>
<arg line="${c.args} ${shld.args}"/>
<arg line="-Xlinker --version-script=@{srcdir}/${target.dll-prefix}@{dllname}.exp"/>
<arg line="-o @{outdir}/${target.dll-prefix}@{dllname}${target.dll-ext}"/>
<arg line="-o @{outdir}/${target.dll-prefix}@{dllname}@{suffix}"/>
<ObjectFiles/>
</exec>
</sequential>
Expand Down Expand Up @@ -1943,11 +1961,12 @@ const char *rvm_target_configuration = "${target.file}";
</CreateDLL>

<!-- create jvm_jni shared library -->
<echo message="Creating jvm_jni${target.dll-ext}"/>
<echo message="Creating jvm_jni${target.jni-suffix}"/>
<CompileCtoObj cfile="${bl.dir}/jni/org_jikesrvm_runtime_DynamicLibrary.c"
objfile="${build.base}/${target.obj-prefix}org_jikesrvm_runtime_DynamicLibrary${target.obj-ext}"
cargs="${rvm.c.args}" />
<CreateDLL outdir="${build.base}" dllname="jvm_jni" srcdir="${bl.dir}/jni" lib="${lib.specifier}jvm${target.lib-ext}">
<CreateDLL outdir="${build.base}" dllname="jvm_jni" srcdir="${bl.dir}/jni" lib="${lib.specifier}jvm${target.lib-ext}"
suffix="${target.jni-suffix}">
<ObjectFiles>
<arg value="${build.base}/${target.obj-prefix}org_jikesrvm_runtime_DynamicLibrary${target.obj-ext}"/>
</ObjectFiles>
Expand Down
6 changes: 6 additions & 0 deletions build/targets/ia32-osx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ target.bootimage.data.address=0x31000000
target.bootimage.rmap.address=0x38000000
target.max-mappable.address=0x80000000
target.address.size=32
target.obj-ext=.o
target.obj-prefix=
target.dll-prefix=lib
target.dll-ext=.dylib
target.lib-ext=
target.lib-prefix=
target.jni-suffix=.jnilib
target.debug-suffix=${target.dll-ext}
target.exe-ext=
target.arch.sse2=full
target.arch.hw_fsqrt=true
4 changes: 2 additions & 2 deletions rvm/src/mrp/debug/DebugEntrypoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public static void debugEntry() {
int cmid = debugArgs.toInt();
CompiledMethod cm;
if(cmid < CompiledMethods.numCompiledMethods()) {
VM.sysWriteln("Looking up compiled method from CMID: ", cmid);
VM.sysWriteln("Looking up compiled method from CMID: ", cmid);
cm = CompiledMethods.getCompiledMethod(cmid);
} else {
VM.sysWriteln("Looking for compiled method associated with IP: ", debugArgs);
VM.sysWriteln("Looking for compiled method associated with IP: ", debugArgs);
cm = CompiledMethods.findMethodForInstruction(debugArgs);
cmid = (cm == null) ? 0 : cm.getId();
}
Expand Down
4 changes: 3 additions & 1 deletion rvm/src/org/jikesrvm/scheduler/TimerThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ public void run() {
disableYieldpoints();
if (verbose>=1) trace("TimerThread","run routine entered");
try {
final long sleepNS = 1000L*1000L*(long)VM.interruptQuantum;
if(VM.VerifyAssertions) VM._assert(sleepNS >= 0);
for (;;) {
sysCall.sysNanoSleep(1000L*1000L*(long)VM.interruptQuantum);
sysCall.sysNanoSleep(sleepNS);

// grab the lock to prevent threads from getting GC'd while we are
// iterating (since this thread doesn't stop for GC)
Expand Down
67 changes: 35 additions & 32 deletions tools/bootloader/jvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "sys.h"
#include <stdarg.h>
#include <string.h>

#ifndef RVM_FOR_HARMONY
#include <sys/mman.h>
Expand Down Expand Up @@ -349,13 +350,15 @@ static void* mapImageFile(const char *fileName, const void *targetAddress,
-1, 0);
#endif
if (bootRegion == (void *) MAP_FAILED) {
ERROR_PRINTF("%s: mmap failed (errno=%d): %s\n", Me, errno, strerror(errno));
char *error_msg=strerror(errno);
ERROR_PRINTF("%s: mmap failed (errno=%d): %s\n", Me, errno, error_msg);
return 0;
}
#ifdef RVM_WITH_OPROFILE
size_t read_len = fread(bootRegion, actualImageSize, 1, fin);
if(read_len != 1) {
ERROR_PRINTF("%s: image read failed (errno=%d): %s\n", Me, errno, strerror(errno));
char *error_msg=strerror(errno);
ERROR_PRINTF("%s: image read failed (errno=%d): %s\n", Me, errno, error_msg);
return 0;
}
#endif
Expand Down Expand Up @@ -388,35 +391,35 @@ static void* mapImageFile(const char *fileName, const void *targetAddress,
static int createVM(int vmInSeparateThread)
{
void *bootDataRegion;
unsigned roundedDataRegionSize;
long roundedDataRegionSize;
void *bootCodeRegion;
unsigned roundedCodeRegionSize;
long roundedCodeRegionSize;
void *bootRMapRegion;
unsigned roundedRMapRegionSize;
long roundedRMapRegionSize;
SYS_START();

bootDataRegion = mapImageFile(bootDataFilename,
(void*)bootImageDataAddress,
JNI_FALSE,
(void*)bootImageDataAddress,
JNI_FALSE,
JNI_TRUE,
&roundedDataRegionSize);
&roundedDataRegionSize);
if (bootDataRegion != (void*)bootImageDataAddress)
return 1;


bootCodeRegion = mapImageFile(bootCodeFilename,
(void*)bootImageCodeAddress,
JNI_TRUE,
(void*)bootImageCodeAddress,
JNI_TRUE,
JNI_FALSE,
&roundedCodeRegionSize);
&roundedCodeRegionSize);
if (bootCodeRegion != (void*)bootImageCodeAddress)
return 1;

bootRMapRegion = mapImageFile(bootRMapFilename,
(void*)bootImageRMapAddress,
JNI_FALSE,
(void*)bootImageRMapAddress,
JNI_FALSE,
JNI_FALSE,
&roundedRMapRegionSize);
&roundedRMapRegionSize);
if (bootRMapRegion != (void*)bootImageRMapAddress)
return 1;

Expand All @@ -426,37 +429,37 @@ static int createVM(int vmInSeparateThread)

if (bootRecord->bootImageDataStart != (Address) bootDataRegion) {
ERROR_PRINTF("%s: image load error: built for %p but loaded at %p\n",
Me, bootRecord->bootImageDataStart, bootDataRegion);
Me, (void*)bootRecord->bootImageDataStart, bootDataRegion);
return 1;
}

if (bootRecord->bootImageCodeStart != (Address) bootCodeRegion) {
ERROR_PRINTF("%s: image load error: built for %p but loaded at %p\n",
Me, bootRecord->bootImageCodeStart, bootCodeRegion);
Me, (void*)bootRecord->bootImageCodeStart, bootCodeRegion);
return 1;
}

if (bootRecord->bootImageRMapStart != (Address) bootRMapRegion) {
ERROR_PRINTF("%s: image load error: built for %p but loaded at %p\n",
Me, bootRecord->bootImageRMapStart, bootRMapRegion);
Me, (void*)bootRecord->bootImageRMapStart, bootRMapRegion);
return 1;
}

if ((bootRecord->spRegister % __SIZEOF_POINTER__) != 0) {
ERROR_PRINTF("%s: image format error: sp (%p) is not word aligned\n",
Me, bootRecord->spRegister);
Me, (void*)bootRecord->spRegister);
return 1;
}

if ((bootRecord->ipRegister % __SIZEOF_POINTER__) != 0) {
ERROR_PRINTF("%s: image format error: ip (%p) is not word aligned\n",
Me, bootRecord->ipRegister);
Me, (void*)bootRecord->ipRegister);
return 1;
}

if (((uint32_t *) bootRecord->spRegister)[-1] != 0xdeadbabe) {
ERROR_PRINTF("%s: image format error: missing stack sanity check marker (%p)\n",
Me, ((int *) bootRecord->spRegister)[-1]);
Me, (void*)(((int *) bootRecord->spRegister)[-1]));
return 1;
}

Expand All @@ -479,18 +482,18 @@ static int createVM(int vmInSeparateThread)

if (verbose) {
TRACE_PRINTF("%s: boot record contents:\n", Me);
TRACE_PRINTF(" bootImageDataStart: %p\n", bootRecord->bootImageDataStart);
TRACE_PRINTF(" bootImageDataEnd: %p\n", bootRecord->bootImageDataEnd);
TRACE_PRINTF(" bootImageCodeStart: %p\n", bootRecord->bootImageCodeStart);
TRACE_PRINTF(" bootImageCodeEnd: %p\n", bootRecord->bootImageCodeEnd);
TRACE_PRINTF(" bootImageRMapStart: %p\n", bootRecord->bootImageRMapStart);
TRACE_PRINTF(" bootImageRMapEnd: %p\n", bootRecord->bootImageRMapEnd);
TRACE_PRINTF(" initialHeapSize: %p\n", bootRecord->initialHeapSize);
TRACE_PRINTF(" maximumHeapSize: %p\n", bootRecord->maximumHeapSize);
TRACE_PRINTF(" spRegister: %p\n", bootRecord->spRegister);
TRACE_PRINTF(" ipRegister: %p\n", bootRecord->ipRegister);
TRACE_PRINTF(" tocRegister: %p\n", bootRecord->tocRegister);
TRACE_PRINTF(" sysConsoleWriteCharIP:%p\n", bootRecord->sysConsoleWriteCharIP);
TRACE_PRINTF(" bootImageDataStart: %p\n", (void*)bootRecord->bootImageDataStart);
TRACE_PRINTF(" bootImageDataEnd: %p\n", (void*)bootRecord->bootImageDataEnd);
TRACE_PRINTF(" bootImageCodeStart: %p\n", (void*)bootRecord->bootImageCodeStart);
TRACE_PRINTF(" bootImageCodeEnd: %p\n", (void*)bootRecord->bootImageCodeEnd);
TRACE_PRINTF(" bootImageRMapStart: %p\n", (void*)bootRecord->bootImageRMapStart);
TRACE_PRINTF(" bootImageRMapEnd: %p\n", (void*)bootRecord->bootImageRMapEnd);
TRACE_PRINTF(" initialHeapSize: %d\n", bootRecord->initialHeapSize);
TRACE_PRINTF(" maximumHeapSize: %d\n", bootRecord->maximumHeapSize);
TRACE_PRINTF(" spRegister: %p\n", (void*)bootRecord->spRegister);
TRACE_PRINTF(" ipRegister: %p\n", (void*)bootRecord->ipRegister);
TRACE_PRINTF(" tocRegister: %p\n", (void*)bootRecord->tocRegister);
TRACE_PRINTF(" sysConsoleWriteCharIP:%p\n", (void*)bootRecord->sysConsoleWriteCharIP);
TRACE_PRINTF(" ...etc... \n");
}

Expand Down
2 changes: 1 addition & 1 deletion tools/bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static void nonstandard_usage()
CONSOLE_PRINTF(" (to execute a class)\n");
CONSOLE_PRINTF("where options include\n");
for (;*msgp; ++msgp) {
CONSOLE_PRINTF( *msgp);
CONSOLE_PRINTF("%s",*msgp);
CONSOLE_PRINTF("\n");
}
}
Expand Down
4 changes: 2 additions & 2 deletions tools/bootloader/sysIO.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ EXTERNAL int sysWriteByte(int fd, int data)
EXTERNAL int sysReadBytes(int fd, char *buf, int cnt)
{
SYS_START();
TRACE_PRINTF("%s: sysReadBytes %d 0x%08x %d\n", Me, fd, buf, cnt);
TRACE_PRINTF("%s: sysReadBytes %d %p %d\n", Me, fd, buf, cnt);
#ifdef RVM_FOR_HARMONY
return hyfile_read(fd, buf, cnt);
#else
Expand Down Expand Up @@ -135,7 +135,7 @@ EXTERNAL int sysReadBytes(int fd, char *buf, int cnt)
EXTERNAL int sysWriteBytes(int fd, char *buf, int cnt)
{
SYS_START();
TRACE_PRINTF("%s: sysWriteBytes %d 0x%08x %d\n", Me, fd, buf, cnt);
TRACE_PRINTF("%s: sysWriteBytes %d %p %d\n", Me, fd, buf, cnt);
#ifdef RVM_FOR_HARMONY
return hyfile_write(fd, buf, cnt);
#else
Expand Down
6 changes: 3 additions & 3 deletions tools/bootloader/sysMath.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ const double maxint = 0.5 + (double)0x7fffffff;
EXTERNAL double sysLongToDouble(long long a)
{
SYS_START();
TRACE_PRINTF("%s: sysLongToDouble %ld\n", Me, a);
TRACE_PRINTF("%s: sysLongToDouble %lld\n", Me, a);
return (double)a;
}

EXTERNAL float sysLongToFloat(long long a)
{
SYS_START();
TRACE_PRINTF("%s: sysLongToFloat %ld\n", Me, a);
TRACE_PRINTF("%s: sysLongToFloat %lld\n", Me, a);
return (float)a;
}

Expand Down Expand Up @@ -79,7 +79,7 @@ EXTERNAL double sysDoubleRemainder(double a, double b)
{
double tmp;
SYS_START();
TRACE_PRINTF("%s: sysDoubleRemainder %f %% %f\n", Me, a);
TRACE_PRINTF("%s: sysDoubleRemainder %f %% %f\n", Me, a, b);
#ifdef _WIN32
tmp = fmod(a, b);
#else
Expand Down
20 changes: 10 additions & 10 deletions tools/bootloader/sysMemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ EXTERNAL void sysSyncCache(void *address, size_t size)
{
uintptr_t start, end, addr;
SYS_START();
TRACE_PRINTF("%s: sync %p %d\n", Me, address, size);
TRACE_PRINTF("%s: sync %p %zd\n", Me, address, size);
#ifdef RVM_FOR_HARMONY
hycpu_flush_icache(address, size);
#else
Expand Down Expand Up @@ -212,7 +212,7 @@ EXTERNAL void * sysMemoryReserve(char *start, size_t length,
SYS_START();
#ifdef RVM_FOR_HARMONY
HyPortVmemIdentifier ident;
TRACE_PRINTF("%s: sysMemoryReserve %p %d - %d %d %d %d\n",
TRACE_PRINTF("%s: sysMemoryReserve %p %zd - %d %d %d %d\n",
Me, start, length, read, write, exec, commit);
ident.pageSize = DefaultPageSize;
ident.mode = 0;
Expand Down Expand Up @@ -245,7 +245,7 @@ EXTERNAL void * sysMemoryReserve(char *start, size_t length,
int flags = MAP_PRIVATE;
int fd = -1;
off_t offset = 0;
TRACE_PRINTF("%s: sysMemoryReserve %p %d - %d %d %d %d\n",
TRACE_PRINTF("%s: sysMemoryReserve %p %zd - %d %d %d %d\n",
Me, start, length, read, write, exec, commit);
#if defined(MAP_ANONYMOUS)
flags |= MAP_ANONYMOUS;
Expand All @@ -268,18 +268,18 @@ EXTERNAL void * sysMemoryReserve(char *start, size_t length,
protection = PROT_NONE;
flags |= MAP_NORESERVE;
}
result = mmap(start, (size_t)(length), protection, flags, fd, (off_t)offset);
result = mmap(start, (size_t)(length), protection, flags, fd, offset);
#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
close(fd);
#endif
if (result == (void *) -1){
CONSOLE_PRINTF("%s: sysMemoryReserve %p %d %d %d %d %d failed with %d.\n",
Me, start, length, protection, flags, fd, offset, errno);
CONSOLE_PRINTF("%s: sysMemoryReserve %p %zd %d %d %d %ld failed with %d.\n",
Me, start, length, protection, flags, fd, (long)offset, errno);
return (void *) errno;
}
#endif // RVM_FOR_HARMONY
if (result != NULL) {
TRACE_PRINTF("MemoryReserve succeeded- region = [0x%x ... 0x%x] size = %d\n", result, ((size_t)result) + length, length);
TRACE_PRINTF("MemoryReserve succeeded- region = [%p ... %p] size = %zd\n", result, (void*)(((size_t)result) + length), length);
}
return result;
}
Expand All @@ -304,7 +304,7 @@ EXTERNAL jboolean sysMemoryFree(char *start, size_t length)
return JNI_FALSE;
}
#else
TRACE_PRINTF("%s: sysMemoryFree %p %d\n", Me, start, length);
TRACE_PRINTF("%s: sysMemoryFree %p %zd\n", Me, start, length);
if (munmap(start, length) == 0) {
return JNI_TRUE;
} else {
Expand Down Expand Up @@ -349,7 +349,7 @@ EXTERNAL jboolean sysMemoryCommit(char *start, size_t length,
}
#else
int protection = 0;
TRACE_PRINTF("%s: sysMemoryCommit %p %d - %d %d %d\n",
TRACE_PRINTF("%s: sysMemoryCommit %p %zd - %d %d %d\n",
Me, start, length, read, write, exec);
if (read) {
protection |= PROT_READ;
Expand Down Expand Up @@ -387,7 +387,7 @@ EXTERNAL jboolean sysMemoryDecommit(char *start, size_t length)
return JNI_FALSE;
}
#else
TRACE_PRINTF("%s: sysMemoryDecommit %p %d\n", Me, start, length);
TRACE_PRINTF("%s: sysMemoryDecommit %p %zd\n", Me, start, length);
return JNI_TRUE; // success - unsupported operation for UNIX environments
#endif // RVM_FOR_HARMONY
}
Expand Down
Loading

0 comments on commit 071eb5d

Please sign in to comment.