diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2023-12-29 06:21:33 +0100 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2023-12-29 06:21:33 +0100 |
commit | 2d6c8fec45b23a8a28668ecf3ef281139ab778a7 (patch) | |
tree | 75d2a8538992129a83c0c2b83688289443d697e5 /source/kit/shared_memory.h | |
parent | 820b171245f2f14766f3accdb0246a4e2c0d596a (diff) | |
download | saw-2d6c8fec45b23a8a28668ecf3ef281139ab778a7.zip |
refactor dependencies; include dependencies source code
Diffstat (limited to 'source/kit/shared_memory.h')
-rw-r--r-- | source/kit/shared_memory.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/source/kit/shared_memory.h b/source/kit/shared_memory.h new file mode 100644 index 0000000..bd910cb --- /dev/null +++ b/source/kit/shared_memory.h @@ -0,0 +1,51 @@ +#ifndef KIT_SHARED_MEMORY_H +#define KIT_SHARED_MEMORY_H + +#include "status.h" +#include "string_ref.h" + +#if !defined(_WIN32) || defined(__CYGWIN__) +# include <limits.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + kit_status_t status; + i64 size; + u8 *bytes; +#if defined(_WIN32) && !defined(__CYGWIN__) + void *_handle; +#else + i8 _owned; + char _name[NAME_MAX + 1]; +#endif +} kit_shared_memory_t; + +enum { + KIT_SHARED_MEMORY_OPEN, + KIT_SHARED_MEMORY_CREATE, +}; + +kit_shared_memory_t kit_shared_memory_open(kit_str_t name, i64 size, + i32 mode); +kit_status_t kit_shared_memory_close(kit_shared_memory_t *mem); +kit_status_t kit_shared_memory_clean(kit_str_t name); + +#ifdef __cplusplus +} +#endif + +#ifndef KIT_DISABLE_SHORT_NAMES +# define shared_memory_t kit_shared_memory_t +# define shared_memory_clean kit_shared_memory_clean +# define shared_memory_open kit_shared_memory_open +# define shared_memory_close kit_shared_memory_close + +# define SHARED_MEMORY_OPEN KIT_SHARED_MEMORY_OPEN +# define SHARED_MEMORY_CREATE KIT_SHARED_MEMORY_CREATE +#endif + +#endif |