| 289 | } |
| 290 | |
| 291 | static int |
| 292 | test_fls(void) |
| 293 | { |
| 294 | struct fls_test_vector { |
| 295 | uint32_t arg; |
| 296 | int rc; |
| 297 | }; |
| 298 | int expected, rc; |
| 299 | uint32_t i, arg; |
| 300 | |
| 301 | const struct fls_test_vector test[] = { |
| 302 | {0x0, 0}, |
| 303 | {0x1, 1}, |
| 304 | {0x4000, 15}, |
| 305 | {0x80000000, 32}, |
| 306 | }; |
| 307 | |
| 308 | for (i = 0; i < RTE_DIM(test); i++) { |
| 309 | uint64_t arg64; |
| 310 | |
| 311 | arg = test[i].arg; |
| 312 | rc = rte_fls_u32(arg); |
| 313 | expected = test[i].rc; |
| 314 | if (rc != expected) { |
| 315 | printf("Wrong rte_fls_u32(0x%x) rc=%d, expected=%d\n", |
| 316 | arg, rc, expected); |
| 317 | return TEST_FAILED; |
| 318 | } |
| 319 | /* 64-bit version */ |
| 320 | arg = test[i].arg; |
| 321 | rc = rte_fls_u64(arg); |
| 322 | expected = test[i].rc; |
| 323 | if (rc != expected) { |
| 324 | printf("Wrong rte_fls_u64(0x%x) rc=%d, expected=%d\n", |
| 325 | arg, rc, expected); |
| 326 | return TEST_FAILED; |
| 327 | } |
| 328 | /* 64-bit version shifted by 32 bits */ |
| 329 | arg64 = (uint64_t)test[i].arg << 32; |
| 330 | rc = rte_fls_u64(arg64); |
| 331 | /* don't shift zero */ |
| 332 | expected = test[i].rc == 0 ? 0 : test[i].rc + 32; |
| 333 | if (rc != expected) { |
| 334 | printf("Wrong rte_fls_u64(0x%" PRIx64 ") rc=%d, expected=%d\n", |
| 335 | arg64, rc, expected); |
| 336 | return TEST_FAILED; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | return 0; |
| 341 | } |
| 342 | |
| 343 | static int |
| 344 | test_common(void) |
no test coverage detected