home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / bugs / 2bsd / 86 < prev    next >
Encoding:
Text File  |  1992-09-01  |  1.9 KB  |  101 lines

  1. Newsgroups: comp.bugs.2bsd
  2. Path: sparky!uunet!europa.asd.contel.com!awds.imsd.contel.com!wlbr!sms
  3. From: sms@WLV.IIPO.GTEGSC.COM (Steven M. Schultz)
  4. Subject: C compiler (/lib/c1) u_char improvement    (#77)
  5. Message-ID: <1992Sep2.205246.21262@wlbr.iipo.gtegsc.com>
  6. Sender: news@wlbr.iipo.gtegsc.com (news)
  7. Nntp-Posting-Host: wlv.iipo.gtegsc.com
  8. Organization: GTE Government Systems
  9. Date: Wed, 2 Sep 92 20:52:46 GMT
  10. Lines: 89
  11.  
  12. Subject: C compiler (/lib/c1) u_char improvement   (#77)
  13. Index:    lib/ccom/optable 2.11BSD
  14.  
  15. Description:
  16.     The C compiler doesn't know it can use the same 'bitb' instructions
  17.     for u_char as it can for char.  This results in extra instructions
  18.     being generated to promote the u_char to int before doing a 'bit'.
  19.  
  20.     This type of construct occurs fairly frequently in the networking
  21.     code because various flag fields are u_char in type.
  22.  
  23. Repeat-By:
  24.  
  25.     Compile the test program (using "cc -O -S"):
  26.  
  27.         char    *b;
  28.         unsigned char *c;
  29.     main()
  30.         {
  31.         if    ((b[1] & 4) == 0)
  32.             exit(2);
  33.         if    ((c[1] & 4) == 0)
  34.             exit(1);
  35.         }
  36.  
  37.     Note that the code reads:
  38.  
  39.     .comm    _b,2
  40.     .comm    _c,2
  41.     .globl    _main
  42.     .text
  43. _main:
  44. ~~main:
  45.     jsr    r5,csv
  46.     mov    _b,r0
  47.     bitb    $4,1(r0)
  48.     jne    L4
  49.     mov    $2,(sp)
  50.     jsr    pc,*$_exit
  51. L4:    mov    _c,r0
  52.     movb    1(r0),r0    /* XXX */
  53.     bic    $!377,r0    /* XXX */
  54.     bit    $4,r0
  55.     jne    L3
  56.     mov    $1,(sp)
  57.     jsr    pc,*$_exit
  58. L3:    jmp    cret
  59.     .globl
  60.     .data
  61.  
  62.   Instead of:
  63.  
  64.     .comm    _b,2
  65.     .comm    _c,2
  66.     .globl    _main
  67.     .text
  68. _main:
  69. ~~main:
  70.     jsr    r5,csv
  71.     mov    _b,r0
  72.     bitb    $4,1(r0)
  73.     jne    L4
  74.     mov    $2,(sp)
  75.     jsr    pc,*$_exit
  76. L4:    mov    _c,r0
  77.     bitb    $4,1(r0)
  78.     jne    L3
  79.     mov    $1,(sp)
  80.     jsr    pc,*$_exit
  81. L3:    jmp    cret
  82.     .globl
  83.     .data
  84.  
  85. Fix:
  86.     Apply the patch below and reinstall 'c1'.
  87. ==============================cut here==============================
  88. *** /usr/src/lib/ccom/optable.old    Wed Oct 23 07:02:57 1991
  89. --- /usr/src/lib/ccom/optable    Tue Jul 28 09:35:00 1992
  90. ***************
  91. *** 1839,1844 ****
  92. --- 1839,1846 ----
  93.       IBE    R,A1
  94.   
  95.   %n*,a
  96. + %nu*,a
  97. + %nub*,a
  98.   %    [move6]
  99.   
  100.   %n,a
  101.