Re: [Mono-dev] [PATCH] Android Support [3/4]

2010-04-20 Thread Paolo Molaro
On 04/19/10 Jonathan Pryor wrote:
 Index: mono/io-layer/collection.c
 ===
 --- mono/io-layer/collection.c(revision 155735)
 +++ mono/io-layer/collection.c(working copy)
 @@ -58,7 +58,10 @@
  ret = pthread_attr_init (attr);
  g_assert (ret == 0);
  
 -#ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE
 +/* Android implements pthread_attr_setstacksize(), but errors out when using
 + * PTHREAD_STACK_MIN: http://code.google.com/p/android/issues/detail?id=7808
 + */
 +#if defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE)  !defined(PLATFORM_ANDROID)
  if (set_stacksize == 0) {
  #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
   ret = pthread_attr_setstacksize (attr, 65536);

Instead of adding more checks there, just change the code to do:
ret = pthread_attr_setstacksize (attr, MAX (65536, PTHREAD_STACK_MIN));

 Index: mono/io-layer/mono-mutex.c
 ===
 --- mono/io-layer/mono-mutex.c(revision 155735)
 +++ mono/io-layer/mono-mutex.c(working copy)
 @@ -22,11 +22,24 @@
  
  
  #ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
 +/* Android does not implement pthread_mutex_timedlock(), but does provide an
 + * unusual declaration: 
 http://code.google.com/p/android/issues/detail?id=7807
 + */
 +#if defined(PLATFORM_ANDROID)
  int pthread_mutex_timedlock (pthread_mutex_t *mutex,
 + struct timespec *timeout);
 +#else
 +int pthread_mutex_timedlock (pthread_mutex_t *mutex,
   const struct timespec *timeout);
 +#endif

Just do this at the start:
#ifdef PLATFORM_ANDROID
#define CONST_NEEDED const
#else
#define CONST_NEEDED const
#endif

And then insert CONST_NEEDED where appropriate instead of the ugly
duplication and ifdef mess.

 Index: mono/mini/exceptions-arm.c
 ===
 --- mono/mini/exceptions-arm.c(revision 155735)
 +++ mono/mini/exceptions-arm.c(working copy)
 @@ -12,7 +12,11 @@
  #include glib.h
  #include signal.h
  #include string.h
 +#if defined(PLATFORM_ANDROID)
 +#include asm/sigcontext.h
 +#else
  #include ucontext.h
 +#endif

Please make sure configure has the appropriate header checks and use:

#ifdef HAVE_ASM_SIGCONTEXT_H
#include asm/sigcontext.h
#endif
#ifdef HAVE_UCONTEXT_H
#include ucontext.h
#endif

We must use feature checks and not platform checks as much as possible.

lupus

-- 
-
lu...@debian.org debian/rules
lu...@ximian.com Monkeys do it better
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Android Support [3/4]

2010-04-20 Thread Andreas Färber
Am 20.04.2010 um 11:16 schrieb Paolo Molaro:

 On 04/19/10 Jonathan Pryor wrote:
 Index: mono/mini/exceptions-arm.c
 ===
 --- mono/mini/exceptions-arm.c   (revision 155735)
 +++ mono/mini/exceptions-arm.c   (working copy)
 @@ -12,7 +12,11 @@
 #include glib.h
 #include signal.h
 #include string.h
 +#if defined(PLATFORM_ANDROID)
 +#include asm/sigcontext.h
 +#else
 #include ucontext.h
 +#endif

 Please make sure configure has the appropriate header checks and use:

 #ifdef HAVE_ASM_SIGCONTEXT_H
 #include asm/sigcontext.h
 #endif
 #ifdef HAVE_UCONTEXT_H
 #include ucontext.h
 #endif

 We must use feature checks and not platform checks as much as  
 possible.

+1. ucontext.h was dropped in POSIX.1-2008, so this is not just about  
Android.

Andreas
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Android Support [3/4]

2010-04-20 Thread Jonathan Pryor
On Tue, 2010-04-20 at 11:16 +0200, Paolo Molaro wrote:
 We must use feature checks and not platform checks as much as possible.

The changes you outlined were commited to trunk (r155826) and the
mono-2-6 branch (r155825).

Thanks,
 - Jon


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Android Support [3/4]

2010-04-19 Thread Rodrigo Kumpera
On Mon, Apr 19, 2010 at 2:44 PM, Jonathan Pryor jonpr...@vt.edu wrote:

 This is a series of patches to add support to Mono for building against
 the Android NDK [0].  Android runs the Linux kernel, but moves many
 things around compared to a normal desktop Linux distro.

 These patches are based against the mono-2-6 branch.

 This third patch patches mono so that it will properly build and link
 under Android.  In particular, note that Android includes pthread_*()
 functions within libc, not libpthread, thus the added configure check.
 ChangeLog messages are within the diff.

 Permission to commit?

 - Jon

 +AC_CHECK_HEADER([malloc.h],
+ [AC_DEFINE([HAVE_USR_INCLUDE_MALLOC_H], [1],
+ [Define to 1 if you have /usr/include/malloc.h.])],,)
+

What's the use for this? We check the header but then we don't use the new
define.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Android Support [3/4]

2010-04-19 Thread Jonathan Pryor
On Mon, 2010-04-19 at 15:22 -0300, Rodrigo Kumpera wrote:
 On Mon, Apr 19, 2010 at 2:44 PM, Jonathan Pryor jonpr...@vt.edu
 wrote:

 +AC_CHECK_HEADER([malloc.h], 
 + [AC_DEFINE([HAVE_USR_INCLUDE_MALLOC_H], [1], 
 + [Define to 1 if you have /usr/include/malloc.h.])],,)
 +

 What's the use for this? We check the header but then we don't use the
 new define.

That's because it's an old define, used in mono/utils/dlmalloc.c and
mono/utils/dlmalloc.h.  I don't know why our configure doesn't set it,
but without this check compiling under the Android NDK results in a
build failure [0].

The primary issue appears to be system header files.  mono-codeman.c
#includes string.h.  Under glibc, string.h only #includes
features.h and stddef.h.

Under Android, however, string.h #includes malloc.h as well, and
malloc.h includes a definition for `struct mallinfo`, and since
mono-codeman.c also #includes dlmalloc.h this results in a duplicate
definition for `struct mallinfo`.

Different system headers, different results.

This also implies that my patch, as is, won't work under desktop Linux
(oops).  Specifically, mono-codeman.c needs to #include malloc.h
before #including dlmalloc.h.

Advice?

 - Jon

[0] In file included from mono-codeman.c:16:dlmalloc.h: At top level:
dlmalloc.h:195: error: redefinition of 'struct mallinfo'


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Android Support [3/4]

2010-04-19 Thread Jonathan Pryor
On Mon, 2010-04-19 at 15:31 -0400, Jonathan Pryor wrote:
 This also implies that my patch, as is, won't work under desktop Linux
 (oops).  Specifically, mono-codeman.c needs to #include malloc.h
 before #including dlmalloc.h.

Never mind; tried the patch as-is, and it builds properly on trunk
(largely because mono-codeman.c doesn't use `struct mallinfo`, so it's
not actually an issue here).

The previous patch, as is, works under desktop Linux.

 - Jon


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Android Support [3/4]

2010-04-19 Thread Rodrigo Kumpera
On Mon, Apr 19, 2010 at 4:43 PM, Jonathan Pryor jonpr...@vt.edu wrote:

 On Mon, 2010-04-19 at 15:31 -0400, Jonathan Pryor wrote:
  This also implies that my patch, as is, won't work under desktop Linux
  (oops).  Specifically, mono-codeman.c needs to #include malloc.h
  before #including dlmalloc.h.

 Never mind; tried the patch as-is, and it builds properly on trunk
 (largely because mono-codeman.c doesn't use `struct mallinfo`, so it's
 not actually an issue here).

 The previous patch, as is, works under desktop Linux.


Looks good to me then.
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Android Support [3/4]

2010-04-19 Thread Jonathan Pryor
On Mon, 2010-04-19 at 17:16 -0300, Rodrigo Kumpera wrote:
 Looks good to me then. 

Thanks.  Committed to mono-2-6 (r155758) and trunk (r155758).

 - Jon


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list