From dafb9e0376df25a266e47929a73e227a1c1d6fe1 Mon Sep 17 00:00:00 2001 From: rtoy <rtoy> Date: Thu, 1 Sep 2011 05:18:26 +0000 Subject: [PATCH] Add os_init0 to allow for some really early OS inits. On Linux, os_init can re-exec lisp to set up the correct personality. Not normally a problem, but if any output happens before os_init is called, the output appears to happen twice. So add os_init0 to do this early on, before any output. This is a bit of a kludge. lisp/lisp.c: o Call os_init0 early in main. lisp/Linux-os.c: o Move the personality stuff from os_init to os_init0. lisp/Darwin-os.c: lisp/FreeBSD-os.c: lisp/NetBSD-os.c: lisp/OpenBSD-os.c: lisp/hpux-os.c: lisp/irix-os.c: lisp/mach-os.c: lisp/osf1-os.c: lisp/solaris-os.c: lisp/sunos-os.c: o Add dummy implementation of os_init0. These OSes don't (currently) need anything special. lisp/os.h: o Declare os_init0. --- lisp/Darwin-os.c | 5 ++++- lisp/FreeBSD-os.c | 6 +++++- lisp/Linux-os.c | 13 ++++++++++--- lisp/NetBSD-os.c | 6 +++++- lisp/OpenBSD-os.c | 6 +++++- lisp/hpux-os.c | 6 +++++- lisp/irix-os.c | 6 +++++- lisp/lisp.c | 12 +++++++++++- lisp/mach-os.c | 6 +++++- lisp/os.h | 3 ++- lisp/osf1-os.c | 6 +++++- lisp/solaris-os.c | 6 +++++- lisp/sunos-os.c | 6 +++++- 13 files changed, 72 insertions(+), 15 deletions(-) diff --git a/lisp/Darwin-os.c b/lisp/Darwin-os.c index 82f0f9c2a..01a5d01e2 100644 --- a/lisp/Darwin-os.c +++ b/lisp/Darwin-os.c @@ -14,7 +14,7 @@ * Frobbed for OpenBSD by Pierre R. Mai, 2001. * Frobbed for Darwin by Pierre R. Mai, 2003. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Darwin-os.c,v 1.32 2011/09/01 04:39:56 rtoy Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Darwin-os.c,v 1.33 2011/09/01 05:18:26 rtoy Exp $ * */ @@ -99,6 +99,9 @@ timebase_init(void) } #endif +void +os_init0(const char *argv[], const char *envp[]) +{} void os_init(const char *argv[], const char *envp[]) diff --git a/lisp/FreeBSD-os.c b/lisp/FreeBSD-os.c index 1e91906f4..84e0b0854 100644 --- a/lisp/FreeBSD-os.c +++ b/lisp/FreeBSD-os.c @@ -12,7 +12,7 @@ * Much hacked by Paul Werkowski * GENCGC support by Douglas Crosher, 1996, 1997. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/FreeBSD-os.c,v 1.37 2010/12/26 16:04:43 rswindells Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/FreeBSD-os.c,v 1.38 2011/09/01 05:18:26 rtoy Exp $ * */ @@ -38,6 +38,10 @@ vm_size_t os_vm_page_size; +void +os_init0(const char *argv[], const char *envp[]) +{} + void os_init(const char *argv[], const char *envp[]) { diff --git a/lisp/Linux-os.c b/lisp/Linux-os.c index 3e3df735e..26e122408 100644 --- a/lisp/Linux-os.c +++ b/lisp/Linux-os.c @@ -15,7 +15,7 @@ * GENCGC support by Douglas Crosher, 1996, 1997. * Alpha support by Julian Dolby, 1999. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Linux-os.c,v 1.51 2010/12/26 16:04:43 rswindells Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/Linux-os.c,v 1.52 2011/09/01 05:18:26 rtoy Exp $ * */ @@ -131,6 +131,15 @@ check_personality(struct utsname *name, const char *argv[], const char *envp[]) #endif } +void +os_init0(const char *argv[], const char *envp[]) +{ + struct utsname name; + + uname(&name); + check_personality(&name, argv, envp); +} + void os_init(const char *argv[], const char *envp[]) { @@ -146,8 +155,6 @@ os_init(const char *argv[], const char *envp[]) } os_vm_page_size = getpagesize(); - - check_personality(&name, argv, envp); } #ifdef __i386 diff --git a/lisp/NetBSD-os.c b/lisp/NetBSD-os.c index df268cd03..1399c402c 100644 --- a/lisp/NetBSD-os.c +++ b/lisp/NetBSD-os.c @@ -15,7 +15,7 @@ * Frobbed for OpenBSD by Pierre R. Mai, 2001. * Frobbed for NetBSD by Pierre R. Mai, 2002. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/NetBSD-os.c,v 1.19 2010/12/26 16:04:43 rswindells Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/NetBSD-os.c,v 1.20 2011/09/01 05:18:26 rtoy Exp $ * */ @@ -45,6 +45,10 @@ size_t os_vm_page_size; #endif +void +os_init0(const char *argv[], const char *envp[]) +{} + void os_init(const char *argv[], const char *envp[]) { diff --git a/lisp/OpenBSD-os.c b/lisp/OpenBSD-os.c index 66978af1d..40b2a700c 100644 --- a/lisp/OpenBSD-os.c +++ b/lisp/OpenBSD-os.c @@ -13,7 +13,7 @@ * GENCGC support by Douglas Crosher, 1996, 1997. * Frobbed for OpenBSD by Pierre R. Mai, 2001. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/OpenBSD-os.c,v 1.10 2010/02/01 16:04:43 rtoy Rel $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/OpenBSD-os.c,v 1.11 2011/09/01 05:18:26 rtoy Exp $ * */ @@ -40,6 +40,10 @@ vm_size_t os_vm_page_size; #endif +void +os_init0(const char *argv[], const char *envp[]) +{} + void os_init(const char *argv[], const char *envp[]) { diff --git a/lisp/hpux-os.c b/lisp/hpux-os.c index e02e0490d..4a614f620 100644 --- a/lisp/hpux-os.c +++ b/lisp/hpux-os.c @@ -1,5 +1,5 @@ /* - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/hpux-os.c,v 1.10 2010/02/01 16:04:43 rtoy Rel $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/hpux-os.c,v 1.11 2011/09/01 05:18:26 rtoy Exp $ * * OS-dependent routines. This file (along with os.h) exports an * OS-independent interface to the operating system VM facilities. @@ -52,6 +52,10 @@ static struct segment { os_vm_address_t protected; } segments[MAX_SEGMENTS]; +void +os_init0(const char *argv[], const char *envp[]) +{} + void os_init(const char *argv[], const char *envp[]) { diff --git a/lisp/irix-os.c b/lisp/irix-os.c index 75b36b439..97d6a0519 100644 --- a/lisp/irix-os.c +++ b/lisp/irix-os.c @@ -1,5 +1,5 @@ /* - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/irix-os.c,v 1.6 2010/02/01 16:04:43 rtoy Rel $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/irix-os.c,v 1.7 2011/09/01 05:18:26 rtoy Exp $ * * OS-dependent routines. This file (along with os.h) exports an * OS-independent interface to the operating system VM facilities. @@ -29,6 +29,10 @@ os_vm_size_t os_vm_page_size = (-1); int zero_fd; +void +os_init0(const char *argv[], const char *envp[]) +{} + void os_init(const char *argv[], const char *envp[]) { diff --git a/lisp/lisp.c b/lisp/lisp.c index 1b56f8ad6..396478d05 100644 --- a/lisp/lisp.c +++ b/lisp/lisp.c @@ -1,7 +1,7 @@ /* * main() entry point for a stand alone lisp image. * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.83 2011/06/10 19:32:31 rtoy Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/lisp.c,v 1.84 2011/09/01 05:18:26 rtoy Exp $ * */ @@ -461,6 +461,16 @@ main(int argc, const char *argv[], const char *envp[]) } + /* + * Do any special OS initialization that needs to be done early. + * In particular, on Linux, we might re-exec ourselves to set our + * personality correctly. Not normally a problem, but this does + * cause any output to happen twice. That can be confusing. + * + * So make sure we don't do any output before this point! + */ + + os_init0(argv, envp); #if defined(SVR4) tzset(); #endif diff --git a/lisp/mach-os.c b/lisp/mach-os.c index 28c2970b0..0b08cdcd8 100644 --- a/lisp/mach-os.c +++ b/lisp/mach-os.c @@ -1,5 +1,5 @@ /* - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/mach-os.c,v 1.8 2010/02/01 16:04:43 rtoy Rel $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/mach-os.c,v 1.9 2011/09/01 05:18:26 rtoy Exp $ * * OS-dependent routines. This file (along with os.h) exports an * OS-independent interface to the operating system VM facilities. @@ -37,6 +37,10 @@ task_self(void) } #endif +void +os_init0(const char *argv[], const char *envp[]) +{} + void os_init(const char *argv[], const char *envp[]) { diff --git a/lisp/os.h b/lisp/os.h index 9a2a8fd46..4c76df2a8 100644 --- a/lisp/os.h +++ b/lisp/os.h @@ -1,5 +1,5 @@ /* - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/os.h,v 1.27 2010/12/26 16:04:43 rswindells Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/os.h,v 1.28 2011/09/01 05:18:26 rtoy Exp $ * * Common interface for os-dependent functions. * @@ -72,6 +72,7 @@ extern os_vm_size_t os_vm_page_size; +extern void os_init0(const char *argv[], const char *envp[]); extern void os_init(const char *argv[], const char *envp[]); extern void os_install_interrupt_handlers(void); diff --git a/lisp/osf1-os.c b/lisp/osf1-os.c index a4c043afc..af10b8ef8 100644 --- a/lisp/osf1-os.c +++ b/lisp/osf1-os.c @@ -1,5 +1,5 @@ /* - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/osf1-os.c,v 1.6 2010/02/01 16:04:43 rtoy Rel $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/osf1-os.c,v 1.7 2011/09/01 05:18:26 rtoy Exp $ * * OS-dependent routines. This file (along with os.h) exports an * OS-independent interface to the operating system VM facilities. @@ -25,6 +25,10 @@ vm_size_t os_vm_page_size; +void +os_init0(const char *argv[], const char *envp[]) +{} + void os_init(const char *argv[], const char *envp[]) { diff --git a/lisp/solaris-os.c b/lisp/solaris-os.c index 140e5db54..815a36dde 100644 --- a/lisp/solaris-os.c +++ b/lisp/solaris-os.c @@ -1,5 +1,5 @@ /* - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/solaris-os.c,v 1.29 2010/12/26 16:04:43 rswindells Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/solaris-os.c,v 1.30 2011/09/01 05:18:26 rtoy Exp $ * * OS-dependent routines. This file (along with os.h) exports an * OS-independent interface to the operating system VM facilities. @@ -72,6 +72,10 @@ os_init_bailout(char *arg) exit(1); } +void +os_init0(const char *argv[], const char *envp[]) +{} + void os_init(const char *argv[], const char *envp[]) { diff --git a/lisp/sunos-os.c b/lisp/sunos-os.c index 536ae7ba8..775eb4060 100644 --- a/lisp/sunos-os.c +++ b/lisp/sunos-os.c @@ -1,5 +1,5 @@ /* - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/sunos-os.c,v 1.12 2010/02/01 16:04:43 rtoy Rel $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/sunos-os.c,v 1.13 2011/09/01 05:18:26 rtoy Exp $ * * OS-dependent routines. This file (along with os.h) exports an * OS-independent interface to the operating system VM facilities. @@ -80,6 +80,10 @@ os_init_bailout(arg) exit(1); } +void +os_init0(const char *argv[], const char *envp[]) +{} + void os_init(const char *argv[], const char *envp[]) { -- GitLab