The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/atomic_common.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2017 The FreeBSD Foundation
    5  * All rights reserved.
    6  *
    7  * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
    8  * under sponsorship from the FreeBSD Foundation.
    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  *
   19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  * $FreeBSD: releng/11.2/sys/sys/atomic_common.h 327195 2017-12-26 10:07:17Z kib $
   32  */
   33 #ifndef _SYS_ATOMIC_COMMON_H_
   34 #define _SYS_ATOMIC_COMMON_H_
   35 
   36 #ifndef _MACHINE_ATOMIC_H_
   37 #error do not include this header, use machine/atomic.h
   38 #endif
   39 
   40 #define atomic_load_char(p)     (*(volatile u_char *)(p))
   41 #define atomic_load_short(p)    (*(volatile u_short *)(p))
   42 #define atomic_load_int(p)      (*(volatile u_int *)(p))
   43 #define atomic_load_long(p)     (*(volatile u_long *)(p))
   44 #define atomic_load_ptr(p)      (*(volatile uintptr_t*)(p))
   45 #define atomic_load_8(p)        (*(volatile uint8_t *)(p))
   46 #define atomic_load_16(p)       (*(volatile uint16_t *)(p))
   47 #define atomic_load_32(p)       (*(volatile uint32_t *)(p))
   48 #ifdef _LP64
   49 #define atomic_load_64(p)       (*(volatile uint64_t *)(p))
   50 #endif
   51 
   52 #define atomic_store_char(p, v)         \
   53     (*(volatile u_char *)(p) = (u_char)(v))
   54 #define atomic_store_short(p, v)                \
   55     (*(volatile u_short *)(p) = (u_short)(v))
   56 #define atomic_store_int(p, v)          \
   57     (*(volatile u_int *)(p) = (u_int)(v))
   58 #define atomic_store_long(p, v)         \
   59     (*(volatile u_long *)(p) = (u_long)(v))
   60 #define atomic_store_ptr(p, v)          \
   61     (*(uintptr_t *)(p) = (uintptr_t)(v))
   62 #define atomic_store_8(p, v)            \
   63     (*(volatile uint8_t *)(p) = (uint8_t)(v))
   64 #define atomic_store_16(p, v)           \
   65     (*(volatile uint16_t *)(p) = (uint16_t)(v))
   66 #define atomic_store_32(p, v)           \
   67     (*(volatile uint32_t *)(p) = (uint32_t)(v))
   68 #ifdef _LP64
   69 #define atomic_store_64(p, v)           \
   70     (*(volatile uint64_t *)(p) = (uint64_t)(v))
   71 #endif
   72 
   73 #endif

Cache object: e75dd95585b150930ac72e5a4305ed88


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.