关于linux内核中的"__attribute__ ((packed))"
关于linux内核中的"__attribute__ ((packed))"
来源:
http://jimmy-lee.blog.hexun.com/8001013_d.html
__attrubte__ ((packed)) 的作用就是告诉编译器取消结构在编译过程中的优化对齐,按照实际占用字节数进行对齐。
#define __u8 unsigned char
#define __u16 unsigned short
/* __attribute__ ((packed)) 的位置约束是放于声明的尾部“;”之前 */
struct str_struct{
__u8 a;
__u8 b;
__u8 c;
__u16 d;
} __attribute__ ((packed));
/* 当用到typedef时,要特别注意__attribute__ ((packed))放置的位置,相当于:
* typedef struct str_stuct str;
* 而struct str_struct 就是上面的那个结构。
*/
typedef struct {
__u8 a;
__u8 b;
__u8 c;
__u16 d;
} __attribute__ ((packed)) str;
/* 在下面这个typedef结构中,__attribute__ ((packed))放在结构名str_temp之后,其作用是被忽略的,注意与结构str的区别。*/
typedef struct {
__u8 a;
__u8 b;
__u8 c;
__u16 d;
}str_temp __attribute__ ((packed));
typedef struct {
__u8 a;
__u8 b;
__u8 c;
__u16 d;
}str_nopacked;
int main(void)
{
printf("sizeof str = %d\n", sizeof(str));
相关文档:
so_test.h:
#include
#include
void test_a();
void test_b();
void test_c();
test_a.c:
#include "so_test.h"
void test_a()
{
printf("this is in test_a...\n");
}
test_b.c:
#include "so_test.h"
void test_b()
{
printf("this is in test_b...\n");
......
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
-->
大家知道,
MeeGo
桌面的最大特点是使用自由(
free
use
),不论你在什么地方(什么国家),也不论你想用它干什么事情。那么,
MeeGo
是不是垃圾代码呢?当然不是。 ......
1.top
top命令可实时地显示Linux系统的进程、CPU、内存、负载等的信息。它是我们了解系统整体状态最好的工具。
top命令的运行状态是一个实时的显示过程,我们可在这个界面监控系统运行情况。我们可通过几个按键来控制top命令,如按q可退出top命令状态,按s可输入信息的更新频率等。这些命令可按h帮助键查询。
2.Ps ......
作者:北南南北
来自:LinuxSir.Org
摘要:本文是关于Linux操作系统主机名(hostname)的文档,对主要配置文件/etc/hosts进行简要的说明 ;另外对基配具工具hostname也进行了举例说明; 欢迎高手斧正,谢谢;
目录
2.1 主机名配置文件 /etc/hosts解说;
2.2 主机名(hostname)和域名(Domain)的区别;
......