| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: atomic.h,v 1.3 2014/04/01 15:28:52 riastradh Exp $ */ | | 1 | /* $NetBSD: atomic.h,v 1.4 2014/06/03 14:59:30 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 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 Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
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. |
| @@ -94,27 +94,27 @@ atomic_inc_return(atomic_t *atomic) | | | @@ -94,27 +94,27 @@ atomic_inc_return(atomic_t *atomic) |
94 | { | | 94 | { |
95 | return (int)atomic_inc_uint_nv(&atomic->a_u.au_uint); | | 95 | return (int)atomic_inc_uint_nv(&atomic->a_u.au_uint); |
96 | } | | 96 | } |
97 | | | 97 | |
98 | static inline int | | 98 | static inline int |
99 | atomic_dec_return(atomic_t *atomic) | | 99 | atomic_dec_return(atomic_t *atomic) |
100 | { | | 100 | { |
101 | return (int)atomic_dec_uint_nv(&atomic->a_u.au_uint); | | 101 | return (int)atomic_dec_uint_nv(&atomic->a_u.au_uint); |
102 | } | | 102 | } |
103 | | | 103 | |
104 | static inline int | | 104 | static inline int |
105 | atomic_dec_and_test(atomic_t *atomic) | | 105 | atomic_dec_and_test(atomic_t *atomic) |
106 | { | | 106 | { |
107 | return (-1 == (int)atomic_dec_uint_nv(&atomic->a_u.au_uint)); | | 107 | return (0 == (int)atomic_dec_uint_nv(&atomic->a_u.au_uint)); |
108 | } | | 108 | } |
109 | | | 109 | |
110 | static inline void | | 110 | static inline void |
111 | atomic_set_mask(unsigned long mask, atomic_t *atomic) | | 111 | atomic_set_mask(unsigned long mask, atomic_t *atomic) |
112 | { | | 112 | { |
113 | atomic_or_uint(&atomic->a_u.au_uint, mask); | | 113 | atomic_or_uint(&atomic->a_u.au_uint, mask); |
114 | } | | 114 | } |
115 | | | 115 | |
116 | static inline void | | 116 | static inline void |
117 | atomic_clear_mask(unsigned long mask, atomic_t *atomic) | | 117 | atomic_clear_mask(unsigned long mask, atomic_t *atomic) |
118 | { | | 118 | { |
119 | atomic_and_uint(&atomic->a_u.au_uint, ~mask); | | 119 | atomic_and_uint(&atomic->a_u.au_uint, ~mask); |
120 | } | | 120 | } |