Print this page
5291 x86 {high,low}bit rely on undefined behavior

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/ia32/ml/ia32.il
          +++ new/usr/src/uts/intel/ia32/ml/ia32.il
↓ open down ↓ 58 lines elided ↑ open up ↑
  59   59          .end
  60   60  
  61   61  /
  62   62  / convert ipl to spl.  This is the identity function for i86
  63   63  /
  64   64          .inline ipltospl,0
  65   65          movl    (%esp), %eax
  66   66          .end
  67   67  
  68   68  /
  69      -/ find the low order bit in a word
  70      -/
  71      -        .inline lowbit,4
  72      -        movl    $-1, %eax
  73      -        bsfl    (%esp), %eax
  74      -        incl    %eax
  75      -        .end
  76      -
  77      -/
  78      -/ find the high order bit in a word
  79      -/
  80      -        .inline highbit,4
  81      -        movl    $-1, %eax
  82      -        bsrl    (%esp), %eax
  83      -        incl    %eax
  84      -        .end
  85      -
  86      -/
  87   69  / Networking byte order functions (too bad, Intel has the wrong byte order)
  88   70  /
  89   71          .inline htonll,4
  90   72          movl    (%esp), %edx
  91   73          movl    4(%esp), %eax
  92   74          bswap   %edx
  93   75          bswap   %eax
  94   76          .end
  95   77  
  96   78          .inline ntohll,4
↓ open down ↓ 122 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX