~statik/ubuntu/maverick/erlang/erlang-merge-testing

« back to all changes in this revision

Viewing changes to erts/include/internal/i386/atomic.h

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-01 10:14:38 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090501101438-6qlr6rsdxgyzrg2z
Tags: 1:13.b-dfsg-2
* Cleaned up patches: removed unneeded patch which helped to support
  different SCTP library versions, made sure that changes for m68k
  architecture applied only when building on this architecture.
* Removed duplicated information from binary packages descriptions.
* Don't require libsctp-dev build-dependency on solaris-i386 architecture
  which allows to build Erlang on Nexenta (thanks to Tim Spriggs for
  the suggestion).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ``The contents of this file are subject to the Erlang Public License,
 
1
/*
 
2
 * %CopyrightBegin%
 
3
 * 
 
4
 * Copyright Ericsson AB 2005-2009. All Rights Reserved.
 
5
 * 
 
6
 * The contents of this file are subject to the Erlang Public License,
2
7
 * Version 1.1, (the "License"); you may not use this file except in
3
8
 * compliance with the License. You should have received a copy of the
4
9
 * Erlang Public License along with this software. If not, it can be
5
 
 * retrieved via the world wide web at http://www.erlang.org/.
 
10
 * retrieved online at http://www.erlang.org/.
6
11
 * 
7
12
 * Software distributed under the License is distributed on an "AS IS"
8
13
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
 * the License for the specific language governing rights and limitations
10
15
 * under the License.
11
16
 * 
12
 
 * The Initial Developer of the Original Code is Ericsson AB.
13
 
 * Portions created by Ericsson are Copyright 2006, Ericsson AB.
14
 
 * All Rights Reserved.''
15
 
 * 
16
 
 *     $Id$
 
17
 * %CopyrightEnd%
17
18
 */
18
19
 
19
20
/*
97
98
#define ethr_native_atomic_dec_return(var) ethr_native_atomic_add_return((var), -1)
98
99
 
99
100
static ETHR_INLINE long
 
101
ethr_native_atomic_cmpxchg(ethr_native_atomic_t *var, long new, long old)
 
102
{
 
103
    __asm__ __volatile__(
 
104
      "lock; cmpxchg" LONG_SUFFIX " %2, %3"
 
105
      : "=a"(old), "=m"(var->counter)
 
106
      : "r"(new), "m"(var->counter), "0"(old)
 
107
      : "cc", "memory"); /* full memory clobber to make this a compiler barrier */
 
108
    return old;
 
109
}
 
110
 
 
111
static ETHR_INLINE long
100
112
ethr_native_atomic_and_retold(ethr_native_atomic_t *var, long mask)
101
113
{
102
114
    long tmp, old;
104
116
    tmp = var->counter;
105
117
    do {
106
118
        old = tmp;
107
 
        __asm__ __volatile__(
108
 
            "lock; cmpxchg" LONG_SUFFIX " %2, %3"
109
 
            : "=a"(tmp), "=m"(var->counter)
110
 
            : "r"(old & mask), "m"(var->counter), "0"(old));
 
119
        tmp = ethr_native_atomic_cmpxchg(var, tmp & mask, tmp);
111
120
    } while (__builtin_expect(tmp != old, 0));
112
121
    /* now tmp is the atomic's previous value */
113
122
    return tmp;
121
130
    tmp = var->counter;
122
131
    do {
123
132
        old = tmp;
124
 
        __asm__ __volatile__(
125
 
            "lock; cmpxchg" LONG_SUFFIX " %2, %3"
126
 
            : "=a"(tmp), "=m"(var->counter)
127
 
            : "r"(old | mask), "m"(var->counter), "0"(old));
 
133
        tmp = ethr_native_atomic_cmpxchg(var, tmp | mask, tmp);
128
134
    } while (__builtin_expect(tmp != old, 0));
129
135
    /* now tmp is the atomic's previous value */
130
136
    return tmp;