57 #include <sys/types.h> 65 #if !defined(_MSC_VER) 77 for (num=0;num<size;num++)
80 printf(
"%.2x\n",((
unsigned char*)ptr)[num]);
82 printf(
"%.2x ",((
unsigned char*)ptr)[num]);
89 static struct sembuf semaphor;
91 semaphor.sem_op = operation;
92 semaphor.sem_flg = SEM_UNDO;
94 if(semop(
id, &semaphor,1) == -1) {
95 dlt_log(LOG_WARNING,
"SHM: semop() failed");
100 struct shmid_ds shm_buf;
108 if ((buf->
shmid = shmget(key, size, IPC_CREAT | 0666)) < 0) {
109 dlt_log(LOG_WARNING,
"SHM: shmget() failed");
114 if (shmctl(buf->
shmid, IPC_STAT, &shm_buf))
116 dlt_log(LOG_WARNING,
"SHM: shmctl() failed");
121 if ((ptr = shmat(buf->
shmid,
NULL, 0)) == (
unsigned char *) -1) {
122 dlt_log(LOG_WARNING,
"SHM: shmat() failed");
127 if( (buf->
semid = semget(
DLT_SHM_SEM,1,S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT|IPC_EXCL)) == -1 ) {
128 if( (buf->
semid = semget(
DLT_SHM_SEM,1,S_IRWXU|S_IRWXG|S_IRWXO|IPC_EXCL)) == -1 ) {
129 dlt_log(LOG_WARNING,
"SHM: semget() failed");
133 if( semctl(buf->
semid,0,SETVAL,(
int)1) == -1 ) {
134 dlt_log(LOG_WARNING,
"SHM: semctl() failed");
145 struct shmid_ds shm_buf;
153 if ((buf->
shmid = shmget(key, 0, 0666)) < 0) {
154 dlt_log(LOG_WARNING,
"SHM: shmget() failed");
159 if (shmctl(buf->
shmid, IPC_STAT, &shm_buf))
161 dlt_log(LOG_WARNING,
"SHM: shmctl() failed");
166 if ((ptr = shmat(buf->
shmid,
NULL, 0)) == (
unsigned char *) -1) {
167 dlt_log(LOG_WARNING,
"shmat() failed");
173 dlt_log(LOG_WARNING,
"SHM: semget() failed");
218 int dlt_shm_push(
DltShm *buf,
const unsigned char *data1,
unsigned int size1,
const unsigned char *data2,
unsigned int size2,
const unsigned char *data3,
unsigned int size3)
281 dlt_log(LOG_WARNING,
"SHM: shmdt() failed");
285 if(shmctl(buf->
shmid,IPC_RMID,
NULL) == -1) {
286 dlt_log(LOG_WARNING,
"SHM: shmdt() failed");
290 if(semctl(buf->
semid,0,IPC_RMID,(
int)0) == -1) {
291 dlt_log(LOG_WARNING,
"SHM: shmdt() failed");
306 dlt_log(LOG_WARNING,
"SHM: shmdt() failed");
#define DLT_SHM_SEM_GET(id)
int dlt_shm_copy(DltShm *buf, unsigned char *data, int max_size)
uint32_t dlt_buffer_get_total_size(DltBuffer *buf)
int dlt_shm_get_total_size(DltShm *buf)
void dlt_shm_pv(int id, int operation)
void dlt_buffer_info(DltBuffer *buf)
DltReturnValue dlt_buffer_free_static(DltBuffer *buf)
DltReturnValue dlt_shm_free_server(DltShm *buf)
DltReturnValue dlt_log(int prio, char *s)
DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
int dlt_shm_push(DltShm *buf, const unsigned char *data1, unsigned int size1, const unsigned char *data2, unsigned int size2, const unsigned char *data3, unsigned int size3)
#define DLT_SHM_SEM_FREE(id)
DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
int dlt_buffer_copy(DltBuffer *buf, unsigned char *data, int max_size)
int dlt_shm_pull(DltShm *buf, unsigned char *data, int max_size)
int dlt_buffer_get_used_size(DltBuffer *buf)
void dlt_shm_status(DltShm *buf)
static char data[kDataSize]
DltReturnValue dlt_shm_init_client(DltShm *buf, int key)
int dlt_shm_get_used_size(DltShm *buf)
void dlt_buffer_status(DltBuffer *buf)
void dlt_shm_info(DltShm *buf)
int dlt_buffer_remove(DltBuffer *buf)
int dlt_buffer_get_message_count(DltBuffer *buf)
void dlt_shm_print_hex(char *ptr, int size)
int dlt_shm_init_server(DltShm *buf, int key, int size)
int dlt_shm_get_message_count(DltShm *buf)
DltReturnValue dlt_shm_free_client(DltShm *buf)
int dlt_buffer_push3(DltBuffer *buf, const unsigned char *data1, unsigned int size1, const unsigned char *data2, unsigned int size2, const unsigned char *data3, unsigned int size3)
int dlt_buffer_pull(DltBuffer *buf, unsigned char *data, int max_size)
int dlt_shm_remove(DltShm *buf)