PICSimLab - Programmable IC Simulator Laboratory 0.9.2
PICSimLab - API
Loading...
Searching...
No Matches
ipc_smem.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2023-2024 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
26#ifndef IPC_SMEM
27#define IPC_SMEM
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32#include <unistd.h>
33
34#ifdef _WIN_
35#include <conio.h>
36#include <windows.h>
37typedef struct {
38 void* pMem;
39 unsigned int size;
40 char key[256];
41 HANDLE hMap;
42 HANDLE hsemid[2];
44
45#else // LINUX
46#include <fcntl.h>
47#include <semaphore.h>
48#include <sys/mman.h>
49#include <time.h>
50typedef struct {
51 void* pMem;
52 unsigned int size;
53 char key[256];
54 sem_t* semid[2];
56#endif
57
58#define SB_FULL 0
59#define SB_EMPTY 1
60
61int sb_setup(const char* key, unsigned int size, shared_block_t* sb);
62void sb_finish(shared_block_t* sb);
63void sb_sem_init(shared_block_t* sb);
64void sb_sem_finish(shared_block_t* sb);
65int sb_sem_wait(shared_block_t* sb, int index);
66int sb_sem_try_wait(shared_block_t* sb, int index);
67int sb_sem_timed_wait(shared_block_t* sb, int index, unsigned int ms);
68void sb_sem_signal(shared_block_t* sb, int index);
69
70#endif
Definition ipc_smem.h:50