/[hurd]/hurd-l4/libl4/ia32/l4/bits/math.h
ViewVC logotype

Diff of /hurd-l4/libl4/ia32/l4/bits/math.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by marcus, Thu Sep 18 15:46:58 2003 UTC revision 1.4 by marcus, Mon Sep 22 20:26:57 2003 UTC
# Line 1  Line 1 
1  /* math.h - Math support routines for ia32.  /* math.h - Math support routines for powerpc.
2     Copyright (C) 2003 Free Software Foundation, Inc.     Copyright (C) 2003 Free Software Foundation, Inc.
3     Written by Marcus Brinkmann <marcus@gnu.org>.     Written by Marcus Brinkmann <marcus@gnu.org>.
4    
# Line 31  __l4_msb (l4_word_t data) Line 31  __l4_msb (l4_word_t data)
31  {  {
32    l4_word_t msb;    l4_word_t msb;
33    
34    __asm__ ("bsr %[data], %[msb]"    /* Count the leading zeros.  */
35             : [msb] "=r" (msb)    asm ("cntlzw %[msb], %[data]"
36             : [data] "rm" (data));         : [msb] "=r" (msb)
37           : "r" (data & -data));
38    
39    return msb + 1;    return 32 - msb;
40  }  }
41    
42    
# Line 46  __l4_lsb (l4_word_t data) Line 47  __l4_lsb (l4_word_t data)
47  {  {
48    l4_word_t lsb;    l4_word_t lsb;
49    
50    __asm__ ("bsf %[data], %[lsb]"    /* x & -x clears all bits in the word except the LSB set.  */
51             : [lsb] "=r" (lsb)    return __l4_msb (data & -data);
            : [data] "rm" (data));  
   
   return lsb + 1;  
52  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26