What is meaning of the '_attribute_((aligned(4)));' in the first line?

后端 未结 3 1038
不思量自难忘°
不思量自难忘° 2021-01-25 05:03
char buf[BUF_LEN]_attribute_((aligned(4)));
ssize_t len, i = 0;
/* read BUF_LEN bytes\' worth of events */
len = read (fd, buf, BUF_LEN);
/* loop over every read event u         


        
3条回答
  •  梦谈多话
    2021-01-25 05:31

    This aligns the memory allocated to buf on a 4-byte boundary. This can speed memory transfers between the CPU and main memory among other things.

提交回复
热议问题