Skip to content

Commit

Permalink
Switch use of malloc/free to sysMalloc/sysFree. Harmony build fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Rogers committed Mar 4, 2009
1 parent 792bfdc commit c9ed392
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
4 changes: 3 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@ Check to make sure all required properties are specified. This includes properti
<exec executable="${c.exe}" failonerror="true">
<arg line="-DLINUX=1 ${rvm.c++.args} -lpthread ${c++.librt} -L${harmony.lib.dir} -lhyprt -lhyarchive -lhyzlib"/>
<arg value="-o"/>
<arg value="${vmi.dll}"/>
<arg value="${toString:vmi.dll}"/>
<arg value="${bl.dir}/harmony.c"/>
<arg value="libraryInterface/Harmony/ASF/native/vmls.c"/>
<arg value="-Wl,--version-script=${bl.dir}/harmony.exp"/>
Expand Down Expand Up @@ -1649,6 +1649,7 @@ Check to make sure all required properties are specified. This includes properti
<equals arg1="${classlib.provider}" arg2="GNU Classpath"/>
</conditions>
<sequential>
<echo message="Creating JikesRVM"/>
<exec executable="${c++.exe}" failonerror="true">
<arg line="${c++.args} ${rvm.common.args} ${gcspy.lib.dir} -lpthread ${perfctr.lib} ${c++.librt} ${rvm.src} ${c++.rdynamic} -g"/>
<arg value="-o"/>
Expand All @@ -1664,6 +1665,7 @@ Check to make sure all required properties are specified. This includes properti
<equals arg1="${classlib.provider}" arg2="Harmony"/>
</conditions>
<sequential>
<echo message="Creating JikesRVM"/>
<exec executable="${c++.exe}" failonerror="true">
<arg line="${c++.args} ${rvm.common.args} ${gcspy.lib.dir} -lpthread ${perfctr.lib} ${c++.librt} ${c++.rdynamic} -g"/>
<arg value="-o"/>
Expand Down
5 changes: 1 addition & 4 deletions tools/bootloader/RunBootImage.C
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@
#include "RunBootImage.h" /* definitions created during the build */
#include "sys.h"
#include <ctype.h> /* isspace */
#include <errno.h> /* for strtol errors */
#include <stdlib.h>
#include <string.h> /* strcmp, ... */
#include <limits.h> /* INT_MAX, ... */

#ifndef RVM_FOR_HARMONY
#include <errno.h>
#endif

uint64_t initialHeapSize; /* Declared in bootImageRunner.h */
uint64_t maximumHeapSize; /* Declared in bootImageRunner.h */

Expand Down
2 changes: 2 additions & 0 deletions tools/bootloader/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,7 @@ extern char *Me;
EXTERNAL void findMappable();
EXTERNAL long long sysNanoTime();
EXTERNAL void sysExit(int) NORETURN;
EXTERNAL void* sysMalloc(int length);
EXTERNAL void sysFree(void *location);

