Add libatomicops
[packages.git] / libs / libatomicops / patches / 001-mips.patch
1 From ths@networkno.de Thu Oct 27 15:44:14 2005
2 Received: (at submit) by bugs.debian.org; 27 Oct 2005 22:44:14 +0000
3 Return-path: <ths@networkno.de>
4 Received: from mx02.qsc.de [213.148.130.14] 
5         by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
6         id 1EVGTm-0002nQ-00; Thu, 27 Oct 2005 15:44:14 -0700
7 Received: from port-195-158-169-21.dynamic.qsc.de ([195.158.169.21] helo=hattusa.textio)
8         by mx02.qsc.de with esmtp (Exim 3.35 #1)
9         id 1EVGTH-00020N-00
10         for submit@bugs.debian.org; Fri, 28 Oct 2005 00:43:43 +0200
11 Received: from ths by hattusa.textio with local (Exim 4.54)
12         id 1EVGTG-000263-9P
13         for submit@bugs.debian.org; Fri, 28 Oct 2005 00:43:42 +0200
14 Date: Fri, 28 Oct 2005 00:43:42 +0200
15 To: submit@bugs.debian.org
16 Subject: [mips/mipsel] FTBFS due to missing arch-specific implementation
17 Message-ID: <20051027224341.GX5721@hattusa.textio>
18 MIME-Version: 1.0
19 Content-Type: text/plain; charset=us-ascii
20 Content-Disposition: inline
21 User-Agent: Mutt/1.5.11
22 From: Thiemo Seufer <ths@networkno.de>
23 Delivered-To: submit@bugs.debian.org
24 X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
25         (1.212-2003-09-23-exp) on spohr.debian.org
26 X-Spam-Level: 
27 X-Spam-Status: No, hits=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE 
28         autolearn=no version=2.60-bugs.debian.org_2005_01_02
29
30 Package: libatomic-ops
31 Version: 1.0-3
32 Tags: patch
33
34 Libatomic-ops currently FTBFS on mips/mipsel because there is no
35 arch-specific implementation, and the generic pthread isn't configured.
36
37 The appended patch adds a basic implementation for linux.
38
39
40 Thiemo
41
42
43 --- libatomic-ops-1.0.away/src/atomic_ops/sysdeps/Makefile.am   2005-08-03 02:05:18.000000000 +0200
44 +++ libatomic-ops-1.0/src/atomic_ops/sysdeps/Makefile.am        2005-10-27 20:59:59.000000000 +0200
45 @@ -26,7 +26,7 @@ nobase_sysdep_HEADERS= generic_pthread.h
46           gcc/alpha.h gcc/arm.h gcc/x86.h \
47           gcc/hppa.h gcc/ia64.h \
48           gcc/powerpc.h gcc/sparc.h \
49 -         gcc/hppa.h gcc/m68k.h gcc/s390.h \
50 +         gcc/hppa.h gcc/m68k.h gcc/mips.h gcc/s390.h \
51           gcc/ia64.h gcc/x86_64.h gcc/cris.h \
52         \
53           icc/ia64.h \
54 --- libatomic-ops-1.0.away/src/atomic_ops/sysdeps/gcc/mips.h    1970-01-01 01:00:00.000000000 +0100
55 +++ libatomic-ops-1.0/src/atomic_ops/sysdeps/gcc/mips.h 2005-10-28 00:11:19.000000000 +0200
56 @@ -0,0 +1,65 @@
57 +/* 
58 + * Copyright (c) 2005  Thiemo Seufer <ths@networkno.de>
59 + *
60 + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
61 + * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
62 + *
63 + * Permission is hereby granted to use or copy this program
64 + * for any purpose,  provided the above notices are retained on all copies.
65 + * Permission to modify the code and to distribute modified code is granted,
66 + * provided the above notices are retained, and a notice that the code was
67 + * modified is included with the above copyright notice.
68 + */
69 +
70 +#include "../all_aligned_atomic_load_store.h"
71 +#include "../test_and_set_t_is_ao_t.h"
72 +
73 +/* Data dependence does not imply read ordering.  */
74 +#define AO_NO_DD_ORDERING
75 +
76 +AO_INLINE void
77 +AO_nop_full()
78 +{
79 +  __asm__ __volatile__(
80 +      "       .set push           \n"
81 +      "       .set mips2          \n"
82 +      "       .set noreorder      \n"
83 +      "       .set nomacro        \n"
84 +      "       sync                \n"
85 +      "       .set pop              "
86 +      : : : "memory");
87 +}
88 +
89 +#define AO_HAVE_nop_full
90 +
91 +AO_INLINE int
92 +AO_compare_and_swap(volatile AO_t *addr, AO_t old, AO_t new_val)
93 +{
94 +  register int was_equal = 0;
95 +  register int temp;
96 +
97 +  __asm__ __volatile__(
98 +      "       .set push           \n"
99 +      "       .set mips2          \n"
100 +      "       .set noreorder      \n"
101 +      "       .set nomacro        \n"
102 +      "1:     ll      %0, %1      \n"
103 +      "       bne     %0, %4, 2f  \n"
104 +      "        move   %0, %3      \n"
105 +      "       sc      %0, %1      \n"
106 +      "       .set pop            \n"
107 +      "       beqz    %0, 1b      \n"
108 +      "       li     %2, 1        \n"
109 +      "2:                           "
110 +      : "=&r" (temp), "+R" (*addr), "+r" (was_equal)
111 +      : "r" (new_val), "r" (old)
112 +      : "memory");
113 +  return was_equal;
114 +}
115 +
116 +#define AO_HAVE_compare_and_swap
117 +
118 +/*
119 + * FIXME: We should also implement fetch_and_add and or primitives
120 + * directly.
121 + */
122 --- libatomic-ops-1.0.away/src/atomic_ops.h     2005-08-03 02:05:18.000000000 +0200
123 +++ libatomic-ops-1.0/src/atomic_ops.h  2005-10-27 21:01:29.000000000 +0200
124 @@ -219,6 +219,9 @@
125  # if defined(__cris__) || defined(CRIS)
126  #   include "atomic_ops/sysdeps/gcc/cris.h"
127  # endif
128 +# if defined(__mips__)
129 +#   include "atomic_ops/sysdeps/gcc/mips.h"
130 +# endif /* __mips__ */
131  #endif /* __GNUC__ && !AO_USE_PTHREAD_DEFS */
132  
133  #if defined(__INTEL_COMPILER) && !defined(AO_USE_PTHREAD_DEFS)
134
135