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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/amd64/ml/amd64.il
          +++ new/usr/src/uts/intel/amd64/ml/amd64.il
↓ open down ↓ 56 lines elided ↑ open up ↑
  57   57          .end
  58   58  
  59   59  /
  60   60  / convert ipl to spl.  This is the identity function for i86
  61   61  /
  62   62          .inline ipltospl,0
  63   63          movq    %rdi, %rax
  64   64          .end
  65   65  
  66   66  /
  67      -/ find the low order bit in a word
  68      -/
  69      -        .inline lowbit,4
  70      -        movq    $-1, %rax
  71      -        bsfq    %rdi, %rax
  72      -        incq    %rax
  73      -        .end
  74      -
  75      -/
  76   67  / Networking byte order functions (too bad, Intel has the wrong byte order)
  77   68  /
  78   69  
  79   70          .inline htonll,4
  80   71          movq    %rdi, %rax
  81   72          bswapq  %rax
  82   73          .end
  83   74  
  84   75          .inline ntohll,4
  85   76          movq    %rdi, %rax
↓ open down ↓ 146 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX