Commit 6ed40d97 authored by Matthieu Dorier's avatar Matthieu Dorier

cleaned up Makefiles and added write-op implementation

parent 5fd40c36
...@@ -9,18 +9,10 @@ AM_CPPFLAGS = -I$(top_srcdir)/include ...@@ -9,18 +9,10 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CFLAGS = AM_CFLAGS =
AM_CXXFLAGS = $(AM_CFLAGS) AM_CXXFLAGS = $(AM_CFLAGS)
lib_LTLIBRARIES = libmobject-store.la lib_LTLIBRARIES = src/libmobject-store.la
libmobject_store_la_SOURCES = src/libmobject-store.c \
src/completion.c \
src/write-op.c \
src/completion.h \
src/log.h \
src/write-op.h \
include/rados-mobject-store.h \
include/mobject-store.h
include_HEADERS = include/mobject-store.h include_HEADERS = include/libmobject-store.h
libmobject_la_CPPFLAGS = -I${srcdir}/include -I${srcdir}/src src_libmobject_la_CPPFLAGS = -I${srcdir}/include -I${srcdir}/src
include Make.rules include Make.rules
......
...@@ -135,8 +135,6 @@ typedef struct mobject_store_write_op *mobject_store_write_op_t; ...@@ -135,8 +135,6 @@ typedef struct mobject_store_write_op *mobject_store_write_op_t;
#define MOBJECT_WRITE_OP_NULL ((mobject_store_write_op_t)0) #define MOBJECT_WRITE_OP_NULL ((mobject_store_write_op_t)0)
#define MOBJECT_WRITE_OP_NULL ((void*)0)
/** /**
* @typedef mobject_store_read_op_t * @typedef mobject_store_read_op_t
* *
...@@ -159,9 +157,7 @@ typedef struct mobject_store_write_op *mobject_store_write_op_t; ...@@ -159,9 +157,7 @@ typedef struct mobject_store_write_op *mobject_store_write_op_t;
*/ */
typedef struct mobject_store_read_op *mobject_store_read_op_t; typedef struct mobject_store_read_op *mobject_store_read_op_t;
#define MOBJECT_READ_OP_NULL ((void*)0) #define MOBJECT_READ_OP_NULL ((mobject_store_read_op_t)0)
#define MOBJECT_READ_OP_NULL ((void*)0)
/** /**
* @typedef mobject_store_completion_t * @typedef mobject_store_completion_t
...@@ -173,8 +169,6 @@ typedef struct mobject_store_completion* mobject_store_completion_t; ...@@ -173,8 +169,6 @@ typedef struct mobject_store_completion* mobject_store_completion_t;
#define MOBJECT_COMPLETION_NULL ((mobject_store_completion_t)0) #define MOBJECT_COMPLETION_NULL ((mobject_store_completion_t)0)
#define MOBJECT_COMPLETION_NULL ((void*)0)
/***************************************** /*****************************************
* mobject store setup/teardown routines * * mobject store setup/teardown routines *
*****************************************/ *****************************************/
......
src_libmobject_store_la_SOURCES += \ src_libmobject_store_la_SOURCES = \
src/libmobject-store.c \ src/libmobject-store.c \
src/completion.c src/completion.h \ src/completion.c \
src/log.h src/write-op.c src/write-op.h \ src/log.h src/write-op.c
include/libmobject-store.h
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __MOBJECT_WRITE_OPCODES_H
#define __MOBJECT_WRITE_OPCODES_H
#include "mobject-store-config.h"
typedef enum {
WRITE_OPCODE_BASE = 0,
WRITE_OPCODE_CREATE,
WRITE_OPCODE_WRITE,
WRITE_OPCODE_WRITE_FULL,
WRITE_OPCODE_WRITE_SAME,
WRITE_OPCODE_APPEND,
WRITE_OPCODE_REMOVE,
WRITE_OPCODE_TRUNCATE,
WRITE_OPCODE_ZERO,
WRITE_OPCODE_OMAP_SET,
WRITE_OPCODE_RM_KEYS
} write_op_code_t;
#define WRITE_ACTION_DOWNCAST(child_obj, base_obj, child_category) \
if(WRITE_OPCODE_ ## child_category != base_obj->type) {\
MOBJECT_LOG("Downcast error: " #base_obj " is not of type WRITE_ACTION_" #child_category);\
}\
struct wr_action_ ## child_category * child_obj = (struct wr_action_ ## child_category *) base_obj;
#define WRITE_ACTION_UPCAST(base_obj, child_obj) \
struct wr_action_BASE* base_obj = (struct wr_action_BASE*) child_obj;
typedef struct wr_action_BASE {
write_op_code_t type;
struct wr_action_base* prev;
struct wr_action_base* next;
}* wr_action_base_t;
typedef struct wr_action_CREATE {
struct wr_action_BASE base;
int exclusive;
}* wr_action_create_t;
typedef struct wr_action_WRITE {
struct wr_action_BASE base;
const char* buffer;
size_t len;
uint64_t offset;
}* wr_action_write_t;
typedef struct wr_action_WRITE_FULL {
struct wr_action_BASE base;
const char* buffer;
size_t len;
}* wr_action_write_full_t;
typedef struct wr_action_WRITE_SAME {
struct wr_action_BASE base;
const char* buffer;
size_t data_len;
size_t write_len;
uint64_t offset;
}* wr_action_write_same_t;
typedef struct wr_action_APPEND {
struct wr_action_BASE base;
const char* buffer;
size_t len;
}* wr_action_append_t;
typedef struct wr_action_REMOVE {
struct wr_action_BASE base;
}* wr_action_remove_t;
typedef struct wr_action_TRUNCATE {
struct wr_action_BASE base;
uint64_t offset;
}* wr_action_truncate_t;
typedef struct wr_action_ZERO {
struct wr_action_BASE base;
uint64_t offset;
uint64_t len;
}* wr_action_zero_t;
typedef struct wr_action_OMAP_SET {
struct wr_action_BASE base;
char const* const* keys;
char const* const* vals;
const size_t* lens;
size_t num;
}* wr_action_omap_set_t;
typedef struct wr_action_RM_KEYS {
struct wr_action_BASE base;
char const* const* keys;
size_t keys_len;
}* wr_action_rm_keys_t;
#endif
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "mobject-store-config.h" #include "mobject-store-config.h"
#include "libmobject-store.h" #include "libmobject-store.h"
#include "log.h"
#include "write-op.h" #include "write-op.h"
#include "completion.h" #include "completion.h"
...@@ -14,8 +15,9 @@ mobject_store_write_op_t mobject_store_create_write_op(void) ...@@ -14,8 +15,9 @@ mobject_store_write_op_t mobject_store_create_write_op(void)
{ {
mobject_store_write_op_t write_op = mobject_store_write_op_t write_op =
(mobject_store_write_op_t)calloc(1, sizeof(struct mobject_store_write_op)); (mobject_store_write_op_t)calloc(1, sizeof(struct mobject_store_write_op));
// XXX assert result is valid MOBJECT_ASSERT(write_op != MOBJECT_WRITE_OP_NULL, "Could not allocate write_op");
// TODO: set fields write_op->num_actions = 0;
write_op->actions = (wr_action_base_t)0;
return write_op; return write_op;
} }
...@@ -30,7 +32,7 @@ void mobject_store_write_op_create(mobject_store_write_op_t write_op, ...@@ -30,7 +32,7 @@ void mobject_store_write_op_create(mobject_store_write_op_t write_op,
int exclusive, int exclusive,
const char* category) const char* category)
{ {
wr_action_create_t action = (wr_action_create_t)calloc(1, sizeof(*action));
} }
void mobject_store_write_op_write(mobject_store_write_op_t write_op, void mobject_store_write_op_write(mobject_store_write_op_t write_op,
......
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
#define __MOBJECT_WRITE_OP_H #define __MOBJECT_WRITE_OP_H
#include "mobject-store-config.h" #include "mobject-store-config.h"
#include "write-actions.h"
struct mobject_store_write_op { struct mobject_store_write_op {
// TODO size_t num_actions;
wr_action_base_t actions;
}; };
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment