/*- * Copyright (c) 2009-2010 Brad Penoff * Copyright (c) 2009-2010 Humaira Kamal * Copyright (c) 2011-2012 Irene Ruengeler * Copyright (c) 2011-2012 Michael Tuexen * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE.
*/
#ifndef _USER_ATOMIC_H_ #define _USER_ATOMIC_H_
/* __Userspace__ version of sys/i386/include/atomic.h goes here */
/* TODO In the future, might want to not use i386 specific assembly. * The options include: * - implement them generically (but maybe not truly atomic?) in userspace * - have ifdef's for __Userspace_arch_ perhaps (OS isn't enough...)
*/
/*Atomically add V to *P.*/ #define atomic_add_int(P, V) (void) __sync_fetch_and_add(P, V)
/*Atomically subtrace V from *P.*/ #define atomic_subtract_int(P, V) (void) __sync_fetch_and_sub(P, V)
/* * Atomically add the value of v to the integer pointed to by p and return * the previous value of *p.
*/ #define atomic_fetchadd_int(p, v) __sync_fetch_and_add(p, v)
/* Following explanation from src/sys/i386/include/atomic.h, * for atomic compare and set * * if (*dst == exp) *dst = src (all 32 bit words) * * Returns 0 on failure, non-zero on success
*/
/* * Atomically add the value of v to the integer pointed to by p and return * the previous value of *p.
*/ #define atomic_fetchadd_int(p, v) AO_fetch_and_add((AO_t*)p, v)
/* Atomically compare *addr to old_val, and replace *addr by new_val if the first comparison succeeds. Returns nonzero if the comparison succeeded and *addr was updated.
*/ /* Following Explanation from src/sys/i386/include/atomic.h, which matches that of AO_compare_and_swap above. * Atomic compare and set, used by the mutex functions * * if (*dst == exp) *dst = src (all 32 bit words) * * Returns 0 on failure, non-zero on success
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.