Commits

Iain Buclaw committed fc1a48b Merge

Merged in jpf/gdc/android-upstream2 (pull request #7)

Comments (0)

Files changed (5)

 #endif
 
 /* mingw and cygwin don't have pthread. %% TODO: check darwin.  */
-#if TARGET_WINDOS || TARGET_OSX
+#if TARGET_WINDOS || TARGET_OSX || TARGET_ANDROID
 #define USE_PTHREADS    0
 #else
 #define USE_PTHREADS    1
     int *args;
 
     /* Whether we need the thread library.  */
-    int need_thread;
+    int need_thread = 0;
 
     /* By default, we throw on the math library if we have one.  */
     int need_math = (MATH_LIBRARY[0] != '\0');
 
     if (saw_librt)
         new_decoded_options[j++] = *saw_librt;
-#if TARGET_LINUX
+#if TARGET_LINUX && !TARGET_ANDROID
     /* Only link if linking statically and target platform supports. */
     else if (library > 0 && (static_phobos || static_link))
     {
 
     if (saw_librt)
         arglist[j++] = saw_librt;
-#if TARGET_LINUX
+#if TARGET_LINUX && !TARGET_ANDROID
     /* Only link if linking statically and target platform supports. */
     else if (library > 0 && (static_phobos || static_link))
     {

d/druntime/rt/memory.d

     }
     version( linux )
     {
-        version = SimpleLibcStackEnd;
-
-        version( SimpleLibcStackEnd )
+        version(Android)
         {
-            extern (C) extern __gshared void* __libc_stack_end;
+            extern(C) void* __get_stack_base(int* p_stack_size);
+        }
+        else
+        {
+            version = SimpleLibcStackEnd;
+    
+            version( SimpleLibcStackEnd )
+            {
+                extern (C) extern __gshared void* __libc_stack_end;
+            }
         }
     }
     version( FreeBSD )
     }
     else version( linux )
     {
-        version( SimpleLibcStackEnd )
+        version(Android)
+        {
+            int stackSize;
+            return __get_stack_base(&stackSize);
+        }
+        else version( SimpleLibcStackEnd )
         {
             return __libc_stack_end;
         }

d/phobos2/acinclude.m4

        d_gc_stack=GC_Use_Stack_GLibC],
       [AC_MSG_RESULT(no)])
 fi
+if test -z "$d_gc_stack"; then
+    AC_MSG_CHECKING([for __get_stack_base])
+    AC_TRY_LINK([],[
+	int stack_size;
+	extern void*  __get_stack_base(int  *p_stack_size);
+	return __get_stack_base(&stack_size) == 0;],
+      [AC_MSG_RESULT(yes)
+       d_gc_stack=GC_Use_Stack_Bionic],
+      [AC_MSG_RESULT(no)])
+fi
 dnl if test -z "$d_gc_stack"; then
 dnl    d_gc_stack=GC_Use_Stack_Guess
 dnl    D_GC_MODULES="$D_GC_MODULES gc/gc_guess_stack.o"

d/phobos2/configure

     conftest$ac_exeext conftest.$ac_ext
 fi
 if test -z "$d_gc_stack"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __get_stack_base" >&5
+$as_echo_n "checking for __get_stack_base... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+	int stack_size;
+	extern void*  __get_stack_base(int  *p_stack_size);
+	return __get_stack_base(&stack_size) == 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       d_gc_stack=GC_Use_Stack_Bionic
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+if test -z "$d_gc_stack"; then
     as_fn_error $? "No usable stack origin information" "$LINENO" 5
 fi
 

d/target-ver-syms.sh

 freebsd*) d_os_versym=FreeBSD ; d_unix=1 ;;
 k*bsd*-gnu) d_os_versym=FreeBSD ; d_unix=1 ;;
 kopensolaris*-gnu) d_os_versym=Solaris; d_unix=1 ;;
-linux*) d_os_versym=linux ; d_unix=1 ;; # This is supposed to be "linux", not "Linux", according to the spec
+linux*) # This is supposed to be "linux", not "Linux", according to the spec
+        d_os_versym=linux ; d_unix=1 ;
+        case "$d_target_os" in
+            *androideabi) d_os_versym=Android; d_os_versym2=linux ;;
+        esac
+        ;;
 mingw32*) case "$target_vendor" in
               pc*) d_os_versym=Win32; d_os_versym2=MinGW32; d_windows=1 ;;
               w64*) d_os_versym=Win64; d_os_versym2=MinGW64; d_windows=1 ;;
 Solaris) echo "#define TARGET_SOLARIS 1" ;;
 Win32)   echo "#define TARGET_WINDOS  1" ;;
 Win64)   echo "#define TARGET_WINDOS  1" ;;
+Android) echo "#define TARGET_ANDROID 1";
+         echo "#define TARGET_LINUX 1";
+         ;;
 *)       echo "#define TARGET_UNIX    1" ;;
 esac