Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make armv7a Flash work; allow parts of it to compile with iphone-gcc

  • Loading branch information...
commit b6a32db5af0d8339f7e2d736375ebe010b7bf5c3 1 parent 0487131
Mobile User authored
View
12 env.mk
@@ -0,0 +1,12 @@
+ifeq "$(shell arch)" "arm"
+export IPHONE_GCC = 1
+SDK := /var/sdk
+XSTUFF := --sysroot $(SDK)
+GCC := gcc $(XSTUFF)
+GXX := g++ $(XSTUFF)
+else
+export IPHONE_GCC = 0
+SDK := /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhone3.2.sdk/
+GCC := /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 --sysroot $(SDK) -arch armv7
+GXX := /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 --sysroot $(SDK) -arch armv7
+endif
View
25 food/Makefile
@@ -1,21 +1,14 @@
-export SDK := /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/
+include ../env.mk
all: food food_wrapper
-STUFF = -mthumb -Wreturn-type -Wall -DHAVE_MACOSX_IPC -DOS_PATH_SEPARATOR="'/'" -DHAVE_PTHREADS -DHAVE_POSIX_FILEMAP -DHAVE_LITTLE_ENDIAN -I. -I../rpc -I../utils -I../utils/libcutils -isysroot $(SDK) -arch armv7 -ffixed-r9 -Wno-uninitialized -g3 -O2
-DEBUG = 1
-
-#ifeq "$(DEBUG)" "1"
-#STUFF += -g3
-#else
-#STUFF += -O2
-#endif
+STUFF = -mthumb -Wreturn-type -Wall -DHAVE_MACOSX_IPC -DOS_PATH_SEPARATOR="'/'" -DHAVE_PTHREADS -DHAVE_POSIX_FILEMAP -DHAVE_LITTLE_ENDIAN -I. -I../rpc -I../utils -I../utils/libcutils -ffixed-r9 -Wno-uninitialized -g3 -O2
%.o: %.cpp common.h ../rpc/food_rpc1.h
- g++-4.2 $(STUFF) -c -o $@ $<
+ $(GXX) $(STUFF) -c -o $@ $<
%.o: %.c common.h ../rpc/food_rpc1.h
- gcc-4.2 $(STUFF) -c -o $@ $<
+ $(GCC) $(STUFF) -c -o $@ $<
multistuff.c: multistuff.py
python multistuff.py
@@ -24,19 +17,19 @@ multistuff.settings.h: multistuff.py
python multistuff.py
myjni.o: myjni.c multistuff.settings.h
- gcc-4.2 $(STUFF) -c -o $@ $<
+ $(GCC) $(STUFF) -c -o $@ $<
%.o: %.S
- gcc-4.2 $(STUFF) -c -o $@ $<
+ $(GCC) $(STUFF) -c -o $@ $<
-OBJS := food.o np.o anp.o neon.o multistuff.o common.o myjni.o classes.o fixups/cfixups.o fixups/cppfixups.o fixups/rthread.o fixups/sfixups.o
+OBJS := food.o np.o anp.o multistuff.o common.o myjni.o classes.o fixups/cfixups.o fixups/cppfixups.o fixups/rthread.o fixups/sfixups.o neon.o
food: ../rpc/food_rpc1.h $(OBJS)
- g++-4.2 $(STUFF) -o food $(OBJS) ../rpc/food_rpc1.o -F$(SDK)/System/Library/Frameworks -F$(SDK)/System/Library/PrivateFrameworks -framework CoreGraphics -framework IOSurface -framework CoreFoundation -framework CoreText -framework AudioToolbox -framework GraphicsServices -image_base 0x08000000
+ $(GXX) $(STUFF) -o food $(OBJS) ../rpc/food_rpc1.o -F$(SDK)/System/Library/Frameworks -F$(SDK)/System/Library/PrivateFrameworks -framework CoreGraphics -framework IOSurface -framework CoreFoundation -framework CoreText -framework AudioToolbox -framework GraphicsServices -image_base 0x08000000
ldid -S food
food_wrapper: food_wrapper.c
- gcc-4.2 $(STUFF) -o food_wrapper food_wrapper.c
+ $(GCC) $(STUFF) -o food_wrapper food_wrapper.c
clean:
rm -f *.o fixups/*.o food
View
4 food/anp.cpp
@@ -1,9 +1,9 @@
#define ANDROID 1
#include <stdlib.h>
#define IOSFC_BUILDING_IOSFC
-#include <IOSurface/IOSurfaceAPI.h>
-#include <CoreGraphics/CoreGraphics.h>
#include <CoreFoundation/CoreFoundation.h>
+#include <IOSurface/IOSurface.h>
+#include <CoreGraphics/CoreGraphics.h>
#include <jni.h>
#include "npapi.h"
#include "android_npapi.h"
View
37 food/classes.c
@@ -247,23 +247,15 @@ jobject new_fps(jclass cls, va_list v) {
//
+jclass system_impl_loadJavaClass(NPP instance, const char* className);
+
jobject loadClass(jobject obj, va_list v) {
CFStringRef className = g(va_arg(v, jstring), "theString");
- if(CFEqual(className, CFSTR("com.adobe.flashplayer.SystemCapabilities"))) {
- dict sc = named_dict("SystemCapabilities");
- s(sc, "HasTrackBall[(Landroid/content/Context;)Z]", make_a(hasTrackBall));
- s(sc, "GetScreenHRes[(Landroid/content/Context;)I]", make_a(getScreenHRes));
- s(sc, "GetScreenVRes[(Landroid/content/Context;)I]", make_a(getScreenVRes));
- s(sc, "GetBitsPerPixel[(Landroid/content/Context;)I]", make_a(getBitsPerPixel));
- return new_jobject(sc);
- } else if(CFEqual(className, CFSTR("com.adobe.flashplayer.RawConfigResources"))) {
- dict rcr = named_dict("RawConfigResources");
- s(rcr, "GetAssetFileDescriptor[(Landroid/content/Context;Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;]", make_a(getAssetFileDescriptor));
- return new_jobject(rcr);
- }
- notice("loadClass: unknown class");
- CFShow(className);
- _abort();
+ char *cs = malloc(CFStringGetLength(className)+1);
+ assert(CFStringGetCString(className, cs, CFStringGetLength(className)+1, kCFStringEncodingUTF8));
+ jobject ret = system_impl_loadJavaClass(NULL, cs);
+ free(cs);
+ return ret;
}
jobject getClassLoader(jobject obj, va_list v) {
@@ -327,6 +319,8 @@ void init_classes() {
s(context, "getSystemService[(Ljava/lang/String;)Ljava/lang/Object;]", make_a(getSystemService));
s(context, "createPackageContext[(Ljava/lang/String;I)Landroid/content/Context;]", make_v(createPackageContext));
s(context, "getClassLoader[()Ljava/lang/ClassLoader;]", make_v(getClassLoader));
+ android_context = new_jobject(context);
+
dict loader = named_dict("ClassLoader");
s(classes, "java/lang/ClassLoader", loader);
dict afd = named_dict("AssetFileDescriptor");
@@ -346,7 +340,17 @@ void init_classes() {
s(surface, "<init>[(Landroid/content/Context;III)V]", make_v(new_fps));
s(classes, "com/adobe/flashplayer/FlashPaintSurface", surface);
- android_context = new_jobject(context);
+ dict sc = named_dict("SystemCapabilities");
+ s(sc, "HasTrackBall[(Landroid/content/Context;)Z]", make_a(hasTrackBall));
+ s(sc, "GetScreenHRes[(Landroid/content/Context;)I]", make_a(getScreenHRes));
+ s(sc, "GetScreenVRes[(Landroid/content/Context;)I]", make_a(getScreenVRes));
+ s(sc, "GetBitsPerPixel[(Landroid/content/Context;)I]", make_a(getBitsPerPixel));
+ s(classes, "com/adobe/flashplayer/SystemCapabilities", sc);
+
+ dict rcr = named_dict("RawConfigResources");
+ s(rcr, "GetAssetFileDescriptor[(Landroid/content/Context;Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;]", make_a(getAssetFileDescriptor));
+ s(classes, "com/adobe/flashplayer/RawConfigResources", rcr);
+
}
static IOSurfaceRef make_iosurface() {
@@ -382,6 +386,7 @@ void do_jni_surface_created(NPP npp_, jobject j) {
log("do_jni_surface_created");
int npp = typeRefToInt(g(j, "npp"));
dict cls = (dict) g(classes, "com/adobe/flashplayer/FlashPaintSurface");
+ assert(cls);
//jboolean (*nioge)(JNIEnv *, jobject, jint) = RawPtrGet(g(cls, "nativeIsOpenGLEnabled[(I)Z]"));
//jboolean (*nias)(JNIEnv *, jobject, jint) = RawPtrGet(g(cls, "nativeIsARGBSurface[(I)Z]"));
void (*nsc)(JNIEnv *, jobject, jint) = RawPtrGet(g(cls, "nativeSurfaceCreated[(I)V]"));
View
2  food/fixups/cfixups.c
@@ -22,10 +22,12 @@
#define _B 0x80
int32_t __atomic_inc(volatile int32_t* addr) {
+ if(!addr) return 0;
return OSAtomicIncrement32Barrier((int32_t*)addr)-1;
}
int32_t __atomic_dec(volatile int32_t* addr) {
+ if(!addr) return 0;
return OSAtomicDecrement32Barrier((int32_t*)addr)+1;
}
View
8 food/fixups/sfixups.S
@@ -1,6 +1,6 @@
.globl ___aeabi_ldivmod
___aeabi_ldivmod:
- push {r4, r5, r6, r7, r8, lr}
+ stmfd sp!, {r4, r5, r6, r7, r8, lr}
mov r5, r2
mov r6, r3
mov r7, r0
@@ -12,12 +12,12 @@ ___aeabi_ldivmod:
add r4, ip, r4
subs r2, r7, r3
sbc r3, r8, r4
- pop {r4, r5, r6, r7, r8, lr}
+ ldmfd sp!, {r4, r5, r6, r7, r8, lr}
bx lr
.globl ___aeabi_uldivmod
___aeabi_uldivmod:
- push {r4, r5, r6, r7, r8, lr}
+ stmfd sp!, {r4, r5, r6, r7, r8, lr}
mov r5, r2
mov r6, r3
mov r7, r0
@@ -29,6 +29,6 @@ ___aeabi_uldivmod:
add r4, ip, r4
subs r2, r7, r3
sbc r3, r8, r4
- pop {r4, r5, r6, r7, r8, lr}
+ ldmfd sp!, {r4, r5, r6, r7, r8, lr}
bx lr
View
2  food/food.c
@@ -77,7 +77,7 @@ void *stubify(void *addy, const char *id, bool needs_mprotect) {
*base++ = 0xe8bdb005;
*base++ = 0x000083f0;
- *base++ = (uint32_t) abort;
+ *base++ = (uint32_t) printf;
*base++ = (uint32_t) dstr;
*base++ = p;
} else {
View
8 food/myjni.c
@@ -198,8 +198,12 @@ void do_jni_onload() {
extern void do_jni_onload(void *);
notice("calling JNI_OnLoad...");
- jint version = ((jint (*)(JavaVM *, void *)) JNI_OnLoad_ptr)(&vm, NULL);
- notice("do_jni_onload: version = %x", (unsigned int) version);
+ if(JNI_OnLoad_ptr) {
+ jint version = ((jint (*)(JavaVM *, void *)) JNI_OnLoad_ptr)(&vm, NULL);
+ notice("do_jni_onload: version = %x", (unsigned int) version);
+ } else {
+ notice("do_jni_onload: no JNI_OnLoad ...");
+ }
}
View
2  rpc/Makefile
@@ -1,6 +1,6 @@
all:
python PROTOCOLBUFFERS.py food.proto
- gcc-4.2 -arch armv7 -O2 -g3 --sysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/ -Dstream_t=int -c food_rpc[12].c
+ gcc -O2 -g3 --sysroot /var/sdk -Dstream_t=int -c food_rpc[12].c
cp food_rpc2.h food_rpc2.c ../Player2/
clean:
rm *.[cho]
View
7 utils/Makefile
@@ -1,8 +1,9 @@
+include ../env.mk
all: libcutils.dylib libutils.dylib
-STUFF := -DHAVE_MACOSX_IPC -DOS_PATH_SEPARATOR="'/'" -DHAVE_PTHREADS -DHAVE_POSIX_FILEMAP -DHAVE_LITTLE_ENDIAN -I. -Ilibcutils -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/ -arch armv7
+STUFF := -DHAVE_MACOSX_IPC -DOS_PATH_SEPARATOR="'/'" -DHAVE_PTHREADS -DHAVE_POSIX_FILEMAP -DHAVE_LITTLE_ENDIAN -I. -Ilibcutils
libcutils.dylib:
- gcc-4.2 $(STUFF) -dynamiclib -o libcutils.dylib libcutils/*.c
+ $(GCC) $(STUFF) -dynamiclib -o libcutils.dylib libcutils/*.c
libutils.dylib:
- g++-4.2 $(STUFF) -dynamiclib -o libutils.dylib utils/* -L. -lcutils -lz
+ $(GXX) $(STUFF) -dynamiclib -o libutils.dylib utils/* -L. -lcutils -lz
clean:
rm -f libutils.dylib libcutils.dylib
View
2  utils/libcutils/atomic.c
@@ -34,10 +34,12 @@ void android_atomic_write(int32_t value, volatile int32_t* addr) {
}
int32_t android_atomic_inc(volatile int32_t* addr) {
+ if(!addr) return 1;
return OSAtomicIncrement32Barrier((int32_t*)addr)-1;
}
int32_t android_atomic_dec(volatile int32_t* addr) {
+ if(!addr) return 1;
return OSAtomicDecrement32Barrier((int32_t*)addr)+1;
}
View
2  utils/utils/RefBase.cpp
@@ -281,6 +281,7 @@ class RefBase::weakref_impl : public RefBase::weakref_type
void RefBase::incStrong(const void* id) const
{
weakref_impl* const refs = mRefs;
+ if(!id || !refs) return;
refs->addWeakRef(id);
refs->incWeak(id);
@@ -301,6 +302,7 @@ void RefBase::incStrong(const void* id) const
void RefBase::decStrong(const void* id) const
{
weakref_impl* const refs = mRefs;
+ if(!id || !refs) return;
refs->removeStrongRef(id);
const int32_t c = android_atomic_dec(&refs->mStrong);
#if PRINT_REFS
Please sign in to comment.
Something went wrong with that request. Please try again.