[Xenomai-git] Henning Schild : lib/cobalt: wrap CXXABI One-time Constructor functions
Module: xenomai-3 Branch: master Commit: e462c8499eaff9c2ff1bf5a745a64613420a9aa1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e462c8499eaff9c2ff1bf5a745a64613420a9aa1 Author: Henning Schild 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 --- 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 000..13432af --- /dev/null +++ b/lib/cobalt/cxaguard.c @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2017 Henning Schild + * + * 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 +#include + +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
[Xenomai-git] Henning Schild : lib/cobalt: wrap CXXABI One-time Constructor functions
Module: xenomai-3 Branch: next Commit: e462c8499eaff9c2ff1bf5a745a64613420a9aa1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e462c8499eaff9c2ff1bf5a745a64613420a9aa1 Author: Henning Schild 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 --- 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 000..13432af --- /dev/null +++ b/lib/cobalt/cxaguard.c @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2017 Henning Schild + * + * 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 +#include + +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
[Xenomai-git] Henning Schild : lib/cobalt: wrap CXXABI One-time Constructor functions
Module: xenomai-3 Branch: stable-3.0.x Commit: e462c8499eaff9c2ff1bf5a745a64613420a9aa1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e462c8499eaff9c2ff1bf5a745a64613420a9aa1 Author: Henning Schild 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 --- 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 000..13432af --- /dev/null +++ b/lib/cobalt/cxaguard.c @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2017 Henning Schild + * + * 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 +#include + +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
[Xenomai-git] Henning Schild : lib/cobalt: wrap CXXABI One-time Constructor functions
Module: xenomai-3 Branch: wip/modechk Commit: e462c8499eaff9c2ff1bf5a745a64613420a9aa1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e462c8499eaff9c2ff1bf5a745a64613420a9aa1 Author: Henning Schild 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 --- 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 000..13432af --- /dev/null +++ b/lib/cobalt/cxaguard.c @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2017 Henning Schild + * + * 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 +#include + +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
[Xenomai-git] Henning Schild : lib/cobalt: wrap CXXABI One-time Constructor functions
Module: xenomai-3 Branch: master Commit: be90f09cf277083ff7021b1f0f1a856c66c42b46 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be90f09cf277083ff7021b1f0f1a856c66c42b46 Author: Henning Schild Date: Wed Jan 25 16:08:00 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 --- lib/cobalt/assert.wrappers |3 +++ lib/cobalt/assert_context.c | 19 +++ lib/cobalt/internal.h | 12 lib/cobalt/wrappers.c | 37 + 4 files changed, 71 insertions(+) diff --git a/lib/cobalt/assert.wrappers b/lib/cobalt/assert.wrappers index 7164858..65320ab 100644 --- a/lib/cobalt/assert.wrappers +++ b/lib/cobalt/assert.wrappers @@ -1,2 +1,5 @@ --wrap malloc --wrap free +--wrap __cxa_guard_acquire +--wrap __cxa_guard_release +--wrap __cxa_guard_abort diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c index 2085953..fd18d6b 100644 --- a/lib/cobalt/assert_context.c +++ b/lib/cobalt/assert_context.c @@ -66,3 +66,22 @@ COBALT_IMPL(void, free, (void *ptr)) assert_nrt(); __STD(free(ptr)); } + +/* CXXABI 3.3.2 One-time Construction API */ +COBALT_IMPL(int, __cxa_guard_acquire, (__guard *g)) +{ + assert_nrt(); + return __STD(__cxa_guard_acquire(g)); +} + +COBALT_IMPL(void, __cxa_guard_release, (__guard *g)) +{ + assert_nrt(); + __STD(__cxa_guard_release(g)); +} + +COBALT_IMPL(void, __cxa_guard_abort, (__guard *g)) +{ + assert_nrt(); + __STD(__cxa_guard_abort(g)); +} diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index fee3fe1..9f58c6a 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -73,4 +73,16 @@ void cobalt_check_features(struct cobalt_featinfo *finfo); extern struct sigaction __cobalt_orig_sigdebug; +#ifdef __ARM_EABI__ +typedef uint32_t __guard; +#else +typedef uint64_t __guard; +#endif +int __real___cxa_guard_acquire(__guard*); +void __real___cxa_guard_release(__guard*); +void __real___cxa_guard_abort(__guard*); +int __cxa_guard_acquire(__guard*); +void __cxa_guard_release(__guard*); +void __cxa_guard_abort(__guard*); + #endif /* _LIB_COBALT_INTERNAL_H */ diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 09c74e5..65dc3bd 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -43,6 +43,7 @@ #include #include #include +#include /* sched */ __weak @@ -532,3 +533,39 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real___cxa_guard_acquire(__guard *g) +{ + return __cxa_guard_acquire(g); +} + +__weak +void __real___cxa_guard_release(__guard *g) +{ + return __cxa_guard_release(g); +} + +__weak +void __real___cxa_guard_abort(__guard *g) +{ + return __cxa_guard_abort(g); +} + +__weak +int __cxa_guard_acquire(__guard *g) +{ + return 0; +} + +__weak +void __cxa_guard_release(__guard *g) +{ + return; +} + +__weak +void __cxa_guard_abort(__guard *g) +{ + return; +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Henning Schild : lib/cobalt: wrap CXXABI One-time Constructor functions
Module: xenomai-3 Branch: next Commit: be90f09cf277083ff7021b1f0f1a856c66c42b46 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be90f09cf277083ff7021b1f0f1a856c66c42b46 Author: Henning Schild Date: Wed Jan 25 16:08:00 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 --- lib/cobalt/assert.wrappers |3 +++ lib/cobalt/assert_context.c | 19 +++ lib/cobalt/internal.h | 12 lib/cobalt/wrappers.c | 37 + 4 files changed, 71 insertions(+) diff --git a/lib/cobalt/assert.wrappers b/lib/cobalt/assert.wrappers index 7164858..65320ab 100644 --- a/lib/cobalt/assert.wrappers +++ b/lib/cobalt/assert.wrappers @@ -1,2 +1,5 @@ --wrap malloc --wrap free +--wrap __cxa_guard_acquire +--wrap __cxa_guard_release +--wrap __cxa_guard_abort diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c index 2085953..fd18d6b 100644 --- a/lib/cobalt/assert_context.c +++ b/lib/cobalt/assert_context.c @@ -66,3 +66,22 @@ COBALT_IMPL(void, free, (void *ptr)) assert_nrt(); __STD(free(ptr)); } + +/* CXXABI 3.3.2 One-time Construction API */ +COBALT_IMPL(int, __cxa_guard_acquire, (__guard *g)) +{ + assert_nrt(); + return __STD(__cxa_guard_acquire(g)); +} + +COBALT_IMPL(void, __cxa_guard_release, (__guard *g)) +{ + assert_nrt(); + __STD(__cxa_guard_release(g)); +} + +COBALT_IMPL(void, __cxa_guard_abort, (__guard *g)) +{ + assert_nrt(); + __STD(__cxa_guard_abort(g)); +} diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index fee3fe1..9f58c6a 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -73,4 +73,16 @@ void cobalt_check_features(struct cobalt_featinfo *finfo); extern struct sigaction __cobalt_orig_sigdebug; +#ifdef __ARM_EABI__ +typedef uint32_t __guard; +#else +typedef uint64_t __guard; +#endif +int __real___cxa_guard_acquire(__guard*); +void __real___cxa_guard_release(__guard*); +void __real___cxa_guard_abort(__guard*); +int __cxa_guard_acquire(__guard*); +void __cxa_guard_release(__guard*); +void __cxa_guard_abort(__guard*); + #endif /* _LIB_COBALT_INTERNAL_H */ diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 09c74e5..65dc3bd 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -43,6 +43,7 @@ #include #include #include +#include /* sched */ __weak @@ -532,3 +533,39 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real___cxa_guard_acquire(__guard *g) +{ + return __cxa_guard_acquire(g); +} + +__weak +void __real___cxa_guard_release(__guard *g) +{ + return __cxa_guard_release(g); +} + +__weak +void __real___cxa_guard_abort(__guard *g) +{ + return __cxa_guard_abort(g); +} + +__weak +int __cxa_guard_acquire(__guard *g) +{ + return 0; +} + +__weak +void __cxa_guard_release(__guard *g) +{ + return; +} + +__weak +void __cxa_guard_abort(__guard *g) +{ + return; +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Henning Schild : lib/cobalt: wrap CXXABI One-time Constructor functions
Module: xenomai-3 Branch: stable-3.0.x Commit: be90f09cf277083ff7021b1f0f1a856c66c42b46 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be90f09cf277083ff7021b1f0f1a856c66c42b46 Author: Henning Schild Date: Wed Jan 25 16:08:00 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 --- lib/cobalt/assert.wrappers |3 +++ lib/cobalt/assert_context.c | 19 +++ lib/cobalt/internal.h | 12 lib/cobalt/wrappers.c | 37 + 4 files changed, 71 insertions(+) diff --git a/lib/cobalt/assert.wrappers b/lib/cobalt/assert.wrappers index 7164858..65320ab 100644 --- a/lib/cobalt/assert.wrappers +++ b/lib/cobalt/assert.wrappers @@ -1,2 +1,5 @@ --wrap malloc --wrap free +--wrap __cxa_guard_acquire +--wrap __cxa_guard_release +--wrap __cxa_guard_abort diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c index 2085953..fd18d6b 100644 --- a/lib/cobalt/assert_context.c +++ b/lib/cobalt/assert_context.c @@ -66,3 +66,22 @@ COBALT_IMPL(void, free, (void *ptr)) assert_nrt(); __STD(free(ptr)); } + +/* CXXABI 3.3.2 One-time Construction API */ +COBALT_IMPL(int, __cxa_guard_acquire, (__guard *g)) +{ + assert_nrt(); + return __STD(__cxa_guard_acquire(g)); +} + +COBALT_IMPL(void, __cxa_guard_release, (__guard *g)) +{ + assert_nrt(); + __STD(__cxa_guard_release(g)); +} + +COBALT_IMPL(void, __cxa_guard_abort, (__guard *g)) +{ + assert_nrt(); + __STD(__cxa_guard_abort(g)); +} diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index fee3fe1..9f58c6a 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -73,4 +73,16 @@ void cobalt_check_features(struct cobalt_featinfo *finfo); extern struct sigaction __cobalt_orig_sigdebug; +#ifdef __ARM_EABI__ +typedef uint32_t __guard; +#else +typedef uint64_t __guard; +#endif +int __real___cxa_guard_acquire(__guard*); +void __real___cxa_guard_release(__guard*); +void __real___cxa_guard_abort(__guard*); +int __cxa_guard_acquire(__guard*); +void __cxa_guard_release(__guard*); +void __cxa_guard_abort(__guard*); + #endif /* _LIB_COBALT_INTERNAL_H */ diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 09c74e5..65dc3bd 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -43,6 +43,7 @@ #include #include #include +#include /* sched */ __weak @@ -532,3 +533,39 @@ unsigned int __real_sleep(unsigned int seconds) { return sleep(seconds); } + +__weak +int __real___cxa_guard_acquire(__guard *g) +{ + return __cxa_guard_acquire(g); +} + +__weak +void __real___cxa_guard_release(__guard *g) +{ + return __cxa_guard_release(g); +} + +__weak +void __real___cxa_guard_abort(__guard *g) +{ + return __cxa_guard_abort(g); +} + +__weak +int __cxa_guard_acquire(__guard *g) +{ + return 0; +} + +__weak +void __cxa_guard_release(__guard *g) +{ + return; +} + +__weak +void __cxa_guard_abort(__guard *g) +{ + return; +} ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Henning Schild : lib/cobalt: wrap CXXABI One-time Constructor functions
Module: xenomai-3 Branch: stable-3.0.x Commit: 0b66d5e9bf392ff68c82e2fede92627a4ddb5550 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0b66d5e9bf392ff68c82e2fede92627a4ddb5550 Author: Henning Schild Date: Wed Jan 25 16:08:00 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 --- lib/cobalt/assert.wrappers |3 + lib/cobalt/assert_context.c | 19 ++ lib/cobalt/internal.h | 12 + lib/cobalt/internal.h.orig | 76 ++ lib/cobalt/wrappers.c | 37 +++ lib/cobalt/wrappers.c.orig | 534 +++ 6 files changed, 681 insertions(+) diff --git a/lib/cobalt/assert.wrappers b/lib/cobalt/assert.wrappers index 7164858..65320ab 100644 --- a/lib/cobalt/assert.wrappers +++ b/lib/cobalt/assert.wrappers @@ -1,2 +1,5 @@ --wrap malloc --wrap free +--wrap __cxa_guard_acquire +--wrap __cxa_guard_release +--wrap __cxa_guard_abort diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c index 2085953..fd18d6b 100644 --- a/lib/cobalt/assert_context.c +++ b/lib/cobalt/assert_context.c @@ -66,3 +66,22 @@ COBALT_IMPL(void, free, (void *ptr)) assert_nrt(); __STD(free(ptr)); } + +/* CXXABI 3.3.2 One-time Construction API */ +COBALT_IMPL(int, __cxa_guard_acquire, (__guard *g)) +{ + assert_nrt(); + return __STD(__cxa_guard_acquire(g)); +} + +COBALT_IMPL(void, __cxa_guard_release, (__guard *g)) +{ + assert_nrt(); + __STD(__cxa_guard_release(g)); +} + +COBALT_IMPL(void, __cxa_guard_abort, (__guard *g)) +{ + assert_nrt(); + __STD(__cxa_guard_abort(g)); +} diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index fee3fe1..9f58c6a 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -73,4 +73,16 @@ void cobalt_check_features(struct cobalt_featinfo *finfo); extern struct sigaction __cobalt_orig_sigdebug; +#ifdef __ARM_EABI__ +typedef uint32_t __guard; +#else +typedef uint64_t __guard; +#endif +int __real___cxa_guard_acquire(__guard*); +void __real___cxa_guard_release(__guard*); +void __real___cxa_guard_abort(__guard*); +int __cxa_guard_acquire(__guard*); +void __cxa_guard_release(__guard*); +void __cxa_guard_abort(__guard*); + #endif /* _LIB_COBALT_INTERNAL_H */ diff --git a/lib/cobalt/internal.h.orig b/lib/cobalt/internal.h.orig new file mode 100644 index 000..fee3fe1 --- /dev/null +++ b/lib/cobalt/internal.h.orig @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2008 Philippe Gerum . + * + * 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. + */ +#ifndef _LIB_COBALT_INTERNAL_H +#define _LIB_COBALT_INTERNAL_H + +#include +#include +#include +#include "current.h" + +extern void *cobalt_umm_private; + +extern void *cobalt_umm_shared; + +static inline int cobalt_is_relaxed(void) +{ + return cobalt_get_current_mode() & XNRELAX; +} + +static inline +struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow) +{ + if (shadow->attr.pshared) + return cobalt_umm_shared + shadow->state_offset; + + return cobalt_umm_private + shadow->state_offset; +} + +static inline atomic_t *mutex_get_ownerp(struct cobalt_mutex_shadow *shadow) +{ + return &mutex_get_state(shadow)->owner; +} + +void cobalt_sigshadow_install_once(void); + +void cobalt_thread_init(void); + +int cobalt_thread_probe(pid_t pid); + +void cobalt_print_init(void); + +void cobalt_print_init_atfork(void); + +void cobalt_ticks_init(unsigned long long freq); + +void cobalt_mutex_init(void); + +void cobalt_default_condattr_init(void); + +int cobalt_xlate_schedparam(int policy, + const struct sched_param_ex *param_ex, + struct sched_param *param); +int cobalt_init(void); + +struct cobalt_featinfo; + +void cobalt_check_features(struct cobalt_featinfo *finfo); + +extern struct sigaction __cobalt_orig_sigdebug; + +#endif /* _LIB_COBALT_INTERNAL_H */ diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c index 09c74e5..65dc3bd 100644 --- a/lib/cobalt/wrappers.c +++ b/lib/cobalt/wrappers.c @@ -43,6 +43,7