> On Mon, 2010-07-26 at 12:49 -0400, John Martin wrote:
> > Slight hijack of this thread, but somewhat on
> topic.
> > The man page for ddi_fls() says:
> > 
> >       int ddi_fls(long mask);
> > ...
> >       mask    A 32-bit argument value to search
> through.
> > 
> > I assume the man page was written prior to LP64.
> > What is the expected behavior on LP64?
> 
> I'd expect that on LP64 its just an int rather than a
> long, but you can
> check the code yourself.  When last I looked,the code
> for this function
> was quite easy to grok.

There is only one function for ILP32 and LP64 and it uses
long for the mask, matching the man page.  The code
lifted from common/os/sunddi.c:

$ cat fls.c
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>

int
ddi_fls(long mask)
{
        while (mask) {
                long nx;

                if ((nx = (mask & (mask - 1))) == 0)
                        break;
                mask = nx;
        }
        return (ffs(mask));
}

int
main(int argc, char *argv[], char *envp[])
{
        long val = -1;

        printf("fls(%ld/0x%lx) = %d\n", val, val, ddi_fls(val));

        return (0);
}
$ cc -m32 fls.c
$ ./a.out
fls(-1/0xffffffff) = 32
$ cc -m64 fls.c
$ ./a.out
fls(-1/0xffffffffffffffff) = 0
$
-- 
This message posted from opensolaris.org
_______________________________________________
driver-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/driver-discuss

Reply via email to