Annotation of win32/apache22/srclib/apr/include/apr_atomic.h, revision 1.1
1.1 ! moko 1: /* Licensed to the Apache Software Foundation (ASF) under one or more
! 2: * contributor license agreements. See the NOTICE file distributed with
! 3: * this work for additional information regarding copyright ownership.
! 4: * The ASF licenses this file to You under the Apache License, Version 2.0
! 5: * (the "License"); you may not use this file except in compliance with
! 6: * the License. You may obtain a copy of the License at
! 7: *
! 8: * http://www.apache.org/licenses/LICENSE-2.0
! 9: *
! 10: * Unless required by applicable law or agreed to in writing, software
! 11: * distributed under the License is distributed on an "AS IS" BASIS,
! 12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! 13: * See the License for the specific language governing permissions and
! 14: * limitations under the License.
! 15: */
! 16:
! 17: #ifndef APR_ATOMIC_H
! 18: #define APR_ATOMIC_H
! 19:
! 20: /**
! 21: * @file apr_atomic.h
! 22: * @brief APR Atomic Operations
! 23: */
! 24:
! 25: #include "apr.h"
! 26: #include "apr_pools.h"
! 27:
! 28: #ifdef __cplusplus
! 29: extern "C" {
! 30: #endif
! 31:
! 32: /**
! 33: * @defgroup apr_atomic Atomic Operations
! 34: * @ingroup APR
! 35: * @{
! 36: */
! 37:
! 38: /**
! 39: * this function is required on some platforms to initialize the
! 40: * atomic operation's internal structures
! 41: * @param p pool
! 42: * @return APR_SUCCESS on successful completion
! 43: * @remark Programs do NOT need to call this directly. APR will call this
! 44: * automatically from apr_initialize.
! 45: * @internal
! 46: */
! 47: APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p);
! 48:
! 49: /*
! 50: * Atomic operations on 32-bit values
! 51: * Note: Each of these functions internally implements a memory barrier
! 52: * on platforms that require it
! 53: */
! 54:
! 55: /**
! 56: * atomically read an apr_uint32_t from memory
! 57: * @param mem the pointer
! 58: */
! 59: APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem);
! 60:
! 61: /**
! 62: * atomically set an apr_uint32_t in memory
! 63: * @param mem pointer to the object
! 64: * @param val value that the object will assume
! 65: */
! 66: APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val);
! 67:
! 68: /**
! 69: * atomically add 'val' to an apr_uint32_t
! 70: * @param mem pointer to the object
! 71: * @param val amount to add
! 72: * @return old value pointed to by mem
! 73: */
! 74: APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val);
! 75:
! 76: /**
! 77: * atomically subtract 'val' from an apr_uint32_t
! 78: * @param mem pointer to the object
! 79: * @param val amount to subtract
! 80: */
! 81: APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val);
! 82:
! 83: /**
! 84: * atomically increment an apr_uint32_t by 1
! 85: * @param mem pointer to the object
! 86: * @return old value pointed to by mem
! 87: */
! 88: APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem);
! 89:
! 90: /**
! 91: * atomically decrement an apr_uint32_t by 1
! 92: * @param mem pointer to the atomic value
! 93: * @return zero if the value becomes zero on decrement, otherwise non-zero
! 94: */
! 95: APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem);
! 96:
! 97: /**
! 98: * compare an apr_uint32_t's value with 'cmp'.
! 99: * If they are the same swap the value with 'with'
! 100: * @param mem pointer to the value
! 101: * @param with what to swap it with
! 102: * @param cmp the value to compare it to
! 103: * @return the old value of *mem
! 104: */
! 105: APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
! 106: apr_uint32_t cmp);
! 107:
! 108: /**
! 109: * exchange an apr_uint32_t's value with 'val'.
! 110: * @param mem pointer to the value
! 111: * @param val what to swap it with
! 112: * @return the old value of *mem
! 113: */
! 114: APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val);
! 115:
! 116: /**
! 117: * compare the pointer's value with cmp.
! 118: * If they are the same swap the value with 'with'
! 119: * @param mem pointer to the pointer
! 120: * @param with what to swap it with
! 121: * @param cmp the value to compare it to
! 122: * @return the old value of the pointer
! 123: */
! 124: APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void *cmp);
! 125:
! 126: /**
! 127: * exchange a pair of pointer values
! 128: * @param mem pointer to the pointer
! 129: * @param with what to swap it with
! 130: * @return the old value of the pointer
! 131: */
! 132: APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with);
! 133:
! 134: /** @} */
! 135:
! 136: #ifdef __cplusplus
! 137: }
! 138: #endif
! 139:
! 140: #endif /* !APR_ATOMIC_H */
E-mail: