Browse Source

Added support for multiple android archs.

Mark Sibly 8 years ago
parent
commit
50e9a1ade0
33 changed files with 1421 additions and 53 deletions
  1. 3 0
      bin/env_windows.txt
  2. BIN
      bin/mx2cc_windows.exe
  3. BIN
      modules/openal/openal-soft/jniLibs/arm64-v8a/libopenal.so
  4. BIN
      modules/openal/openal-soft/jniLibs/armeabi/libopenal.so
  5. BIN
      modules/openal/openal-soft/jniLibs/mips/libopenal.so
  6. BIN
      modules/openal/openal-soft/jniLibs/mips64/libopenal.so
  7. BIN
      modules/openal/openal-soft/jniLibs/x86/libopenal.so
  8. BIN
      modules/openal/openal-soft/jniLibs/x86_64/libopenal.so
  9. 24 23
      modules/openal/openal.monkey2
  10. 8 2
      modules/std/fiber/fcontext.monkey2
  11. 58 0
      modules/std/fiber/native/asm/android-arm/jump.S
  12. 62 0
      modules/std/fiber/native/asm/android-arm/make.S
  13. 63 0
      modules/std/fiber/native/asm/android-arm/ontop.S
  14. 88 0
      modules/std/fiber/native/asm/android-arm64/jump.S
  15. 71 0
      modules/std/fiber/native/asm/android-arm64/make.S
  16. 87 0
      modules/std/fiber/native/asm/android-arm64/ontop.S
  17. 86 0
      modules/std/fiber/native/asm/android-mips/jump.S
  18. 86 0
      modules/std/fiber/native/asm/android-mips/make.S
  19. 87 0
      modules/std/fiber/native/asm/android-mips/ontop.S
  20. 86 0
      modules/std/fiber/native/asm/android-mips64/jump.S
  21. 86 0
      modules/std/fiber/native/asm/android-mips64/make.S
  22. 87 0
      modules/std/fiber/native/asm/android-mips64/ontop.S
  23. 59 0
      modules/std/fiber/native/asm/android-x86/jump.S
  24. 94 0
      modules/std/fiber/native/asm/android-x86/make.S
  25. 61 0
      modules/std/fiber/native/asm/android-x86/ontop.S
  26. 67 0
      modules/std/fiber/native/asm/android-x86_64/jump.S
  27. 62 0
      modules/std/fiber/native/asm/android-x86_64/make.S
  28. 69 0
      modules/std/fiber/native/asm/android-x86_64/ontop.S
  29. 3 4
      src/mx2cc/builder.monkey2
  30. 2 7
      src/mx2cc/buildproduct.monkey2
  31. 3 3
      src/mx2cc/mx2cc.monkey2
  32. 17 12
      src/mx2cc/test.monkey2
  33. 2 2
      src/mx2cc/util.monkey2

+ 3 - 0
bin/env_windows.txt

@@ -73,6 +73,9 @@ MX2_CPP_OPTS_EMSCRIPTEN_RELEASE=-O3
 
 'PATH=D:\devtools\Android\sdk\ndk-bundle;${PATH}
 
+'Uncomment below to build for ALL android architectures (slow). Defaults to armeabi-v7a.
+MX2_ANDROID_APP_ABI=armeabi-v7a x86
+'MX2_ANDROID_APP_ABI=all
 
 '***** RASPBIAN *****
 

BIN
bin/mx2cc_windows.exe


BIN
modules/openal/openal-soft/jniLibs/arm64-v8a/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/armeabi/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/mips/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/mips64/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/x86/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/x86_64/libopenal.so


+ 24 - 23
modules/openal/openal.monkey2

@@ -1,45 +1,46 @@
 
-#import "<libc>"
+#Import "<libc>"
 
 #if __TARGET__="windows"
 
-	#import "openal-soft/bin/OpenAL32.dll"
-	#import "openal-soft/lib/OpenAL32.lib"
+	#Import "openal-soft/bin/OpenAL32.dll"
+	#Import "openal-soft/lib/OpenAL32.lib"
 		
-	#import "openal-soft/include/*.h"
-	#import "<AL/al.h>"
-	#import "<AL/alc.h>"
+	#Import "openal-soft/include/*.h"
+	#Import "<AL/al.h>"
+	#Import "<AL/alc.h>"
 	
 #else if __TARGET__="macos"
 	
-	#import "<OpenAL.framework>"
+	#Import "<OpenAL.framework>"
 		
-	#import "<OpenAL/al.h>"
-	#import "<OpenAL/alc.h>"
+	#Import "<OpenAL/al.h>"
+	#Import "<OpenAL/alc.h>"
 		
 #else if __TARGET__="linux" or __TARGET__="raspbian"
 	
-	#import "<libopenal.a>"
-	#import "<AL/al.h>"
-	#import "<AL/alc.h>"
+	#Import "<libopenal.a>"
 	
-#else if __TARGET__="emscripten"
-
-	#import "<AL/al.h>"
-	#import "<AL/alc.h>"
+	#Import "<AL/al.h>"
+	#Import "<AL/alc.h>"
+	
+#Else if __TARGET__="emscripten"
 
-#else if __TARGET__="android"
+	#Import "<AL/al.h>"
+	#Import "<AL/alc.h>"
 
-	#Import "openal-soft/jniLibs/armeabi-v7a/libopenal.so"
+#Else if __TARGET__="android"
+	
+	#Import "openal-soft/jniLibs/$(TARGET_ARCH_ABI)/libopenal.so"
 
