26#ifdef __WINE_WINTERNL_H
54 ok(
hntdll != 0,
"LoadLibrary failed\n");
77static void test_RtlInitializeBitMap(
void)
86 pRtlInitializeBitMap(&bm,
buff, 800);
89 ok(
buff[0] == 77 &&
buff[79] == 77,
"wrote to buffer\n");
92static void test_RtlSetAllBits(
void)
98 pRtlInitializeBitMap(&bm,
buff, 1);
102 buff[3] == 0xff,
"didn't round up size\n");
103 ok(
buff[4] == 0,
"set more than rounded size\n");
106static void test_RtlClearAllBits(
void)
108 if (!pRtlClearAllBits)
112 pRtlInitializeBitMap(&bm,
buff, 1);
114 pRtlClearAllBits(&bm);
116 ok(
buff[4] == 0xff,
"cleared more than rounded size\n");
119static void test_RtlSetBits(
void)
125 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
127 pRtlSetBits(&bm, 0, 1);
128 ok(
buff[0] == 1,
"didn't set 1st bit\n");
131 pRtlSetBits(&bm, 7, 2);
132 ok(
buff[0] == 0x80 &&
buff[1] == 1,
"didn't span w/len < 8\n");
135 pRtlSetBits(&bm, 7, 10);
136 ok(
buff[0] == 0x80 &&
buff[1] == 0xff &&
buff[2] == 1,
"didn't span w/len > 8\n");
139 pRtlSetBits(&bm, 0, 8);
140 ok(
buff[0] == 0xff,
"didn't set all bits\n");
141 ok(!
buff[1],
"set too many bits\n");
143 pRtlSetBits(&bm,
sizeof(
buff)*8-1, 1);
144 ok(
buff[
sizeof(
buff)-1] == 0x80,
"didn't set last bit\n");
147static void test_RtlClearBits(
void)
153 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
155 pRtlClearBits(&bm, 0, 1);
156 ok(
buff[0] == 0xfe,
"didn't clear 1st bit\n");
159 pRtlClearBits(&bm, 7, 2);
160 ok(
buff[0] == 0x7f &&
buff[1] == 0xfe,
"didn't span w/len < 8\n");
163 pRtlClearBits(&bm, 7, 10);
164 ok(
buff[0] == 0x7f &&
buff[1] == 0 &&
buff[2] == 0xfe,
"didn't span w/len > 8\n");
167 pRtlClearBits(&bm, 0, 8);
168 ok(!
buff[0],
"didn't clear all bits\n");
169 ok(
buff[1] == 0xff,
"cleared too many bits\n");
171 pRtlClearBits(&bm,
sizeof(
buff)*8-1, 1);
172 ok(
buff[
sizeof(
buff)-1] == 0x7f,
"didn't set last bit\n");
175static void test_RtlCheckBit(
void)
180 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
181 pRtlSetBits(&bm, 0, 1);
182 pRtlSetBits(&bm, 7, 2);
183 pRtlSetBits(&bm,
sizeof(
buff)*8-1, 1);
186 ok (bRet,
"didn't find set bit\n");
188 ok (bRet,
"didn't find set bit\n");
190 ok (bRet,
"didn't find set bit\n");
192 ok (bRet,
"didn't find set bit\n");
194 ok (!bRet,
"found non set bit\n");
196 ok (!bRet,
"found non set bit\n");
199static void test_RtlAreBitsSet(
void)
207 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
209 bRet = pRtlAreBitsSet(&bm, 0, 1);
210 ok (!bRet,
"found set bits after init\n");
212 pRtlSetBits(&bm, 0, 1);
213 bRet = pRtlAreBitsSet(&bm, 0, 1);
214 ok (bRet,
"didn't find set bits\n");
217 pRtlSetBits(&bm, 7, 2);
218 bRet = pRtlAreBitsSet(&bm, 7, 2);
219 ok(bRet,
"didn't find w/len < 8\n");
220 bRet = pRtlAreBitsSet(&bm, 6, 3);
221 ok(!bRet,
"found non set bit\n");
222 bRet = pRtlAreBitsSet(&bm, 7, 3);
223 ok(!bRet,
"found non set bit\n");
226 pRtlSetBits(&bm, 7, 10);
227 bRet = pRtlAreBitsSet(&bm, 7, 10);
228 ok(bRet,
"didn't find w/len < 8\n");
229 bRet = pRtlAreBitsSet(&bm, 6, 11);
230 ok(!bRet,
"found non set bit\n");
231 bRet = pRtlAreBitsSet(&bm, 7, 11);
232 ok(!bRet,
"found non set bit\n");
235 pRtlSetBits(&bm, 0, 8);
236 bRet = pRtlAreBitsSet(&bm, 0, 8);
237 ok(bRet,
"didn't find whole byte\n");
239 pRtlSetBits(&bm,
sizeof(
buff)*8-1, 1);
240 bRet = pRtlAreBitsSet(&bm,
sizeof(
buff)*8-1, 1);
241 ok(bRet,
"didn't find last bit\n");
244static void test_RtlAreBitsClear(
void)
248 if (!pRtlAreBitsClear)
252 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
254 bRet = pRtlAreBitsClear(&bm, 0, 1);
255 ok (!bRet,
"found clear bits after init\n");
257 pRtlClearBits(&bm, 0, 1);
258 bRet = pRtlAreBitsClear(&bm, 0, 1);
259 ok (bRet,
"didn't find set bits\n");
262 pRtlClearBits(&bm, 7, 2);
263 bRet = pRtlAreBitsClear(&bm, 7, 2);
264 ok(bRet,
"didn't find w/len < 8\n");
265 bRet = pRtlAreBitsClear(&bm, 6, 3);
266 ok(!bRet,
"found non clear bit\n");
267 bRet = pRtlAreBitsClear(&bm, 7, 3);
268 ok(!bRet,
"found non clear bit\n");
271 pRtlClearBits(&bm, 7, 10);
272 bRet = pRtlAreBitsClear(&bm, 7, 10);
273 ok(bRet,
"didn't find w/len < 8\n");
274 bRet = pRtlAreBitsClear(&bm, 6, 11);
275 ok(!bRet,
"found non clear bit\n");
276 bRet = pRtlAreBitsClear(&bm, 7, 11);
277 ok(!bRet,
"found non clear bit\n");
280 pRtlClearBits(&bm, 0, 8);
281 bRet = pRtlAreBitsClear(&bm, 0, 8);
282 ok(bRet,
"didn't find whole byte\n");
284 pRtlClearBits(&bm,
sizeof(
buff)*8-1, 1);
285 bRet = pRtlAreBitsClear(&bm,
sizeof(
buff)*8-1, 1);
286 ok(bRet,
"didn't find last bit\n");
289static void test_RtlNumberOfSetBits(
void)
293 if (!pRtlNumberOfSetBits)
297 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
299 ulCount = pRtlNumberOfSetBits(&bm);
300 ok(ulCount == 0,
"set bits after init\n");
302 pRtlSetBits(&bm, 0, 1);
303 ulCount = pRtlNumberOfSetBits(&bm);
304 ok(ulCount == 1,
"count wrong\n");
306 pRtlSetBits(&bm, 7, 8);
307 ulCount = pRtlNumberOfSetBits(&bm);
308 ok(ulCount == 8+1,
"count wrong\n");
310 pRtlSetBits(&bm, 17, 33);
311 ulCount = pRtlNumberOfSetBits(&bm);
312 ok(ulCount == 8+1+33,
"count wrong\n");
314 pRtlSetBits(&bm,
sizeof(
buff)*8-1, 1);
315 ulCount = pRtlNumberOfSetBits(&bm);
316 ok(ulCount == 8+1+33+1,
"count wrong\n");
319static void test_RtlNumberOfClearBits(
void)
323 if (!pRtlNumberOfClearBits)
327 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
329 ulCount = pRtlNumberOfClearBits(&bm);
330 ok(ulCount == 0,
"cleared bits after init\n");
332 pRtlClearBits(&bm, 0, 1);
333 ulCount = pRtlNumberOfClearBits(&bm);
334 ok(ulCount == 1,
"count wrong\n");
336 pRtlClearBits(&bm, 7, 8);
337 ulCount = pRtlNumberOfClearBits(&bm);
338 ok(ulCount == 8+1,
"count wrong\n");
340 pRtlClearBits(&bm, 17, 33);
341 ulCount = pRtlNumberOfClearBits(&bm);
342 ok(ulCount == 8+1+33,
"count wrong\n");
344 pRtlClearBits(&bm,
sizeof(
buff)*8-1, 1);
345 ulCount = pRtlNumberOfClearBits(&bm);
346 ok(ulCount == 8+1+33+1,
"count wrong\n");
350static void test_RtlFindSetBitsAndClear(
void)
355 if (!pRtlFindSetBitsAndClear)
359 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
361 pRtlSetBits(&bm, 0, 32);
362 ulPos = pRtlFindSetBitsAndClear(&bm, 32, 0);
363 ok (ulPos == 0,
"didn't find bits\n");
366 bRet = pRtlAreBitsClear(&bm, 0, 32);
367 ok (bRet,
"found but didn't clear\n");
371 pRtlSetBits(&bm, 40, 77);
372 ulPos = pRtlFindSetBitsAndClear(&bm, 77, 0);
373 ok (ulPos == 40,
"didn't find bits\n");
376 bRet = pRtlAreBitsClear(&bm, 40, 77);
377 ok (bRet,
"found but didn't clear\n");
382static void test_RtlFindClearBitsAndSet(
void)
387 if (!pRtlFindClearBitsAndSet)
390 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
393 pRtlSetBits(&bm, 0, 32);
394 ulPos = pRtlFindSetBitsAndClear(&bm, 32, 0);
395 ok (ulPos == 0,
"didn't find bits\n");
398 bRet = pRtlAreBitsClear(&bm, 0, 32);
399 ok (bRet,
"found but didn't clear\n");
403 pRtlClearBits(&bm, 40, 77);
404 ulPos = pRtlFindClearBitsAndSet(&bm, 77, 50);
405 ok (ulPos == 40,
"didn't find bits\n");
408 bRet = pRtlAreBitsSet(&bm, 40, 77);
409 ok (bRet,
"found but didn't set\n");
413static void test_RtlFindMostSignificantBit(
void)
419 if (!pRtlFindMostSignificantBit)
422 for (
i = 0;
i < 64;
i++)
427 cPos = pRtlFindMostSignificantBit(ulLong);
428 ok (cPos ==
i,
"didn't find MSB 0x%s %d %d\n",
432 ulLong = ((ulLong - 1) << 1) | 1;
434 cPos = pRtlFindMostSignificantBit(ulLong);
435 ok (cPos ==
i,
"didn't find MSB 0x%s %d %d\n",
438 cPos = pRtlFindMostSignificantBit(0);
439 ok (cPos == -1,
"found bit when not set\n");
442static void test_RtlFindLeastSignificantBit(
void)
448 if (!pRtlFindLeastSignificantBit)
451 for (
i = 0;
i < 64;
i++)
455 cPos = pRtlFindLeastSignificantBit(ulLong);
456 ok (cPos ==
i,
"didn't find LSB 0x%s %d %d\n",
461 cPos = pRtlFindLeastSignificantBit(ulLong);
462 ok (cPos ==
i,
"didn't find LSB 0x%s %d %d\n",
465 cPos = pRtlFindLeastSignificantBit(0);
466 ok (cPos == -1,
"found bit when not set\n");
470static void test_RtlFindSetRuns(
void)
475 if (!pRtlFindSetRuns)
478 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
481 ulCount = pRtlFindSetRuns(&bm, runs, 16,
TRUE);
482 ok (ulCount == 0,
"found set bits in empty bitmap\n");
484 memset(runs, 0,
sizeof(runs));
486 ulCount = pRtlFindSetRuns(&bm, runs, 16,
TRUE);
487 ok (ulCount == 1,
"didn't find set bits\n");
489 ok (runs[0].NumberOfBits ==
sizeof(
buff)*8,
"bad size\n");
492 memset(runs, 0,
sizeof(runs));
494 pRtlSetBits(&bm, 7, 19);
495 pRtlSetBits(&bm, 101, 3);
496 pRtlSetBits(&bm, 1877, 33);
499 ulCount = pRtlFindSetRuns(&bm, runs, 2,
FALSE);
500 ok(ulCount == 2,
"RtlFindClearRuns returned %d, expected 2\n", ulCount);
503 ok (runs[0].NumberOfBits + runs[1].NumberOfBits == 19 + 3,
"bad size\n");
508 memset(runs, 0,
sizeof(runs));
509 ulCount = pRtlFindSetRuns(&bm, runs, 2,
TRUE);
510 ok(ulCount == 2,
"RtlFindClearRuns returned %d, expected 2\n", ulCount);
513 ok (runs[0].NumberOfBits + runs[1].NumberOfBits == 33 + 19,
"bad size\n");
518 memset(runs, 0,
sizeof(runs));
519 ulCount = pRtlFindSetRuns(&bm, runs, 3,
TRUE);
520 ok(ulCount == 3,
"RtlFindClearRuns returned %d, expected 3\n", ulCount);
527 ok (runs[0].NumberOfBits + runs[1].NumberOfBits
528 + runs[2].NumberOfBits == 19 + 3 + 33,
"bad size\n");
533 if (pRtlFindLongestRunSet)
537 ulCount = pRtlFindLongestRunSet(&bm, &ulStart);
538 ok(ulCount == 33 && ulStart == 1877,
"didn't find longest %d %d\n",ulCount,ulStart);
541 ulCount = pRtlFindLongestRunSet(&bm, &ulStart);
542 ok(ulCount == 0,
"found longest when none set\n");
547static void test_RtlFindClearRuns(
void)
552 if (!pRtlFindClearRuns)
555 pRtlInitializeBitMap(&bm,
buff,
sizeof(
buff)*8);
558 ulCount = pRtlFindClearRuns(&bm, runs, 16,
TRUE);
559 ok (ulCount == 0,
"found clear bits in full bitmap\n");
561 memset(runs, 0,
sizeof(runs));
563 ulCount = pRtlFindClearRuns(&bm, runs, 16,
TRUE);
564 ok (ulCount == 1,
"didn't find clear bits\n");
566 ok (runs[0].NumberOfBits ==
sizeof(
buff)*8,
"bad size\n");
569 memset(runs, 0,
sizeof(runs));
571 pRtlClearBits(&bm, 7, 19);
572 pRtlClearBits(&bm, 101, 3);
573 pRtlClearBits(&bm, 1877, 33);
576 ulCount = pRtlFindClearRuns(&bm, runs, 2,
FALSE);
577 ok(ulCount == 2,
"RtlFindClearRuns returned %d, expected 2\n", ulCount);
580 ok (runs[0].NumberOfBits + runs[1].NumberOfBits == 19 + 3,
"bad size\n");
585 memset(runs, 0,
sizeof(runs));
586 ulCount = pRtlFindClearRuns(&bm, runs, 2,
TRUE);
587 ok(ulCount == 2,
"RtlFindClearRuns returned %d, expected 2\n", ulCount);
590 ok (runs[0].NumberOfBits + runs[1].NumberOfBits == 33 + 19,
"bad size\n");
595 memset(runs, 0,
sizeof(runs));
596 ulCount = pRtlFindClearRuns(&bm, runs, 3,
TRUE);
597 ok(ulCount == 3,
"RtlFindClearRuns returned %d, expected 3\n", ulCount);
604 ok (runs[0].NumberOfBits + runs[1].NumberOfBits
605 + runs[2].NumberOfBits == 19 + 3 + 33,
"bad size\n");
610 if (pRtlFindLongestRunClear)
614 ulCount = pRtlFindLongestRunClear(&bm, &ulStart);
615 ok(ulCount == 33 && ulStart == 1877,
"didn't find longest\n");
618 ulCount = pRtlFindLongestRunClear(&bm, &ulStart);
619 ok(ulCount == 0,
"found longest when none clear\n");
627#ifdef __WINE_WINTERNL_H
630 if (pRtlInitializeBitMap)
632 test_RtlInitializeBitMap();
633 test_RtlSetAllBits();
634 test_RtlClearAllBits();
638 test_RtlAreBitsSet();
639 test_RtlAreBitsClear();
640 test_RtlNumberOfSetBits();
641 test_RtlNumberOfClearBits();
642 test_RtlFindSetBitsAndClear();
643 test_RtlFindClearBitsAndSet();
644 test_RtlFindMostSignificantBit();
645 test_RtlFindLeastSignificantBit();
646 test_RtlFindSetRuns();
647 test_RtlFindClearRuns();
#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