reset: enum cow_err_kind exists

deleted union poison

deleted struct cow_error
error_handling
Avril 4 years ago
parent aeb3f528d4
commit a5d5d1b9fd
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -8,7 +8,7 @@ extern "C" {
#include <stdlib.h> #include <stdlib.h>
enum cow_err { enum cow_err_kind {
COW_ERR_UNKNOWN =0, COW_ERR_UNKNOWN =0,
COW_ERR_NONE =1, // Success COW_ERR_NONE =1, // Success
@ -43,7 +43,7 @@ static inline
#ifdef _COW_NO_ASSUME_ABI #ifdef _COW_NO_ASSUME_ABI
#define _cow_size_unsafe(v) cow_size(v) #define _cow_size_unsafe(v) cow_size(v)
#else #else
// XXX: This macro is *VERY* ABI sensitive. This shouldn't be used if the ABI has changed since the build of libcow's `cow_t.h` passed its static assertions in *both* the C and C++ implementations. // XXX: This macro is *VERY* ABI sensitive. This shouldn't be used if the ABI has changed since the build of libcow's `cow_t.h` passed its stati assertions in *both* the C and C++ implementations.
// The C++ API uses this by default for its `Cow::size()` function. // The C++ API uses this by default for its `Cow::size()` function.
#define _cow_size_unsafe(v) (*(((size_t*)(v))+1)) #define _cow_size_unsafe(v) (*(((size_t*)(v))+1))
__attribute__((deprecated("size() is safer and offers better codegen."))) __attribute__((deprecated("size() is safer and offers better codegen.")))

@ -92,7 +92,8 @@ size_t cow_size(const cow_t* cow)
inline internal cow_t _cow_create_unboxed(size_t size) inline internal cow_t _cow_create_unboxed(size_t size)
{ {
cow_t ret; cow_t ret;
ret.error = COW_POISON_NONE;
//ret.error = COW_POISON_NONE;
ret.size = size; ret.size = size;
ret.fd = shm_fd(size); ret.fd = shm_fd(size);
ret.origin = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, ret.fd, 0); ret.origin = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, ret.fd, 0);
@ -124,7 +125,7 @@ cow_t* cow_clone(const cow_t* cow)
{ {
cow_t clone; cow_t clone;
clone.error = COW_POISON_NONE; //clone.error = COW_POISON_NONE;
clone.origin = mmap(cow->origin, cow->size, PROT_READ|PROT_WRITE, MAP_PRIVATE, cow_real_fd(cow), 0); clone.origin = mmap(cow->origin, cow->size, PROT_READ|PROT_WRITE, MAP_PRIVATE, cow_real_fd(cow), 0);
if(clone.origin == MAP_FAILED) die("cow_clone:mmap"); if(clone.origin == MAP_FAILED) die("cow_clone:mmap");
clone.fd = (~INT_MAX) | cow->fd; clone.fd = (~INT_MAX) | cow->fd;

@ -20,9 +20,6 @@ struct cow_mapped_slice {
size_t size; // Should be at this offset. size_t size; // Should be at this offset.
int fd; // Will be ORd with ~INT_MAX if it's a clone. Will be >0 if it's the original. int fd; // Will be ORd with ~INT_MAX if it's a clone. Will be >0 if it's the original.
// Error status
union poison error;
}; // cow_t, *cow }; // cow_t, *cow
#ifdef __cplusplus #ifdef __cplusplus

@ -1,13 +0,0 @@
#include "error.h"
internal void _cow_poison(cow_t* restrict cow, enum cow_err kind, const char *msg)
{
if(cow->error.e_global) {
}
}
internal void _cow_poison_ref(cow_t* restrict cow, cow_error* globl)
{
}

@ -12,6 +12,8 @@ extern "C" {
#define restrict __restrict__ #define restrict __restrict__
#endif #endif
/*
Failed:
typedef struct cow_error cow_error; typedef struct cow_error cow_error;
union poison { union poison {
struct cow_error { struct cow_error {
@ -31,6 +33,7 @@ union poison {
void _cow_poison(cow_t* restrict cow, enum cow_err kind, const char *msg) internal; void _cow_poison(cow_t* restrict cow, enum cow_err kind, const char *msg) internal;
void _cow_poison_ref(cow_t* restrict cow, cow_error* globl) internal; void _cow_poison_ref(cow_t* restrict cow, cow_error* globl) internal;
*/
#ifdef __cplusplus #ifdef __cplusplus
} }

Loading…
Cancel
Save