27#define WIN32_NO_STATUS
33#ifdef __WINE_WINTERNL_H
63 ok(
hntdll != 0,
"LoadLibrary failed\n");
88static void test_RtlInitializeBitMap(
void)
97 pRtlInitializeBitMap(&bm,
buff, 800);
100 ok(
buff[0] == 77 &&
buff[79] == 77,
"wrote to buffer\n");
103static void test_RtlSetAllBits(
void)
109 pRtlInitializeBitMap(&bm,
buff, 1);
113 buff[3] == 0xff,
"didn't round up size\n");
114 ok(
buff[4] == 0,
"set more than rounded size\n");
117static void test_RtlClearAllBits(
void)
119 if (!pRtlClearAllBits)
123 pRtlInitializeBitMap(&bm,
buff, 1);
125 pRtlClearAllBits(&bm);
127 ok(
buff[4] == 0xff,
"cleared more than rounded size\n");
130static void test_RtlSetBits(
void)
136 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
138 pRtlSetBits(&bm, 0, 1);
139 ok(
buff[0] == 1,
"didn't set 1st bit\n");
142 pRtlSetBits(&bm, 7, 2);
143 ok(
buff[0] == 0x80 &&
buff[1] == 1,
"didn't span w/len < 8\n");
146 pRtlSetBits(&bm, 7, 10);
147 ok(
buff[0] == 0x80 &&
buff[1] == 0xff &&
buff[2] == 1,
"didn't span w/len > 8\n");
150 pRtlSetBits(&bm, 0, 8);
151 ok(
buff[0] == 0xff,
"didn't set all bits\n");
152 ok(!
buff[1],
"set too many bits\n");
154 pRtlSetBits(&bm,
sizeof(
buff)*8-1, 1);
155 ok(
buff[
sizeof(
buff)-1] == 0x80,
"didn't set last bit\n");
158static void test_RtlClearBits(
void)
164 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
166 pRtlClearBits(&bm, 0, 1);
167 ok(
buff[0] == 0xfe,
"didn't clear 1st bit\n");
170 pRtlClearBits(&bm, 7, 2);
171 ok(
buff[0] == 0x7f &&
buff[1] == 0xfe,
"didn't span w/len < 8\n");
174 pRtlClearBits(&bm, 7, 10);
175 ok(
buff[0] == 0x7f &&
buff[1] == 0 &&
buff[2] == 0xfe,
"didn't span w/len > 8\n");
178 pRtlClearBits(&bm, 0, 8);
179 ok(!
buff[0],
"didn't clear all bits\n");
180 ok(
buff[1] == 0xff,
"cleared too many bits\n");
182 pRtlClearBits(&bm,
sizeof(
buff)*8-1, 1);
183 ok(
buff[
sizeof(
buff)-1] == 0x7f,
"didn't set last bit\n");
186static void test_RtlCheckBit(
void)
191 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
192 pRtlSetBits(&bm, 0, 1);
193 pRtlSetBits(&bm, 7, 2);
194 pRtlSetBits(&bm,
sizeof(
buff)*8-1, 1);
197 ok (bRet,
"didn't find set bit\n");
199 ok (bRet,
"didn't find set bit\n");
201 ok (bRet,
"didn't find set bit\n");
203 ok (bRet,
"didn't find set bit\n");
205 ok (!bRet,
"found non set bit\n");
207 ok (!bRet,
"found non set bit\n");
210static void test_RtlAreBitsSet(
void)
218 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
220 bRet = pRtlAreBitsSet(&bm, 0, 1);
221 ok (!bRet,
"found set bits after init\n");
223 pRtlSetBits(&bm, 0, 1);
224 bRet = pRtlAreBitsSet(&bm, 0, 1);
225 ok (bRet,
"didn't find set bits\n");
228 pRtlSetBits(&bm, 7, 2);
229 bRet = pRtlAreBitsSet(&bm, 7, 2);
230 ok(bRet,
"didn't find w/len < 8\n");
231 bRet = pRtlAreBitsSet(&bm, 6, 3);
232 ok(!bRet,
"found non set bit\n");
233 bRet = pRtlAreBitsSet(&bm, 7, 3);
234 ok(!bRet,
"found non set bit\n");
237 pRtlSetBits(&bm, 7, 10);
238 bRet = pRtlAreBitsSet(&bm, 7, 10);
239 ok(bRet,
"didn't find w/len < 8\n");
240 bRet = pRtlAreBitsSet(&bm, 6, 11);
241 ok(!bRet,
"found non set bit\n");
242 bRet = pRtlAreBitsSet(&bm, 7, 11);
243 ok(!bRet,
"found non set bit\n");
246 pRtlSetBits(&bm, 0, 8);
247 bRet = pRtlAreBitsSet(&bm, 0, 8);
248 ok(bRet,
"didn't find whole byte\n");
250 pRtlSetBits(&bm,
sizeof(
buff)*8-1, 1);
251 bRet = pRtlAreBitsSet(&bm,
sizeof(
buff)*8-1, 1);
252 ok(bRet,
"didn't find last bit\n");
255static void test_RtlAreBitsClear(
void)
259 if (!pRtlAreBitsClear)
263 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
265 bRet = pRtlAreBitsClear(&bm, 0, 1);
266 ok (!bRet,
"found clear bits after init\n");
268 pRtlClearBits(&bm, 0, 1);
269 bRet = pRtlAreBitsClear(&bm, 0, 1);
270 ok (bRet,
"didn't find set bits\n");
273 pRtlClearBits(&bm, 7, 2);
274 bRet = pRtlAreBitsClear(&bm, 7, 2);
275 ok(bRet,
"didn't find w/len < 8\n");
276 bRet = pRtlAreBitsClear(&bm, 6, 3);
277 ok(!bRet,
"found non clear bit\n");
278 bRet = pRtlAreBitsClear(&bm, 7, 3);
279 ok(!bRet,
"found non clear bit\n");
282 pRtlClearBits(&bm, 7, 10);
283 bRet = pRtlAreBitsClear(&bm, 7, 10);
284 ok(bRet,
"didn't find w/len < 8\n");
285 bRet = pRtlAreBitsClear(&bm, 6, 11);
286 ok(!bRet,
"found non clear bit\n");
287 bRet = pRtlAreBitsClear(&bm, 7, 11);
288 ok(!bRet,
"found non clear bit\n");
291 pRtlClearBits(&bm, 0, 8);
292 bRet = pRtlAreBitsClear(&bm, 0, 8);
293 ok(bRet,
"didn't find whole byte\n");
295 pRtlClearBits(&bm,
sizeof(
buff)*8-1, 1);
296 bRet = pRtlAreBitsClear(&bm,
sizeof(
buff)*8-1, 1);
297 ok(bRet,
"didn't find last bit\n");
300static void test_RtlNumberOfSetBits(
void)
304 if (!pRtlNumberOfSetBits)
308 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
310 ulCount = pRtlNumberOfSetBits(&bm);
311 ok(ulCount == 0,
"set bits after init\n");
313 pRtlSetBits(&bm, 0, 1);
314 ulCount = pRtlNumberOfSetBits(&bm);
315 ok(ulCount == 1,
"count wrong\n");
317 pRtlSetBits(&bm, 7, 8);
318 ulCount = pRtlNumberOfSetBits(&bm);
319 ok(ulCount == 8+1,
"count wrong\n");
321 pRtlSetBits(&bm, 17, 33);
322 ulCount = pRtlNumberOfSetBits(&bm);
323 ok(ulCount == 8+1+33,
"count wrong\n");
325 pRtlSetBits(&bm,
sizeof(
buff)*8-1, 1);
326 ulCount = pRtlNumberOfSetBits(&bm);
327 ok(ulCount == 8+1+33+1,
"count wrong\n");
330static void test_RtlNumberOfClearBits(
void)
334 if (!pRtlNumberOfClearBits)
338 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
340 ulCount = pRtlNumberOfClearBits(&bm);
341 ok(ulCount == 0,
"cleared bits after init\n");
343 pRtlClearBits(&bm, 0, 1);
344 ulCount = pRtlNumberOfClearBits(&bm);
345 ok(ulCount == 1,
"count wrong\n");
347 pRtlClearBits(&bm, 7, 8);
348 ulCount = pRtlNumberOfClearBits(&bm);
349 ok(ulCount == 8+1,
"count wrong\n");
351 pRtlClearBits(&bm, 17, 33);
352 ulCount = pRtlNumberOfClearBits(&bm);
353 ok(ulCount == 8+1+33,
"count wrong\n");
355 pRtlClearBits(&bm,
sizeof(
buff)*8-1, 1);
356 ulCount = pRtlNumberOfClearBits(&bm);
357 ok(ulCount == 8+1+33+1,
"count wrong\n");
361static void test_RtlFindSetBitsAndClear(
void)
366 if (!pRtlFindSetBitsAndClear)
370 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
372 pRtlSetBits(&bm, 0, 32);
373 ulPos = pRtlFindSetBitsAndClear(&bm, 32, 0);
374 ok (ulPos == 0,
"didn't find bits\n");
377 bRet = pRtlAreBitsClear(&bm, 0, 32);
378 ok (bRet,
"found but didn't clear\n");
382 pRtlSetBits(&bm, 40, 77);
383 ulPos = pRtlFindSetBitsAndClear(&bm, 77, 0);
384 ok (ulPos == 40,
"didn't find bits\n");
387 bRet = pRtlAreBitsClear(&bm, 40, 77);
388 ok (bRet,
"found but didn't clear\n");
393static void test_RtlFindClearBitsAndSet(
void)
398 if (!pRtlFindClearBitsAndSet)
401 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
404 pRtlSetBits(&bm, 0, 32);
405 ulPos = pRtlFindSetBitsAndClear(&bm, 32, 0);
406 ok (ulPos == 0,
"didn't find bits\n");
409 bRet = pRtlAreBitsClear(&bm, 0, 32);
410 ok (bRet,
"found but didn't clear\n");
414 pRtlClearBits(&bm, 40, 77);
415 ulPos = pRtlFindClearBitsAndSet(&bm, 77, 50);
416 ok (ulPos == 40,
"didn't find bits\n");
419 bRet = pRtlAreBitsSet(&bm, 40, 77);
420 ok (bRet,
"found but didn't set\n");
424static void test_RtlFindMostSignificantBit(
void)
430 if (!pRtlFindMostSignificantBit)
433 for (
i = 0;
i < 64;
i++)
438 cPos = pRtlFindMostSignificantBit(ulLong);
439 ok (cPos ==
i,
"didn't find MSB 0x%s %d %d\n",
443 ulLong = ((ulLong - 1) << 1) | 1;
445 cPos = pRtlFindMostSignificantBit(ulLong);
446 ok (cPos ==
i,
"didn't find MSB 0x%s %d %d\n",
449 cPos = pRtlFindMostSignificantBit(0);
450 ok (cPos == -1,
"found bit when not set\n");
453static void test_RtlFindLeastSignificantBit(
void)
459 if (!pRtlFindLeastSignificantBit)
462 for (
i = 0;
i < 64;
i++)
466 cPos = pRtlFindLeastSignificantBit(ulLong);
467 ok (cPos ==
i,
"didn't find LSB 0x%s %d %d\n",
472 cPos = pRtlFindLeastSignificantBit(ulLong);
473 ok (cPos ==
i,
"didn't find LSB 0x%s %d %d\n",
476 cPos = pRtlFindLeastSignificantBit(0);
477 ok (cPos == -1,
"found bit when not set\n");
481static void test_RtlFindSetRuns(
void)
486 if (!pRtlFindSetRuns)
489 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
492 ulCount = pRtlFindSetRuns(&bm, runs, 16,
TRUE);
493 ok (ulCount == 0,
"found set bits in empty bitmap\n");
495 memset(runs, 0,
sizeof(runs));
497 ulCount = pRtlFindSetRuns(&bm, runs, 16,
TRUE);
498 ok (ulCount == 1,
"didn't find set bits\n");
500 ok (runs[0].NumberOfBits ==
sizeof(
buff)*8,
"bad size\n");
503 memset(runs, 0,
sizeof(runs));
505 pRtlSetBits(&bm, 7, 19);
506 pRtlSetBits(&bm, 101, 3);
507 pRtlSetBits(&bm, 1877, 33);
510 ulCount = pRtlFindSetRuns(&bm, runs, 2,
FALSE);
511 ok(ulCount == 2,
"RtlFindClearRuns returned %ld, expected 2\n", ulCount);
514 ok (runs[0].NumberOfBits + runs[1].NumberOfBits == 19 + 3,
"bad size\n");
519 memset(runs, 0,
sizeof(runs));
520 ulCount = pRtlFindSetRuns(&bm, runs, 2,
TRUE);
521 ok(ulCount == 2,
"RtlFindClearRuns returned %ld, expected 2\n", ulCount);
524 ok (runs[0].NumberOfBits + runs[1].NumberOfBits == 33 + 19,
"bad size\n");
529 memset(runs, 0,
sizeof(runs));
530 ulCount = pRtlFindSetRuns(&bm, runs, 3,
TRUE);
531 ok(ulCount == 3,
"RtlFindClearRuns returned %ld, expected 3\n", ulCount);
538 ok (runs[0].NumberOfBits + runs[1].NumberOfBits
539 + runs[2].NumberOfBits == 19 + 3 + 33,
"bad size\n");
544 if (pRtlFindLongestRunSet)
548 ulCount = pRtlFindLongestRunSet(&bm, &ulStart);
549 ok(ulCount == 33 && ulStart == 1877,
"didn't find longest %ld %ld\n",ulCount,ulStart);
552 ulCount = pRtlFindLongestRunSet(&bm, &ulStart);
553 ok(ulCount == 0,
"found longest when none set\n");
558static void test_RtlFindClearRuns(
void)
563 if (!pRtlFindClearRuns)
566 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
569 ulCount = pRtlFindClearRuns(&bm, runs, 16,
TRUE);
570 ok (ulCount == 0,
"found clear bits in full bitmap\n");
572 memset(runs, 0,
sizeof(runs));
574 ulCount = pRtlFindClearRuns(&bm, runs, 16,
TRUE);
575 ok (ulCount == 1,
"didn't find clear bits\n");
577 ok (runs[0].NumberOfBits ==
sizeof(
buff)*8,
"bad size\n");
580 memset(runs, 0,
sizeof(runs));
582 pRtlClearBits(&bm, 7, 19);
583 pRtlClearBits(&bm, 101, 3);
584 pRtlClearBits(&bm, 1877, 33);
587 ulCount = pRtlFindClearRuns(&bm, runs, 2,
FALSE);
588 ok(ulCount == 2,
"RtlFindClearRuns returned %ld, expected 2\n", ulCount);
591 ok (runs[0].NumberOfBits + runs[1].NumberOfBits == 19 + 3,
"bad size\n");
596 memset(runs, 0,
sizeof(runs));
597 ulCount = pRtlFindClearRuns(&bm, runs, 2,
TRUE);
598 ok(ulCount == 2,
"RtlFindClearRuns returned %ld, expected 2\n", ulCount);
601 ok (runs[0].NumberOfBits + runs[1].NumberOfBits == 33 + 19,
"bad size\n");
606 memset(runs, 0,
sizeof(runs));
607 ulCount = pRtlFindClearRuns(&bm, runs, 3,
TRUE);
608 ok(ulCount == 3,
"RtlFindClearRuns returned %ld, expected 3\n", ulCount);
615 ok (runs[0].NumberOfBits + runs[1].NumberOfBits
616 + runs[2].NumberOfBits == 19 + 3 + 33,
"bad size\n");
621 if (pRtlFindLongestRunClear)
625 ulCount = pRtlFindLongestRunClear(&bm, &ulStart);
626 ok(ulCount == 33 && ulStart == 1877,
"didn't find longest\n");
629 ulCount = pRtlFindLongestRunClear(&bm, &ulStart);
630 ok(ulCount == 0,
"found longest when none clear\n");
635static void test_RtlFindNextForwardRunSet(
void)
637 BYTE mask[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff };
639 ULONG ulCount, lpPos;
640 if (!pRtlFindNextForwardRunSet)
643 pRtlInitializeBitMap(&bm,
mask, 62);
644 ulCount = pRtlFindNextForwardRunSet(&bm, ulStart, &lpPos);
645 ok(ulCount == 6,
"Invalid length of found set run: %ld, expected 6\n", ulCount);
646 ok(lpPos == 56,
"Invalid position of found set run: %ld, expected 56\n", lpPos);
649static void test_RtlFindNextForwardRunClear(
void)
651 BYTE mask[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 };
653 ULONG ulCount, lpPos;
654 if (!pRtlFindNextForwardRunClear)
657 pRtlInitializeBitMap(&bm,
mask, 62);
658 ulCount = pRtlFindNextForwardRunClear(&bm, ulStart, &lpPos);
659 ok(ulCount == 6,
"Invalid length of found clear run: %ld, expected 6\n", ulCount);
660 ok(lpPos == 56,
"Invalid position of found clear run: %ld, expected 56\n", lpPos);
667#ifdef __WINE_WINTERNL_H
670 if (pRtlInitializeBitMap)
672 test_RtlInitializeBitMap();
673 test_RtlSetAllBits();
674 test_RtlClearAllBits();
678 test_RtlAreBitsSet();
679 test_RtlAreBitsClear();
680 test_RtlNumberOfSetBits();
681 test_RtlNumberOfClearBits();
682 test_RtlFindSetBitsAndClear();
683 test_RtlFindClearBitsAndSet();
684 test_RtlFindMostSignificantBit();
685 test_RtlFindLeastSignificantBit();
686 test_RtlFindSetRuns();
687 test_RtlFindClearRuns();
688 test_RtlFindNextForwardRunSet();
689 test_RtlFindNextForwardRunClear();
#define GetProcAddress(x, y)
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
static unsigned char buff[32768]
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static void InitFunctionPtrs(void)
struct _RTL_BITMAP_RUN * PRTL_BITMAP_RUN