Commit da2918e9 authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

some cleanup of structures

parent 141bbf2a
...@@ -37,7 +37,7 @@ static hg_return_t encode_read_action_read(hg_proc_t proc, uint64_t* pos, rd_act ...@@ -37,7 +37,7 @@ static hg_return_t encode_read_action_read(hg_proc_t proc, uint64_t* pos, rd_act
args_rd_action_read a; args_rd_action_read a;
a.offset = action->offset; a.offset = action->offset;
a.len = action->len; a.len = action->len;
a.bulk_offset = action->u.bulk_offset; a.bulk_offset = action->buffer.as_offset;
*pos += a.len; *pos += a.len;
return hg_proc_memcpy(proc, &a, sizeof(a)); return hg_proc_memcpy(proc, &a, sizeof(a));
} }
...@@ -50,10 +50,10 @@ static hg_return_t decode_read_action_read(hg_proc_t proc, uint64_t* pos, rd_act ...@@ -50,10 +50,10 @@ static hg_return_t decode_read_action_read(hg_proc_t proc, uint64_t* pos, rd_act
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
*action = (rd_action_read_t)calloc(1, sizeof(**action)); *action = (rd_action_read_t)calloc(1, sizeof(**action));
(*action)->offset = a.offset; (*action)->offset = a.offset;
(*action)->len = a.len; (*action)->len = a.len;
(*action)->u.bulk_offset = a.bulk_offset; (*action)->buffer.as_offset = a.bulk_offset;
*pos += a.len; *pos += a.len;
return ret; return ret;
} }
...@@ -195,6 +195,8 @@ hg_return_t hg_proc_mobject_store_read_op_t(hg_proc_t proc, mobject_store_read_o ...@@ -195,6 +195,8 @@ hg_return_t hg_proc_mobject_store_read_op_t(hg_proc_t proc, mobject_store_read_o
switch(hg_proc_get_op(proc)) { switch(hg_proc_get_op(proc)) {
case HG_ENCODE: case HG_ENCODE:
MOBJECT_ASSERT(read_op->use_local_pointers == 0, "Cannot encode a read_op before it has been prepared");
// encode the bulk handle associated with the series of operations // encode the bulk handle associated with the series of operations
ret = hg_proc_hg_bulk_t(proc, &(read_op->bulk_handle)); ret = hg_proc_hg_bulk_t(proc, &(read_op->bulk_handle));
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
......
...@@ -58,10 +58,10 @@ static hg_return_t decode_write_action_write(hg_proc_t proc, uint64_t* pos, wr_a ...@@ -58,10 +58,10 @@ static hg_return_t decode_write_action_write(hg_proc_t proc, uint64_t* pos, wr_a
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
*action = (wr_action_write_t)calloc(1, sizeof(**action)); *action = (wr_action_write_t)calloc(1, sizeof(**action));
(*action)->u.bulk_offset = *pos; (*action)->buffer.as_offset = *pos;
(*action)->len = a.len; (*action)->len = a.len;
(*action)->offset = a.offset; (*action)->offset = a.offset;
*pos += a.len; *pos += a.len;
return ret; return ret;
} }
...@@ -83,7 +83,7 @@ static hg_return_t decode_write_action_write_full(hg_proc_t proc, uint64_t* pos, ...@@ -83,7 +83,7 @@ static hg_return_t decode_write_action_write_full(hg_proc_t proc, uint64_t* pos,
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
*action = (wr_action_write_full_t)calloc(1, sizeof(**action)); *action = (wr_action_write_full_t)calloc(1, sizeof(**action));
(*action)->u.bulk_offset = *pos; (*action)->buffer.as_offset = *pos;
(*action)->len = a.len; (*action)->len = a.len;
*pos += a.len; *pos += a.len;
...@@ -109,11 +109,11 @@ static hg_return_t decode_write_action_write_same(hg_proc_t proc, uint64_t* pos, ...@@ -109,11 +109,11 @@ static hg_return_t decode_write_action_write_same(hg_proc_t proc, uint64_t* pos,
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
*action = (wr_action_write_same_t)calloc(1, sizeof(**action)); *action = (wr_action_write_same_t)calloc(1, sizeof(**action));
(*action)->u.bulk_offset = *pos; (*action)->buffer.as_offset = *pos;
(*action)->data_len = a.data_len; (*action)->data_len = a.data_len;
(*action)->write_len = a.write_len; (*action)->write_len = a.write_len;
(*action)->offset = a.offset; (*action)->offset = a.offset;
*pos += a.data_len; *pos += a.data_len;
return ret; return ret;
} }
...@@ -135,9 +135,9 @@ static hg_return_t decode_write_action_append(hg_proc_t proc, uint64_t* pos, wr_ ...@@ -135,9 +135,9 @@ static hg_return_t decode_write_action_append(hg_proc_t proc, uint64_t* pos, wr_
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
*action = (wr_action_append_t)calloc(1, sizeof(**action)); *action = (wr_action_append_t)calloc(1, sizeof(**action));
(*action)->u.bulk_offset = *pos; (*action)->buffer.as_offset = *pos;
(*action)->len = a.len; (*action)->len = a.len;
*pos += a.len; *pos += a.len;
return ret; return ret;
} }
...@@ -297,6 +297,8 @@ hg_return_t hg_proc_mobject_store_write_op_t(hg_proc_t proc, mobject_store_write ...@@ -297,6 +297,8 @@ hg_return_t hg_proc_mobject_store_write_op_t(hg_proc_t proc, mobject_store_write
switch(hg_proc_get_op(proc)) { switch(hg_proc_get_op(proc)) {
case HG_ENCODE: case HG_ENCODE:
MOBJECT_ASSERT(write_op->use_local_pointers == 0, "Cannot encode a write_op before it has been prepared");
// encode the bulk handle associated with the series of operations // encode the bulk handle associated with the series of operations
ret = hg_proc_hg_bulk_t(proc, &(write_op->bulk_handle)); ret = hg_proc_hg_bulk_t(proc, &(write_op->bulk_handle));
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
......
...@@ -45,9 +45,9 @@ typedef struct rd_action_READ { ...@@ -45,9 +45,9 @@ typedef struct rd_action_READ {
uint64_t offset; uint64_t offset;
size_t len; size_t len;
union { union {
char* buffer; char* as_pointer;
uint64_t bulk_offset; uint64_t as_offset;
} u; } buffer;
size_t* bytes_read; size_t* bytes_read;
int* prval; int* prval;
}* rd_action_read_t; }* rd_action_read_t;
......
...@@ -66,13 +66,13 @@ void mobject_store_read_op_read(mobject_store_read_op_t read_op, ...@@ -66,13 +66,13 @@ void mobject_store_read_op_read(mobject_store_read_op_t read_op,
MOBJECT_ASSERT(read_op != MOBJECT_READ_OP_NULL, "invalid mobject_store_read_op_t obect"); MOBJECT_ASSERT(read_op != MOBJECT_READ_OP_NULL, "invalid mobject_store_read_op_t obect");
MOBJECT_ASSERT(read_op->use_local_pointers, "can't modify a read_op that has been sent"); MOBJECT_ASSERT(read_op->use_local_pointers, "can't modify a read_op that has been sent");
rd_action_read_t action = (rd_action_read_t)calloc(1, sizeof(*action)); rd_action_read_t action = (rd_action_read_t)calloc(1, sizeof(*action));
action->base.type = READ_OPCODE_READ; action->base.type = READ_OPCODE_READ;
action->offset = offset; action->offset = offset;
action->len = len; action->len = len;
action->u.buffer = buffer; action->buffer.as_pointer = buffer;
action->bytes_read = bytes_read; action->bytes_read = bytes_read;
action->prval = prval; action->prval = prval;
READ_ACTION_UPCAST(base, action); READ_ACTION_UPCAST(base, action);
DL_APPEND(read_op->actions, base); DL_APPEND(read_op->actions, base);
......
...@@ -46,9 +46,9 @@ typedef struct wr_action_CREATE { ...@@ -46,9 +46,9 @@ typedef struct wr_action_CREATE {
typedef struct wr_action_WRITE { typedef struct wr_action_WRITE {
struct wr_action_BASE base; struct wr_action_BASE base;
union { union {
const char* buffer; const char* as_pointer;
uint64_t bulk_offset; uint64_t as_offset;
} u; } buffer;
size_t len; size_t len;
uint64_t offset; uint64_t offset;
}* wr_action_write_t; }* wr_action_write_t;
...@@ -56,18 +56,18 @@ typedef struct wr_action_WRITE { ...@@ -56,18 +56,18 @@ typedef struct wr_action_WRITE {
typedef struct wr_action_WRITE_FULL { typedef struct wr_action_WRITE_FULL {
struct wr_action_BASE base; struct wr_action_BASE base;
union { union {
const char* buffer; const char* as_pointer;
uint64_t bulk_offset; uint64_t as_offset;
} u; } buffer;
size_t len; size_t len;
}* wr_action_write_full_t; }* wr_action_write_full_t;
typedef struct wr_action_WRITE_SAME { typedef struct wr_action_WRITE_SAME {
struct wr_action_BASE base; struct wr_action_BASE base;
union { union {
const char* buffer; const char* as_pointer;
uint64_t bulk_offset; uint64_t as_offset;
} u; } buffer;
size_t data_len; size_t data_len;
size_t write_len; size_t write_len;
uint64_t offset; uint64_t offset;
...@@ -76,9 +76,9 @@ typedef struct wr_action_WRITE_SAME { ...@@ -76,9 +76,9 @@ typedef struct wr_action_WRITE_SAME {
typedef struct wr_action_APPEND { typedef struct wr_action_APPEND {
struct wr_action_BASE base; struct wr_action_BASE base;
union { union {
const char* buffer; const char* as_pointer;
uint64_t bulk_offset; uint64_t as_offset;
} u; } buffer;
size_t len; size_t len;
}* wr_action_append_t; }* wr_action_append_t;
......
...@@ -67,11 +67,11 @@ void mobject_store_write_op_write(mobject_store_write_op_t write_op, ...@@ -67,11 +67,11 @@ void mobject_store_write_op_write(mobject_store_write_op_t write_op,
MOBJECT_ASSERT(write_op != MOBJECT_WRITE_OP_NULL, "invalid mobject_store_write_op_t obect"); MOBJECT_ASSERT(write_op != MOBJECT_WRITE_OP_NULL, "invalid mobject_store_write_op_t obect");
MOBJECT_ASSERT(write_op->use_local_pointers, "can't modify a write_op that has been sent"); MOBJECT_ASSERT(write_op->use_local_pointers, "can't modify a write_op that has been sent");
wr_action_write_t action = (wr_action_write_t)calloc(1, sizeof(*action)); wr_action_write_t action = (wr_action_write_t)calloc(1, sizeof(*action));
action->base.type = WRITE_OPCODE_WRITE; action->base.type = WRITE_OPCODE_WRITE;
action->u.buffer = buffer; action->buffer.as_pointer = buffer;
action->len = len; action->len = len;
action->offset = offset; action->offset = offset;
WRITE_ACTION_UPCAST(base, action); WRITE_ACTION_UPCAST(base, action);
DL_APPEND(write_op->actions, base); DL_APPEND(write_op->actions, base);
...@@ -88,7 +88,7 @@ void mobject_store_write_op_write_full(mobject_store_write_op_t write_op, ...@@ -88,7 +88,7 @@ void mobject_store_write_op_write_full(mobject_store_write_op_t write_op,
wr_action_write_full_t action = (wr_action_write_full_t)calloc(1, sizeof(*action)); wr_action_write_full_t action = (wr_action_write_full_t)calloc(1, sizeof(*action));
action->base.type = WRITE_OPCODE_WRITE_FULL; action->base.type = WRITE_OPCODE_WRITE_FULL;
action->u.buffer = buffer; action->buffer.as_pointer = buffer;
action->len = len; action->len = len;
/* POTENTIAL OPTIMIZATION (INCOMPLETE) /* POTENTIAL OPTIMIZATION (INCOMPLETE)
...@@ -126,7 +126,7 @@ void mobject_store_write_op_writesame(mobject_store_write_op_t write_op, ...@@ -126,7 +126,7 @@ void mobject_store_write_op_writesame(mobject_store_write_op_t write_op,
wr_action_write_same_t action = (wr_action_write_same_t)calloc(1, sizeof(*action)); wr_action_write_same_t action = (wr_action_write_same_t)calloc(1, sizeof(*action));
action->base.type = WRITE_OPCODE_WRITE_SAME; action->base.type = WRITE_OPCODE_WRITE_SAME;
action->u.buffer = buffer; action->buffer.as_pointer = buffer;
action->data_len = data_len; action->data_len = data_len;
action->write_len = write_len; action->write_len = write_len;
action->offset = offset; action->offset = offset;
...@@ -146,7 +146,7 @@ void mobject_store_write_op_append(mobject_store_write_op_t write_op, ...@@ -146,7 +146,7 @@ void mobject_store_write_op_append(mobject_store_write_op_t write_op,
wr_action_append_t action = (wr_action_append_t)calloc(1, sizeof(*action)); wr_action_append_t action = (wr_action_append_t)calloc(1, sizeof(*action));
action->base.type = WRITE_OPCODE_APPEND; action->base.type = WRITE_OPCODE_APPEND;
action->u.buffer = buffer; action->buffer.as_pointer = buffer;
action->len = len; action->len = len;
WRITE_ACTION_UPCAST(base, action); WRITE_ACTION_UPCAST(base, action);
......
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