Tue Jun 3 14:59:30 2014 UTC ()
Fix atomic_dec_and_test in <linux/atomic.h>: test 0, not -1.


(riastradh)
diff -r1.3 -r1.4 src/sys/external/bsd/drm2/include/linux/atomic.h

cvs diff -r1.3 -r1.4 src/sys/external/bsd/drm2/include/linux/atomic.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/include/linux/atomic.h 2014/04/01 15:28:52 1.3
+++ src/sys/external/bsd/drm2/include/linux/atomic.h 2014/06/03 14:59:30 1.4
@@ -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
98static inline int 98static inline int
99atomic_dec_return(atomic_t *atomic) 99atomic_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
104static inline int 104static inline int
105atomic_dec_and_test(atomic_t *atomic) 105atomic_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
110static inline void 110static inline void
111atomic_set_mask(unsigned long mask, atomic_t *atomic) 111atomic_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
116static inline void 116static inline void
117atomic_clear_mask(unsigned long mask, atomic_t *atomic) 117atomic_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}