Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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
");
  exit(1);
}

1) What does '&' operator mean in the preceding code?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...