Rename header magic macro

Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
This commit is contained in:
Tushar Gohad 2014-07-18 03:02:13 -07:00
parent ca04a8625d
commit 901c37cee6
2 changed files with 21 additions and 18 deletions

View File

@ -34,10 +34,6 @@
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */
#define PYECC_HEADER_MAGIC 0xb0c5ecc
#define talloc(type, num) (type *) malloc(sizeof(type) * (num))
#if __STDC_VERSION__ < 199901L
#if __GNUC__ >= 2
#define __func__ __FUNCTION__
@ -49,9 +45,12 @@
#define log_error(str) \
fprintf(stderr, "%s:%d (%s): %s\n", __FILE__, __LINE__, __func__, str)
/*
* Prevent the compiler from padding
* this by using the __packed__ keyword
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */
/**
* liberasurecode fragment header definition
*
* Prevent the compiler from padding this by using the __packed__ keyword
*/
typedef struct __attribute__((__packed__)) fragment_header_s
{
@ -66,8 +65,12 @@ typedef struct __attribute__((__packed__)) fragment_header_s
uint32_t aligned_padding[3];
} fragment_header_t;
#define LIBERASURECODE_FRAG_HEADER_MAGIC 0xb0c5ecc
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */
#define talloc(type, num) (type *) malloc(sizeof(type) * (num))
/* Determine if an address is aligned to a particular boundary */
static inline
int is_addr_aligned(unsigned long addr, int align)
@ -122,7 +125,7 @@ void init_fragment_header(char *buf)
{
fragment_header_t *header = (fragment_header_t *) buf;
header->magic = PYECC_HEADER_MAGIC;
header->magic = LIBERASURECODE_FRAG_HEADER_MAGIC;
}
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */

View File

@ -108,7 +108,7 @@ char *alloc_fragment_buffer(int size)
if (buf) {
header = (fragment_header_t *) buf;
header->magic = PYECC_HEADER_MAGIC;
header->magic = LIBERASURECODE_FRAG_HEADER_MAGIC;
}
return buf;
@ -125,7 +125,7 @@ int free_fragment_buffer(char *buf)
buf -= sizeof(fragment_header_t);
header = (fragment_header_t *) buf;
if (header->magic != PYECC_HEADER_MAGIC) {
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
fprintf(stderr,
"Invalid fragment header (free fragment)!");
return -1;
@ -194,7 +194,7 @@ char *get_fragment_ptr_from_data(char *buf)
header = (fragment_header_t *) buf;
if (header->magic != PYECC_HEADER_MAGIC) {
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
fprintf(stderr, "Invalid fragment header (get header ptr)!\n");
return NULL;
}
@ -208,7 +208,7 @@ int set_fragment_idx(char *buf, int idx)
{
fragment_header_t *header = (fragment_header_t *) buf;
if (header->magic != PYECC_HEADER_MAGIC) {
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
fprintf(stderr, "Invalid fragment header (idx check)!\n");
return -1;
}
@ -222,7 +222,7 @@ int get_fragment_idx(char *buf)
{
fragment_header_t *header = (fragment_header_t *) buf;
if (header->magic != PYECC_HEADER_MAGIC) {
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
fprintf(stderr, "Invalid fragment header (get idx)!");
return -1;
}
@ -234,7 +234,7 @@ int set_fragment_size(char *buf, int size)
{
fragment_header_t *header = (fragment_header_t *) buf;
if (header->magic != PYECC_HEADER_MAGIC) {
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
fprintf(stderr, "Invalid fragment header (size check)!");
return -1;
}
@ -248,7 +248,7 @@ int get_fragment_size(char *buf)
{
fragment_header_t *header = (fragment_header_t *) buf;
if (header->magic != PYECC_HEADER_MAGIC) {
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
fprintf(stderr, "Invalid fragment header (get size)!");
return -1;
}
@ -260,7 +260,7 @@ int set_orig_data_size(char *buf, int orig_data_size)
{
fragment_header_t *header = (fragment_header_t *) buf;
if (header->magic != PYECC_HEADER_MAGIC) {
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
fprintf(stderr, "Invalid fragment header (set orig data check)!");
return -1;
}
@ -274,7 +274,7 @@ int get_orig_data_size(char *buf)
{
fragment_header_t *header = (fragment_header_t *) buf;
if (header->magic != PYECC_HEADER_MAGIC) {
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
fprintf(stderr, "Invalid fragment header (get orig data check)!");
return -1;
}
@ -288,7 +288,7 @@ int validate_fragment(char *buf)
{
fragment_header_t *header = (fragment_header_t *) buf;
if (header->magic != PYECC_HEADER_MAGIC) {
if (header->magic != LIBERASURECODE_FRAG_HEADER_MAGIC) {
return -1;
}