网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Linux内核容器怎么使用

本篇内容主要讲解“Linux内核容器怎么使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux内核容器怎么使用”吧!

创新互联专注于振兴企业网站建设,响应式网站设计,商城网站定制开发。振兴网站建设公司,为振兴等地区提供建站服务。全流程按需求定制开发,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务

文件:include/linux/kernel.h,定义如下:

/** * container_of - cast a member of a structure out to the containing structure * @ptr:    the pointer to the member. * @type:   the type of the container struct this is embedded in. * @member: the name of the member within the struct. * */#define container_of(ptr, type, member) ({          \    const typeof( ((type *)0)->member ) *__mptr = (ptr);    \    (type *)( (char *)__mptr - offsetof(type,member) );})    #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
一、功能

功能:根据结构体type中成员member的指针ptr获取容器结构体type的地址。

二、参数

1)ptr:指向结构体成员member的指针

2)type:容器结构体类型

3)member:结构体中的成员

三、说明

1)typeof:获取成员member的数据类型

2)(type *)0:定义type结构体类型的0指针

3)typeof( ((type *)0)->member ) *__mptr:即定义member类型的指针__mptr

4)offsetof(type,member):计算成员member的偏移量

5)(type *):定义结构体type指针

图解如下:

Linux内核容器怎么使用

四、示例

文件:drivers/gpu/drm/rockchip/rockchip_drm_vop.c

## 1.定义结构体vopstruct vop {    struct drm_crtc crtc;    ...};## 2.使用container_of(),通过结构体vop中成员crtc的地址x,获取vop地址#define to_vop(x) container_of(x, struct vop, crtc)## 3.初始化结构体vop指针static int vop_hdr_atomic_check(struct drm_crtc *crtc,                struct drm_crtc_state *crtc_state){    struct vop *vop = to_vop(crtc);    ...}

到此,相信大家对“Linux内核容器怎么使用”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!


分享文章:Linux内核容器怎么使用
URL分享:http://bjjierui.cn/article/jodgjh.html

其他资讯