Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/bind9/isc
File: rwlock.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_RWLOCK_H
[12] Fix | Delete
#define ISC_RWLOCK_H 1
[13] Fix | Delete
[14] Fix | Delete
#include <inttypes.h>
[15] Fix | Delete
[16] Fix | Delete
/*! \file isc/rwlock.h */
[17] Fix | Delete
[18] Fix | Delete
#include <isc/condition.h>
[19] Fix | Delete
#include <isc/lang.h>
[20] Fix | Delete
#include <isc/platform.h>
[21] Fix | Delete
#include <isc/types.h>
[22] Fix | Delete
[23] Fix | Delete
#if defined(ISC_PLATFORM_HAVESTDATOMIC)
[24] Fix | Delete
#if defined(__cplusplus)
[25] Fix | Delete
#include <isc/stdatomic.h>
[26] Fix | Delete
#else
[27] Fix | Delete
#include <stdatomic.h>
[28] Fix | Delete
#endif
[29] Fix | Delete
#endif
[30] Fix | Delete
[31] Fix | Delete
ISC_LANG_BEGINDECLS
[32] Fix | Delete
[33] Fix | Delete
typedef enum {
[34] Fix | Delete
isc_rwlocktype_none = 0,
[35] Fix | Delete
isc_rwlocktype_read,
[36] Fix | Delete
isc_rwlocktype_write
[37] Fix | Delete
} isc_rwlocktype_t;
[38] Fix | Delete
[39] Fix | Delete
#ifdef ISC_PLATFORM_USETHREADS
[40] Fix | Delete
# if defined(ISC_PLATFORM_HAVESTDATOMIC)
[41] Fix | Delete
# define ISC_RWLOCK_USEATOMIC 1
[42] Fix | Delete
# define ISC_RWLOCK_USESTDATOMIC 1
[43] Fix | Delete
# else /* defined(ISC_PLATFORM_HAVESTDATOMIC) */
[44] Fix | Delete
# if defined(ISC_PLATFORM_HAVEXADD) && defined(ISC_PLATFORM_HAVECMPXCHG)
[45] Fix | Delete
# define ISC_RWLOCK_USEATOMIC 1
[46] Fix | Delete
# endif
[47] Fix | Delete
# endif /* defined(ISC_PLATFORM_HAVESTDATOMIC) */
[48] Fix | Delete
[49] Fix | Delete
struct isc_rwlock {
[50] Fix | Delete
/* Unlocked. */
[51] Fix | Delete
unsigned int magic;
[52] Fix | Delete
isc_mutex_t lock;
[53] Fix | Delete
[54] Fix | Delete
#if defined(ISC_RWLOCK_USEATOMIC)
[55] Fix | Delete
/*
[56] Fix | Delete
* When some atomic instructions with hardware assistance are
[57] Fix | Delete
* available, rwlock will use those so that concurrent readers do not
[58] Fix | Delete
* interfere with each other through mutex as long as no writers
[59] Fix | Delete
* appear, massively reducing the lock overhead in the typical case.
[60] Fix | Delete
*
[61] Fix | Delete
* The basic algorithm of this approach is the "simple
[62] Fix | Delete
* writer-preference lock" shown in the following URL:
[63] Fix | Delete
* http://www.cs.rochester.edu/u/scott/synchronization/pseudocode/rw.html
[64] Fix | Delete
* but our implementation does not rely on the spin lock unlike the
[65] Fix | Delete
* original algorithm to be more portable as a user space application.
[66] Fix | Delete
*/
[67] Fix | Delete
[68] Fix | Delete
/* Read or modified atomically. */
[69] Fix | Delete
#if defined(ISC_RWLOCK_USESTDATOMIC)
[70] Fix | Delete
atomic_int_fast32_t spins;
[71] Fix | Delete
atomic_int_fast32_t write_requests;
[72] Fix | Delete
atomic_int_fast32_t write_completions;
[73] Fix | Delete
atomic_int_fast32_t cnt_and_flag;
[74] Fix | Delete
atomic_int_fast32_t write_granted;
[75] Fix | Delete
#else
[76] Fix | Delete
int32_t spins;
[77] Fix | Delete
int32_t write_requests;
[78] Fix | Delete
int32_t write_completions;
[79] Fix | Delete
int32_t cnt_and_flag;
[80] Fix | Delete
int32_t write_granted;
[81] Fix | Delete
#endif
[82] Fix | Delete
[83] Fix | Delete
/* Locked by lock. */
[84] Fix | Delete
isc_condition_t readable;
[85] Fix | Delete
isc_condition_t writeable;
[86] Fix | Delete
unsigned int readers_waiting;
[87] Fix | Delete
[88] Fix | Delete
/* Unlocked. */
[89] Fix | Delete
unsigned int write_quota;
[90] Fix | Delete
[91] Fix | Delete
#else /* ISC_RWLOCK_USEATOMIC */
[92] Fix | Delete
[93] Fix | Delete
/*%< Locked by lock. */
[94] Fix | Delete
isc_condition_t readable;
[95] Fix | Delete
isc_condition_t writeable;
[96] Fix | Delete
isc_rwlocktype_t type;
[97] Fix | Delete
[98] Fix | Delete
/*% The number of threads that have the lock. */
[99] Fix | Delete
unsigned int active;
[100] Fix | Delete
[101] Fix | Delete
/*%
[102] Fix | Delete
* The number of lock grants made since the lock was last switched
[103] Fix | Delete
* from reading to writing or vice versa; used in determining
[104] Fix | Delete
* when the quota is reached and it is time to switch.
[105] Fix | Delete
*/
[106] Fix | Delete
unsigned int granted;
[107] Fix | Delete
[108] Fix | Delete
unsigned int spins;
[109] Fix | Delete
unsigned int readers_waiting;
[110] Fix | Delete
unsigned int writers_waiting;
[111] Fix | Delete
unsigned int read_quota;
[112] Fix | Delete
unsigned int write_quota;
[113] Fix | Delete
isc_rwlocktype_t original;
[114] Fix | Delete
#endif /* ISC_RWLOCK_USEATOMIC */
[115] Fix | Delete
};
[116] Fix | Delete
#else /* ISC_PLATFORM_USETHREADS */
[117] Fix | Delete
struct isc_rwlock {
[118] Fix | Delete
unsigned int magic;
[119] Fix | Delete
isc_rwlocktype_t type;
[120] Fix | Delete
unsigned int active;
[121] Fix | Delete
};
[122] Fix | Delete
#endif /* ISC_PLATFORM_USETHREADS */
[123] Fix | Delete
[124] Fix | Delete
[125] Fix | Delete
isc_result_t
[126] Fix | Delete
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
[127] Fix | Delete
unsigned int write_quota);
[128] Fix | Delete
[129] Fix | Delete
isc_result_t
[130] Fix | Delete
isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type);
[131] Fix | Delete
[132] Fix | Delete
isc_result_t
[133] Fix | Delete
isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type);
[134] Fix | Delete
[135] Fix | Delete
isc_result_t
[136] Fix | Delete
isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type);
[137] Fix | Delete
[138] Fix | Delete
isc_result_t
[139] Fix | Delete
isc_rwlock_tryupgrade(isc_rwlock_t *rwl);
[140] Fix | Delete
[141] Fix | Delete
void
[142] Fix | Delete
isc_rwlock_downgrade(isc_rwlock_t *rwl);
[143] Fix | Delete
[144] Fix | Delete
void
[145] Fix | Delete
isc_rwlock_destroy(isc_rwlock_t *rwl);
[146] Fix | Delete
[147] Fix | Delete
ISC_LANG_ENDDECLS
[148] Fix | Delete
[149] Fix | Delete
#endif /* ISC_RWLOCK_H */
[150] Fix | Delete
[151] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function