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

« back to all changes in this revision

Viewing changes to lib/isc/x86_64/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) 2005, 2007, 2008  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.128.2 2008/01/24 23:46:26 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
/* We share the gcc-version with x86_32 */
 
28
#error "impossible case.  check build configuration"
 
29
 
 
30
#elif defined(ISC_PLATFORM_USESTDASM)
 
31
/*
 
32
 * The followings are "generic" assembly code which implements the same
 
33
 * functionality in case the gcc extension cannot be used.  It should be
 
34
 * better to avoid inlining below, since we directly refer to specific
 
35
 * registers for arguments, which would not actually correspond to the
 
36
 * intended address or value in the embedded mnemonic.
 
37
 */
 
38
#include <isc/util.h>           /* for 'UNUSED' macro */
 
39
 
 
40
static isc_int32_t
 
41
isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) {
 
42
        UNUSED(p);
 
43
        UNUSED(val);
 
44
 
 
45
        __asm (
 
46
                "movq %rdi, %rdx\n"
 
47
                "movl %esi, %eax\n"
 
48
#ifdef ISC_PLATFORM_USETHREADS
 
49
                "lock;"
 
50
#endif
 
51
                "xadd %eax, (%rdx)\n"
 
52
                /*
 
53
                 * XXX: assume %eax will be used as the return value.
 
54
                 */
 
55
                );
 
56
}
 
57
 
 
58
#ifdef ISC_PLATFORM_HAVEXADDQ
 
59
static isc_int64_t
 
60
isc_atomic_xaddq(isc_int64_t *p, isc_int64_t val) {
 
61
        UNUSED(p);
 
62
        UNUSED(val);
 
63
 
 
64
        __asm (
 
65
                "movq %rdi, %rdx\n"
 
66
                "movq %rsi, %rax\n"
 
67
#ifdef ISC_PLATFORM_USETHREADS
 
68
                "lock;"
 
69
#endif
 
70
                "xaddq %rax, (%rdx)\n"
 
71
                /*
 
72
                 * XXX: assume %rax will be used as the return value.
 
73
                 */
 
74
                );
 
75
}
 
76
#endif
 
77
 
 
78
static void
 
79
isc_atomic_store(isc_int32_t *p, isc_int32_t val) {
 
80
        UNUSED(p);
 
81
        UNUSED(val);
 
82
 
 
83
        __asm (
 
84
                "movq %rdi, %rax\n"
 
85
                "movl %esi, %edx\n"
 
86
#ifdef ISC_PLATFORM_USETHREADS
 
87
                "lock;"
 
88
#endif
 
89
                "xchgl (%rax), %edx\n"
 
90
                /*
 
91
                 * XXX: assume %rax will be used as the return value.
 
92
                 */
 
93
                );
 
94
}
 
95
 
 
96
static isc_int32_t
 
97
isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) {
 
98
        UNUSED(p);
 
99
        UNUSED(cmpval);
 
100
        UNUSED(val);
 
101
 
 
102
        __asm (
 
103
                "movl %edx, %ecx\n"
 
104
                "movl %esi, %eax\n"
 
105
                "movq %rdi, %rdx\n"
 
106
 
 
107
#ifdef ISC_PLATFORM_USETHREADS
 
108
                "lock;"
 
109
#endif
 
110
                /*
 
111
                 * If (%rdi) == %eax then (%rdi) := %edx.
 
112
                 * %eax is set to old (%ecx), which will be the return value.
 
113
                 */
 
114
                "cmpxchgl %ecx, (%rdx)"
 
115
                );
 
116
}
 
117
 
 
118
#else /* !ISC_PLATFORM_USEGCCASM && !ISC_PLATFORM_USESTDASM */
 
119
 
 
120
#error "unsupported compiler.  disable atomic ops by --disable-atomic"
 
121
 
 
122
#endif
 
123
#endif /* ISC_ATOMIC_H */