From 5ac6ae9c12a6e4ca356d5e268b171d906e734e05 Mon Sep 17 00:00:00 2001 From: Tushar Gohad Date: Thu, 17 Sep 2015 23:23:01 +0000 Subject: Move fragment_header defn to main erasurecode header --- include/erasurecode/erasurecode.h | 28 ++++++++++++++++++++++++---- include/erasurecode/erasurecode_helpers.h | 23 +---------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/include/erasurecode/erasurecode.h b/include/erasurecode/erasurecode.h index 7bdad5d..793b829 100644 --- a/include/erasurecode/erasurecode.h +++ b/include/erasurecode/erasurecode.h @@ -29,7 +29,6 @@ #ifndef _ERASURECODE_H_ #define _ERASURECODE_H_ -#include "list.h" #include "erasurecode_stdinc.h" #include "erasurecode_version.h" @@ -259,9 +258,6 @@ fragment_metadata uint32_t backend_version; /* 4 */ } fragment_metadata_t; -#define FRAGSIZE_2_BLOCKSIZE(fragment_size) \ - (fragment_size - sizeof(fragment_header_t)) - /** * Get opaque metadata for a fragment. The metadata is opaque to the * client, but meaningful to the underlying library. It is used to verify @@ -303,6 +299,30 @@ int is_invalid_fragment(int desc, char *fragment); int liberasurecode_verify_stripe_metadata(int desc, char **fragments, int num_fragments); +/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */ + +/** + * liberasurecode fragment header definition + * + * Prevent the compiler from padding this by using the __packed__ keyword + */ + +#define LIBERASURECODE_FRAG_HEADER_MAGIC 0xb0c5ecc +#define LIBERASURECODE_MAX_CHECKSUM_LEN 8 /* quad words */ + +typedef struct __attribute__((__packed__)) fragment_header_s +{ + fragment_metadata_t meta; /* 59 bytes */ + uint32_t magic; /* 4 bytes */ + uint32_t libec_version; /* 4 bytes */ + // We must be aligned to 16-byte boundaries + // So, size this array accordingly + uint8_t aligned_padding[13]; +} fragment_header_t; + +#define FRAGSIZE_2_BLOCKSIZE(fragment_size) \ + (fragment_size - sizeof(fragment_header_t)) + /* ==~=*=~===~=*=~==~=*=~== liberasurecode Helpers ==~*==~=*=~==~=~=*=~==~= */ /** diff --git a/include/erasurecode/erasurecode_helpers.h b/include/erasurecode/erasurecode_helpers.h index 33b26bd..3982b18 100644 --- a/include/erasurecode/erasurecode_helpers.h +++ b/include/erasurecode/erasurecode_helpers.h @@ -1,5 +1,5 @@ /* - * + * Copyright 2014, Kevin Greenan, Tushar Gohda, All rights reserved * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,27 +34,6 @@ /* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */ -/** - * liberasurecode fragment header definition - * - * Prevent the compiler from padding this by using the __packed__ keyword - */ - -#define LIBERASURECODE_FRAG_HEADER_MAGIC 0xb0c5ecc -#define LIBERASURECODE_MAX_CHECKSUM_LEN 8 /* quad words */ - -typedef struct __attribute__((__packed__)) fragment_header_s -{ - fragment_metadata_t meta; /* 59 bytes */ - uint32_t magic; /* 4 bytes */ - uint32_t libec_version; /* 4 bytes */ - // We must be aligned to 16-byte boundaries - // So, size this array accordingly - uint8_t aligned_padding[13]; -} fragment_header_t; - -/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */ - #define talloc(type, num) (type *) malloc(sizeof(type) * (num)) /* Determine if an address is aligned to a particular boundary */ -- cgit v1.2.1