diff --git a/reactos/hal/halx86/irql.c b/reactos/hal/halx86/irql.c index 328a8eba822..f31d1385b47 100644 --- a/reactos/hal/halx86/irql.c +++ b/reactos/hal/halx86/irql.c @@ -9,7 +9,6 @@ /* INCLUDES *****************************************************************/ #include -#include #include #include diff --git a/reactos/ntoskrnl/include/internal/bitops.h b/reactos/ntoskrnl/include/internal/bitops.h deleted file mode 100644 index 7c0123bbd3a..00000000000 --- a/reactos/ntoskrnl/include/internal/bitops.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _I386_BITOPS_H -#define _I386_BITOPS_H - -/* - * Copyright 1992, Linus Torvalds. - */ - -/* - * These have to be done with inline assembly: that way the bit-setting - * is guaranteed to be atomic. All bit operations return 0 if the bit - * was cleared before the operation and != 0 if it was not. - * - * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). - */ - -/* - * Function prototypes to keep gcc -Wall happy - */ -extern void set_bit(int nr, volatile void * addr); -extern void clear_bit(int nr, volatile void * addr); -extern void change_bit(int nr, volatile void * addr); -extern int test_and_set_bit(int nr, volatile void * addr); -extern int test_and_clear_bit(int nr, volatile void * addr); -extern int test_and_change_bit(int nr, volatile void * addr); -extern int test_bit(int nr, volatile void * addr); -extern int find_first_zero_bit(void * addr, unsigned size); -extern int find_next_zero_bit (void * addr, int size, int offset); -extern unsigned long ffz(unsigned long word); - -#endif /* _I386_BITOPS_H */ diff --git a/reactos/ntoskrnl/mm/kmap.c b/reactos/ntoskrnl/mm/kmap.c index 7431e23819a..e33aff2b4d9 100644 --- a/reactos/ntoskrnl/mm/kmap.c +++ b/reactos/ntoskrnl/mm/kmap.c @@ -1,4 +1,4 @@ -/* $Id: kmap.c,v 1.11 2001/11/25 15:21:11 dwelch Exp $ +/* $Id: kmap.c,v 1.12 2001/12/06 00:54:54 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -44,7 +43,7 @@ ExUnmapPage(PVOID Addr) KeAcquireSpinLock(&AllocMapLock, &oldIrql); MmDeleteVirtualMapping(NULL, (PVOID)Addr, FALSE, NULL, NULL); - clear_bit(i%32, &AllocMap[i/32]); + AllocMap[i / 32] &= (~(1 << (i % 32))); KeReleaseSpinLock(&AllocMapLock, oldIrql); } @@ -103,10 +102,10 @@ ExAllocatePageWithPhysPage(ULONG PhysPage) KeAcquireSpinLock(&AllocMapLock, &oldlvl); for (i = 1; i < ALLOC_MAP_SIZE; i++) { - if (!test_bit(i % 32, &AllocMap[i / 32])) + if (!(AllocMap[i / 32] & (1 << (i % 32)))) { DPRINT("i %x\n",i); - set_bit(i % 32, &AllocMap[i / 32]); + AllocMap[i / 32] |= (1 << (i % 32)); addr = (ULONG)(NonPagedPoolBase + (i*PAGESIZE)); Status = MmCreateVirtualMapping(NULL, (PVOID)addr, @@ -137,10 +136,12 @@ MiFreeNonPagedPoolRegion(PVOID Addr, ULONG Count, BOOLEAN Free) { ULONG i; ULONG Base = (Addr - NonPagedPoolBase) / PAGESIZE; + ULONG Offset; for (i = 0; i < Count; i++) { - clear_bit((Base + i) % 32, &AllocMap[(Base + i) / 32]); + Offset = Base + i; + AllocMap[Offset / 32] &= (~(1 << (Offset % 32))); MmDeleteVirtualMapping(NULL, Addr + (i * PAGESIZE), Free, @@ -161,7 +162,7 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages) for (i=1; i #include #include -#include #include #include diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index 29a6c2504d4..51fa252847a 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -1,4 +1,4 @@ -/* $Id: mminit.c,v 1.26 2001/11/25 15:21:11 dwelch Exp $ +/* $Id: mminit.c,v 1.27 2001/12/06 00:54:54 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/reactos/ntoskrnl/mm/npool.c b/reactos/ntoskrnl/mm/npool.c index 20a78e5e069..d91d009a8be 100644 --- a/reactos/ntoskrnl/mm/npool.c +++ b/reactos/ntoskrnl/mm/npool.c @@ -1,4 +1,4 @@ -/* $Id: npool.c,v 1.49 2001/11/25 15:21:11 dwelch Exp $ +/* $Id: npool.c,v 1.50 2001/12/06 00:54:54 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index 40e8df185b8..886fec7ea3b 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: pagefile.c,v 1.12 2001/10/10 21:57:00 hbirr Exp $ +/* $Id: pagefile.c,v 1.13 2001/12/06 00:54:54 dwelch Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/mm/pagefile.c @@ -29,7 +29,6 @@ /* INCLUDES *****************************************************************/ #include -#include #include #include #include @@ -204,20 +203,28 @@ static ULONG MiAllocPageFromPagingFile(PPAGINGFILE PagingFile) { KIRQL oldIrql; - ULONG i; - ULONG off; + ULONG i, j; KeAcquireSpinLock(&PagingFile->AllocMapLock, &oldIrql); for (i = 0; i < PagingFile->AllocMapSize; i++) { - off = find_first_zero_bit(PagingFile->AllocMap, - PagingFile->AllocMapSize * 32); - clear_bit(off % 32, &PagingFile->AllocMap[off / 32]); - PagingFile->UsedPages--; - PagingFile->FreePages++; - KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql); - return(off); + for (j = 0; j < 32; j++) + { + if (!(PagingFile->AllocMap[i] & (1 << j))) + { + break; + } + } + if (j == 32) + { + continue; + } + PagingFile->AllocMap[i] |= (1 << j); + PagingFile->UsedPages--; + PagingFile->FreePages++; + KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql); + return((i * 32) + j); } KeReleaseSpinLock(&PagingFile->AllocMapLock, oldIrql); @@ -237,7 +244,7 @@ MmFreeSwapPage(SWAPENTRY Entry) KeAcquireSpinLock(&PagingFileListLock, &oldIrql); KeAcquireSpinLockAtDpcLevel(&PagingFileList[i]->AllocMapLock); - set_bit(off % 32, &PagingFileList[i]->AllocMap[off / 32]); + PagingFileList[i]->AllocMap[off / 32] |= (1 << (off % 32)); PagingFileList[i]->FreePages++; PagingFileList[i]->UsedPages--;