home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!bnr.co.uk!uknet!mcsun!sun4nl!fwi.uva.nl!vdlinden
- From: vdlinden@fwi.uva.nl (Frank van der Linden)
- Newsgroups: comp.unix.bsd
- Subject: gcc 2.x and kernel building
- Message-ID: <1992Dec28.213027.18853@fwi.uva.nl>
- Date: 28 Dec 92 21:30:27 GMT
- Sender: news@fwi.uva.nl
- Organization: FWI, University of Amsterdam
- Lines: 250
- Nntp-Posting-Host: carol.fwi.uva.nl
-
-
- Hi,
-
- In a message a lot of weeks ago Kim Andersen wrote that the 386bsd
- kernel could be compiled with gcc 2.x apart from machdep.c.
- Seeing nothing in this group about a fix for machdep.c, I tried to
- make a working kernel with gcc 2.3.3.
- The problem is in the structures defined in "/sys/i386/include/segments.h".
- All the fields of these structures (descriptor tables) _have_to_be_
- byte aligned because the Intel 386/486 CPU wants it that way.This is
- no problem with gcc 1.39, but gcc 2.x aligns the struct fields on 4
- byte boundaries.
- An example : struct { int x:16; int y:32; } s;
- With gcc 1.39 sizeof(s) = 6.
- With gcc 2.3 sizeof(s) = 8.
-
- Solution:
- 1. add HANDLE_SYSV_PRAGMA to gcc's config/i386bsd.h.
- 2. put #pragma pack(1) at the beginning (line 59) of segments.h
- put #pragma pack(4) at the end (line 196) of segments.h
-
- I have appended all my patches at the end of this message.
- The patch for ldexp.c is here because I encountered problems - atof(3)
- depends on ldexp() and atof("1.0") returned -1.0 - with the original
- patch that Wolfgang posted to this group about two months ago (maybe
- I messed things up when I applied the patch originally). I exchanged
- temp and temp2 and the problems went away.
- The patch for npx.c includes an old patch (outb(0xf1,0) instead of
- outb(0xb1,0) and two changes in the comments) posted to this group
- a long time ago.
- The patch for segments.h includes a couple of long lines (> 80 chars),
- which may cause this patch to fail.
-
- Happy new year,
-
- Onno van der Linden c/o vdlinden@fwi.uva.nl
-
- *** /usr/src/sys.386bsd/kern/init_main.c.orig Fri Dec 25 21:25:06 1992
- --- /usr/src/sys.386bsd/kern/init_main.c Sat Dec 26 14:16:33 1992
- ***************
- *** 85,88 ****
- --- 85,92 ----
- int boothowto;
-
- + #if __GNUC__ >= 2
- + __main(){}
- + #endif
- +
- /*
- * System startup; initialize the world, create process 0,
-
- *** /usr/src/sys.386bsd/i386/include/segments.h.orig Sat Dec 26 20:01:00 1992
- --- /usr/src/sys.386bsd/i386/include/segments.h Sun Dec 27 18:26:04 1992
- ***************
- *** 56,59 ****
- --- 56,61 ----
- #define GSEL(s,r) (((s)<<3) | r) /* a global selector */
-
- + #pragma pack(1)
- +
- /*
- * Memory and System segment descriptors
- ***************
- *** 195,196 ****
- --- 197,200 ----
- #define NIDT 256
- #define NRSVIDT 32 /* reserved entries for cpu exceptions */
- +
- + #pragma pack(4)
-
- *** /usr/src/sys.386bsd/i386/isa/npx.c.orig Sat Dec 26 12:36:41 1992
- --- /usr/src/sys.386bsd/i386/isa/npx.c Sat Dec 26 12:54:46 1992
- ***************
- *** 127,135 ****
- asm(" fldcw %0" : : "g" (wd));
- if (curpcb) {
- ! asm(" fnsave %0 " : : "g" (curpcb->pcb_savefpu) );
- curpcb->pcb_flags |= FP_NEEDSRESTORE;
- }
- load_cr0(rcr0() | CR0_EM); /* start emulating */
- ! outb(0xb1,0); /* reset processor */
- }
-
- --- 127,135 ----
- asm(" fldcw %0" : : "g" (wd));
- if (curpcb) {
- ! asm(" fnsave %0 " : : "m" (curpcb->pcb_savefpu) );
- curpcb->pcb_flags |= FP_NEEDSRESTORE;
- }
- load_cr0(rcr0() | CR0_EM); /* start emulating */
- ! outb(0xf1,0); /* reset coprocessor */
- }
-
- ***************
- *** 142,146 ****
- npxproc = curproc;
- npxpcb = curpcb;
- ! asm(" frstor %0 " : : "g" (curpcb->pcb_savefpu) );
- }
-
- --- 142,146 ----
- npxproc = curproc;
- npxpcb = curpcb;
- ! asm(" frstor %0 " : : "m" (curpcb->pcb_savefpu) );
- }
-
- ***************
- *** 151,155 ****
-
- if (npxproc == 0) panic ("npxunload");
- ! asm(" fsave %0 " : : "g" (npxpcb->pcb_savefpu) );
- npxproc = 0 ;
- }
- --- 151,155 ----
-
- if (npxproc == 0) panic ("npxunload");
- ! asm(" fsave %0 " : : "m" (npxpcb->pcb_savefpu) );
- npxproc = 0 ;
- }
- ***************
- *** 162,166 ****
- static status;
-
- ! outb(0xf0,0); /* reset processor */
- /*pg("npxintr");*/
-
- --- 162,166 ----
- static status;
-
- ! outb(0xf0,0); /* clear BUSY# latch */
- /*pg("npxintr");*/
-
- ***************
- *** 168,172 ****
- /* sync state in process context structure, in advance of debugger/process looking for it */
- if (npxproc == 0 || npxexists == 0) panic ("npxintr");
- ! asm (" fnsave %0 " : : "g" (npxpcb->pcb_savefpu) );
-
- #ifdef notyet
- --- 168,172 ----
- /* sync state in process context structure, in advance of debugger/process looking for it */
- if (npxproc == 0 || npxexists == 0) panic ("npxintr");
- ! asm (" fnsave %0 " : : "m" (npxpcb->pcb_savefpu) );
-
- #ifdef notyet
- ***************
- *** 207,211 ****
- load_cr0(rcr0() & ~CR0_EM); /* stop emulating */
- if (curpcb->pcb_flags & FP_NEEDSRESTORE)
- ! asm(" frstor %0 " : : "g" (curpcb->pcb_savefpu));
- curpcb->pcb_flags |= FP_WASUSED | FP_NEEDSSAVE;
- curpcb->pcb_flags &= ~FP_NEEDSRESTORE;
- --- 207,211 ----
- load_cr0(rcr0() & ~CR0_EM); /* stop emulating */
- if (curpcb->pcb_flags & FP_NEEDSRESTORE)
- ! asm(" frstor %0 " : : "m" (curpcb->pcb_savefpu));
- curpcb->pcb_flags |= FP_WASUSED | FP_NEEDSSAVE;
- curpcb->pcb_flags &= ~FP_NEEDSRESTORE;
-
- *** /usr/src/sys.386bsd/i386/isa/pccons.c.orig Fri Dec 25 13:12:24 1992
- --- /usr/src/sys.386bsd/i386/isa/pccons.c Fri Dec 25 21:43:12 1992
- ***************
- *** 861,865 ****
-
- unsigned __debug = 0; /*0xffe */;
- ! static char scantokey[] {
- 0,
- 120, /* F9 */
- --- 861,865 ----
-
- unsigned __debug = 0; /*0xffe */;
- ! static char scantokey[] = {
- 0,
- 120, /* F9 */
- ***************
- *** 959,963 ****
- 0,
- 0,
- ! 45, ?* na*/
- 0,
- 0,
- --- 959,963 ----
- 0,
- 0,
- ! 45, /* na*/
- 0,
- 0,
- ***************
- *** 995,999 ****
- 118, /* F7 */
- };
- ! static char extscantokey[] {
- 0,
- 120, /* F9 */
- --- 995,999 ----
- 118, /* F7 */
- };
- ! static char extscantokey[] = {
- 0,
- 120, /* F9 */
- ***************
- *** 1093,1097 ****
- 0,
- 0,
- ! 45, ?* na*/
- 0,
- 0,
- --- 1093,1097 ----
- 0,
- 0,
- ! 45, /* na*/
- 0,
- 0,
-
- *** /usr/src/lib/libc/i386/gen/ldexp.c.orig Fri Apr 12 21:39:44 1991
- --- /usr/src/lib/libc/i386/gen/ldexp.c Mon Dec 28 17:31:53 1992
- ***************
- *** 44,47 ****
- --- 44,49 ----
- * Written by Sean Eric Fagan (sef@kithrup.COM)
- * Sun Mar 11 20:27:09 PST 1990
- + * Modified by Wolfgang Solfrank (ws@tools.de) for GCC 2.1
- + * Tue Jun 9 12:56:33 MET DST 1992
- */
-
- ***************
- *** 56,62 ****
- --- 58,74 ----
- double temp, texp, temp2;
- texp = exp;
- + #ifdef __GNUC__
- + #if __GNUC__ >= 2
- + asm ("fscale "
- + : "=u" (temp2), "=t" (temp)
- + : "0" (texp), "1" (value));
- + #else
- asm ("fscale ; fxch %%st(1) ; fstp%L1 %1 "
- : "=f" (temp), "=0" (temp2)
- : "0" (texp), "f" (value));
- + #endif
- + #else
- + error unknown asm
- + #endif
- return (temp);
- }
- --
- Frank van der Linden. Internet : vdlinden@fwi.uva.nl
- * WARNING ---- The author of this message has once seen some AT&T Unix source *
- * code, so now this message is probably copyrighted by them! You have been *
- * reading this entirely at your own risk.. *
-