问题
int fd = open("/dev/mem", O_RDWR);
present = (unsigned char *)mmap(0,
getpagesize(),
PROT_READ|PROT_WRITE,
MAP_SHARED,
fd,
0x22400000);
if ((*present & 1) == 0)
{
printf("Converter not present\n");
exit(1);
}
1) What does '&' operator mean in the preceding code?
回答1:
It is the bitwise and operator. This means that the result of the operation is to perform binary and
of the two operands but bit-by-bit (in a bitwise fashion i.e).
In this case it is checking that the first bit of the memory pointed to by present is 0.
来源:https://stackoverflow.com/questions/14928972/what-does-stands-for-in-c-and-mmap