shlwapi: DISPPARAMS on Invoke are never NULL.
[wine.git] / libs / port / ffs.c
blob76330559b5a7b0524e75a22f9c124214da400e2b
1 /*
2 * ffs function
4 * Copyright 2004 Hans Leidekker
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #ifndef HAVE_FFS
25 int ffs( int x )
27 unsigned int y = (unsigned int)x;
29 if (y & 0x00000001) return 1;
30 if (y & 0x00000002) return 2;
31 if (y & 0x00000004) return 3;
32 if (y & 0x00000008) return 4;
33 if (y & 0x00000010) return 5;
34 if (y & 0x00000020) return 6;
35 if (y & 0x00000040) return 7;
36 if (y & 0x00000080) return 8;
37 if (y & 0x00000100) return 9;
38 if (y & 0x00000200) return 10;
39 if (y & 0x00000400) return 11;
40 if (y & 0x00000800) return 12;
41 if (y & 0x00001000) return 13;
42 if (y & 0x00002000) return 14;
43 if (y & 0x00004000) return 15;
44 if (y & 0x00008000) return 16;
45 if (y & 0x00010000) return 17;
46 if (y & 0x00020000) return 18;
47 if (y & 0x00040000) return 19;
48 if (y & 0x00080000) return 20;
49 if (y & 0x00100000) return 21;
50 if (y & 0x00200000) return 22;
51 if (y & 0x00400000) return 23;
52 if (y & 0x00800000) return 24;
53 if (y & 0x01000000) return 25;
54 if (y & 0x02000000) return 26;
55 if (y & 0x04000000) return 27;
56 if (y & 0x08000000) return 28;
57 if (y & 0x10000000) return 29;
58 if (y & 0x20000000) return 30;
59 if (y & 0x40000000) return 31;
60 if (y & 0x80000000) return 32;
62 return 0;
64 #endif /* HAVE_FFS */