Mon Jan 27 20:01:50 2014 UTC ()
Return old


(matt)
diff -r1.7 -r1.8 src/common/lib/libc/atomic/atomic_and_64_cas.c

cvs diff -r1.7 -r1.8 src/common/lib/libc/atomic/atomic_and_64_cas.c (expand / switch to unified diff)

--- src/common/lib/libc/atomic/atomic_and_64_cas.c 2014/01/27 18:29:47 1.7
+++ src/common/lib/libc/atomic/atomic_and_64_cas.c 2014/01/27 20:01:50 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: atomic_and_64_cas.c,v 1.7 2014/01/27 18:29:47 matt Exp $ */ 1/* $NetBSD: atomic_and_64_cas.c,v 1.8 2014/01/27 20:01:50 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe. 8 * by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -36,26 +36,27 @@ @@ -36,26 +36,27 @@
36#ifdef __HAVE_ATOMIC64_OPS 36#ifdef __HAVE_ATOMIC64_OPS
37 37
38uint64_t __sync_fetch_and_and_8(volatile uint64_t *, uint64_t); 38uint64_t __sync_fetch_and_and_8(volatile uint64_t *, uint64_t);
39 39
40uint64_t 40uint64_t
41__sync_fetch_and_and_8(volatile uint64_t *addr, uint64_t val) 41__sync_fetch_and_and_8(volatile uint64_t *addr, uint64_t val)
42{ 42{
43 uint64_t old, new; 43 uint64_t old, new;
44 44
45 do { 45 do {
46 old = *addr; 46 old = *addr;
47 new = old & val; 47 new = old & val;
48 } while (atomic_cas_64(addr, old, new) != old); 48 } while (atomic_cas_64(addr, old, new) != old);
 49 return old;
49} 50}
50 51
51void 52void
52atomic_and_64(volatile uint64_t *addr, uint64_t val) 53atomic_and_64(volatile uint64_t *addr, uint64_t val)
53{ 54{
54 (void) __sync_fetch_and_and_8(addr, val); 55 (void) __sync_fetch_and_and_8(addr, val);
55} 56}
56 57
57#undef atomic_and_64 58#undef atomic_and_64
58atomic_op_alias(atomic_and_64,_atomic_and_64) 59atomic_op_alias(atomic_and_64,_atomic_and_64)
59 60
60#if defined(_LP64) 61#if defined(_LP64)
61#undef atomic_and_ulong 62#undef atomic_and_ulong