1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
7 */
8
9/*
10 * M. Raasveldt
11 * This file contains a number of functions for interprocess communication.
12 */
13
14#ifndef _GDK_INTERPROCES_H_
15#define _GDK_INTERPROCES_H_
16
17#ifdef HAVE_FORK
18#include "gdk.h"
19
20#include <stddef.h>
21
22//! Obtain a set of unique identifiers that can be used to create memory mapped files or semaphores
23gdk_export size_t GDKuniqueid(size_t offset);
24
25/*
26 * Memory-Mapped File operations, used for transporting data between processes
27 */
28
29//! Create a memory mapped file if it does not exist and open it
30gdk_export void *GDKinitmmap(size_t id, size_t size, size_t *return_size);
31//! Release a memory mapped file that was created through GDKinitmmap
32gdk_export gdk_return GDKreleasemmap(void *ptr, size_t size, size_t id);
33//! snprintf the file name of a memory mapped file (as created by GDKinitmmap)
34gdk_export gdk_return GDKmmapfile(str buffer, size_t max, size_t id);
35
36/*
37 * Interprocess-Semaphores, used for cross process lock operations
38 */
39
40//! Create an interprocess semaphore
41gdk_export gdk_return GDKcreatesem(int id, int count, int *semid);
42//! Get an interprocess semaphore that was already created using GDKcreatesem
43gdk_export gdk_return GDKgetsem(int sem_id, int count, int *semid);
44//! Gets the value of an interprocess semaphore
45gdk_export gdk_return GDKgetsemval(int sem_id, int number, int *semval);
46//! Change the value of an interprocess semaphore
47gdk_export gdk_return GDKchangesemval(int sem_id, int number, int change);
48//! Change the value of an interprocess semaphore with a timeout
49gdk_export gdk_return GDKchangesemval_timeout(int sem_id, int number, int change, int timeout_mseconds, bool *succeed);
50//! Destroy an interprocess semaphore
51gdk_export gdk_return GDKreleasesem(int sem_id);
52
53/*
54 * Operations for copying a BAT into a memory mapped file
55 */
56
57//! Returns the size of the buffer necessary to copy the BAT into
58gdk_export size_t GDKbatcopysize(BAT *bat, str colname);
59//! Copies a BAT into the given destination. Returns the amount of bytes copied (equiv. to GDKbatcopysize(bat))
60gdk_export size_t GDKbatcopy(char *dest, BAT *bat, str colname);
61//! Reads a BAT from the given source (one that was copied into by GDKbatcopy)
62gdk_export size_t GDKbatread(char *src, BAT **bat, str *colname);
63
64
65#endif
66
67#endif /* _GDK_INTERPROCES_H_ */
68