#endif // RVM_SYSCALL_DEFINITIONS
5 changes: 3 additions & 2 deletions tools/bootloader/sysMemory.C
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ EXTERNAL jboolean sysMemoryFree(char *start, size_t length)
SYS_START();
TRACE_PRINTF("%s: sysMemoryFree %p %d\n", Me, start, length);
#ifdef RVM_FOR_HARMONY
if (hyvmem_free_memory(start, length) == 0) {
if (hyvmem_free_memory(start, length, NULL) == 0) {
return JNI_TRUE;
} else {
return JNI_FALSE;
Expand Down Expand Up @@ -376,11 +376,12 @@ EXTERNAL void findMappable()
int granularity = 1 << 22; // every 4 megabytes
int max = (1 << 30) / (granularity >> 2);
int pageSize = sysGetPageSize();
SYS_START();
for (int i=0; i<max; i++) {
char *start = (char *) (i * granularity);
void *result = sysMemoryReserve(start, pageSize, JNI_TRUE, JNI_TRUE, JNI_TRUE, JNI_TRUE);
if (result == NULL) {
CONSOLE_PRINTF("%p FAILED with errno %d: %s\n", start, errno, strerror(errno));
CONSOLE_PRINTF("%p FAILED\n", start);
} else {
CONSOLE_PRINTF("%p SUCCESS\n", start);
sysMemoryFree(start, pageSize);
Expand Down
18 changes: 9 additions & 9 deletions tools/bootloader/sysThread.C
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ EXTERNAL Address sysThreadCreate(Address tr, Address ip, Address fp)
TRACE_PRINTF("%s: sysThreadCreate %p %p %p\n", Me, tr, ip, fp);

// create arguments - memory reclaimed in sysThreadStartup
sysThreadArguments = (Address *)malloc(sizeof(Address[3]));
sysThreadArguments = (Address *)sysMalloc(sizeof(Address[3]));
sysThreadArguments[0] = tr;
sysThreadArguments[1] = ip;
sysThreadArguments[2] = fp;
Expand Down Expand Up @@ -336,7 +336,7 @@ static void* sysThreadStartup(void *args)

SYS_START();
memset (&stack, 0, sizeof stack);
stackBuf = (char*)malloc(sizeof(char[SIGSTKSZ]));
stackBuf = (char*)sysMalloc(sizeof(char[SIGSTKSZ]));
stack.ss_sp = stackBuf;
stack.ss_flags = 0;
stack.ss_size = SIGSTKSZ;
Expand All @@ -348,19 +348,19 @@ static void* sysThreadStartup(void *args)
tr = ((Address *)args)[0];
ip = ((Address *)args)[1];
fp = ((Address *)args)[2];
free(args);
sysFree(args);

jb = (jmp_buf*)malloc(sizeof(jmp_buf));
jb = (jmp_buf*)sysMalloc(sizeof(jmp_buf));
if (setjmp(*jb)) {
// this is where we come to terminate the thread
#ifdef RVM_FOR_HARMONY
hythread_detach(NULL);
#endif
free(jb);
sysFree(jb);
*(int*)(tr + RVMThread_execStatus_offset) = RVMThread_TERMINATED;
stack.ss_flags = SS_DISABLE;
sigaltstack(&stack, 0);
free(stackBuf);
sysFree(stackBuf);
} else {
setThreadLocal(TerminateJmpBufKey, (void*)jb);
TRACE_PRINTF("%s: sysThreadStartup: pr=%p ip=%p fp=%p\n", Me, tr, ip, fp);
Expand Down Expand Up @@ -418,7 +418,7 @@ EXTERNAL void sysSetupHardwareTrapHandler()
stack_t stack;

memset (&stack, 0, sizeof stack);
stack.ss_sp = (char*)malloc(sizeof(char[SIGSTKSZ]));
stack.ss_sp = (char*)sysMalloc(sizeof(char[SIGSTKSZ]));

stack.ss_size = SIGSTKSZ;
if (sigaltstack (&stack, 0)) {
Expand Down Expand Up @@ -582,7 +582,7 @@ EXTERNAL Address sysMonitorCreate()
hythread_monitor_t monitor;
hythread_monitor_init_with_name(&monitor, 0, NULL);
#else
vmmonitor_t *monitor = (vmmonitor_t*)malloc(sizeof(vmmonitor_t));
vmmonitor_t *monitor = (vmmonitor_t*)sysMalloc(sizeof(vmmonitor_t));
pthread_mutex_init(&monitor->mutex, NULL);
pthread_cond_init(&monitor->cond, NULL);
#endif
Expand All @@ -599,7 +599,7 @@ EXTERNAL void sysMonitorDestroy(Address _monitor)
vmmonitor_t *monitor = (vmmonitor_t*)_monitor;
pthread_mutex_destroy(&monitor->mutex);
pthread_cond_destroy(&monitor->cond);
free(monitor);
sysFree(monitor);
#endif
}

Expand Down

0 comments on commit c9ed392

Please sign in to comment.