atomic_store.c revision 1.2
11.2Sjoerg/* $NetBSD: atomic_store.c,v 1.2 2014/07/06 01:19:45 joerg Exp $ */ 21.1Sjoerg 31.1Sjoerg/*- 41.1Sjoerg * Copyright (c) 2014 The NetBSD Foundation, Inc. 51.1Sjoerg * All rights reserved. 61.1Sjoerg * 71.1Sjoerg * Redistribution and use in source and binary forms, with or without 81.1Sjoerg * modification, are permitted provided that the following conditions 91.1Sjoerg * are met: 101.1Sjoerg * 1. Redistributions of source code must retain the above copyright 111.1Sjoerg * notice, this list of conditions and the following disclaimer. 121.1Sjoerg * 2. Redistributions in binary form must reproduce the above copyright 131.1Sjoerg * notice, this list of conditions and the following disclaimer in the 141.1Sjoerg * documentation and/or other materials provided with the distribution. 151.1Sjoerg * 161.1Sjoerg * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 171.1Sjoerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 181.1Sjoerg * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 191.1Sjoerg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 201.1Sjoerg * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 211.1Sjoerg * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 221.1Sjoerg * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 231.1Sjoerg * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 241.1Sjoerg * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 251.1Sjoerg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 261.1Sjoerg * POSSIBILITY OF SUCH DAMAGE. 271.1Sjoerg */ 281.1Sjoerg 291.1Sjoerg#include <sys/cdefs.h> 301.2Sjoerg__RCSID("$NetBSD: atomic_store.c,v 1.2 2014/07/06 01:19:45 joerg Exp $"); 311.1Sjoerg 321.1Sjoerg#include "atomic_op_namespace.h" 331.1Sjoerg 341.1Sjoerg#include <sys/types.h> 351.1Sjoerg#include <sys/atomic.h> 361.1Sjoerg 371.1Sjoerg#define atomic_store_n(n,b) \ 381.2Sjoergvoid __atomic_store_ ## n(volatile uint ## b ## _t *, uint ## b ## _t, int); \ 391.1Sjoergvoid \ 401.2Sjoerg__atomic_store_ ## n(volatile uint ## b ## _t *ptr, uint ## b ## _t val, \ 411.2Sjoerg int memmodel) \ 421.1Sjoerg{ \ 431.1Sjoerg membar_enter(); \ 441.1Sjoerg *ptr = val; \ 451.1Sjoerg membar_exit(); \ 461.1Sjoerg} 471.1Sjoerg 481.1Sjoergatomic_store_n(1, 8) 491.1Sjoergatomic_store_n(2, 16) 501.1Sjoergatomic_store_n(4, 32) 511.1Sjoerg#ifdef __HAVE_ATOMIC_CAS_64_UP 521.1Sjoergatomic_store_n(8, 64) 531.1Sjoerg#endif 54