From 65aa60c7a864495631c6e919fdf47dfb824af273 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Mon, 26 Jan 2004 20:00:38 +0000 Subject: small clean-up: typedef to desambiguate const, prototypes... ok drahn@, some time ago. --- lib/csu/crtbegin.c | 11 ++++++----- lib/csu/crtbeginS.c | 11 ++++++----- lib/csu/crtend.c | 7 ++++--- lib/csu/crtendS.c | 7 ++++--- lib/csu/extern.h | 23 +++++++++++++++++++++++ 5 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 lib/csu/extern.h (limited to 'lib/csu') diff --git a/lib/csu/crtbegin.c b/lib/csu/crtbegin.c index 6399d6c8075..834f8a1e3db 100644 --- a/lib/csu/crtbegin.c +++ b/lib/csu/crtbegin.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crtbegin.c,v 1.7 2004/01/08 14:59:15 drahn Exp $ */ +/* $OpenBSD: crtbegin.c,v 1.8 2004/01/26 20:00:37 espie Exp $ */ /* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */ /* @@ -43,10 +43,11 @@ #include "md_init.h" #include "os-note-elf.h" +#include "extern.h" -static const void (*__CTOR_LIST__[1])(void) +static const init_f __CTOR_LIST__[1] __attribute__((section(".ctors"))) = { (void *)-1 }; /* XXX */ -static const void (*__DTOR_LIST__[1])(void) +static const init_f __DTOR_LIST__[1] __attribute__((section(".dtors"))) = { (void *)-1 }; /* XXX */ static void __dtors(void); @@ -56,7 +57,7 @@ static void __dtors() { unsigned long i = (unsigned long) __DTOR_LIST__[0]; - void const (**p)(void); + const init_f *p; if (i == -1) { for (i = 1; __DTOR_LIST__[i] != NULL; i++) @@ -71,7 +72,7 @@ __dtors() static void __ctors() { - void const (**p)(void) = __CTOR_LIST__ + 1; + const init_f *p = __CTOR_LIST__ + 1; while (*p) (**p++)(); diff --git a/lib/csu/crtbeginS.c b/lib/csu/crtbeginS.c index 08ec27bb21c..b9f2e61e4b9 100644 --- a/lib/csu/crtbeginS.c +++ b/lib/csu/crtbeginS.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crtbeginS.c,v 1.5 2004/01/08 14:59:15 drahn Exp $ */ +/* $OpenBSD: crtbeginS.c,v 1.6 2004/01/26 20:00:37 espie Exp $ */ /* $NetBSD: crtbegin.c,v 1.1 1996/09/12 16:59:03 cgd Exp $ */ /* @@ -42,10 +42,11 @@ */ #include #include "md_init.h" +#include "extern.h" -static void (*__CTOR_LIST__[1])(void) +static init_f __CTOR_LIST__[1] __attribute__((section(".ctors"))) = { (void *)-1 }; /* XXX */ -static void (*__DTOR_LIST__[1])(void) +static init_f __DTOR_LIST__[1] __attribute__((section(".dtors"))) = { (void *)-1 }; /* XXX */ static void __dtors(void); @@ -55,7 +56,7 @@ void __dtors(void) { unsigned long i = (unsigned long) __DTOR_LIST__[0]; - void (**p)(void); + init_f *p; if (i == -1) { for (i = 1; __DTOR_LIST__[i] != NULL; i++) @@ -71,7 +72,7 @@ __dtors(void) static void __ctors(void) { - void (**p)(void) = __CTOR_LIST__ + 1; + init_f *p = __CTOR_LIST__ + 1; while (*p) { (**p++)(); diff --git a/lib/csu/crtend.c b/lib/csu/crtend.c index 484ca3cc5d3..7c751465c7d 100644 --- a/lib/csu/crtend.c +++ b/lib/csu/crtend.c @@ -1,12 +1,13 @@ -/* $OpenBSD: crtend.c,v 1.3 2004/01/08 14:59:15 drahn Exp $ */ +/* $OpenBSD: crtend.c,v 1.4 2004/01/26 20:00:37 espie Exp $ */ /* $NetBSD: crtend.c,v 1.1 1996/09/12 16:59:04 cgd Exp $ */ #include #include "md_init.h" +#include "extern.h" -static void (*__CTOR_LIST__[1])(void) +static init_f __CTOR_LIST__[1] __attribute__((section(".ctors"))) = { (void *)0 }; /* XXX */ -static void (*__DTOR_LIST__[1])(void) +static init_f __DTOR_LIST__[1] __attribute__((section(".dtors"))) = { (void *)0 }; /* XXX */ MD_SECTION_EPILOGUE(".init"); diff --git a/lib/csu/crtendS.c b/lib/csu/crtendS.c index dd957d071fc..1137b450202 100644 --- a/lib/csu/crtendS.c +++ b/lib/csu/crtendS.c @@ -1,12 +1,13 @@ -/* $OpenBSD: crtendS.c,v 1.3 2004/01/08 14:59:15 drahn Exp $ */ +/* $OpenBSD: crtendS.c,v 1.4 2004/01/26 20:00:37 espie Exp $ */ /* $NetBSD: crtend.c,v 1.1 1997/04/16 19:38:24 thorpej Exp $ */ #include #include "md_init.h" +#include "extern.h" -static void (*__CTOR_LIST__[1])(void) +static init_f __CTOR_LIST__[1] __attribute__((section(".ctors"))) = { (void *)0 }; /* XXX */ -static void (*__DTOR_LIST__[1])(void) +static init_f __DTOR_LIST__[1] __attribute__((section(".dtors"))) = { (void *)0 }; /* XXX */ MD_SECTION_EPILOGUE(".init"); diff --git a/lib/csu/extern.h b/lib/csu/extern.h new file mode 100644 index 00000000000..53d49a36788 --- /dev/null +++ b/lib/csu/extern.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2004 Marc Espie + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +struct ps_strings; + +extern void ___start(int argc, char **argv, char **envp, void (*cleanup)(void), + const void *obj, struct ps_strings *ps_strings); +extern void __init(void); +extern int main(int argc, char *argv[], char *envp[]); + +typedef void (*init_f)(void); -- cgit v1.2.3