71 lines
2.0 KiB
C
71 lines
2.0 KiB
C
/*
|
|
************************************************************************
|
|
**
|
|
** Copyright (c) 2010 by
|
|
** Core|Vision B.V.
|
|
** Cereslaan 10b
|
|
** 5384 VT Heesch
|
|
** The Netherlands
|
|
**
|
|
** All Rights Reserved
|
|
**
|
|
************************************************************************
|
|
*/
|
|
/*
|
|
************************************************************************
|
|
**
|
|
** Project name: Dual Inventive: Utility Library
|
|
** Filename: cp3000-shmem.h
|
|
** Author: Jack Weeland
|
|
** Date: October 26, 2010
|
|
** File version: 1.00 of October 26, 2010
|
|
**
|
|
************************************************************************
|
|
*/
|
|
/*
|
|
************************************************************************
|
|
**
|
|
** CP3000 inter-process shared memory functions
|
|
**
|
|
************************************************************************
|
|
*/
|
|
|
|
#ifndef __CP3000_SHARED_MEMORY_H
|
|
#define __CP3000_SHARED_MEMORY_H
|
|
|
|
/*
|
|
** Datatype
|
|
*/
|
|
|
|
typedef struct CP3000_SHARED_MEMORY *cp3000_shmem_t;
|
|
|
|
/*
|
|
** Constants for the 'flags' to 'cp3000_shmem_init()'
|
|
*/
|
|
|
|
#define CP3000_SHMEM_READ 0x0001 // read only access
|
|
#define CP3000_SHMEM_WRITE 0x0002 // read and write access
|
|
#define CP3000_SHMEM_PRIVATE 0x0100 // access for the current user only
|
|
|
|
/*
|
|
** Exported functions
|
|
*/
|
|
|
|
// Initialization and destruction
|
|
cp3000_shmem_t cp3000_shmem_init(const char *name, size_t size, unsigned int flags);
|
|
int cp3000_shmem_deinit(cp3000_shmem_t);
|
|
|
|
// Provide access to the shared memory region
|
|
void *cp3000_shmem(cp3000_shmem_t);
|
|
// Get the size of the shared memory object (may be changed after 'cp3000_shmem_init()')
|
|
size_t cp3000_shmem_size(cp3000_shmem_t);
|
|
|
|
// Safe access, with size checking etc.
|
|
// Return the number of bytes copied
|
|
int cp3000_shmem_read(cp3000_shmem_t, void *buffer, size_t bufsz);
|
|
int cp3000_shmem_read_at(cp3000_shmem_t, int offset, void *buffer, size_t bufsz);
|
|
int cp3000_shmem_write(cp3000_shmem_t, const void *buffer, size_t bufsz);
|
|
int cp3000_shmem_write_at(cp3000_shmem_t, int offset, const void *buffer, size_t bufsz);
|
|
|
|
#endif /* __CP3000_SHARED_MEMORY_H */
|