| 1 |
/**************************************************************************/ |
| 2 |
/* */ |
| 3 |
/* This file is part of Frama-C. */ |
| 4 |
/* */ |
| 5 |
/* Copyright (C) 2007-2022 */ |
| 6 |
/* CEA (Commissariat à l'énergie atomique et aux énergies */ |
| 7 |
/* alternatives) */ |
| 8 |
/* */ |
| 9 |
/* you can redistribute it and/or modify it under the terms of the GNU */ |
| 10 |
/* Lesser General Public License as published by the Free Software */ |
| 11 |
/* Foundation, version 2.1. */ |
| 12 |
/* */ |
| 13 |
/* It is distributed in the hope that it will be useful, */ |
| 14 |
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 15 |
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
| 16 |
/* GNU Lesser General Public License for more details. */ |
| 17 |
/* */ |
| 18 |
/* See the GNU Lesser General Public License version 2.1 */ |
| 19 |
/* for more details (enclosed in the file licenses/LGPLv2.1). */ |
| 20 |
/* */ |
| 21 |
/**************************************************************************/ |
| 22 |
|
| 23 |
#ifndef __FC_SYS_SHM_H__ |
| 24 |
#define __FC_SYS_SHM_H__ |
| 25 |
#include "../features.h" |
| 26 |
__PUSH_FC_STDLIB |
| 27 |
__BEGIN_DECLS |
| 28 |
|
| 29 |
#include "../__fc_define_pid_t.h" |
| 30 |
#include "../__fc_define_size_t.h" |
| 31 |
#include "../__fc_define_time_t.h" |
| 32 |
|
| 33 |
// POSIX: "the <sys/shm.h> header shall include the <sys/ipc.h> header." |
| 34 |
#include <sys/ipc.h> |
| 35 |
|
| 36 |
// The values for the constants below are based on an x86 Linux, |
| 37 |
// declared in the order given by POSIX.1-2008. |
| 38 |
|
| 39 |
#define SHM_RDONLY 010000 |
| 40 |
#define SHM_RND 020000 |
| 41 |
|
| 42 |
// TODO: parametrize the page size according to the machdep? |
| 43 |
#define __FC_PAGE_SIZE 4096 |
| 44 |
#define SHMLBA __FC_PAGE_SIZE |
| 45 |
|
| 46 |
typedef unsigned long shmatt_t; |
| 47 |
|
| 48 |
struct shmid_ds { |
| 49 |
struct ipc_perm shm_perm; |
| 50 |
size_t shm_segsz; |
| 51 |
pid_t shm_lpid; |
| 52 |
pid_t shm_cpid; |
| 53 |
shmatt_t shm_nattch; |
| 54 |
time_t shm_atime; |
| 55 |
time_t shm_dtime; |
| 56 |
time_t shm_ctime; |
| 57 |
}; |
| 58 |
|
| 59 |
extern void *shmat(int, const void *, int); |
| 60 |
extern int shmctl(int, int, struct shmid_ds *); |
| 61 |
extern int shmdt(const void *); |
| 62 |
extern int shmget(key_t, size_t, int); |
| 63 |
|
| 64 |
__END_DECLS |
| 65 |
__POP_FC_STDLIB |
| 66 |
#endif |