[Spice-devel] New thread: problems in porting glib2.0 and snappy onto android

Shuxiang Lim shohyanglim at gmail.com
Tue Mar 22 00:19:50 PDT 2011


Thanks for inspiring! Sorry for being unable to response instantly 'cause
we're of diff.  semisphere.
   The android-bluetooth module DOES have glib included, it uses only
libglib, and now I've compiled it under android souce into libglib.so,but
it's not usable to spice-gtk for it's glib-2.0-20 which cannot afford some
methods such as "g_byte_array_unref".etc,and there's none
libgio/libgthread/libgmodule which are also needed by spicec-glib or snappy.
   As I've mentioned, in running of snappy,the segfault/sigbus comes from
libgobj and my patching work is mainly in libgio.
   And I have found no clue of successful use of libgio..etc. in Android.
   So now, I suppose the problems are basically from two points:(suppose the
spice-gtk has no wrong-use of glib)
1. The compiling fault such as the incorrect alignment setting which is the
sin of the sigbus
2. The danger in the patching of the definitions from arpa/nameser*.h which
may cause segfault.
   Anybody can give me some instructions of testing libg*?
   Appreciating.

On Mon, Mar 21, 2011 at 6:30 PM, Alon Levy <alevy at redhat.com> wrote:

> On Mon, Mar 21, 2011 at 06:13:12PM +0800, Shuxiang Lim wrote:
> > Hi, I open this new thread to clearly describe my condition:
> >
>
> did you notice the post mentioning glib is actually part of android
> since it's used for bluetooth? maybe you can find out which version / where
> the headers / libs are and just link with it?
>
> I am trying to setup an environment according to your instructions but I
> don't have any hw to test with. It will take me some time though.
>
> Alon
>
> > 1.I use the android NDK provided by Mozzila which has nearly full C++
> > support:
> >
> http://ftp.mozilla.org/pub/mozilla.org/mobile/source/android-ndk-r4c-0moz3.tar.bz2
> > and I have modified Andrew Ross's agcc to partner with this NDK:
> > http://blog.csdn.net/rozenix/archive/2011/02/28/6212994.aspx
> >
> > 2. Then I cross compile glib2.28.1 onto Android in this order:
> > 1)libiconv-1.13.1.tar.gz:
> > configured by:
> > *CC=agcc CXX=agcc LD=arm-eabi-ld RANLIB=arm-eabi-ranlib \
> > PKG_CONFIG_LIBDIR=/data/local/lib/pkgconfig:/data/local/share/pkgconfig/
> \
> >     ./configure \
> >     --prefix=/data/local \
> >     --host=arm-eabi-linux \**
> >     --enable-malloc0returnsnull \*
> > *    --enable-shared \*
> >  2)gettext-0.18.1.1.tar.gz
> > configured by:
> > *CC=agcc CPPFLAGS="-I/data/local/include" LDFLAGS="-L/data/local/lib"
> > CXX=agcc LD=arm-eabi-ld RANLIB=arm-eabi-ranlib \
> > PKG_CONFIG_LIBDIR=/data/local/lib/pkgconfig:/data/local/share/pkgconfig/
> \
> >     ./configure \
> >     --prefix=/data/local \
> >     --host=arm-eabi-linux \
> >     --enable-malloc0returnsnull \
> >     --enable-shared \
> >     --cache-file=arm.cache \
> >     --without-included-regex \
> >     --disable-java --disable-openmp --without-libiconv-prefix
> > --without-libintl-prefix --without-libglib-2.0-prefix
> > --without-libcroco-0.6-prefix --with-included-libxml
> > --without-libncurses-prefix --without-libtermcap-prefix
> > --without-libcurses-prefix --without-libexpat-prefix --without-emacs
> >   * But the build of gettext will not fully succeed,never mind, I need
> only
> > libintl.so so just make install.
> >
> > 3)  glib-2.28.1.tar.gz
> > 1st, do patching with my attached file(these are all that I found that
> have
> > to be modified)
> > 2nd, write this into the cache file arm.cache:
> > *glib_cv_stack_grows=no**
> > glib_cv_uscore=no
> > ac_cv_func_posix_getpwuid_r=no
> > ac_cv_func_posix_getgrgid_r=no*
> > 3rd, configured  the same as libiconv.
> > 4th, remove the -lpthread in gthread/Makefile.
> > 5td, make;make install
> >
> > 3. Also I have to port pixman and openssl onto android.
> > 1)pixman-0.20.0: config. make;make install same as libiconv
> > 2)openssl-1.0.0: config by:
> > ./config no-asm shared --prefix=/data/local/
> > then modify the Makefile:gcc-->agcc remove the -m64..etc.
> > make...
> >
> > 3. So I disable the audio channels and build snappy onto android with
> this
> > script under spice-gtk/gtk:
> > #!/bin/bash
> > COMMON_DIR=../common
> > SPICE_GLIB_SRC="coroutine_gthread.c spice-util.c spice-session.c
> > spice-channel.c spice-glib-enums.c spice-marshal.c
> generated_demarshallers.c
> > generated_demarshallers1.c generated_marshallers.c
> generated_marshallers1.c
> > gio-coroutine.c channel-base.c channel-main.c channel-display.c
> > channel-display-mjpeg.c channel-cursor.c channel-inputs.c decode-glz.c
> > decode-jpeg.c decode-zlib.c $COMMON_DIR/mem.c $COMMON_DIR/marshaller.c
> > $COMMON_DIR/canvas_utils.c $COMMON_DIR/sw_canvas.c
> > $COMMON_DIR/pixman_utils.c $COMMON_DIR/lines.c $COMMON_DIR/rop3.c
> > $COMMON_DIR/quic.c $COMMON_DIR/lz.c $COMMON_DIR/region.c
> > $COMMON_DIR/ssl_verify.c"
> > CPP_FLAGS="-DHAVE_CONFIG_H -DSW_CANVAS_CACHE  -D_REENTRANT -I. -I..
> > -I../common -I/data/local/include/spice-1 -I/data/local/include/pixman-1
> > -I/data/local/include -I/data/local/include/glib-2.0
> > -I/data/local/lib/glib-2.0/include"
> > C_FLAGS="-std=gnu99 -Wall -Wno-sign-compare -Wno-deprecated-declarations
> > -Wl,--no-undefined -fPIC -DPIC "
> > LD_FLAGS="-L/data/local/lib/ -lpixman-1 -lm  -lssl -lcrypto -ljpeg -lz
> > -lglib-2.0  -lgio-2.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 "
> > echo "agcc -shared -o libspicec_glib.so $SPICE_GLIB_SRC $CPP_FLAGS
> $C_FLAGS
> > $LD_FLAGS"
> > agcc -shared -o libspicec.so  $SPICE_GLIB_SRC $CPP_FLAGS $C_FLAGS
> $LD_FLAGS
> > agcc -o snappy spice-cmdline.c snappy.c -DG_LOG_DOMAIN=\"GSpice\"
> > -DSW_CANVAS_CACHE -DSPICE_GTK_LOCALEDIR=\"/usr/local/share/locale\"
> > $CPP_FLAGS $C_FLAGS $LD_FLAGS -lspicec -lintl -liconv -L./
> >
> > then I put all the snappy,libspicec.so,lib*so onto android dev. and
> > reproduce the faults.
> > Thanks.
>
> > --- glib-2.28.1/glib/gstrfuncs.c      2011-02-16 10:55:33.000000000 +0800
> > +++ aglib-2.28.1/glib/gstrfuncs.c     2011-03-21 16:33:18.000000000 +0800
> > @@ -442,8 +442,12 @@ g_ascii_strtod (const gchar *nptr,
> >
> >    fail_pos = NULL;
> >
> > +#ifdef ANDROID
> > +  decimal_point = ".";
> > +#else
> >    locale_data = localeconv ();
> >    decimal_point = locale_data->decimal_point;
> > +#endif
> >    decimal_point_len = strlen (decimal_point);
> >
> >    g_assert (decimal_point_len != 0);
> > @@ -656,8 +660,12 @@ g_ascii_formatd (gchar       *buffer,
> >
> >    _g_snprintf (buffer, buf_len, format, d);
> >
> > +#ifdef ANDROID
> > +  decimal_point = ".";
> > +#else
> >    locale_data = localeconv ();
> >    decimal_point = locale_data->decimal_point;
> > +#endif
> >    decimal_point_len = strlen (decimal_point);
> >
> >    g_assert (decimal_point_len != 0);
> > --- glib-2.28.1/glib/gutils.c 2011-02-11 23:23:13.000000000 +0800
> > +++ aglib-2.28.1/glib/gutils.c        2011-03-21 17:08:09.000000000 +0800
> > @@ -29,6 +29,9 @@
> >   */
> >
> >  #include "config.h"
> > +#ifdef ANDROID
> > +#undef HAVE_PWD_H
> > +#endif
> >
> >  #ifdef HAVE_UNISTD_H
> >  #include <unistd.h>
> > --- glib-2.28.1/gio/libasyncns/asyncns.c      2010-04-13
> 21:33:16.000000000 +0800
> > +++ aglib-2.28.1/gio/libasyncns/asyncns.c     2011-03-21
> 17:11:43.000000000 +0800
> > @@ -18,6 +18,30 @@
> >    <http://www.gnu.org/licenses/>.
> >  ***/
> >
> > +#ifdef ANDROID
> > +typedef struct {
> > +     unsigned        id :16;         /*%< query identification number */
> > +                     /* fields in third byte */
> > +     unsigned        rd :1;          /*%< recursion desired */
> > +     unsigned        tc :1;          /*%< truncated message */
> > +     unsigned        aa :1;          /*%< authoritive answer */
> > +     unsigned        opcode :4;      /*%< purpose of message */
> > +     unsigned        qr :1;          /*%< response flag */
> > +                     /* fields in fourth byte */
> > +     unsigned        rcode :4;       /*%< response code */
> > +     unsigned        cd: 1;          /*%< checking disabled by resolver
> */
> > +     unsigned        ad: 1;          /*%< authentic data from named */
> > +     unsigned        unused :1;      /*%< unused bits (MBZ as of
> 4.9.3a3) */
> > +     unsigned        ra :1;          /*%< recursion available */
> > +                     /* remaining bytes */
> > +     unsigned        qdcount :16;    /*%< number of question entries */
> > +     unsigned        ancount :16;    /*%< number of answer entries */
> > +     unsigned        nscount :16;    /*%< number of authority entries */
> > +     unsigned        arcount :16;    /*%< number of resource entries */
> > +} HEADER;
> > +#endif
> > +
> > +
> >  #ifdef HAVE_CONFIG_H
> >  #include "g-asyncns.h"
> >  #endif
> > @@ -57,6 +81,10 @@
> >  #include <inttypes.h>
> >  #endif
> >
> > +#ifdef ANDROID
> > +#undef HAVE_SYS_PRCTL_H
> > +#endif
> > +
> >  #ifdef HAVE_SYS_PRCTL_H
> >  #include <sys/prctl.h>
> >  #endif
> > --- glib-2.28.1/gio/gresolver.c       2011-02-11 23:23:11.000000000 +0800
> > +++ aglib-2.28.1/gio/gresolver.c      2011-03-21 16:42:18.000000000 +0800
> > @@ -20,6 +20,61 @@
> >   * Boston, MA 02111-1307, USA.
> >   */
> >
> > +#ifdef ANDROID
> > +/*%
> > + * Inline versions of get/put short/long.  Pointer is advanced.
> > + */
> > +#define NS_INT32SZ   4       /*%< #/bytes of data in a u_int32_t */
> > +#define NS_INT16SZ   2       /*%< #/bytes of data in a u_int16_t */
> > +#define NS_GET16(s, cp) do { \
> > +     register const u_char *t_cp = (const u_char *)(cp); \
> > +     (s) = ((u_int16_t)t_cp[0] << 8) \
> > +         | ((u_int16_t)t_cp[1]) \
> > +         ; \
> > +     (cp) += NS_INT16SZ; \
> > +} while (0)
> > +#define NS_GET32(l, cp) do { \
> > +     register const u_char *t_cp = (const u_char *)(cp); \
> > +     (l) = ((u_int32_t)t_cp[0] << 24) \
> > +         | ((u_int32_t)t_cp[1] << 16) \
> > +         | ((u_int32_t)t_cp[2] << 8) \
> > +         | ((u_int32_t)t_cp[3]) \
> > +         ; \
> > +     (cp) += NS_INT32SZ; \
> > +} while (0)
> > +
> > +
> > +#define      GETSHORT                NS_GET16
> > +#define      GETLONG                 NS_GET32
> > +
> > +#define ns_c_in      1       /*%< Internet. */
> > +#define ns_t_srv     33      /*%< Internet. */
> > +#define C_IN         ns_c_in
> > +#define      T_SRV           ns_t_srv
> > +
> > +typedef struct {
> > +     unsigned        id :16;         /*%< query identification number */
> > +                     /* fields in third byte */
> > +     unsigned        rd :1;          /*%< recursion desired */
> > +     unsigned        tc :1;          /*%< truncated message */
> > +     unsigned        aa :1;          /*%< authoritive answer */
> > +     unsigned        opcode :4;      /*%< purpose of message */
> > +     unsigned        qr :1;          /*%< response flag */
> > +                     /* fields in fourth byte */
> > +     unsigned        rcode :4;       /*%< response code */
> > +     unsigned        cd: 1;          /*%< checking disabled by resolver
> */
> > +     unsigned        ad: 1;          /*%< authentic data from named */
> > +     unsigned        unused :1;      /*%< unused bits (MBZ as of
> 4.9.3a3) */
> > +     unsigned        ra :1;          /*%< recursion available */
> > +                     /* remaining bytes */
> > +     unsigned        qdcount :16;    /*%< number of question entries */
> > +     unsigned        ancount :16;    /*%< number of answer entries */
> > +     unsigned        nscount :16;    /*%< number of authority entries */
> > +     unsigned        arcount :16;    /*%< number of resource entries */
> > +} HEADER;
> > +#endif
> > +
> > +
> >  #include "config.h"
> >  #include <glib.h>
> >  #include "glibintl.h"
> > --- glib-2.28.1/gio/gthreadedresolver.c       2011-02-11
> 23:23:12.000000000 +0800
> > +++ aglib-2.28.1/gio/gthreadedresolver.c      2011-03-21
> 16:44:29.000000000 +0800
> > @@ -20,6 +20,60 @@
> >   * Boston, MA 02111-1307, USA.
> >   */
> >
> > +#ifdef ANDROID
> > +/*%
> > + * Inline versions of get/put short/long.  Pointer is advanced.
> > + */
> > +#define NS_INT32SZ   4       /*%< #/bytes of data in a u_int32_t */
> > +#define NS_INT16SZ   2       /*%< #/bytes of data in a u_int16_t */
> > +#define NS_GET16(s, cp) do { \
> > +     register const u_char *t_cp = (const u_char *)(cp); \
> > +     (s) = ((u_int16_t)t_cp[0] << 8) \
> > +         | ((u_int16_t)t_cp[1]) \
> > +         ; \
> > +     (cp) += NS_INT16SZ; \
> > +} while (0)
> > +#define NS_GET32(l, cp) do { \
> > +     register const u_char *t_cp = (const u_char *)(cp); \
> > +     (l) = ((u_int32_t)t_cp[0] << 24) \
> > +         | ((u_int32_t)t_cp[1] << 16) \
> > +         | ((u_int32_t)t_cp[2] << 8) \
> > +         | ((u_int32_t)t_cp[3]) \
> > +         ; \
> > +     (cp) += NS_INT32SZ; \
> > +} while (0)
> > +
> > +
> > +#define      GETSHORT                NS_GET16
> > +#define      GETLONG                 NS_GET32
> > +
> > +#define ns_c_in      1       /*%< Internet. */
> > +#define ns_t_srv     33      /*%< Internet. */
> > +#define C_IN         ns_c_in
> > +#define      T_SRV           ns_t_srv
> > +
> > +     typedef struct {
> > +         unsigned    id :16;         /*%< query identification number */
> > +         /* fields in third byte */
> > +         unsigned    rd :1;          /*%< recursion desired */
> > +         unsigned    tc :1;          /*%< truncated message */
> > +         unsigned    aa :1;          /*%< authoritive answer */
> > +         unsigned    opcode :4;      /*%< purpose of message */
> > +         unsigned    qr :1;          /*%< response flag */
> > +         /* fields in fourth byte */
> > +         unsigned    rcode :4;       /*%< response code */
> > +         unsigned    cd: 1;          /*%< checking disabled by resolver
> */
> > +         unsigned    ad: 1;          /*%< authentic data from named */
> > +         unsigned    unused :1;      /*%< unused bits (MBZ as of
> 4.9.3a3) */
> > +         unsigned    ra :1;          /*%< recursion available */
> > +         /* remaining bytes */
> > +         unsigned    qdcount :16;    /*%< number of question entries */
> > +         unsigned    ancount :16;    /*%< number of answer entries */
> > +         unsigned    nscount :16;    /*%< number of authority entries */
> > +         unsigned    arcount :16;    /*%< number of resource entries */
> > +     } HEADER;
> > +#endif
> > +
> >  #include "config.h"
> >  #include <glib.h>
> >  #include "glibintl.h"
> > --- glib-2.28.1/gio/gunixresolver.c   2011-02-11 23:23:12.000000000 +0800
> > +++ aglib-2.28.1/gio/gunixresolver.c  2011-03-21 16:45:01.000000000 +0800
> > @@ -20,6 +20,62 @@
> >   * Boston, MA 02111-1307, USA.
> >   */
> >
> > +#ifdef ANDROID
> > +/*%
> > + * Inline versions of get/put short/long.  Pointer is advanced.
> > + */
> > +#define NS_INT32SZ   4       /*%< #/bytes of data in a u_int32_t */
> > +#define NS_INT16SZ   2       /*%< #/bytes of data in a u_int16_t */
> > +#define NS_GET16(s, cp) do { \
> > +     register const u_char *t_cp = (const u_char *)(cp); \
> > +     (s) = ((u_int16_t)t_cp[0] << 8) \
> > +         | ((u_int16_t)t_cp[1]) \
> > +         ; \
> > +     (cp) += NS_INT16SZ; \
> > +} while (0)
> > +#define NS_GET32(l, cp) do { \
> > +     register const u_char *t_cp = (const u_char *)(cp); \
> > +     (l) = ((u_int32_t)t_cp[0] << 24) \
> > +         | ((u_int32_t)t_cp[1] << 16) \
> > +         | ((u_int32_t)t_cp[2] << 8) \
> > +         | ((u_int32_t)t_cp[3]) \
> > +         ; \
> > +     (cp) += NS_INT32SZ; \
> > +} while (0)
> > +
> > +
> > +#define      GETSHORT                NS_GET16
> > +#define      GETLONG                 NS_GET32
> > +
> > +#define ns_c_in      1       /*%< Internet. */
> > +#define ns_t_srv     33      /*%< Internet. */
> > +#define C_IN         ns_c_in
> > +#define      T_SRV           ns_t_srv
> > +
> > +     typedef struct {
> > +         unsigned    id :16;         /*%< query identification number */
> > +         /* fields in third byte */
> > +         unsigned    rd :1;          /*%< recursion desired */
> > +         unsigned    tc :1;          /*%< truncated message */
> > +         unsigned    aa :1;          /*%< authoritive answer */
> > +         unsigned    opcode :4;      /*%< purpose of message */
> > +         unsigned    qr :1;          /*%< response flag */
> > +         /* fields in fourth byte */
> > +         unsigned    rcode :4;       /*%< response code */
> > +         unsigned    cd: 1;          /*%< checking disabled by resolver
> */
> > +         unsigned    ad: 1;          /*%< authentic data from named */
> > +         unsigned    unused :1;      /*%< unused bits (MBZ as of
> 4.9.3a3) */
> > +         unsigned    ra :1;          /*%< recursion available */
> > +         /* remaining bytes */
> > +         unsigned    qdcount :16;    /*%< number of question entries */
> > +         unsigned    ancount :16;    /*%< number of answer entries */
> > +         unsigned    nscount :16;    /*%< number of authority entries */
> > +         unsigned    arcount :16;    /*%< number of resource entries */
> > +     } HEADER;
> > +#endif
> > +
> > +
> > +
> >  #include "config.h"
> >  #include <glib.h>
> >  #include "glibintl.h"
> > --- glib-2.28.1/gio/glocalfileinfo.c  2011-02-11 23:23:11.000000000 +0800
> > +++ aglib-2.28.1/gio/glocalfileinfo.c 2011-03-21 16:55:10.000000000 +0800
> > @@ -1096,7 +1096,11 @@ lookup_uid_data (uid_t uid)
> >        if (pwbufp->pw_name != NULL && pwbufp->pw_name[0] != 0)
> >       data->user_name = convert_pwd_string_to_utf8 (pwbufp->pw_name);
> >
> > +#ifdef ANDROID
> > +      gecos = NULL;
> > +#else
> >        gecos = pwbufp->pw_gecos;
> > +#endif
> >
> >        if (gecos)
> >       {
> > --- glib-2.28.1/gio/ginetaddress.c    2011-02-11 23:23:11.000000000 +0800
> > +++ aglib-2.28.1/gio/ginetaddress.c   2011-03-21 16:55:45.000000000 +0800
> > @@ -20,6 +20,27 @@
> >   * Authors: Christian Kellner <gicmo at gnome.org>
> >   *          Samuel Cormier-Iijima <sciyoshi at gmail.com>
> >   */
> > +#ifdef ANDROID
> > +#define IN6_IS_ADDR_MC_NODELOCAL(a) \
> > +     (IN6_IS_ADDR_MULTICAST(a)
>   \
> > +      && ((((__const uint8_t *) (a))[1] & 0xf) == 0x1))
> > +
> > +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
> > +     (IN6_IS_ADDR_MULTICAST(a)
>   \
> > +      && ((((__const uint8_t *) (a))[1] & 0xf) == 0x2))
> > +
> > +#define IN6_IS_ADDR_MC_SITELOCAL(a) \
> > +     (IN6_IS_ADDR_MULTICAST(a)
>   \
> > +      && ((((__const uint8_t *) (a))[1] & 0xf) == 0x5))
> > +
> > +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
> > +     (IN6_IS_ADDR_MULTICAST(a)
>   \
> > +      && ((((__const uint8_t *) (a))[1] & 0xf) == 0x8))
> > +
> > +#define IN6_IS_ADDR_MC_GLOBAL(a) \
> > +     (IN6_IS_ADDR_MULTICAST(a)
>   \
> > +      && ((((__const uint8_t *) (a))[1] & 0xf) == 0xe))
> > +#endif
> >
> >  #include <config.h>
> >
>
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20110322/fa15b151/attachment-0001.html>


More information about the Spice-devel mailing list