summaryrefslogtreecommitdiffstats
path: root/lib/csu/sparc64
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2002-07-16 12:28:50 +0000
committermarkm <markm@FreeBSD.org>2002-07-16 12:28:50 +0000
commitbedd05ccecbd002c4865f3dff35af258f0e5dd94 (patch)
tree4dcd84e724c9495af7116ae6dbbcee1b0420fb84 /lib/csu/sparc64
parent4de6bef14519eb23505d35e15226e5711028252c (diff)
downloadFreeBSD-src-bedd05ccecbd002c4865f3dff35af258f0e5dd94.zip
FreeBSD-src-bedd05ccecbd002c4865f3dff35af258f0e5dd94.tar.gz
The main reason for this is to reduce diffs between all the crt1.c's.
Assembler macros are tidied up and made as similar as sanely possible. The macros are translated into C (__inline static) functions for lint. Declaration orders are made the same. Declarations are all ISOfied and tidied up. Comment contents have gratuitous diffs removed. The net result is a bunch of crt1.c's that are 90% the same. It may be possible to now encapsulate the differences in one MD header, and have only one MI crt1.c file (although the macros to do this may be ugly). Helpful comments by: obrien, bde Alpha tested by: des i386-elf tested by: markm
Diffstat (limited to 'lib/csu/sparc64')
-rw-r--r--lib/csu/sparc64/crt1.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/lib/csu/sparc64/crt1.c b/lib/csu/sparc64/crt1.c
index cd684f3..4bde8dc 100644
--- a/lib/csu/sparc64/crt1.c
+++ b/lib/csu/sparc64/crt1.c
@@ -1,5 +1,5 @@
-/*
- * Copyright 2001 David E. O'Brien
+/*-
+ * Copyright 2001 David E. O'Brien.
* All rights reserved.
* Copyright (c) 1995, 1998 Berkeley Software Design, Inc.
* All rights reserved.
@@ -29,25 +29,32 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef lint
#ifndef __GNUC__
#error "GCC is needed to compile this file"
#endif
+#endif /* lint */
#include <stdlib.h>
+
#include "libc_private.h"
#include "crtbrand.c"
struct Struct_Obj_Entry;
struct ps_strings;
-#pragma weak _DYNAMIC
extern int _DYNAMIC;
+#pragma weak _DYNAMIC
+
+typedef void (*fptr)(void);
-extern void _init(void);
extern void _fini(void);
+extern void _init(void);
extern int main(int, char **, char **);
-extern void __sparc64_sigtramp_setup(void);
-extern void __sparc64_utrap_setup(void);
+extern void _start(char **, void (*)(void), struct Struct_Obj_Entry *,
+ struct ps_strings *);
+extern void __sparc_sigtramp_setup(void);
+extern void __sparc_utrap_setup(void);
#ifdef GCRT
extern void _mcleanup(void);
@@ -59,9 +66,30 @@ extern int etext;
char **environ;
const char *__progname = "";
+/*
+ * Grab %g1 before it gets used for anything by the compiler.
+ * Sparc ELF psABI specifies a termination routine (if any) will be in
+ * %g1
+ */
+static __inline fptr
+get_term(void)
+{
+ fptr retval;
+
+#if 0
+#ifdef __GNUC__
+ __asm__ volatile("mov %%g1,%0" : "=r"(retval));
+#else
+ retval = (fptr)0; /* XXXX Fix this for other compilers */
+#endif
+#else
+ retval = (fptr)0; /* XXXX temporary */
+#endif
+ return(retval);
+}
+
/* The entry function. */
/*
- *
* %o0 holds ps_strings pointer. For Solaris compat and/or shared
* libraries, if %g1 is not 0, it is a routine to pass to atexit().
* (By passing the pointer in the usual argument register, we avoid
@@ -70,26 +98,20 @@ const char *__progname = "";
* Note: kernel may (is not set in stone yet) pass ELF aux vector in %o1,
* but for now we do not use it here.
*/
+/* ARGSUSED */
void
-_start(char **ap,
- void (*cleanup)(void), /* from shared loader */
- struct Struct_Obj_Entry *obj, /* from shared loader */
- struct ps_strings *ps_strings)
+_start(char **ap, void (*cleanup)(void), struct Struct_Obj_Entry *obj __unused,
+ struct ps_strings *ps_strings __unused)
{
+ void (*term)(void);
int argc;
char **argv;
char **env;
const char *s;
-#if 0
- void (*term)(void);
- /* Grab %g1 before it gets used for anything by the compiler. */
- /* Sparc ELF psABI specifies a termination routine (if any) will be in
- %g1 */
- __asm__ volatile("mov %%g1,%0" : "=r"(term));
-#endif
+ term = get_term();
- argc = * (long *) ap;
+ argc = *(long *)(void *)ap;
argv = ap + 1;
env = ap + 2 + argc;
environ = env;
@@ -102,14 +124,13 @@ _start(char **ap,
__sparc_sigtramp_setup();
__sparc_utrap_setup();
-#if 0
+
/*
* If the kernel or a shared library wants us to call
* a termination function, arrange to do so.
*/
if (term)
atexit(term);
-#endif
if (&_DYNAMIC != NULL)
atexit(cleanup);
OpenPOWER on IntegriCloud