[BACK]Return to atomic.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / sys

Annotation of src/sys/sys/atomic.h, Revision 1.6.8.1

1.6.8.1 ! bouyer      1: /*     $NetBSD$        */
1.2       ad          2:
                      3: /*-
                      4:  * Copyright (c) 2007 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by Jason R. Thorpe.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *     This product includes software developed by the NetBSD
                     21:  *     Foundation, Inc. and its contributors.
                     22:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     23:  *    contributors may be used to endorse or promote products derived
                     24:  *    from this software without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     27:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     28:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     29:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     30:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     31:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     32:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     33:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     34:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     35:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     36:  * POSSIBILITY OF SUCH DAMAGE.
                     37:  */
                     38:
                     39: #ifndef _SYS_ATOMIC_H_
                     40: #define        _SYS_ATOMIC_H_
                     41:
                     42: #include <sys/types.h>
1.6.8.1 ! bouyer     43: #if !defined(_KERNEL) && !defined(_STANDALONE)
1.2       ad         44: #include <stdint.h>
                     45: #endif
                     46:
                     47: /*
                     48:  * Atomic ADD
                     49:  */
1.5       ad         50: void           atomic_add_32(volatile uint32_t *, int32_t);
                     51: void           atomic_add_int(volatile unsigned int *, int);
                     52: void           atomic_add_long(volatile unsigned long *, long);
1.2       ad         53: void           atomic_add_ptr(volatile void *, ssize_t);
                     54: void           atomic_add_64(volatile uint64_t *, int64_t);
                     55:
1.5       ad         56: uint32_t       atomic_add_32_nv(volatile uint32_t *, int32_t);
                     57: unsigned int   atomic_add_int_nv(volatile unsigned int *, int);
                     58: unsigned long  atomic_add_long_nv(volatile unsigned long *, long);
1.2       ad         59: void *         atomic_add_ptr_nv(volatile void *, ssize_t);
1.6       ad         60: uint64_t       atomic_add_64_nv(volatile uint64_t *, int64_t);
1.2       ad         61:
                     62: /*
                     63:  * Atomic AND
                     64:  */
                     65: void           atomic_and_32(volatile uint32_t *, uint32_t);
                     66: void           atomic_and_uint(volatile unsigned int *, unsigned int);
                     67: void           atomic_and_ulong(volatile unsigned long *, unsigned long);
                     68: void           atomic_and_64(volatile uint64_t *, uint64_t);
                     69:
                     70: uint32_t       atomic_and_32_nv(volatile uint32_t *, uint32_t);
                     71: unsigned int   atomic_and_uint_nv(volatile unsigned int *, unsigned int);
                     72: unsigned long  atomic_and_ulong_nv(volatile unsigned long *, unsigned long);
                     73: uint64_t       atomic_and_64_nv(volatile uint64_t *, uint64_t);
                     74:
                     75: /*
                     76:  * Atomic OR
                     77:  */
                     78: void           atomic_or_32(volatile uint32_t *, uint32_t);
                     79: void           atomic_or_uint(volatile unsigned int *, unsigned int);
                     80: void           atomic_or_ulong(volatile unsigned long *, unsigned long);
                     81: void           atomic_or_64(volatile uint64_t *, uint64_t);
                     82:
                     83: uint32_t       atomic_or_32_nv(volatile uint32_t *, uint32_t);
                     84: unsigned int   atomic_or_uint_nv(volatile unsigned int *, unsigned int);
                     85: unsigned long  atomic_or_ulong_nv(volatile unsigned long *, unsigned long);
                     86: uint64_t       atomic_or_64_nv(volatile uint64_t *, uint64_t);
                     87:
                     88: /*
                     89:  * Atomic COMPARE-AND-SWAP
                     90:  */
                     91: uint32_t       atomic_cas_32(volatile uint32_t *, uint32_t, uint32_t);
                     92: unsigned int   atomic_cas_uint(volatile unsigned int *, unsigned int,
                     93:                                unsigned int);
                     94: unsigned long  atomic_cas_ulong(volatile unsigned long *, unsigned long,
                     95:                                 unsigned long);
                     96: void *         atomic_cas_ptr(volatile void *, void *, void *);
                     97: uint64_t       atomic_cas_64(volatile uint64_t *, uint64_t, uint64_t);
                     98:
                     99: /*
                    100:  * Atomic SWAP
                    101:  */
                    102: uint32_t       atomic_swap_32(volatile uint32_t *, uint32_t);
                    103: unsigned int   atomic_swap_uint(volatile unsigned int *, unsigned int);
                    104: unsigned long  atomic_swap_ulong(volatile unsigned long *, unsigned long);
                    105: void *         atomic_swap_ptr(volatile void *, void *);
                    106: uint64_t       atomic_swap_64(volatile uint64_t *, uint64_t);
                    107:
                    108: /*
                    109:  * Atomic DECREMENT
                    110:  */
                    111: void           atomic_dec_32(volatile uint32_t *);
                    112: void           atomic_dec_uint(volatile unsigned int *);
                    113: void           atomic_dec_ulong(volatile unsigned long *);
                    114: void           atomic_dec_ptr(volatile void *);
                    115: void           atomic_dec_64(volatile uint64_t *);
                    116:
                    117: uint32_t       atomic_dec_32_nv(volatile uint32_t *);
                    118: unsigned int   atomic_dec_uint_nv(volatile unsigned int *);
                    119: unsigned long  atomic_dec_ulong_nv(volatile unsigned long *);
                    120: void *         atomic_dec_ptr_nv(volatile void *);
                    121: uint64_t       atomic_dec_64_nv(volatile uint64_t *);
                    122:
                    123: /*
                    124:  * Atomic INCREMENT
                    125:  */
                    126: void           atomic_inc_32(volatile uint32_t *);
                    127: void           atomic_inc_uint(volatile unsigned int *);
                    128: void           atomic_inc_ulong(volatile unsigned long *);
                    129: void           atomic_inc_ptr(volatile void *);
                    130: void           atomic_inc_64(volatile uint64_t *);
                    131:
                    132: uint32_t       atomic_inc_32_nv(volatile uint32_t *);
                    133: unsigned int   atomic_inc_uint_nv(volatile unsigned int *);
                    134: unsigned long  atomic_inc_ulong_nv(volatile unsigned long *);
                    135: void *         atomic_inc_ptr_nv(volatile void *);
                    136: uint64_t       atomic_inc_64_nv(volatile uint64_t *);
                    137:
                    138: /*
                    139:  * Memory barrier operations
                    140:  */
                    141: void           membar_enter(void);
                    142: void           membar_exit(void);
                    143: void           membar_producer(void);
                    144: void           membar_consumer(void);
                    145: void           membar_sync(void);
                    146:
                    147: #endif /* ! _SYS_ATOMIC_H_ */

CVSweb <webmaster@jp.NetBSD.org>