X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Funit%2Ftest_build.c;h=d3c20351bdc7e410d02fd2f03f3254f390b8c931;hb=fcab075f67cf3e29e8556b4af1bbbfb210977ac2;hp=b2786c55c00253d8d51ab6e1ae8ed90329755f85;hpb=c8292aa76bf23db3b6031cd49c0e6c469d0c889d;p=urcu.git diff --git a/tests/unit/test_build.c b/tests/unit/test_build.c index b2786c5..d3c2035 100644 --- a/tests/unit/test_build.c +++ b/tests/unit/test_build.c @@ -1,20 +1,6 @@ -/* - * Copyright 2021 Simon Marchi - * - * 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. - */ +// SPDX-FileCopyrightText: 2021 Simon Marchi +// +// SPDX-License-Identifier: GPL-2.0-or-later /* * This file is meant to verify that headers are compatible with both C and @@ -59,6 +45,15 @@ #include "tap.h" +struct my_tls_struct { + int int1; + char char1; + void *void1; +}; + +static DEFINE_URCU_TLS(int, my_tls_int); +static DEFINE_URCU_TLS(struct my_tls_struct, my_tls_struct); + static void test_lfstack(void) { struct cds_lfs_stack s; @@ -97,6 +92,35 @@ void test_build_cds_list_head_init(void) }; } +static +void test_urcu_tls(void) +{ + URCU_TLS(my_tls_int) = 1; + URCU_TLS(my_tls_struct).int1 = 1; + URCU_TLS(my_tls_struct).char1 = 'a'; + URCU_TLS(my_tls_struct).void1 = NULL; +} + +struct an_opaque_struct; +struct a_clear_struct +{ + int x; +}; + +static +void test_build_rcu_dereference(void) +{ + static struct an_opaque_struct *opaque = NULL; + static struct an_opaque_struct *const opaque_const = NULL; + static struct a_clear_struct *clear = NULL; + static struct a_clear_struct *const clear_const = NULL; + + (void) rcu_dereference(opaque); + (void) rcu_dereference(opaque_const); + (void) rcu_dereference(clear); + (void) rcu_dereference(clear_const); +} + int main(void) { plan_tests(3); @@ -105,6 +129,8 @@ int main(void) test_wfstack(); test_wfcqueue(); test_build_cds_list_head_init(); + test_urcu_tls(); + test_build_rcu_dereference(); return exit_status(); }