include the right files
[reactos.git] / reactos / ntoskrnl / rtl / bit.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: bit.c,v 1.2 2004/08/07 19:13:27 ion Exp $
20 *
21 * PROJECT: ReactOS kernel
22 * PURPOSE: Runtime code
23 * FILE: ntoskrnl/rtl/bit.c
24 * PROGRAMER: Eric Kohl
25 */
26
27 /* INCLUDES *****************************************************************/
28
29 #include <ddk/ntddk.h>
30
31
32 /* FUNCTIONS ****************************************************************/
33
34 /*
35 * @implemented
36 */
37 CCHAR STDCALL
38 RtlFindLeastSignificantBit (IN ULONGLONG Set)
39 {
40 int i;
41
42 if (Set == 0ULL)
43 return -1;
44
45 for (i = 0; i < 64; i++)
46 {
47 if (Set & (1 << i))
48 return (CCHAR)i;
49 }
50
51 return -1;
52 }
53
54 /*
55 * @implemented
56 */
57 CCHAR STDCALL
58 RtlFindMostSignificantBit (IN ULONGLONG Set)
59 {
60 int i;
61
62 if (Set == 0ULL)
63 return -1;
64
65 for (i = 63; i >= 0; i--)
66 {
67 if (Set & (1 << i))
68 return (CCHAR)i;
69 }
70
71 return -1;
72 }
73
74 /* EOF */