~ubuntu-branches/ubuntu/maverick/bind9/maverick

« back to all changes in this revision

Viewing changes to lib/isc/ia64/include/isc/atomic.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, LaMont Jones, Internet Software Consortium, Inc, localization folks
  • Date: 2008-08-02 14:20:20 UTC
  • mfrom: (1.2.1 upstream) (6.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080802142020-l1hon9jy8lbbjxmg
[LaMont Jones]

* default to using resolvconf if it is installed
* fix sonames and dependencies.  Closes: #149259, #492418
* Do not build-depend libcap2-dev on non-linux.  Closes: #493392
* drop unused query-loc manpage.  Closes: #492564
* lwresd: Deliver /etc/bind directory.  Closes: #490027
* fix query-source comment in default install

[Internet Software Consortium, Inc]

* 9.5.0-P2.  Closes: #492949

[localization folks]

* l10n: Spanish debconf translation.  Closes: #492425 (Ignacio Mondino)
* l10n: Swedish debconf templates.  Closes: #491369 (Martin Ågren)
* l10n: Japanese debconf translations.  Closes: #492048 (Hideki Yamane
  (Debian-JP))
* l10n: Finnish translation.  Closes: #490630 (Esko Arajärvi)
* l10n: Italian debconf translations.  Closes: #492587 (Alessandro Vietta)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2006, 2007  Internet Systems Consortium, Inc. ("ISC")
 
3
 *
 
4
 * Permission to use, copy, modify, and/or distribute this software for any
 
5
 * purpose with or without fee is hereby granted, provided that the above
 
6
 * copyright notice and this permission notice appear in all copies.
 
7
 *
 
8
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
 
9
 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 
10
 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 
11
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 
12
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 
13
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
14
 * PERFORMANCE OF THIS SOFTWARE.
 
15
 */
 
16
 
 
17
/* $Id: atomic.h,v 1.4 2007/06/19 23:47:17 tbox Exp $ */
 
18
 
 
19
#ifndef ISC_ATOMIC_H
 
20
#define ISC_ATOMIC_H 1
 
21
 
 
22
#include <isc/platform.h>
 
23
#include <isc/types.h>
 
24
 
 
25
#ifdef ISC_PLATFORM_USEGCCASM
 
26
/*
 
27
 * This routine atomically increments the value stored in 'p' by 'val', and
 
28
 * returns the previous value.
 
29
 *
 
30
 * Open issue: can 'fetchadd' make the code faster for some particular values
 
31
 * (e.g., 1 and -1)?
 
32
 */
 
33
static inline isc_int32_t
 
34
isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) {
 
35
        isc_int32_t prev, swapped;
 
36
 
 
37
        for (prev = *(volatile isc_int32_t *)p; ; prev = swapped) {
 
38
                swapped = prev + val;
 
39
                __asm__ volatile(
 
40
                        "mov ar.ccv=%2;"
 
41
                        "cmpxchg4.acq %0=%4,%3,ar.ccv"
 
42
                        : "=r" (swapped), "=m" (*p)
 
43
                        : "r" (prev), "r" (swapped), "m" (*p)
 
44
                        : "memory");
 
45
                if (swapped == prev)
 
46
                        break;
 
47
        }
 
48
 
 
49
        return (prev);
 
50
}
 
51
 
 
52
/*
 
53
 * This routine atomically stores the value 'val' in 'p'.
 
54
 */
 
55
static inline void
 
56
isc_atomic_store(isc_int32_t *p, isc_int32_t val) {
 
57
        __asm__ volatile(
 
58
                "st4.rel %0=%1"
 
59
                : "=m" (*p)
 
60
                : "r" (val)
 
61
                : "memory"
 
62
                );
 
63
}
 
64
 
 
65
/*
 
66
 * This routine atomically replaces the value in 'p' with 'val', if the
 
67
 * original value is equal to 'cmpval'.  The original value is returned in any
 
68
 * case.
 
69
 */
 
70
static inline isc_int32_t
 
71
isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) {
 
72
        isc_int32_t ret;
 
73
 
 
74
        __asm__ volatile(
 
75
                "mov ar.ccv=%2;"
 
76
                "cmpxchg4.acq %0=%4,%3,ar.ccv"
 
77
                : "=r" (ret), "=m" (*p)
 
78
                : "r" (cmpval), "r" (val), "m" (*p)
 
79
                : "memory");
 
80
 
 
81
        return (ret);
 
82
}
 
83
#else /* !ISC_PLATFORM_USEGCCASM */
 
84
 
 
85
#error "unsupported compiler.  disable atomic ops by --disable-atomic"
 
86
 
 
87
#endif
 
88
#endif /* ISC_ATOMIC_H */