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


  47 /
  48         .inline curcpup,0
  49         movq    %gs:0x10, %rax
  50         .end
  51 
  52 /
  53 / return caller
  54 /
  55         .inline caller,0
  56         movq    8(%rbp), %rax
  57         .end
  58 
  59 /
  60 / convert ipl to spl.  This is the identity function for i86
  61 /
  62         .inline ipltospl,0
  63         movq    %rdi, %rax
  64         .end
  65 
  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 / Networking byte order functions (too bad, Intel has the wrong byte order)
  77 /
  78 
  79         .inline htonll,4
  80         movq    %rdi, %rax
  81         bswapq  %rax
  82         .end
  83 
  84         .inline ntohll,4
  85         movq    %rdi, %rax
  86         bswapq  %rax
  87         .end
  88 
  89         .inline htonl,4
  90         movl    %edi, %eax
  91         bswap   %eax
  92         .end
  93 
  94         .inline ntohl,4
  95         movl    %edi, %eax




  47 /
  48         .inline curcpup,0
  49         movq    %gs:0x10, %rax
  50         .end
  51 
  52 /
  53 / return caller
  54 /
  55         .inline caller,0
  56         movq    8(%rbp), %rax
  57         .end
  58 
  59 /
  60 / convert ipl to spl.  This is the identity function for i86
  61 /
  62         .inline ipltospl,0
  63         movq    %rdi, %rax
  64         .end
  65 
  66 /









  67 / Networking byte order functions (too bad, Intel has the wrong byte order)
  68 /
  69 
  70         .inline htonll,4
  71         movq    %rdi, %rax
  72         bswapq  %rax
  73         .end
  74 
  75         .inline ntohll,4
  76         movq    %rdi, %rax
  77         bswapq  %rax
  78         .end
  79 
  80         .inline htonl,4
  81         movl    %edi, %eax
  82         bswap   %eax
  83         .end
  84 
  85         .inline ntohl,4
  86         movl    %edi, %eax