-	#import "openal-soft/include/*.h"
-	#import "<AL/al.h>"
-	#import "<AL/alc.h>"
+	#Import "openal-soft/include/*.h"
+	#Import "<AL/al.h>"
+	#Import "<AL/alc.h>"
 	
 #else if __TARGET__="ios"
 
-	#import "<OpenAL/al.h>"
-	#import "<OpenAL/alc.h>"
+	#Import "<OpenAL/al.h>"
+	#Import "<OpenAL/alc.h>"
 
 #endif
 		

+ 8 - 2
modules/std/fiber/fcontext.monkey2

@@ -26,12 +26,18 @@ Namespace std.fiber
 	#import "native/asm/jump_x86_64_sysv_elf_gas.S"
 	#import "native/asm/ontop_x86_64_sysv_elf_gas.S"
 	
-#Else If __TARGET__="android" or __TARGET__="raspbian"
+#Else If __TARGET__="android"
+ 
+	#Import "native/asm/android-$(TARGET_ARCH)/make.S"
+	#Import "native/asm/android-$(TARGET_ARCH)/jump.S"
+	#Import "native/asm/android-$(TARGET_ARCH)/ontop.S"
+
+#Else If __TARGET__="raspbian"
 
 	#import "native/asm/make_arm_aapcs_elf_gas.S"
 	#import "native/asm/jump_arm_aapcs_elf_gas.S"
 	#import "native/asm/ontop_arm_aapcs_elf_gas.S"
-
+	
 #Else If __TARGET__="ios"
 
 	#import "native/asm/make_arm_aapcs_macho_gas.S"

+ 58 - 0
modules/std/fiber/native/asm/android-arm/jump.S

