X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Ftest_uatomic.c;h=804ce7bd8a79b1945f9fcd9ea5098d3f34a7a971;hp=2c8c2324c3d658aa4ea1f0a3f3caf9c8c84dbf0d;hb=a5bae03d59c22e57263b8610b9fed99738303cf0;hpb=bf33aaea06cbf8257cc49c38abca6d26c0c31c78 diff --git a/tests/test_uatomic.c b/tests/test_uatomic.c index 2c8c232..804ce7b 100644 --- a/tests/test_uatomic.c +++ b/tests/test_uatomic.c @@ -1,10 +1,36 @@ +/* + * test_uatomic.c + * + * Userspace RCU library - test atomic operations + * + * Copyright February 2009 - Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + #include #include -#include +#include struct testvals { +#ifdef UATOMIC_HAS_ATOMIC_BYTE unsigned char c; +#endif +#ifdef UATOMIC_HAS_ATOMIC_SHORT unsigned short s; +#endif unsigned int i; unsigned long l; }; @@ -40,6 +66,10 @@ do { \ assert(uatomic_read(ptr) == 122); \ v = uatomic_sub_return(ptr, 1); \ assert(v == 121); \ + uatomic_sub(ptr, (unsigned int) 2); \ + assert(uatomic_read(ptr) == 119); \ + uatomic_inc(ptr); \ + uatomic_inc(ptr); \ assert(uatomic_read(ptr) == 121); \ uatomic_and(ptr, 129); \ assert(uatomic_read(ptr) == 1); \