003 File Manager
Current Path:
/usr/src/contrib/subversion/subversion/libsvn_subr
usr
/
src
/
contrib
/
subversion
/
subversion
/
libsvn_subr
/
📁
..
📄
adler32.c
(3.16 KB)
📄
atomic.c
(7.23 KB)
📄
auth.c
(32.4 KB)
📄
auth.h
(6.1 KB)
📄
base64.c
(19.18 KB)
📄
bit_array.c
(6.26 KB)
📄
cache-inprocess.c
(21.2 KB)
📄
cache-membuffer.c
(116.43 KB)
📄
cache-memcache.c
(17.35 KB)
📄
cache-null.c
(4.35 KB)
📄
cache.c
(10.22 KB)
📄
cache.h
(4.03 KB)
📄
cache_config.c
(6.01 KB)
📄
checksum.c
(24.17 KB)
📄
checksum.h
(2.32 KB)
📄
cmdline.c
(58.99 KB)
📄
compat.c
(5.28 KB)
📄
compress_lz4.c
(4.51 KB)
📄
compress_zlib.c
(6.85 KB)
📄
config.c
(39.66 KB)
📄
config_auth.c
(8.65 KB)
📄
config_file.c
(70.25 KB)
📄
config_impl.h
(6.15 KB)
📄
config_keys.inc
(2.65 KB)
📄
config_win.c
(9.61 KB)
📄
crypto.c
(25.19 KB)
📄
crypto.h
(5.43 KB)
📄
ctype.c
(13.81 KB)
📄
date.c
(12.86 KB)
📄
debug.c
(3.77 KB)
📄
deprecated.c
(64.3 KB)
📄
dirent_uri.c
(80.17 KB)
📄
dirent_uri.h
(1.43 KB)
📄
dso.c
(3.74 KB)
📄
encode.c
(2.69 KB)
📄
eol.c
(2.79 KB)
📄
error.c
(24.52 KB)
📄
errorcode.inc
(4.27 KB)
📄
fnv1a.c
(6.92 KB)
📄
fnv1a.h
(3.04 KB)
📄
genctype.py
(3.84 KB)
📄
gpg_agent.c
(22.29 KB)
📄
hash.c
(19.59 KB)
📄
internal_statements.h
(1.87 KB)
📄
internal_statements.sql
(1.58 KB)
📄
io.c
(182.6 KB)
📄
iter.c
(3.84 KB)
📄
libsvn_subr.pc.in
(515 B)
📄
lock.c
(1.69 KB)
📄
log.c
(14 KB)
📁
lz4
📄
macos_keychain.c
(9.7 KB)
📄
magic.c
(5.25 KB)
📄
md5.c
(1.8 KB)
📄
mergeinfo.c
(89.24 KB)
📄
mutex.c
(3.06 KB)
📄
nls.c
(3.06 KB)
📄
object_pool.c
(9.76 KB)
📄
opt.c
(39.34 KB)
📄
opt.h
(1.89 KB)
📄
packed_data.c
(33.43 KB)
📄
path.c
(35.99 KB)
📄
pool.c
(4.35 KB)
📄
pools.h
(1.45 KB)
📄
prefix_string.c
(10.65 KB)
📄
prompt.c
(28.82 KB)
📄
properties.c
(13.59 KB)
📄
quoprint.c
(8.96 KB)
📄
root_pools.c
(3.15 KB)
📄
simple_providers.c
(25.54 KB)
📄
skel.c
(23.04 KB)
📄
sorts.c
(15.9 KB)
📄
spillbuf.c
(19.78 KB)
📄
sqlite.c
(49.68 KB)
📄
sqlite3wrapper.c
(3.16 KB)
📄
ssl_client_cert_providers.c
(6.66 KB)
📄
ssl_client_cert_pw_providers.c
(18.93 KB)
📄
ssl_server_trust_providers.c
(7.77 KB)
📄
stream.c
(65.69 KB)
📄
string.c
(40.2 KB)
📄
subst.c
(67.57 KB)
📄
sysinfo.c
(43.67 KB)
📄
sysinfo.h
(2.58 KB)
📄
target.c
(11.58 KB)
📄
temp_serializer.c
(14.02 KB)
📄
time.c
(9.08 KB)
📄
token.c
(2.58 KB)
📄
types.c
(9.43 KB)
📄
user.c
(2.66 KB)
📄
username_providers.c
(9.2 KB)
📄
utf.c
(40.38 KB)
📁
utf8proc
📄
utf8proc.c
(20.71 KB)
📄
utf_validate.c
(13.3 KB)
📄
utf_width.c
(10.85 KB)
📄
validate.c
(3.35 KB)
📄
version.c
(9.89 KB)
📄
win32_crashrpt.c
(25.06 KB)
📄
win32_crashrpt.h
(1.35 KB)
📄
win32_crashrpt_dll.h
(4 KB)
📄
win32_crypto.c
(18.12 KB)
📄
win32_xlate.c
(7.3 KB)
📄
win32_xlate.h
(2.11 KB)
📄
x509.h
(3.75 KB)
📄
x509info.c
(9.53 KB)
📄
x509parse.c
(35.77 KB)
📄
xml.c
(20.01 KB)
Editing: atomic.c
/* atomic.c : perform atomic initialization * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * ==================================================================== */ #include <assert.h> #include <apr_time.h> #include "svn_pools.h" #include "private/svn_atomic.h" #include "private/svn_mutex.h" /* Magic values for atomic initialization */ #define SVN_ATOMIC_UNINITIALIZED 0 #define SVN_ATOMIC_START_INIT 1 #define SVN_ATOMIC_INIT_FAILED 2 #define SVN_ATOMIC_INITIALIZED 3 /* Baton used by init_funct_t and init_once(). */ typedef struct init_baton_t init_baton_t; /* Initialization function wrapper. Hides API details from init_once(). The implementation must return FALSE on failure. */ typedef svn_boolean_t (*init_func_t)(init_baton_t *init_baton); /* * This is the actual atomic initialization driver. * Returns FALSE on failure. */ static svn_boolean_t init_once(volatile svn_atomic_t *global_status, init_func_t init_func, init_baton_t *init_baton) { /* !! Don't use localizable strings in this function, because these !! might cause deadlocks. This function can be used to initialize !! libraries that are used for generating error messages. */ /* We have to call init_func exactly once. Because APR doesn't have statically-initialized mutexes, we implement a poor man's spinlock using svn_atomic_cas. */ svn_atomic_t status = svn_atomic_cas(global_status, SVN_ATOMIC_START_INIT, SVN_ATOMIC_UNINITIALIZED); for (;;) { switch (status) { case SVN_ATOMIC_UNINITIALIZED: { const svn_boolean_t result = init_func(init_baton); const svn_atomic_t init_state = (result ? SVN_ATOMIC_INITIALIZED : SVN_ATOMIC_INIT_FAILED); svn_atomic_cas(global_status, init_state, SVN_ATOMIC_START_INIT); return result; } case SVN_ATOMIC_START_INIT: /* Wait for the init function to complete. */ apr_sleep(APR_USEC_PER_SEC / 1000); status = svn_atomic_cas(global_status, SVN_ATOMIC_UNINITIALIZED, SVN_ATOMIC_UNINITIALIZED); continue; case SVN_ATOMIC_INIT_FAILED: return FALSE; case SVN_ATOMIC_INITIALIZED: return TRUE; default: /* Something went seriously wrong with the atomic operations. */ abort(); } } } /* This baton structure is used by the two flavours of init-once APIs to hide their differences from the init_once() driver. Each private API uses only selected parts of the baton. No part of this structure changes unless a wrapped init function is actually invoked by init_once(). */ struct init_baton_t { /* Used only by svn_atomic__init_once()/err_init_func_wrapper() */ svn_atomic__err_init_func_t err_init_func; svn_error_t *err; apr_pool_t *pool; /* Used only by svn_atomic__init_no_error()/str_init_func_wrapper() */ svn_atomic__str_init_func_t str_init_func; const char *errstr; /* Used by both pairs of functions */ void *baton; }; /* Wrapper for the svn_atomic__init_once init function. */ static svn_boolean_t err_init_func_wrapper(init_baton_t *init_baton) { init_baton->err = init_baton->err_init_func(init_baton->baton, init_baton->pool); return (init_baton->err == SVN_NO_ERROR); } svn_error_t * svn_atomic__init_once(volatile svn_atomic_t *global_status, svn_atomic__err_init_func_t err_init_func, void *baton, apr_pool_t* pool) { init_baton_t init_baton; init_baton.err_init_func = err_init_func; init_baton.err = NULL; init_baton.pool = pool; init_baton.baton = baton; if (init_once(global_status, err_init_func_wrapper, &init_baton)) return SVN_NO_ERROR; return svn_error_create(SVN_ERR_ATOMIC_INIT_FAILURE, init_baton.err, "Couldn't perform atomic initialization"); } /* Wrapper for the svn_atomic__init_no_error init function. */ static svn_boolean_t str_init_func_wrapper(init_baton_t *init_baton) { init_baton->errstr = init_baton->str_init_func(init_baton->baton); return (init_baton->errstr == NULL); } const char * svn_atomic__init_once_no_error(volatile svn_atomic_t *global_status, svn_atomic__str_init_func_t str_init_func, void *baton) { init_baton_t init_baton; init_baton.str_init_func = str_init_func; init_baton.errstr = NULL; init_baton.baton = baton; if (init_once(global_status, str_init_func_wrapper, &init_baton)) return NULL; /* Our init function wrapper may not have been called; make sure that we return generic error message in that case. */ if (!init_baton.errstr) return "Couldn't perform atomic initialization"; else return init_baton.errstr; } /* The process-global counter that we use to produce process-wide unique * values. Since APR has no 64 bit atomics, all access to this will be * serialized through COUNTER_MUTEX. */ static apr_uint64_t uniqiue_counter = 0; /* The corresponding mutex and initialization state. */ static volatile svn_atomic_t counter_status = SVN_ATOMIC_UNINITIALIZED; static svn_mutex__t *counter_mutex = NULL; /* svn_atomic__err_init_func_t implementation that initializes COUNTER_MUTEX. * Note that neither argument will be used and should be NULL. */ static svn_error_t * init_unique_counter(void *null_baton, apr_pool_t *null_pool) { /* COUNTER_MUTEX is global, so it needs to live in a global pool. * APR also makes those thread-safe by default. */ SVN_ERR(svn_mutex__init(&counter_mutex, TRUE, svn_pool_create(NULL))); return SVN_NO_ERROR; } /* Read and increment UNIQIUE_COUNTER. Return the new value in *VALUE. * Call this function only while having acquired the COUNTER_MUTEX. */ static svn_error_t * read_unique_counter(apr_uint64_t *value) { *value = ++uniqiue_counter; return SVN_NO_ERROR; } svn_error_t * svn_atomic__unique_counter(apr_uint64_t *value) { SVN_ERR(svn_atomic__init_once(&counter_status, init_unique_counter, NULL, NULL)); SVN_MUTEX__WITH_LOCK(counter_mutex, read_unique_counter(value)); return SVN_NO_ERROR; }
Upload File
Create Folder