嵌入式linux 共享内存,【ARM&Linux】共享内存的使用

/****************************************************************************************

* 文件名: mytype.h

* 创建者: Kun

* 时 间: 2018/0/12

* 联 系: 153471503@qq.com

* 简 介: linux常用类型定义

*****************************************************************************************/

#ifndef _MYTYPE_H_

#define _MYTYPE_H_

//--------------------------< 预添加头文件包含 >----------------------//

#define USE_TIME 0

#define USE_SIGNAL 0

#define USE_SHARE_MEMORY 1

#define USE_SEMAPHORE 0

#define USE_FILE_CTL 0

//-------------------------------< end ----------------------------//

//---------------------------< includes >---------------------------//

// c标准库头文件

#include

#include

#include

// 信号使用相关头文件

#if USE_SIGNAL

#include

#endif // USE_SIGNAL

// 信号量操作相关头文件

#if USE_SEMAPHORE

#include

#include

#endif // USE_SEMAPHORE

// 共享内存操作相关头文件

#if USE_SHARE_MEMORY

#include

#endif // USE_SHARE_MEMORY

// 系统调用式文件编程头文件

#include

// 该文件所定义的接口通常都是大量针对系统调用的封装,

// 如 fork、pipe 以及各种 I/O 原语(read、write、close 等等)。

#include

// linux系统中类型定义相关头文件

#include

// 文件状态,是unix/linux系统定义文件状态所在的伪标准头文件。

#if USE_FILE_CTL

#include

#endif // USE_FILE_CTL

#if USE_TIME

// 时间编程相关头文件

#include

#endif // USE_TIME

//-------------------------< includes end >-------------------------//

// bool类型定义

#ifndef bool

typedef unsigned int bool;

#endif

enum

{

true = 1,

false = !true

};

// 常用无符号数据类型定义

typedef unsigned int uint;

typedef unsigned char uchar;

typedef unsigned short ushort;

//----------------------< 调试信息输入相关宏定义 >----------------------//

#define DEBUG_INFO(...) printf("Info: "); printf(__VA_ARGS__)

#define DEBUG_ERROR(...) printf("Error: "); printf(__VA_ARGS__)

#define DEBUG_WARNING(...) printf("Warning: "); printf(__VA_ARGS__)

#define DEBUG_PRINTF(...) printf(__VA_ARGS__)

//------------------------------------------------------------------//

// 信号量使用封装结构

#if USE_SEMAPHORE

typedef struct sem_use_st SEM_USE_ST;

struct sem_use_st

{

int semid;

key_t key;

struct sembuf sops;

};

#endif // USE_SEMAPHORE

// 共享内存使用封装结构

#if USE_SHARE_MEMORY

typedef struct shmem_use_st SHMEM_USE_ST;

struct shmem_use_st

{

int shmid;

key_t key;

};

#define BUF_SIZE 1024*1 //共享内存大小

typedef struct shmem_area SHMEM_AREA;

struct shmem_area

{

bool isnull;

char data[BUF_SIZE];

};

#endif // USE_SHARE_MEMORY

#endif // _TYPE_H_

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值