Module: xenomai-3 Branch: wip/modechk Commit: e462c8499eaff9c2ff1bf5a745a64613420a9aa1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e462c8499eaff9c2ff1bf5a745a64613420a9aa1
Author: Henning Schild <henning.sch...@siemens.com> Date: Sun Mar 12 18:30:57 2017 +0100 lib/cobalt: wrap CXXABI One-time Constructor functions The implementation of these functions uses locks and has the potential to trigger a SIGXCPU when contended. Wrap them with assert_nrt so they reliably cause a switch when used in the rt context. Signed-off-by: Henning Schild <henning.sch...@siemens.com> --- lib/cobalt/Makefile.am | 1 + lib/cobalt/cxaguard.c | 55 +++++++++++++++++++++++++++++++++++++++++++ lib/cobalt/modechk.wrappers | 3 +++ 3 files changed, 59 insertions(+) diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am index 6189755..6275eb4 100644 --- a/lib/cobalt/Makefile.am +++ b/lib/cobalt/Makefile.am @@ -53,6 +53,7 @@ libcobalt_la_CPPFLAGS = \ lib_LIBRARIES = libmodechk.a libmodechk_a_SOURCES = \ + cxaguard.c \ malloc.c \ malloc-nowrap.c diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c new file mode 100644 index 0000000..13432af --- /dev/null +++ b/lib/cobalt/cxaguard.c @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2017 Henning Schild <henning.sch...@siemens.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include <stdint.h> +#include <cobalt/wrappers.h> + +void assert_nrt(void); + +#ifdef __ARM_EABI__ +typedef uint32_t __cxa_guard_type; +#else +typedef uint64_t __cxa_guard_type; +#endif + +COBALT_DECL(int, __cxa_guard_acquire(__cxa_guard_type *g)); +int __real_cxa_guard_acquire(__cxa_guard_type *g); + +/* CXXABI 3.3.2 One-time Construction API */ +COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g)) +{ + assert_nrt(); + return __STD(__cxa_guard_acquire(g)); +} + +COBALT_DECL(void, __cxa_guard_release(__cxa_guard_type *g)); +void __real_cxa_guard_release(__cxa_guard_type *g); + +COBALT_IMPL(void, __cxa_guard_release, (__cxa_guard_type *g)) +{ + assert_nrt(); + __STD(__cxa_guard_release(g)); +} + +COBALT_DECL(void, __cxa_guard_abort(__cxa_guard_type *g)); +void __real_cxa_guard_abort(__cxa_guard_type *g); + +COBALT_IMPL(void, __cxa_guard_abort, (__cxa_guard_type *g)) +{ + assert_nrt(); + __STD(__cxa_guard_abort(g)); +} diff --git a/lib/cobalt/modechk.wrappers b/lib/cobalt/modechk.wrappers index 7164858..65320ab 100644 --- a/lib/cobalt/modechk.wrappers +++ b/lib/cobalt/modechk.wrappers @@ -1,2 +1,5 @@ --wrap malloc --wrap free +--wrap __cxa_guard_acquire +--wrap __cxa_guard_release +--wrap __cxa_guard_abort _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git