https://github.com/janycode/myGitCode/blob/master/my_mark_program/bit_test.c
/*
* 使用bit位作为掩码来实现计数累加,和对计数累加的判断,限制计数是limit=100
*/
#include <stdio.h>
#include <stdlib.h>
#define MASK_BIT(val, bit) ((val)[((bit) / 32)] & (1 << ((bit) % 32)))
typedef struct {
unsigned int id_mask[4];
} data_t;
static data_t g_data_t = {0};
static long test_value = 0;
void func_bit (int *p_id, int limit) {
int cnt = 1;
printf ("while: cnt = %d ", cnt);
while (MASK_BIT(g_data_t.id_mask, cnt)) {
cnt++;
if (cnt >= limit) {
break;
}
printf ("%d ", cnt);
}
printf ("\n\n");
g_data_t.id_mask[