Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/bind9/isc
File: atomic.h
/*
[0] Fix | Delete
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
[1] Fix | Delete
*
[2] Fix | Delete
* This Source Code Form is subject to the terms of the Mozilla Public
[3] Fix | Delete
* License, v. 2.0. If a copy of the MPL was not distributed with this
[4] Fix | Delete
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
[5] Fix | Delete
*
[6] Fix | Delete
* See the COPYRIGHT file distributed with this work for additional
[7] Fix | Delete
* information regarding copyright ownership.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
[11] Fix | Delete
#ifndef ISC_ATOMIC_H
[12] Fix | Delete
#define ISC_ATOMIC_H 1
[13] Fix | Delete
[14] Fix | Delete
#include <inttypes.h>
[15] Fix | Delete
[16] Fix | Delete
#include <isc/platform.h>
[17] Fix | Delete
#include <isc/types.h>
[18] Fix | Delete
[19] Fix | Delete
#ifdef ISC_PLATFORM_USEGCCASM
[20] Fix | Delete
/*
[21] Fix | Delete
* This routine atomically increments the value stored in 'p' by 'val', and
[22] Fix | Delete
* returns the previous value.
[23] Fix | Delete
*/
[24] Fix | Delete
static __inline__ int32_t
[25] Fix | Delete
isc_atomic_xadd(int32_t *p, int32_t val) {
[26] Fix | Delete
int32_t prev = val;
[27] Fix | Delete
[28] Fix | Delete
__asm__ volatile(
[29] Fix | Delete
#ifdef ISC_PLATFORM_USETHREADS
[30] Fix | Delete
"lock;"
[31] Fix | Delete
#endif
[32] Fix | Delete
"xadd %0, %1"
[33] Fix | Delete
:"=q"(prev)
[34] Fix | Delete
:"m"(*p), "0"(prev)
[35] Fix | Delete
:"memory", "cc");
[36] Fix | Delete
[37] Fix | Delete
return (prev);
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
#ifdef ISC_PLATFORM_HAVEXADDQ
[41] Fix | Delete
static __inline__ int64_t
[42] Fix | Delete
isc_atomic_xaddq(int64_t *p, int64_t val) {
[43] Fix | Delete
int64_t prev = val;
[44] Fix | Delete
[45] Fix | Delete
__asm__ volatile(
[46] Fix | Delete
#ifdef ISC_PLATFORM_USETHREADS
[47] Fix | Delete
"lock;"
[48] Fix | Delete
#endif
[49] Fix | Delete
"xaddq %0, %1"
[50] Fix | Delete
:"=q"(prev)
[51] Fix | Delete
:"m"(*p), "0"(prev)
[52] Fix | Delete
:"memory", "cc");
[53] Fix | Delete
[54] Fix | Delete
return (prev);
[55] Fix | Delete
}
[56] Fix | Delete
#endif /* ISC_PLATFORM_HAVEXADDQ */
[57] Fix | Delete
[58] Fix | Delete
/*
[59] Fix | Delete
* This routine atomically stores the value 'val' in 'p' (32-bit version).
[60] Fix | Delete
*/
[61] Fix | Delete
static __inline__ void
[62] Fix | Delete
isc_atomic_store(int32_t *p, int32_t val) {
[63] Fix | Delete
__asm__ volatile(
[64] Fix | Delete
#ifdef ISC_PLATFORM_USETHREADS
[65] Fix | Delete
/*
[66] Fix | Delete
* xchg should automatically lock memory, but we add it
[67] Fix | Delete
* explicitly just in case (it at least doesn't harm)
[68] Fix | Delete
*/
[69] Fix | Delete
"lock;"
[70] Fix | Delete
#endif
[71] Fix | Delete
[72] Fix | Delete
"xchgl %1, %0"
[73] Fix | Delete
:
[74] Fix | Delete
: "r"(val), "m"(*p)
[75] Fix | Delete
: "memory");
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
#ifdef ISC_PLATFORM_HAVEATOMICSTOREQ
[79] Fix | Delete
/*
[80] Fix | Delete
* This routine atomically stores the value 'val' in 'p' (64-bit version).
[81] Fix | Delete
*/
[82] Fix | Delete
static __inline__ void
[83] Fix | Delete
isc_atomic_storeq(int64_t *p, int64_t val) {
[84] Fix | Delete
__asm__ volatile(
[85] Fix | Delete
#ifdef ISC_PLATFORM_USETHREADS
[86] Fix | Delete
/*
[87] Fix | Delete
* xchg should automatically lock memory, but we add it
[88] Fix | Delete
* explicitly just in case (it at least doesn't harm)
[89] Fix | Delete
*/
[90] Fix | Delete
"lock;"
[91] Fix | Delete
#endif
[92] Fix | Delete
[93] Fix | Delete
"xchgq %1, %0"
[94] Fix | Delete
:
[95] Fix | Delete
: "r"(val), "m"(*p)
[96] Fix | Delete
: "memory");
[97] Fix | Delete
}
[98] Fix | Delete
#endif /* ISC_PLATFORM_HAVEATOMICSTOREQ */
[99] Fix | Delete
[100] Fix | Delete
/*
[101] Fix | Delete
* This routine atomically replaces the value in 'p' with 'val', if the
[102] Fix | Delete
* original value is equal to 'cmpval'. The original value is returned in any
[103] Fix | Delete
* case.
[104] Fix | Delete
*/
[105] Fix | Delete
static __inline__ int32_t
[106] Fix | Delete
isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) {
[107] Fix | Delete
__asm__ volatile(
[108] Fix | Delete
#ifdef ISC_PLATFORM_USETHREADS
[109] Fix | Delete
"lock;"
[110] Fix | Delete
#endif
[111] Fix | Delete
"cmpxchgl %1, %2"
[112] Fix | Delete
: "=a"(cmpval)
[113] Fix | Delete
: "r"(val), "m"(*p), "a"(cmpval)
[114] Fix | Delete
: "memory");
[115] Fix | Delete
[116] Fix | Delete
return (cmpval);
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
#elif defined(ISC_PLATFORM_USESTDASM)
[120] Fix | Delete
/*
[121] Fix | Delete
* The following are "generic" assembly code which implements the same
[122] Fix | Delete
* functionality in case the gcc extension cannot be used. It should be
[123] Fix | Delete
* better to avoid inlining below, since we directly refer to specific
[124] Fix | Delete
* positions of the stack frame, which would not actually point to the
[125] Fix | Delete
* intended address in the embedded mnemonic.
[126] Fix | Delete
*/
[127] Fix | Delete
static int32_t
[128] Fix | Delete
isc_atomic_xadd(int32_t *p, int32_t val) {
[129] Fix | Delete
(void)(p);
[130] Fix | Delete
(void)(val);
[131] Fix | Delete
[132] Fix | Delete
__asm (
[133] Fix | Delete
"movl 8(%ebp), %ecx\n"
[134] Fix | Delete
"movl 12(%ebp), %edx\n"
[135] Fix | Delete
#ifdef ISC_PLATFORM_USETHREADS
[136] Fix | Delete
"lock;"
[137] Fix | Delete
#endif
[138] Fix | Delete
"xadd %edx, (%ecx)\n"
[139] Fix | Delete
[140] Fix | Delete
/*
[141] Fix | Delete
* set the return value directly in the register so that we
[142] Fix | Delete
* can avoid guessing the correct position in the stack for a
[143] Fix | Delete
* local variable.
[144] Fix | Delete
*/
[145] Fix | Delete
"movl %edx, %eax"
[146] Fix | Delete
);
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
static void
[150] Fix | Delete
isc_atomic_store(int32_t *p, int32_t val) {
[151] Fix | Delete
(void)(p);
[152] Fix | Delete
(void)(val);
[153] Fix | Delete
[154] Fix | Delete
__asm (
[155] Fix | Delete
"movl 8(%ebp), %ecx\n"
[156] Fix | Delete
"movl 12(%ebp), %edx\n"
[157] Fix | Delete
#ifdef ISC_PLATFORM_USETHREADS
[158] Fix | Delete
"lock;"
[159] Fix | Delete
#endif
[160] Fix | Delete
"xchgl (%ecx), %edx\n"
[161] Fix | Delete
);
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
static int32_t
[165] Fix | Delete
isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) {
[166] Fix | Delete
(void)(p);
[167] Fix | Delete
(void)(cmpval);
[168] Fix | Delete
(void)(val);
[169] Fix | Delete
[170] Fix | Delete
__asm (
[171] Fix | Delete
"movl 8(%ebp), %ecx\n"
[172] Fix | Delete
"movl 12(%ebp), %eax\n" /* must be %eax for cmpxchgl */
[173] Fix | Delete
"movl 16(%ebp), %edx\n"
[174] Fix | Delete
#ifdef ISC_PLATFORM_USETHREADS
[175] Fix | Delete
"lock;"
[176] Fix | Delete
#endif
[177] Fix | Delete
[178] Fix | Delete
/*
[179] Fix | Delete
* If (%ecx) == %eax then (%ecx) := %edx.
[180] Fix | Delete
% %eax is set to old (%ecx), which will be the return value.
[181] Fix | Delete
*/
[182] Fix | Delete
"cmpxchgl %edx, (%ecx)"
[183] Fix | Delete
);
[184] Fix | Delete
}
[185] Fix | Delete
#else /* !ISC_PLATFORM_USEGCCASM && !ISC_PLATFORM_USESTDASM */
[186] Fix | Delete
[187] Fix | Delete
#error "unsupported compiler. disable atomic ops by --disable-atomic"
[188] Fix | Delete
[189] Fix | Delete
#endif
[190] Fix | Delete
#endif /* ISC_ATOMIC_H */
[191] Fix | Delete
[192] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function