Various fixes (mostly making things more strict) to get the code to

compile on Mac OS X
This commit is contained in:
Eric Scharff 2007-09-19 10:22:19 -06:00
parent 8b17df5b48
commit f430f3f00e
9 changed files with 37 additions and 16 deletions

View File

@ -1,6 +1,6 @@
#include "stdlib.h"
#include "string.h"
#include "zlib.h"
#include "zlib-custom.h"
#include "jni.h"
#include "jni-util.h"

View File

@ -8,6 +8,19 @@ ifeq ($(arch),i686)
arch = i386
endif
platform = $(shell uname -s)
ifeq ($(platform),Darwin)
rdynamic =
thread-cflags =
shared = -dynamiclib
so-extension = dylib
else
rdynamic = -rdynamic
thread-cflags = -pthread
shared = -shared
so-extension = so
endif
mode = debug
bld = build/$(arch)/$(mode)
@ -16,7 +29,7 @@ src = src
classpath = classpath
test = test
input = $(cls)/GC.class
input = $(cls)/Hello.class
cxx = g++
cc = gcc
@ -30,7 +43,6 @@ show-size = :
warnings = -Wall -Wextra -Werror -Wold-style-cast -Wunused-parameter \
-Winit-self -Wconversion
thread-cflags = -pthread
thread-lflags = -lpthread
cflags = $(warnings) -fPIC -fno-rtti -fno-exceptions -fvisibility=hidden \
@ -63,7 +75,7 @@ stdcpp-objects = $(call cpp-objects,$(stdcpp-sources),$(src))
jni-sources = $(shell find $(classpath) -name '*.cpp')
jni-objects = $(call cpp-objects,$(jni-sources),$(classpath))
jni-cflags = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux $(cflags)
jni-library = $(bld)/libnatives.so
jni-library = $(bld)/libnatives.$(so-extension)
generated-code = \
$(bld)/type-enums.cpp \
@ -213,11 +225,11 @@ $(jni-objects): $(bld)/%.o: $(classpath)/%.cpp
$(jni-library): $(jni-objects)
@echo "linking $(@)"
$(cc) $(lflags) -shared $(^) -o $(@)
$(cc) $(lflags) $(shared) $(^) -o $(@)
$(executable): $(interpreter-objects) $(stdcpp-objects)
@echo "linking $(@)"
$(cc) $(lflags) -rdynamic $(^) -o $(@)
$(cc) $(lflags) $(rdynamic) $(^) -o $(@)
@$(strip) --strip-all $(@)
@$(show-size) $(@)

View File

@ -1,4 +1,3 @@
#include "builtin.h"
#include "machine.h"
#include "constants.h"
#include "run.h"

View File

@ -1,10 +1,10 @@
#include "types.h"
.text
.globl cdeclCall
.type cdeclCall, @function
.globl _cdeclCall
//.type cdeclCall, @function
cdeclCall:
_cdeclCall:
pushl %ebp
movl %esp,%ebp

View File

@ -11,11 +11,14 @@
#ifdef __i386__
# define LD "d"
# define ULD "lu"
# define LLD "lld"
#elif defined __x86_64__
# define LD "ld"
# define ULD "lu"
# define LLD "ld"
# define LLD "ld"
#else
#error "Unsupported architecture"
#endif
#define NO_RETURN __attribute__((noreturn))

View File

@ -1,4 +1,4 @@
#include "zlib.h"
#include "zlib-custom.h"
#include "system.h"
#include "finder.h"

View File

@ -1663,7 +1663,7 @@ inline uint32_t
popInt(Thread* t)
{
if (DebugStack) {
fprintf(stderr, "pop int %"LD" at %d\n",
fprintf(stderr, "pop int %"ULD" at %d\n",
t->stack[((t->sp - 1) * 2) + 1],
t->sp - 1);
}
@ -1721,7 +1721,7 @@ inline uint32_t
peekInt(Thread* t, unsigned index)
{
if (DebugStack) {
fprintf(stderr, "peek int %"LD" at %d\n",
fprintf(stderr, "peek int %"ULD" at %d\n",
t->stack[(index * 2) + 1],
index);
}

View File

@ -25,7 +25,7 @@ cdeclCall(void* function, void* stack, unsigned stackSize,
namespace {
inline uint64_t
dynamicCall(void* function, uint32_t* arguments, uint8_t*,
dynamicCall(void* function, uintptr_t* arguments, uint8_t*,
unsigned, unsigned argumentsSize, unsigned returnType)
{
return cdeclCall(function, arguments, argumentsSize, returnType);
@ -511,7 +511,7 @@ class MySystem: public System {
count -= *up;
if (Verbose) {
fprintf(stderr, "free %"LD"; count: %d; limit: %d\n",
fprintf(stderr, "free %"ULD"; count: %d; limit: %d\n",
*up, count, limit);
}

7
src/zlib-custom.h Normal file
View File

@ -0,0 +1,7 @@
#include "zlib.h"
#ifdef inflateInit2
#undef inflateInit2
#define inflateInit2(strm, windowBits) \
inflateInit2_((strm), (windowBits), ZLIB_VERSION, static_cast<int>(sizeof(z_stream)))
#endif