rpms/crystalspace/devel crystalspace-1.2-ppc64.patch, NONE, 1.1 crystalspace.spec, 1.4, 1.5

Hans de Goede (jwrdegoede) fedora-extras-commits at redhat.com
Tue Jun 17 07:26:39 UTC 2008


Author: jwrdegoede

Update of /cvs/extras/rpms/crystalspace/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15663

Modified Files:
	crystalspace.spec 
Added Files:
	crystalspace-1.2-ppc64.patch 
Log Message:
* Tue Jun 17 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 1.2-6
- Fix building on ppc64, patch from David Woodhouse


crystalspace-1.2-ppc64.patch:

--- NEW FILE crystalspace-1.2-ppc64.patch ---
--- crystalspace-src-1.2/include/csutil/threading/atomicops_gcc_ppc.h~	2007-10-04 12:25:05.000000000 +0100
+++ crystalspace-src-1.2/include/csutil/threading/atomicops_gcc_ppc.h	2008-06-13 10:53:34.000000000 +0100
@@ -47,7 +47,23 @@ namespace Threading
 
     inline static void* Set (void** target, void* value)
     {
+#if CS_PROCESSOR_SIZE == 32
       return (void*)Set ((int32*)target, (int32)value);
+#elif CS_PROCESSOR_SIZE == 64
+      __asm__ __volatile__
+        (
+        "       lwsync \n"
+        "1:     ldarx   %0,0,%2 \n"
+        "       dcbt     0,%2 \n"
+        "       stdcx.  %3,0,%2 \n"
+        "       bne-    1b\n"
+        "       isync \n"
+        : "=&r" (value), "=m" (*(unsigned int *)target)
+        : "r" (target), "r" (value), "m" (*(unsigned int *)target)
+        : "cc", "memory"
+        );
+      return value;
+#endif
     }
 
     inline static int32 CompareAndSet (int32* target, int32 value,
@@ -74,21 +90,47 @@ namespace Threading
     inline static void* CompareAndSet (void** target, void* value,
       void* comparand)
     {
+#if CS_PROCESSOR_SIZE == 32
       return (void*)CompareAndSet ((int32*)target, (int32)value, 
         (int32)comparand);
+#elif CS_PROCESSOR_SIZE == 64
+      void *prev;
+
+      __asm__ __volatile__ (
+      "       lwsync \n"
+      "1:     ldarx   %0,0,%2\n"
+      "       cmpd    0,%0,%3\n"
+      "       bne-    2f\n"
+      "       dcbt     0,%2 \n"
+      "       stdcx.  %4,0,%2\n"
+      "       bne-    1b\n"
+      "       isync     \n"
+      "2:"
+      : "=&r" (prev), "=m" (*target)
+      : "r" (target), "r" (comparand), "r" (value), "m" (*target)
+      : "cc", "memory");
+      return prev;
+#endif
     }
 
     inline static int32 Increment (int32* target, int32 incr = 1)
     {
-      //@@Potentially dangerous code, needs to be revisited
-      int32 prevValue, currValue, nextValue;
-      do 
-      {
-        currValue = *target;
-        nextValue = currValue + incr;
-        prevValue = CompareAndSet (target, nextValue, currValue);
-      } while(prevValue == currValue);
-      return nextValue;
+      int32 value;
+
+      __asm__ __volatile__
+        (
+        "       lwsync \n"
+        "1:     lwarx   %0,0,%2 \n"
+        "       addw    %0,%0,%3 \n"
+        "       dcbt     0,%2 \n"
+        "       stwcx.  %0,0,%2 \n"
+        "       bne-    1b\n"
+        "       isync \n"
+        : "=&r" (value), "=m" (*(unsigned int *)target)
+        : "r" (target), "r" (incr), "m" (*(unsigned int *)target)
+        : "cc", "memory"
+        );
+      return value;
     }
 
     inline static int32 Decrement (int32* target)


Index: crystalspace.spec
===================================================================
RCS file: /cvs/extras/rpms/crystalspace/devel/crystalspace.spec,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- crystalspace.spec	22 May 2008 10:31:43 -0000	1.4
+++ crystalspace.spec	17 Jun 2008 07:25:56 -0000	1.5
@@ -2,7 +2,7 @@
 
 Name:           crystalspace
 Version:        1.2
-Release:        5%{?dist}
+Release:        6%{?dist}
 Summary:        Crystal Space a free 3D engine
 Group:          System Environment/Libraries
 # most of crystalspace is LGPLv2+, but the sndsys class (and its plugins) and
@@ -14,19 +14,13 @@
 URL:            http://www.crystalspace3d.org/
 Source0:        http://www.crystalspace3d.org/downloads/release/%{name}-src-%{version}.tar.bz2
 Patch0:         crystalspace-1.2-cs-config.patch
+Patch1:         crystalspace-1.2-ppc64.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires:  libpng-devel libjpeg-devel libmng-devel lcms-devel swig
 BuildRequires:  libvorbis-devel alsa-lib-devel freetype-devel
 BuildRequires:  cal3d-devel ode-devel cegui-devel libGLU-devel lib3ds-devel
 BuildRequires:  python-devel freealut-devel mikmod-devel
 BuildRequires:  libXxf86vm-devel SDL-devel wxGTK-devel libXaw-devel
-# Fails on ppc64 with the following error in deep magic code, help appreciated
-# ./include/csutil/threading/atomicops_gcc_ppc.h: In static member function 'static void* CS::Threading::AtomicOperationsPPCGCC::Set(void**, void*)':
-# ./include/csutil/threading/atomicops_gcc_ppc.h:50: error: cast from 'void*' to 'int32' loses precision
-# ./include/csutil/threading/atomicops_gcc_ppc.h: In static member function 'static void* CS::Threading::AtomicOperationsPPCGCC::CompareAndSet(void**, void*, void*)':
-# ./include/csutil/threading/atomicops_gcc_ppc.h:77: error: cast from 'void*' to 'int32' loses precision
-# ./include/csutil/threading/atomicops_gcc_ppc.h:78: error: cast from 'void*' to 'int32' loses precision
-ExcludeArch:    ppc64
 
 %description
 Crystal Space is a free (LGPL) and portable 3D SDK
@@ -74,6 +68,7 @@
 %prep
 %setup -q -n %{name}-src-%{version}
 %patch0 -p1 -z .cs-config
+%patch1 -p1
 sed -i 's/COMPILER.CFLAGS.debug += -DCS_DEBUG ;//' Jamrules
 # work around mikmod not being linked to libdl as it should (bug 431745)
 sed -i 's/-lmikmod/-lmikmod -ldl/g' configure
@@ -215,6 +210,9 @@
 
 
 %changelog
+* Tue Jun 17 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 1.2-6
+- Fix building on ppc64, patch from David Woodhouse
+
 * Mon May 19 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 1.2-5
 - Rebuild for new cegui
 - Work around redhat bugzilla bug 432185 on ppc by disabling python on ppc




More information about the fedora-extras-commits mailing list