diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2017-01-21 05:46:57 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2017-01-21 05:46:57 +0000 |
commit | 88a8b11c3a9f976c251644d88dd89f8f96dd8c27 (patch) | |
tree | e5ec6b48f61c5cb81cb02b5c552ab2d1cd1f70f5 /lib | |
parent | 9a302bd2ce6b791c5c6ebe5666355ec437ac1d03 (diff) |
Make crtbegin.c and crtbeginS.c consistent on stylistic points
ok kettenis@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/csu/crtbegin.c | 16 | ||||
-rw-r--r-- | lib/csu/crtbeginS.c | 20 |
2 files changed, 16 insertions, 20 deletions
diff --git a/lib/csu/crtbegin.c b/lib/csu/crtbegin.c index 3d359e62e59..8b0b401047a 100644 --- a/lib/csu/crtbegin.c +++ b/lib/csu/crtbegin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crtbegin.c,v 1.22 2017/01/21 00:45:13 guenther Exp $ */ +/* $OpenBSD: crtbegin.c,v 1.23 2017/01/21 05:46:56 guenther Exp $ */ /* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */ /* @@ -84,11 +84,9 @@ long __guard_local __dso_hidden __attribute__((section(".openbsd.randomdata"))); MD_DATA_SECTION_SYMBOL_VALUE(".ctors", init_f, __CTOR_LIST__, -1); MD_DATA_SECTION_SYMBOL_VALUE(".dtors", init_f, __DTOR_LIST__, -1); -static void __dtors(void) __used; -static void __ctors(void) __used; static void -__ctors() +__ctors(void) { unsigned long i = (unsigned long) __CTOR_LIST__[0]; const init_f *p; @@ -104,7 +102,7 @@ __ctors() } static void -__dtors() +__dtors(void) { const init_f *p = __DTOR_LIST__ + 1; @@ -126,7 +124,7 @@ MD_SECT_CALL_FUNC(".fini", __do_fini); void -__do_init() +__do_init(void) { static int initialized = 0; static struct dwarf2_eh_object object; @@ -141,14 +139,14 @@ __do_init() __register_frame_info(__EH_FRAME_BEGIN__, &object); if (__JCR_LIST__[0] && _Jv_RegisterClasses) _Jv_RegisterClasses(__JCR_LIST__); - (__ctors)(); + __ctors(); atexit(__fini); } } void -__do_fini() +__do_fini(void) { static int finalized = 0; @@ -157,7 +155,7 @@ __do_fini() /* * Call global destructors. */ - (__dtors)(); + __dtors(); } } diff --git a/lib/csu/crtbeginS.c b/lib/csu/crtbeginS.c index 7cc8252e58c..84db538b089 100644 --- a/lib/csu/crtbeginS.c +++ b/lib/csu/crtbeginS.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crtbeginS.c,v 1.17 2017/01/21 00:45:13 guenther Exp $ */ +/* $OpenBSD: crtbeginS.c,v 1.18 2017/01/21 05:46:56 guenther Exp $ */ /* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */ /* @@ -38,7 +38,6 @@ * constructors and destructors. The first element contains the * number of pointers in each. * The tables are also null-terminated. - */ #include <stdlib.h> @@ -96,14 +95,12 @@ asm(".hidden pthread_atfork\n .weak pthread_atfork"); MD_DATA_SECTION_SYMBOL_VALUE(".ctors", init_f, __CTOR_LIST__, -1); MD_DATA_SECTION_SYMBOL_VALUE(".dtors", init_f, __DTOR_LIST__, -1); -static void __dtors(void) __used; -static void __ctors(void) __used; -void +static void __ctors(void) { unsigned long i = (unsigned long) __CTOR_LIST__[0]; - init_f *p; + const init_f *p; if (i == -1) { for (i = 1; __CTOR_LIST__[i] != NULL; i++) @@ -111,20 +108,19 @@ __ctors(void) i--; } p = __CTOR_LIST__ + i; - while (i--) { + while (i--) (**p--)(); - } } static void __dtors(void) { - init_f *p = __DTOR_LIST__ + 1; + const init_f *p = __DTOR_LIST__ + 1; - while (*p) { + while (*p) (**p++)(); - } } + void _init(void); void _fini(void); static void _do_init(void) __used; @@ -137,6 +133,7 @@ MD_SECTION_PROLOGUE(".fini", _fini); MD_SECT_CALL_FUNC(".init", _do_init); MD_SECT_CALL_FUNC(".fini", _do_fini); + void _do_init(void) { @@ -159,6 +156,7 @@ void _do_fini(void) { static int finalized = 0; + if (!finalized) { finalized = 1; |