[ydl-gen] YDL 6.0 libcairo

Kevin Diggs kevdig at hypersurf.com
Mon Jun 23 15:00:24 MDT 2008


Hi,

	I was messing around trying to get the kernel gconfig thing to display 
on an x86 (i.e. little endian server). It took me longer than I care to 
admit to figure out why my fix was not ... compilin' right.

	Anyone know why libcairo seems to compile debug? I tried doing a:

rpmbuild -bc SPECS/cairo.spec

My .rpmrc contains:

optflags: ppc -mcpu=powerpc -O2
optflags: ppc64 -mcpu=powerpc -O2

The -g seems hard coded in the Makefile{s}? Is the libcairo that is 
shipped compiled debug? Anyone know how to find out? I forced an 
optimized build (-O2) and my fix shows up. It (gconfig) seems to work, 
both on the local display (Radeon 9200 or some such) as well as on an 
x86 laptop running Debian (Radeon 9000).

The fix is (actually this is against cairo-1.2.4-3.src.rpm, which 
actually fixes the little endian server crash, but less efficiently - 
this fix MAY have alignment issues):

[kevdig at PowerMacG5 src]$ diff -U3 cairo-xlib-private-{old,new}_h|more
--- cairo-xlib-private-old_h    2006-08-10 13:14:47.000000000 -0700
+++ cairo-xlib-private-new_h    2008-06-23 10:48:51.000000000 -0700
@@ -51,4 +51,58 @@
  cairo_private cairo_xlib_screen_info_t *
  _cairo_xlib_screen_info_get (Display *display, Screen *screen);

+static __inline__ void bswap32_st(unsigned int val, unsigned int *dest);
+static __inline__ void bswap16_st(unsigned short val, unsigned short 
*dest);
+
+#ifdef __GNUC__
+#ifdef __powerpc__
+static __inline__ void bswap32_st(unsigned int val, unsigned int *dest)
+{
+       __asm__ __volatile__ (
+               "stwbrx %0,0,%1\n"
+               :
+               :"r"(val),"r"(dest)
+       );
+}
+
+static __inline__ void bswap16_st(unsigned short val, unsigned short *dest)
+{
+       __asm__ __volatile__ (
+               "sthbrx %0,0,%1\n"
+               :
+               :"r"(val),"r"(dest)
+       );
+}
+#elif __i386__
+static __inline__ void bswap32_st(unsigned int val, unsigned int *dest)
+{
+       __asm__ __volatile__ (
+               "bswapl %0\n"
+               "movl %0,(%1)\n"
+               :
+               :"r"(val),"r"(dest)
+       );
+
+static __inline__ void bswap16_st(unsigned short val, unsigned short *dest)
+{
+       __asm__ __volatile__ (
+               "bswapw %0\n"
+               "movw %0,(%1)\n"
+               :
+               :"r"(val),"r"(dest)
+       );
+#endif /* probably missing a catch all for GNUC and other than x86 and 
+ powerpc */
+#else
+#include <byteswap.h>
+
+void __inline__ bswap32_st(unsigned int val, unsigned int *dest)
+{
+       *dest=bswap32(val);
+}
+
+void __inline__ bswap16_st(unsigned short val, unsigned short *dest)
+{
+       *dest=bswap16(val);
+}
+#endif
  #endif /* CAIRO_XLIB_PRIVATE_H */

[kevdig at PowerMacG5 src]$ diff -U3 cairo-xlib-surface-{old,new}_c|more
--- cairo-xlib-surface-old_c    2008-06-23 00:42:49.000000000 -0700
+++ cairo-xlib-surface-new_c    2008-06-23 11:28:34.000000000 -0700
@@ -403,8 +403,12 @@
      for (j = ximage->height; j; j--) {
         uint16_t *p = (uint16_t *)line;
         for (i = ximage->width; i; i--) {
+#if 0
             *p = (((*p & 0x00ff) << 8) |
                   ((*p)          >> 8));
+#else
+           bswap16_st(*p,p);
+#endif
             p++;
         }

@@ -421,10 +425,14 @@
      for (j = ximage->height; j; j--) {
         uint32_t *p = (uint32_t *)line;
         for (i = ximage->width; i; i--) {
+#if 0
             *p = (((*p & 0x000000ff) << 24) |
                   ((*p & 0x0000ff00) << 8) |
                   ((*p & 0x00ff0000) >> 8) |
                   ((*p)              >> 24));
+#else
+           bswap32_st(*p,p);
+#endif
             p++;
         }

@@ -2452,10 +2460,14 @@
             d = data;
             while (c >= 4)
             {
+#if 0
                 n[3] = d[0];
                 n[2] = d[1];
                 n[1] = d[2];
                 n[0] = d[3];
+#else
+               bswap32_st(*(unsigned int *)d,(unsigned int *)n);
+#endif
                 d += 4;
                 n += 4;
                 c -= 4;


More information about the yellowdog-general mailing list