@@ -0,0 +1,58 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |hiddn|  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |  v8 |  lr |  pc | FCTX| DATA|                 |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,%function
+jump_fcontext:
+    @ save LR as PC
+    push {lr}
+    @ save hidden,V1-V8,LR
+    push {a1,v1-v8,lr}
+
+    @ store RSP (pointing to context-data) in A1
+    mov  a1, sp
+
+    @ restore RSP (pointing to context-data) from A2
+    mov  sp, a2
+
+    @ restore hidden,V1-V8,LR
+    pop {a4,v1-v8,lr}
+
+    @ return transfer_t from jump
+    str  a1, [a4, #0]
+    str  a3, [a4, #4]
+    @ pass transfer_t as first arg in context function
+    @ A1 == FCTX, A2 == DATA
+    mov  a2, a3
+
+    @ restore PC
+    pop {pc}
+.size jump_fcontext,.-jump_fcontext
+
+@ Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 62 - 0
modules/std/fiber/native/asm/android-arm/make.S

@@ -0,0 +1,62 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |hiddn|  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |  v8 |  lr |  pc | FCTX| DATA|                 |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,%function
+make_fcontext:
+    @ shift address in A1 to lower 16 byte boundary
+    bic  a1, a1, #15
+
+    @ reserve space for context-data on context-stack
+    sub  a1, a1, #60
+
+    @ third arg of make_fcontext() == address of context-function
+    str  a3, [a1, #40]
+
+    @ compute address of returned transfer_t
+    add  a2, a1, #44
+    mov  a3, a2
+    str  a3, [a1, #0]
+
+    @ compute abs address of label finish
+    adr  a2, finish
+    @ save address of finish as return-address for context-function
+    @ will be entered after context-function returns
+    str  a2, [a1, #36]
+
+    bx  lr @ return pointer to context-data
+
+finish:
+    @ exit code is zero
+    mov  a1, #0
+    @ exit application
+    bl  _exit@PLT
+.size make_fcontext,.-make_fcontext
+
+@ Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 63 - 0
modules/std/fiber/native/asm/android-arm/ontop.S

@@ -0,0 +1,63 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |hiddn|  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |  v8 |  lr |  pc | FCTX| DATA|                 |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+.text
+.globl ontop_fcontext
+.align 2
+.type ontop_fcontext,%function
+ontop_fcontext:
+    @ save LR as PC
+    push {lr}
+    @ save hidden,V1-V8,LR
+    push {a1,v1-v8,lr}
+
+    @ store RSP (pointing to context-data) in A1
+    mov  a1, sp
+
+    @ restore RSP (pointing to context-data) from A2
+    mov  sp, a2
+
+    @ store parent context in A2
+    mov  a2, a1
+
+    @ restore hidden,V1-V8,LR
+    pop {a1,v1-v8,lr}
+
+    @ return transfer_t from jump
+    str  a2, [a1, #0]
+    str  a3, [a1, #4]
+    @ pass transfer_t as first arg in context function
+    @ A1 == hidden, A2 == FCTX, A3 == DATA
+
+    @ skip PC
+    add  sp, sp, #4
+
+    @ jump to ontop-function
+    bx  a4
+.size ontop_fcontext,.-ontop_fcontext
+
+@ Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 88 - 0
modules/std/fiber/native/asm/android-arm64/jump.S

@@ -0,0 +1,88 @@
+/*
+            Copyright Edward Nevill + Oliver Kowalke 2015
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |    x19    |    x20    |    x21    |    x22    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |    x23    |    x24    |    x25    |    x26    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  16 |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  *
+ *  -------------------------------------------------  *
+ *  | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c|  *
+ *  -------------------------------------------------  *
+ *  |    x27    |    x28    |    FP     |     LR    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  *
+ *  -------------------------------------------------  *
+ *  | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c|  *
+ *  -------------------------------------------------  *
+ *  |     PC    |   align   |           |           |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+# .cpu    generic+fp+simd
+.text
+.align  2
+.global jump_fcontext
+.type   jump_fcontext, %function
+jump_fcontext:
+    # prepare stack for GP + FPU
+    sub  sp, sp, #0x70
+
+    # save x19-x30
+    stp  x19, x20, [sp, #0x00]
+    stp  x21, x22, [sp, #0x10]
+    stp  x23, x24, [sp, #0x20]
+    stp  x25, x26, [sp, #0x30]
+    stp  x27, x28, [sp, #0x40]
+    stp  x29, x30, [sp, #0x50]
+
+    # save LR as PC
+    str  x30, [sp, #0x60]
+
+    # store RSP (pointing to context-data) in X0
+    mov  x4, sp
+
+    # restore RSP (pointing to context-data) from X1
+    mov  sp, x0
+
+    # load x19-x30
+    ldp  x19, x20, [sp, #0x00]
+    ldp  x21, x22, [sp, #0x10]
+    ldp  x23, x24, [sp, #0x20]
+    ldp  x25, x26, [sp, #0x30]
+    ldp  x27, x28, [sp, #0x40]
+    ldp  x29, x30, [sp, #0x50]
+
+    # return transfer_t from jump
+    # pass transfer_t as first arg in context function
+    # X0 == FCTX, X1 == DATA
+    mov x0, x4
+
+    # load pc
+    ldr  x4, [sp, #0x60]
+
+    # restore stack from GP + FPU
+    add  sp, sp, #0x70
+
+    ret x4
+.size   jump_fcontext,.-jump_fcontext
+# Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 71 - 0
modules/std/fiber/native/asm/android-arm64/make.S

@@ -0,0 +1,71 @@
+/*
+            Copyright Edward Nevill + Oliver Kowalke 2015
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |    x19    |    x20    |    x21    |    x22    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |    x23    |    x24    |    x25    |    x26    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  16 |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  *
+ *  -------------------------------------------------  *
+ *  | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c|  *
+ *  -------------------------------------------------  *
+ *  |    x27    |    x28    |    FP     |     LR    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  *
+ *  -------------------------------------------------  *
+ *  | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c|  *
+ *  -------------------------------------------------  *
+ *  |     PC    |   align   |           |           |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+# .cpu    generic+fp+simd
+.text
+.align  2
+.global make_fcontext
+.type   make_fcontext, %function
+make_fcontext:
+    # shift address in x0 (allocated stack) to lower 16 byte boundary
+    and x0, x0, ~0xF
+
+    # reserve space for context-data on context-stack
+    sub  x0, x0, #0x70
+
+    # third arg of make_fcontext() == address of context-function
+    # store address as a PC to jump in
+    str  x2, [x0, #0x60]
+
+    # save address of finish as return-address for context-function
+    # will be entered after context-function returns (LR register)
+    adr  x1, finish
+    str  x1, [x0, #0x58]
+
+    ret  x30 // return pointer to context-data (x0)
+
+finish:
+    # exit code is zero
+    mov  x0, #0
+    # exit application
+    bl  _exit
+
+.size   make_fcontext,.-make_fcontext
+# Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 87 - 0
modules/std/fiber/native/asm/android-arm64/ontop.S

@@ -0,0 +1,87 @@
+/*
+            Copyright Edward Nevill + Oliver Kowalke 2015
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |    x19    |    x20    |    x21    |    x22    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |    x23    |    x24    |    x25    |    x26    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  16 |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  *
+ *  -------------------------------------------------  *
+ *  | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c|  *
+ *  -------------------------------------------------  *
+ *  |    x27    |    x28    |    FP     |     LR    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  *
+ *  -------------------------------------------------  *
+ *  | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c|  *
+ *  -------------------------------------------------  *
+ *  |     PC    |   align   |           |           |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+# .cpu    generic+fp+simd
+.text
+.align  2
+.global ontop_fcontext
+.type   ontop_fcontext, %function
+ontop_fcontext:
+    # prepare stack for GP + FPU
+    sub  sp, sp, #0x70
+
+    # save x19-x30
+    stp  x19, x20, [sp, #0x00]
+    stp  x21, x22, [sp, #0x10]
+    stp  x23, x24, [sp, #0x20]
+    stp  x25, x26, [sp, #0x30]
+    stp  x27, x28, [sp, #0x40]
+    stp  x29, x30, [sp, #0x50]
+
+    # save LR as PC
+    str  x30, [sp, #0x60]
+
+    # store RSP (pointing to context-data) in X5
+    mov  x4, sp
+
+    # restore RSP (pointing to context-data) from X1
+    mov  sp, x0
+
+    # load x19-x30
+    ldp  x19, x20, [sp, #0x00]
+    ldp  x21, x22, [sp, #0x10]
+    ldp  x23, x24, [sp, #0x20]
+    ldp  x25, x26, [sp, #0x30]
+    ldp  x27, x28, [sp, #0x40]
+    ldp  x29, x30, [sp, #0x50]
+
+    # return transfer_t from jump
+    # pass transfer_t as first arg in context function
+    # X0 == FCTX, X1 == DATA
+    mov x0, x4
+
+    # skip pc
+    # restore stack from GP + FPU
+    add  sp, sp, #0x70
+
+    # jump to ontop-function
+    ret x2
+.size   ontop_fcontext,.-ontop_fcontext
+# Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 86 - 0
modules/std/fiber/native/asm/android-mips/jump.S

@@ -0,0 +1,86 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,@function
+.ent jump_fcontext
+jump_fcontext:
+    # reserve space on stack
+    addiu $sp, $sp, -112
+
+    sw  $s0, ($sp)  # save S0
+    sw  $s1, 4($sp)  # save S1
+    sw  $s2, 8($sp)  # save S2
+    sw  $s3, 12($sp)  # save S3
+    sw  $s4, 16($sp)  # save S4
+    sw  $s5, 20($sp)  # save S5
+    sw  $s6, 24($sp)  # save S6
+    sw  $s7, 28($sp)  # save S7
+    sw  $fp, 32($sp)  # save FP
+    sw  $a0, 36($sp)  # save hidden, address of returned transfer_t
+    sw  $ra, 40($sp)  # save RA
+    sw  $ra, 44($sp)  # save RA as PC
+
+    # store SP (pointing to context-data) in A0
+    move  $a0, $sp
+
+    # restore SP (pointing to context-data) from A1
+    move  $sp, $a1
+
+    lw  $s0, ($sp)  # restore S0
+    lw  $s1, 4($sp)  # restore S1
+    lw  $s2, 8($sp)  # restore S2
+    lw  $s3, 12($sp)  # restore S3
+    lw  $s4, 16($sp)  # restore S4
+    lw  $s5, 20($sp)  # restore S5
+    lw  $s6, 24($sp)  # restore S6
+    lw  $s7, 28($sp)  # restore S7
+    lw  $fp, 32($sp)  # restore FP
+    lw  $t0, 36($sp)  # restore hidden, address of returned transfer_t
+    lw  $ra, 40($sp)  # restore RA
+
+    # load PC
+    lw  $t9, 44($sp)
+
+    # adjust stack
+    addiu $sp, $sp, 112
+    
+    # return transfer_t from jump
+    sw  $a0, ($t0)  # fctx of transfer_t
+    sw  $a1, 4($t0) # data of transfer_t
+    # pass transfer_t as first arg in context function
+    # A0 == fctx, A1 == data
+    move  $a1, $a2 
+
+    # jump to context
+    jr  $t9
+.end jump_fcontext
+.size jump_fcontext, .-jump_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 86 - 0
modules/std/fiber/native/asm/android-mips/make.S

@@ -0,0 +1,86 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+.ent make_fcontext
+make_fcontext:
+#ifdef __PIC__
+.set    noreorder
+.cpload $t9
+.set    reorder
+#endif
+    # first arg of make_fcontext() == top address of context-stack
+    move $v0, $a0
+
+    # shift address in A0 to lower 16 byte boundary
+    move $v1, $v0
+    li $v0, -16 # 0xfffffffffffffff0
+    and $v0, $v1, $v0
+
+    # reserve space for context-data on context-stack
+    # including 48 byte of shadow space (sp % 16 == 0)
+    addiu $v0, $v0, -112
+
+    # third arg of make_fcontext() == address of context-function
+    sw  $a2, 44($v0)
+    # save global pointer in context-data
+    sw  $gp, 48($v0)
+
+    # compute address of returned transfer_t
+    addiu $t0, $v0, 52
+    sw  $t0, 36($v0)
+
+    # compute abs address of label finish
+    la  $t9, finish
+    # save address of finish as return-address for context-function
+    # will be entered after context-function returns
+    sw  $t9, 40($v0)
+
+    jr  $ra # return pointer to context-data
+
+finish:
+    lw $gp, 0($sp)
+    # allocate stack space (contains shadow space for subroutines)
+    addiu  $sp, $sp, -32
+    # save return address
+    sw  $ra, 28($sp)
+
+    # restore GP (global pointer)
+#    move  $gp, $s1
+    # exit code is zero
+    move  $a0, $zero
+    # address of exit
+    lw  $t9, %call16(_exit)($gp)
+    # exit application
+    jalr  $t9
+.end make_fcontext
+.size make_fcontext, .-make_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 87 - 0
modules/std/fiber/native/asm/android-mips/ontop.S

@@ -0,0 +1,87 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl ontop_fcontext
+.align 2
+.type ontop_fcontext,@function
+.ent ontop_fcontext
+ontop_fcontext:
+    # reserve space on stack
+    addiu $sp, $sp, -112
+
+    sw  $s0, ($sp)  # save S0
+    sw  $s1, 4($sp)  # save S1
+    sw  $s2, 8($sp)  # save S2
+    sw  $s3, 12($sp)  # save S3
+    sw  $s4, 16($sp)  # save S4
+    sw  $s5, 20($sp)  # save S5
+    sw  $s6, 24($sp)  # save S6
+    sw  $s7, 28($sp)  # save S7
+    sw  $fp, 32($sp)  # save FP
+    sw  $a0, 36($sp)  # save hidden, address of returned transfer_t
+    sw  $ra, 40($sp)  # save RA
+    sw  $ra, 44($sp)  # save RA as PC
+
+    # store SP (pointing to context-data) in A0
+    move  $a0, $sp
+
+    # restore SP (pointing to context-data) from A1
+    move  $sp, $a1
+
+    lw  $s0, ($sp)  # restore S0
+    lw  $s1, 4($sp)  # restore S1
+    lw  $s2, 8($sp)  # restore S2
+    lw  $s3, 12($sp)  # restore S3
+    lw  $s4, 16($sp)  # restore S4
+    lw  $s5, 20($sp)  # restore S5
+    lw  $s6, 24($sp)  # restore S6
+    lw  $s7, 28($sp)  # restore S7
+    lw  $fp, 32($sp)  # restore FP
+    lw  $t0, 36($sp)  # restore hidden, address of returned transfer_t
+    lw  $ra, 40($sp)  # restore RA
+
+    # load PC
+    lw  $t9, 44($sp)
+
+    # adjust stack
+    addiu $sp, $sp, 112
+    
+    # return transfer_t from jump
+    sw  $a0, ($t0)  # fctx of transfer_t
+    sw  $a2, 4($t0) # data of transfer_t
+    # pass transfer_t as first arg in context function
+    # A0 == hidden, A1 == fctx, A2 == data
+    move  $a1, $a0 
+    move  $a0, $t0 
+
+    # jump to context
+    jr  $a3
+.end ontop_fcontext
+.size ontop_fcontext, .-ontop_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 86 - 0
modules/std/fiber/native/asm/android-mips64/jump.S

@@ -0,0 +1,86 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,@function
+.ent jump_fcontext
+jump_fcontext:
+    # reserve space on stack
+    addiu $sp, $sp, -112
+
+    sw  $s0, ($sp)  # save S0
+    sw  $s1, 4($sp)  # save S1
+    sw  $s2, 8($sp)  # save S2
+    sw  $s3, 12($sp)  # save S3
+    sw  $s4, 16($sp)  # save S4
+    sw  $s5, 20($sp)  # save S5
+    sw  $s6, 24($sp)  # save S6
+    sw  $s7, 28($sp)  # save S7
+    sw  $fp, 32($sp)  # save FP
+    sw  $a0, 36($sp)  # save hidden, address of returned transfer_t
+    sw  $ra, 40($sp)  # save RA
+    sw  $ra, 44($sp)  # save RA as PC
+
+    # store SP (pointing to context-data) in A0
+    move  $a0, $sp
+
+    # restore SP (pointing to context-data) from A1
+    move  $sp, $a1
+
+    lw  $s0, ($sp)  # restore S0
+    lw  $s1, 4($sp)  # restore S1
+    lw  $s2, 8($sp)  # restore S2
+    lw  $s3, 12($sp)  # restore S3
+    lw  $s4, 16($sp)  # restore S4
+    lw  $s5, 20($sp)  # restore S5
+    lw  $s6, 24($sp)  # restore S6
+    lw  $s7, 28($sp)  # restore S7
+    lw  $fp, 32($sp)  # restore FP
+    lw  $t0, 36($sp)  # restore hidden, address of returned transfer_t
+    lw  $ra, 40($sp)  # restore RA
+
+    # load PC
+    lw  $t9, 44($sp)
+
+    # adjust stack
+    addiu $sp, $sp, 112
+    
+    # return transfer_t from jump
+    sw  $a0, ($t0)  # fctx of transfer_t
+    sw  $a1, 4($t0) # data of transfer_t
+    # pass transfer_t as first arg in context function
+    # A0 == fctx, A1 == data
+    move  $a1, $a2 
+
+    # jump to context
+    jr  $t9
+.end jump_fcontext
+.size jump_fcontext, .-jump_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 86 - 0
modules/std/fiber/native/asm/android-mips64/make.S

@@ -0,0 +1,86 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+.ent make_fcontext
+make_fcontext:
+#ifdef __PIC__
+.set    noreorder
+.cpload $t9
+.set    reorder
+#endif
+    # first arg of make_fcontext() == top address of context-stack
+    move $v0, $a0
+
+    # shift address in A0 to lower 16 byte boundary
+    move $v1, $v0
+    li $v0, -16 # 0xfffffffffffffff0
+    and $v0, $v1, $v0
+
+    # reserve space for context-data on context-stack
+    # including 48 byte of shadow space (sp % 16 == 0)
+    addiu $v0, $v0, -112
+
+    # third arg of make_fcontext() == address of context-function
+    sw  $a2, 44($v0)
+    # save global pointer in context-data
+    sw  $gp, 48($v0)
+
+    # compute address of returned transfer_t
+    addiu $t0, $v0, 52
+    sw  $t0, 36($v0)
+
+    # compute abs address of label finish
+    la  $t9, finish
+    # save address of finish as return-address for context-function
+    # will be entered after context-function returns
+    sw  $t9, 40($v0)
+
+    jr  $ra # return pointer to context-data
+
+finish:
+    lw $gp, 0($sp)
+    # allocate stack space (contains shadow space for subroutines)
+    addiu  $sp, $sp, -32
+    # save return address
+    sw  $ra, 28($sp)
+
+    # restore GP (global pointer)
+#    move  $gp, $s1
+    # exit code is zero
+    move  $a0, $zero
+    # address of exit
+    lw  $t9, %call16(_exit)($gp)
+    # exit application
+    jalr  $t9
+.end make_fcontext
+.size make_fcontext, .-make_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 87 - 0
modules/std/fiber/native/asm/android-mips64/ontop.S

@@ -0,0 +1,87 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl ontop_fcontext
+.align 2
+.type ontop_fcontext,@function
+.ent ontop_fcontext
+ontop_fcontext:
+    # reserve space on stack
+    addiu $sp, $sp, -112
+
+    sw  $s0, ($sp)  # save S0
+    sw  $s1, 4($sp)  # save S1
+    sw  $s2, 8($sp)  # save S2
+    sw  $s3, 12($sp)  # save S3
+    sw  $s4, 16($sp)  # save S4
+    sw  $s5, 20($sp)  # save S5
+    sw  $s6, 24($sp)  # save S6
+    sw  $s7, 28($sp)  # save S7
+    sw  $fp, 32($sp)  # save FP
+    sw  $a0, 36($sp)  # save hidden, address of returned transfer_t
+    sw  $ra, 40($sp)  # save RA
+    sw  $ra, 44($sp)  # save RA as PC
+
+    # store SP (pointing to context-data) in A0
+    move  $a0, $sp
+
+    # restore SP (pointing to context-data) from A1
+    move  $sp, $a1
+
+    lw  $s0, ($sp)  # restore S0
+    lw  $s1, 4($sp)  # restore S1
+    lw  $s2, 8($sp)  # restore S2
+    lw  $s3, 12($sp)  # restore S3
+    lw  $s4, 16($sp)  # restore S4
+    lw  $s5, 20($sp)  # restore S5
+    lw  $s6, 24($sp)  # restore S6
+    lw  $s7, 28($sp)  # restore S7
+    lw  $fp, 32($sp)  # restore FP
+    lw  $t0, 36($sp)  # restore hidden, address of returned transfer_t
+    lw  $ra, 40($sp)  # restore RA
+
+    # load PC
+    lw  $t9, 44($sp)
+
+    # adjust stack
+    addiu $sp, $sp, 112
+    
+    # return transfer_t from jump
+    sw  $a0, ($t0)  # fctx of transfer_t
+    sw  $a2, 4($t0) # data of transfer_t
+    # pass transfer_t as first arg in context function
+    # A0 == hidden, A1 == fctx, A2 == data
+    move  $a1, $a0 
+    move  $a0, $t0 
+
+    # jump to context
+    jr  $a3
+.end ontop_fcontext
+.size ontop_fcontext, .-ontop_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 59 - 0
modules/std/fiber/native/asm/android-x86/jump.S

@@ -0,0 +1,59 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*****************************************************************************************
+ *                                                                                       *
+ *  -----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6     |    7    |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18   |   0x1c  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   EDI   |   ESI   |   EBX   |   EBP   |   EIP    |  hidden |    to    |   data  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *                                                                                       *
+ *****************************************************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,@function
+jump_fcontext:
+    pushl  %ebp  /* save EBP */
+    pushl  %ebx  /* save EBX */
+    pushl  %esi  /* save ESI */
+    pushl  %edi  /* save EDI */
+
+    /* store fcontext_t in ECX */
+    movl  %esp, %ecx
+
+    /* first arg of jump_fcontext() == fcontext to jump to */
+    movl  0x18(%esp), %eax
+
+    /* second arg of jump_fcontext() == data to be transferred */
+    movl  0x1c(%esp), %edx
+
+    /* restore ESP (pointing to context-data) from EAX */
+    movl  %eax, %esp
+
+    /* address of returned transport_t */
+    movl 0x14(%esp), %eax
+    /* return parent fcontext_t */
+    movl  %ecx, (%eax)
+    /* return data */
+    movl %edx, 0x4(%eax)
+
+    popl  %edi  /* restore EDI */
+    popl  %esi  /* restore ESI */
+    popl  %ebx  /* restore EBX */
+    popl  %ebp  /* restore EBP */
+
+    /* jump to context */
+    ret $4
+.size jump_fcontext,.-jump_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 94 - 0
modules/std/fiber/native/asm/android-x86/make.S

@@ -0,0 +1,94 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*****************************************************************************************
+ *                                                                                       *
+ *  -----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6     |    7    |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18   |   0x1c  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   EDI   |   ESI   |   EBX   |   EBP   |   EIP    |  hidden |    to    |   data  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *                                                                                       *
+ *****************************************************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+make_fcontext:
+    /* first arg of make_fcontext() == top of context-stack */
+    movl  0x4(%esp), %eax
+
+    /* reserve space for first argument of context-function
+       rax might already point to a 16byte border */
+    leal  -0x8(%eax), %eax
+
+    /* shift address in EAX to lower 16 byte boundary */
+    andl  $-16, %eax
+
+    /* reserve space for context-data on context-stack */
+    leal  -0x28(%eax), %eax
+
+    /* third arg of make_fcontext() == address of context-function */
+    /* stored in EBX */
+    movl  0xc(%esp), %ecx
+    movl  %ecx, 0x8(%eax)
+
+    /* return transport_t */
+    /* FCTX == EDI, DATA == ESI */
+    leal  (%eax), %ecx
+    movl  %ecx, 0x14(%eax)
+
+    /* compute abs address of label trampoline */
+    call  1f
+    /* address of trampoline 1 */
+1:  popl  %ecx
+    /* compute abs address of label trampoline */
+    addl  $trampoline-1b, %ecx
+    /* save address of trampoline as return address */
+    /* will be entered after calling jump_fcontext() first time */
+    movl  %ecx, 0x10(%eax)
+
+    /* compute abs address of label finish */
+    call  2f
+    /* address of label 2 */
+2:  popl  %ecx
+    /* compute abs address of label finish */
+    addl  $finish-2b, %ecx
+    /* save address of finish as return-address for context-function */
+    /* will be entered after context-function returns */
+    movl  %ecx, 0xc(%eax) 
+
+    ret /* return pointer to context-data */
+
+trampoline:
+    /* move transport_t for entering context-function */
+    movl  %edi, (%esp)
+    movl  %esi, 0x4(%esp)
+    pushl %ebp
+    /* jump to context-function */
+    jmp *%ebx
+
+finish:
+    call  3f
+    /* address of label 3 */
+3:  popl  %ebx
+    /* compute address of GOT and store it in EBX */
+    addl  $_GLOBAL_OFFSET_TABLE_+[.-3b], %ebx
+
+    /* exit code is zero */
+    xorl  %eax, %eax
+    movl  %eax, (%esp)
+    /* exit application */
+    call  _exit@PLT
+    hlt
+.size make_fcontext,.-make_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 61 - 0
modules/std/fiber/native/asm/android-x86/ontop.S

@@ -0,0 +1,61 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*****************************************************************************************
+ *                                                                                       *
+ *  -----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6     |    7    |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18   |   0x1c  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   EDI   |   ESI   |   EBX   |   EBP   |   EIP    |  hidden |    to    |   data  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *                                                                                       *
+ *****************************************************************************************/
+
+.text
+.globl ontop_fcontext
+.align 2
+.type ontop_fcontext,@function
+ontop_fcontext:
+    pushl  %ebp  /* save EBP */
+    pushl  %ebx  /* save EBX */
+    pushl  %esi  /* save ESI */
+    pushl  %edi  /* save EDI */
+
+    /* store fcontext_t in ECX */
+    movl  %esp, %ecx
+
+    /* first arg of ontop_fcontext() == fcontext to jump to */
+    movl  0x18(%esp), %eax
+
+    /* pass parent fcontext_t */
+    movl  %ecx, 0x18(%eax)
+
+    /* second arg of ontop_fcontext() == data to be transferred */
+    movl  0x1c(%esp), %ecx
+
+    /* pass data */
+    movl %ecx, 0x1c(%eax)
+
+    /* third arg of ontop_fcontext() == ontop-function */
+    movl  0x20(%esp), %ecx
+
+    /* restore ESP (pointing to context-data) from EDX */
+    movl  %eax, %esp
+
+    popl  %edi  /* restore EDI */
+    popl  %esi  /* restore ESI */
+    popl  %ebx  /* restore EBX */
+    popl  %ebp  /* restore EBP */
+
+    /* jump to context */
+    jmp *%ecx
+.size ontop_fcontext,.-ontop_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 67 - 0
modules/std/fiber/native/asm/android-x86_64/jump.S

@@ -0,0 +1,67 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+            http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/****************************************************************************************
+ *                                                                                      *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        R12        |         R13       |         R14        |        R15        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    8    |    9    |   10    |   11    |    12    |    13   |    14   |    15   |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |   0x28  |  0x2c   |   0x30   |   0x34  |   0x38  |   0x3c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        RBX        |         RBP       |         RIP        |       EXIT        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *                                                                                      *
+ ****************************************************************************************/
+
+.text
+.globl jump_fcontext
+.type jump_fcontext,@function
+.align 16
+jump_fcontext:
+    pushq  %rbp  /* save RBP */
+    pushq  %rbx  /* save RBX */
+    pushq  %r15  /* save R15 */
+    pushq  %r14  /* save R14 */
+    pushq  %r13  /* save R13 */
+    pushq  %r12  /* save R12 */
+
+    /* store RSP (pointing to context-data) in RAX */
+    movq  %rsp, %rax
+
+    /* restore RSP (pointing to context-data) from RDI */
+    movq  %rdi, %rsp
+
+    popq  %r12  /* restrore R12 */
+    popq  %r13  /* restrore R13 */
+    popq  %r14  /* restrore R14 */
+    popq  %r15  /* restrore R15 */
+    popq  %rbx  /* restrore RBX */
+    popq  %rbp  /* restrore RBP */
+
+    /* restore return-address */
+    popq  %r8
+
+    /* return transfer_t from jump */
+    /* RAX == fctx, RDX == data */
+    movq  %rsi, %rdx
+    /* pass transfer_t as first arg in context function */
+    /* RDI == fctx, RSI == data */
+    movq  %rax, %rdi
+
+    /* indirect jump to context */
+    jmp  *%r8
+.size jump_fcontext,.-jump_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 62 - 0
modules/std/fiber/native/asm/android-x86_64/make.S

@@ -0,0 +1,62 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+            http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/****************************************************************************************
+ *                                                                                      *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        R12        |         R13       |         R14        |        R15        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    8    |    9    |   10    |   11    |    12    |    13   |    14   |    15   |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |   0x28  |  0x2c   |   0x30   |   0x34  |   0x38  |   0x3c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        RBX        |         RBP       |         RIP        |       EXIT        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *                                                                                      *
+ ****************************************************************************************/
+
+.text
+.globl make_fcontext
+.type make_fcontext,@function
+.align 16
+make_fcontext:
+    /* first arg of make_fcontext() == top of context-stack */
+    movq  %rdi, %rax
+
+    /* shift address in RAX to lower 16 byte boundary */
+    andq  $-16, %rax
+
+    /* reserve space for context-data on context-stack */
+    /* on context-function entry: (RSP -0x8) % 16 == 0 */
+    leaq  -0x40(%rax), %rax
+
+    /* third arg of make_fcontext() == address of context-function */
+    movq  %rdx, 0x30(%rax)
+
+    /* compute abs address of label finish */
+    leaq  finish(%rip), %rcx
+    /* save address of finish as return-address for context-function */
+    /* will be entered after context-function returns */
+    movq  %rcx, 0x38(%rax)
+
+    ret /* return pointer to context-data */
+
+finish:
+    /* exit code is zero */
+    xorq  %rdi, %rdi
+    /* exit application */
+    call  _exit@PLT
+    hlt
+.size make_fcontext,.-make_fcontext
+
+/* Mark that we don't need executable stack. */
+.section .note.GNU-stack,"",%progbits

+ 69 - 0
modules/std/fiber/native/asm/android-x86_64/ontop.S

@@ -0,0 +1,69 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+            http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/****************************************************************************************
+ *                                                                                      *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        R12        |         R13       |         R14        |        R15        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    8    |    9    |   10    |   11    |    12    |    13   |    14   |    15   |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |   0x28  |  0x2c   |   0x30   |   0x34  |   0x38  |   0x3c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        RBX        |         RBP       |         RIP        |       EXIT        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *                                                                                      *
+ ****************************************************************************************/
+
+.text
+.globl ontop_fcontext
+.type ontop_fcontext,@function
+.align 16
+ontop_fcontext:
+    pushq  %rbp  /* save RBP */
+    pushq  %rbx  /* save RBX */
+    pushq  %r15  /* save R15 */
+    pushq  %r14  /* save R14 */
+    pushq  %r13  /* save R13 */
+    pushq  %r12  /* save R12 */
+
+    /* store RSP (pointing to context-data) in RAX */
+    movq  %rsp, %rax
+
+    /* restore RSP (pointing to context-data) from RDI */
+    movq  %rdi, %rsp
+
+    popq  %r12  /* restrore R12 */
+    popq  %r13  /* restrore R13 */
+    popq  %r14  /* restrore R14 */
+    popq  %r15  /* restrore R15 */
+    popq  %rbx  /* restrore RBX */
+    popq  %rbp  /* restrore RBP */
+
+    /* preserve ontop-function in R8 */
+    movq  %rdx, %r8
+
+    /* return transfer_t from jump */
+    /* RAX == fctx, RDX == data */
+    movq  %rsi, %rdx
+    /* pass transfer_t as first arg in context function */
+    /* RDI == fctx, RSI == data */
+    movq  %rax, %rdi
+
+    /* keep return-address on stack */
+
+    /* indirect jump to context */
+    jmp  *%r8
+.size ontop_fcontext,.-ontop_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 3 - 4
src/mx2cc/builder.monkey2

@@ -690,7 +690,7 @@ Class BuilderInstance
 		Endif
 		
 		Local qpath:="~q"+path+"~q"
-
+		
 		Select ext
 		Case ".framework"
 			
@@ -700,7 +700,6 @@ Class BuilderInstance
 			Endif
 			
 		Default
-		
 			Select GetFileType( path )
 			Case FileType.Directory
 			
@@ -709,8 +708,8 @@ Class BuilderInstance
 				
 			Case FileType.None
 			
-				New BuildEx( "File "+qpath+" not found" )
-				Return
+'				New BuildEx( "File "+qpath+" not found" )
+'				Return
 				
 			End
 		End

+ 2 - 7
src/mx2cc/buildproduct.monkey2

@@ -661,13 +661,8 @@ Class AndroidBuildProduct Extends BuildProduct
 		
 		buf.Push( "APP_OPTIM := "+opts.config )
 		
-		buf.Push( "APP_ABI := armeabi-v7a" )
-'		buf.Push( "APP_ABI := armeabi armeabi-v7a x86" )
-'		buf.Push( "APP_ABI := armeabi-v7a x86" )
-'		buf.Push( "APP_ABI := all" )
-
-		buf.Push( "APP_PLATFORM := 10" )
-		
+		buf.Push( "APP_ABI := "+GetEnv( "MX2_ANDROID_APP_ABI","armeabi-v7a" ) )
+		buf.Push( "APP_PLATFORM := "+GetEnv( "MX2_ANDROID_APP_PLATFORM","10" ) )
 		buf.Push( "APP_CFLAGS += -std=gnu99" )
 		buf.Push( "APP_CPPFLAGS += -std=c++11" )
 		buf.Push( "APP_CPPFLAGS += -frtti" )

+ 3 - 3
src/mx2cc/mx2cc.monkey2

@@ -21,9 +21,9 @@ Using mx2..
 
 Global StartDir:String
 
-Const TestArgs:="mx2cc makedocs"
-
-'Const TestArgs:="mx2cc makeapp -apptype=console src/mx2cc/test.monkey2"
+Const TestArgs:="mx2cc makemods -target=android"
+ 
+'Const TestArgs:="mx2cc makeapp -apptype=console -target=android src/mx2cc/test.monkey2"
 
 'To build with old mx2cc...
 '

+ 17 - 12
src/mx2cc/test.monkey2

@@ -1,27 +1,32 @@
-
-Namespace test
+Namespace myapp
 
 #Import "<std>"
+#Import "<mojo>"
 
 Using std..
+Using mojo..
+
+Class MyWindow Extends Window
 
-Struct Test<T>
+	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )
+
+		Super.New( title,width,height,flags )
+	End
 
-	Const A:=New Test( 10 )
-	Const B:=New Test[ 100 ]
+	Method OnRender( canvas:Canvas ) Override
 	
-	Field t:T
+		RequestRender()
 	
-	Method New( t:T )
-		Self.t=t
+		canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )
 	End
+	
 End
 
-
 Function Main()
 
-	Print Test<Int>.A.t
-	Print Test<Int>.B.Length
+	New AppInstance
 	
-
+	New MyWindow
+	
+	App.Run()
 End

+ 2 - 2
src/mx2cc/util.monkey2

@@ -79,10 +79,10 @@ Function MungPath:String( path:String )
 	Return id
 End
 
-Function GetEnv:String( name:String )
+Function GetEnv:String( name:String,defaultValue:String="" )
 	Local p:=getenv( name )
 	If p Return String.FromCString( p )
-	Return ""
+	Return defaultValue
 End
 
 Function SetEnv( name:String,value:String )