home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / bsd / 10705 < prev    next >
Encoding:
Text File  |  1992-12-29  |  7.0 KB  |  262 lines

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!mcsun!sun4nl!fwi.uva.nl!vdlinden
  2. From: vdlinden@fwi.uva.nl (Frank van der Linden)
  3. Newsgroups: comp.unix.bsd
  4. Subject: gcc 2.x and kernel building
  5. Message-ID: <1992Dec28.213027.18853@fwi.uva.nl>
  6. Date: 28 Dec 92 21:30:27 GMT
  7. Sender: news@fwi.uva.nl
  8. Organization: FWI, University of Amsterdam
  9. Lines: 250
  10. Nntp-Posting-Host: carol.fwi.uva.nl
  11.  
  12.  
  13.  Hi,
  14.  
  15.  In a message a lot of weeks ago Kim Andersen wrote that the 386bsd
  16. kernel could be compiled with gcc 2.x apart from machdep.c.
  17. Seeing nothing in this group about a fix for machdep.c, I tried to
  18. make a working kernel with gcc 2.3.3.
  19.  The problem is in the structures defined in "/sys/i386/include/segments.h".
  20. All the fields of these structures (descriptor tables) _have_to_be_
  21. byte aligned because the Intel 386/486 CPU wants it that way.This is
  22. no problem with gcc 1.39, but gcc 2.x aligns the struct fields on 4
  23. byte boundaries.
  24.  An example : struct { int x:16; int y:32; } s;
  25.               With gcc 1.39 sizeof(s) = 6.
  26.               With gcc 2.3 sizeof(s) = 8.
  27.  
  28.  Solution:
  29. 1. add HANDLE_SYSV_PRAGMA to gcc's config/i386bsd.h.
  30. 2. put #pragma pack(1) at the beginning (line 59) of segments.h
  31.    put #pragma pack(4) at the end (line 196) of segments.h
  32.  
  33.  I have appended all my patches at the end of this message.
  34.  The patch for ldexp.c is here because I encountered problems - atof(3)
  35. depends on ldexp() and atof("1.0") returned -1.0 - with the original
  36. patch that Wolfgang posted to this group about two months ago (maybe
  37. I messed things up when I applied the patch originally). I exchanged
  38. temp and temp2 and the problems went away.
  39.  The patch for npx.c includes an old patch (outb(0xf1,0) instead of
  40. outb(0xb1,0) and two changes in the comments) posted to this group
  41. a long time ago.
  42.  The patch for segments.h includes a couple of long lines (> 80 chars),
  43. which may cause this patch to fail.
  44.  
  45. Happy new year,
  46.  
  47. Onno van der Linden      c/o         vdlinden@fwi.uva.nl
  48.  
  49. *** /usr/src/sys.386bsd/kern/init_main.c.orig    Fri Dec 25 21:25:06 1992
  50. --- /usr/src/sys.386bsd/kern/init_main.c    Sat Dec 26 14:16:33 1992
  51. ***************
  52. *** 85,88 ****
  53. --- 85,92 ----
  54.   int    boothowto;
  55.   
  56. + #if __GNUC__ >= 2
  57. + __main(){}
  58. + #endif
  59.   /*
  60.    * System startup; initialize the world, create process 0,
  61.  
  62. *** /usr/src/sys.386bsd/i386/include/segments.h.orig    Sat Dec 26 20:01:00 1992
  63. --- /usr/src/sys.386bsd/i386/include/segments.h    Sun Dec 27 18:26:04 1992
  64. ***************
  65. *** 56,59 ****
  66. --- 56,61 ----
  67.   #define    GSEL(s,r)    (((s)<<3) | r)            /* a global selector */
  68.   
  69. + #pragma pack(1)
  70.   /*
  71.    * Memory and System segment descriptors
  72. ***************
  73. *** 195,196 ****
  74. --- 197,200 ----
  75.   #define    NIDT    256
  76.   #define    NRSVIDT    32        /* reserved entries for cpu exceptions */
  77. + #pragma pack(4)
  78.  
  79. *** /usr/src/sys.386bsd/i386/isa/npx.c.orig    Sat Dec 26 12:36:41 1992
  80. --- /usr/src/sys.386bsd/i386/isa/npx.c    Sat Dec 26 12:54:46 1992
  81. ***************
  82. *** 127,135 ****
  83.       asm("    fldcw %0" : : "g" (wd));
  84.       if (curpcb) {
  85. !         asm("    fnsave %0 " : : "g" (curpcb->pcb_savefpu) );
  86.           curpcb->pcb_flags |= FP_NEEDSRESTORE;
  87.       }
  88.       load_cr0(rcr0() | CR0_EM);    /* start emulating */
  89. !     outb(0xb1,0);        /* reset processor */
  90.   }
  91.   
  92. --- 127,135 ----
  93.       asm("    fldcw %0" : : "g" (wd));
  94.       if (curpcb) {
  95. !         asm("    fnsave %0 " : : "m" (curpcb->pcb_savefpu) );
  96.           curpcb->pcb_flags |= FP_NEEDSRESTORE;
  97.       }
  98.       load_cr0(rcr0() | CR0_EM);    /* start emulating */
  99. !     outb(0xf1,0);        /* reset coprocessor */
  100.   }
  101.   
  102. ***************
  103. *** 142,146 ****
  104.       npxproc = curproc;
  105.       npxpcb = curpcb;
  106. !     asm("    frstor %0 " : : "g" (curpcb->pcb_savefpu) );
  107.   }
  108.   
  109. --- 142,146 ----
  110.       npxproc = curproc;
  111.       npxpcb = curpcb;
  112. !     asm("    frstor %0 " : : "m" (curpcb->pcb_savefpu) );
  113.   }
  114.   
  115. ***************
  116. *** 151,155 ****
  117.   
  118.       if (npxproc == 0) panic ("npxunload");
  119. !     asm("    fsave %0 " : : "g" (npxpcb->pcb_savefpu) );
  120.       npxproc = 0 ;
  121.   }
  122. --- 151,155 ----
  123.   
  124.       if (npxproc == 0) panic ("npxunload");
  125. !     asm("    fsave %0 " : : "m" (npxpcb->pcb_savefpu) );
  126.       npxproc = 0 ;
  127.   }
  128. ***************
  129. *** 162,166 ****
  130.   static status;
  131.   
  132. !     outb(0xf0,0);        /* reset processor */
  133.   /*pg("npxintr");*/
  134.   
  135. --- 162,166 ----
  136.   static status;
  137.   
  138. !     outb(0xf0,0);        /* clear BUSY# latch */
  139.   /*pg("npxintr");*/
  140.   
  141. ***************
  142. *** 168,172 ****
  143.       /* sync state in process context structure, in advance of debugger/process looking for it */
  144.       if (npxproc == 0 || npxexists == 0) panic ("npxintr");
  145. !     asm ("    fnsave %0 " : : "g" (npxpcb->pcb_savefpu) );
  146.   
  147.   #ifdef notyet
  148. --- 168,172 ----
  149.       /* sync state in process context structure, in advance of debugger/process looking for it */
  150.       if (npxproc == 0 || npxexists == 0) panic ("npxintr");
  151. !     asm ("    fnsave %0 " : : "m" (npxpcb->pcb_savefpu) );
  152.   
  153.   #ifdef notyet
  154. ***************
  155. *** 207,211 ****
  156.       load_cr0(rcr0() & ~CR0_EM);    /* stop emulating */
  157.           if (curpcb->pcb_flags & FP_NEEDSRESTORE)
  158. !         asm("    frstor %0 " : : "g" (curpcb->pcb_savefpu));
  159.       curpcb->pcb_flags |= FP_WASUSED | FP_NEEDSSAVE;
  160.       curpcb->pcb_flags &= ~FP_NEEDSRESTORE;
  161. --- 207,211 ----
  162.       load_cr0(rcr0() & ~CR0_EM);    /* stop emulating */
  163.           if (curpcb->pcb_flags & FP_NEEDSRESTORE)
  164. !         asm("    frstor %0 " : : "m" (curpcb->pcb_savefpu));
  165.       curpcb->pcb_flags |= FP_WASUSED | FP_NEEDSSAVE;
  166.       curpcb->pcb_flags &= ~FP_NEEDSRESTORE;
  167.  
  168. *** /usr/src/sys.386bsd/i386/isa/pccons.c.orig    Fri Dec 25 13:12:24 1992
  169. --- /usr/src/sys.386bsd/i386/isa/pccons.c    Fri Dec 25 21:43:12 1992
  170. ***************
  171. *** 861,865 ****
  172.   
  173.   unsigned    __debug = 0; /*0xffe */;
  174. ! static char scantokey[] {
  175.   0,
  176.   120,    /* F9 */
  177. --- 861,865 ----
  178.   
  179.   unsigned    __debug = 0; /*0xffe */;
  180. ! static char scantokey[] = {
  181.   0,
  182.   120,    /* F9 */
  183. ***************
  184. *** 959,963 ****
  185.   0,
  186.   0,
  187. ! 45,    ?* na*/
  188.   0,
  189.   0,
  190. --- 959,963 ----
  191.   0,
  192.   0,
  193. ! 45,    /* na*/
  194.   0,
  195.   0,
  196. ***************
  197. *** 995,999 ****
  198.   118,    /* F7 */
  199.   };
  200. ! static char extscantokey[] {
  201.   0,
  202.   120,    /* F9 */
  203. --- 995,999 ----
  204.   118,    /* F7 */
  205.   };
  206. ! static char extscantokey[] = {
  207.   0,
  208.   120,    /* F9 */
  209. ***************
  210. *** 1093,1097 ****
  211.   0,
  212.   0,
  213. ! 45,    ?* na*/
  214.   0,
  215.   0,
  216. --- 1093,1097 ----
  217.   0,
  218.   0,
  219. ! 45,    /* na*/
  220.   0,
  221.   0,
  222.  
  223. *** /usr/src/lib/libc/i386/gen/ldexp.c.orig    Fri Apr 12 21:39:44 1991
  224. --- /usr/src/lib/libc/i386/gen/ldexp.c    Mon Dec 28 17:31:53 1992
  225. ***************
  226. *** 44,47 ****
  227. --- 44,49 ----
  228.    * Written by Sean Eric Fagan (sef@kithrup.COM)
  229.    * Sun Mar 11 20:27:09 PST 1990
  230. +  * Modified by Wolfgang Solfrank (ws@tools.de) for GCC 2.1
  231. +  * Tue Jun  9 12:56:33 MET DST 1992
  232.    */
  233.   
  234. ***************
  235. *** 56,62 ****
  236. --- 58,74 ----
  237.       double temp, texp, temp2;
  238.       texp = exp;
  239. + #ifdef    __GNUC__
  240. + #if    __GNUC__ >= 2
  241. +     asm ("fscale "
  242. +         : "=u" (temp2), "=t" (temp)
  243. +         : "0" (texp), "1" (value));
  244. + #else
  245.       asm ("fscale ; fxch %%st(1) ; fstp%L1 %1 "
  246.           : "=f" (temp), "=0" (temp2)
  247.           : "0" (texp), "f" (value));
  248. + #endif
  249. + #else
  250. + error unknown asm
  251. + #endif
  252.       return (temp);
  253.   }
  254. -- 
  255.   Frank van der Linden.                        Internet : vdlinden@fwi.uva.nl
  256. * WARNING ---- The author of this message has once seen some AT&T Unix source *
  257. * code, so now this message is probably copyrighted by them! You have been    *
  258. * reading this entirely at your own risk..                                    *
  259.