2016-08-13 17:11:11 -07:00
|
|
|
#ifndef PLASMA_H
|
|
|
|
#define PLASMA_H
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2016-09-10 16:39:24 -07:00
|
|
|
#include <stddef.h>
|
2016-08-13 17:11:11 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
2016-08-17 12:54:34 -07:00
|
|
|
#ifdef NDEBUG
|
2016-09-08 15:28:27 -07:00
|
|
|
#define LOG_DEBUG(M, ...)
|
2016-08-17 12:54:34 -07:00
|
|
|
#else
|
2016-09-08 15:28:27 -07:00
|
|
|
#define LOG_DEBUG(M, ...) \
|
|
|
|
fprintf(stderr, "[DEBUG] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
|
2016-08-17 12:54:34 -07:00
|
|
|
#endif
|
|
|
|
|
2016-09-10 16:39:24 -07:00
|
|
|
#ifdef PLASMA_LOGGIN_ON
|
|
|
|
#define LOG_INFO(M, ...) \
|
|
|
|
fprintf(stderr, "[INFO] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define LOG_INFO(M, ...)
|
|
|
|
#endif
|
|
|
|
|
2016-09-08 15:28:27 -07:00
|
|
|
#define LOG_ERR(M, ...) \
|
|
|
|
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \
|
|
|
|
errno == 0 ? "None" : strerror(errno), ##__VA_ARGS__)
|
2016-08-13 17:11:11 -07:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int64_t size;
|
|
|
|
int64_t create_time;
|
|
|
|
int64_t construct_duration;
|
|
|
|
} plasma_object_info;
|
|
|
|
|
2016-09-07 20:19:37 -07:00
|
|
|
/* Represents an object id hash, can hold a full SHA1 hash */
|
2016-09-08 15:28:27 -07:00
|
|
|
typedef struct { unsigned char id[20]; } plasma_id;
|
2016-08-13 17:11:11 -07:00
|
|
|
|
|
|
|
enum plasma_request_type {
|
2016-09-07 20:19:37 -07:00
|
|
|
/* Create a new object. */
|
|
|
|
PLASMA_CREATE,
|
|
|
|
/* Get an object. */
|
|
|
|
PLASMA_GET,
|
|
|
|
/* seal an object */
|
|
|
|
PLASMA_SEAL,
|
|
|
|
/* request transfer to another store */
|
|
|
|
PLASMA_TRANSFER,
|
|
|
|
/* Header for sending data */
|
|
|
|
PLASMA_DATA,
|
2016-08-13 17:11:11 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int type;
|
|
|
|
plasma_id object_id;
|
|
|
|
int64_t size;
|
2016-08-15 16:41:22 -07:00
|
|
|
uint8_t addr[4];
|
|
|
|
int port;
|
2016-08-13 17:11:11 -07:00
|
|
|
} plasma_request;
|
|
|
|
|
|
|
|
enum plasma_reply_type {
|
2016-09-07 20:19:37 -07:00
|
|
|
/* the file descriptor represents an object */
|
|
|
|
PLASMA_OBJECT,
|
|
|
|
/* the file descriptor represents a future */
|
|
|
|
PLASMA_FUTURE,
|
2016-08-13 17:11:11 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int type;
|
2016-09-10 16:39:24 -07:00
|
|
|
ptrdiff_t offset;
|
|
|
|
int64_t map_size;
|
|
|
|
int64_t object_size;
|
2016-08-13 17:11:11 -07:00
|
|
|
} plasma_reply;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
plasma_id object_id;
|
|
|
|
void *data;
|
|
|
|
int64_t size;
|
|
|
|
int writable;
|
|
|
|
} plasma_buffer;
|
|
|
|
|
2016-09-07 20:19:37 -07:00
|
|
|
/* Connect to the local plasma store UNIX domain socket */
|
2016-09-08 15:28:27 -07:00
|
|
|
int plasma_store_connect(const char *socket_name);
|
2016-08-13 17:11:11 -07:00
|
|
|
|
2016-09-07 20:19:37 -07:00
|
|
|
/* Connect to a possibly remote plasma manager */
|
2016-09-08 15:28:27 -07:00
|
|
|
int plasma_manager_connect(const char *addr, int port);
|
2016-09-05 15:34:11 -07:00
|
|
|
|
|
|
|
void plasma_create(int store, plasma_id object_id, int64_t size, void **data);
|
|
|
|
void plasma_get(int store, plasma_id object_id, int64_t *size, void **data);
|
|
|
|
void plasma_seal(int store, plasma_id object_id);
|
|
|
|
|
|
|
|
void plasma_send(int conn, plasma_request *req);
|
2016-08-17 12:54:34 -07:00
|
|
|
|
2016-08-13 17:11:11 -07:00
|
|
|
#endif
|