Commit f653f041 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

format

parent 4f43c44f
......@@ -3,9 +3,9 @@
#include "io.h"
#include "logger_tools.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**
* @brief print a header struct
......@@ -32,7 +32,6 @@ void header_print(const struct header *h) {
}
/* mask contains... TODO */
};
/**
......@@ -88,8 +87,7 @@ int header_change_offset_direction(struct header *h, void *map) {
h->forward_offset = !h->forward_offset;
size_t offset = LOGGER_VERSION_SIZE;
return io_write_data(map, LOGGER_NBER_SIZE, &h->forward_offset,
&offset);
return io_write_data(map, LOGGER_NBER_SIZE, &h->forward_offset, &offset);
}
/**
......@@ -109,7 +107,8 @@ int header_read(struct header *h, void *map) {
io_read_data(map, LOGGER_NBER_SIZE, &h->forward_offset, &offset);
if (h->forward_offset != 0 && h->forward_offset != 1)
error(EIO, "Non boolean value for the offset direction (%i)", h->forward_offset);
error(EIO, "Non boolean value for the offset direction (%i)",
h->forward_offset);
/* read offset to first data */
h->offset_first = 0;
......@@ -152,7 +151,7 @@ int header_read(struct header *h, void *map) {
header_print(h);
#endif
error(EIO, "Wrong header size (in header %li, current %li)",
h->offset_first, offset);
h->offset_first, offset);
}
return 0;
......
......@@ -20,7 +20,7 @@ struct header {
/* Number of bytes for names */
size_t name;
/* number of masks */
size_t nber_mask;
......
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "io.h"
#include "header.h"
#include "io.h"
#include "logger_tools.h"
/**
......
......@@ -149,7 +149,7 @@ static PyObject *loadFromIndex(__attribute__((unused)) PyObject *self,
/* Reset header */
header_free(&h);
if (header_read(&h, map) != 0) return NULL;
}
......
......@@ -127,7 +127,8 @@ int tools_reverse_offset(const struct header *h, void *map, size_t *offset) {
/* modify previous offset */
size_t abs_prev_offset = cur_offset - prev_offset + LOGGER_MASK_SIZE;
error_code = io_write_data(map, LOGGER_OFFSET_SIZE, &prev_offset, &abs_prev_offset);
error_code =
io_write_data(map, LOGGER_OFFSET_SIZE, &prev_offset, &abs_prev_offset);
if (error_code != 0) error(errno, "Unable to write offset");
#ifdef SWIFT_DEBUG_CHECKS
......@@ -192,7 +193,8 @@ int tools_check_offset(const struct header *h, void *map, size_t *offset) {
if (pointed_mask != mask)
error(EIO, "Error in the offset (mask %lu != %lu) at %lu and %lu", mask,
pointed_mask,
*offset - header_get_mask_size(h, mask) - LOGGER_MASK_SIZE - LOGGER_OFFSET_SIZE,
*offset - header_get_mask_size(h, mask) - LOGGER_MASK_SIZE -
LOGGER_OFFSET_SIZE,
pointed_offset - LOGGER_MASK_SIZE - LOGGER_OFFSET_SIZE);
if (pointed_mask == 128) return 0;
......
......@@ -42,14 +42,14 @@ struct header;
#define error(err, s, ...) \
({ \
error_no_return(err, s, ##__VA_ARGS__); \
exit(1); \
exit(1); \
})
#define error_no_return(err, s, ...) \
({ \
char error_msg[STRING_SIZE]; \
#define error_no_return(err, s, ...) \
({ \
char error_msg[STRING_SIZE]; \
sprintf(error_msg, "%s:%s():%i: " s ": %s\n", __FILE__, __FUNCTION__, \
__LINE__, ##__VA_ARGS__, strerror(err)); \
__LINE__, ##__VA_ARGS__, strerror(err)); \
})
#endif
......
#include "particle.h"
#include "header.h"
#include "io.h"
#include "timeline.h"
#include "logger_tools.h"
#include "timeline.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
/**
* @brief print a particle
......@@ -156,7 +156,8 @@ int particle_read(struct particle *part, const struct header *h, void *map,
if (h_offset == 0) return 0;
/* get absolute offset of next particle */
h_offset += *offset - header_get_mask_size(h, mask) - LOGGER_MASK_SIZE - LOGGER_OFFSET_SIZE;
h_offset += *offset - header_get_mask_size(h, mask) - LOGGER_MASK_SIZE -
LOGGER_OFFSET_SIZE;
part_next.time = time_array_get_time(times, h_offset);
......@@ -182,8 +183,7 @@ int particle_read(struct particle *part, const struct header *h, void *map,
* @return error code
*/
int particle_interpolate(struct particle *part_curr,
const struct particle *part_next,
const double time) {
const struct particle *part_next, const double time) {
if (!part_curr) error(EFAULT, "part_curr is NULL");
if (!part_next) error(EFAULT, "part_next is NULL");
......
......@@ -2,8 +2,8 @@
#define __PARTICLE_H__
#include "header.h"
#include "timeline.h"
#include "logger_tools.h"
#include "timeline.h"
#include <stdio.h>
#include <stdlib.h>
......@@ -57,7 +57,6 @@ int particle_read_field(struct particle *part, void *map, size_t *offset,
const char *field, const size_t size);
int particle_interpolate(struct particle *part_curr,
const struct particle *part_next,
const double time);
const struct particle *part_next, const double time);
#endif //__PARTICLE_H__
......@@ -21,8 +21,7 @@ double time_convert_to_double(const integertime_t ti, const double timeBase) {
*
* @return converted time
*/
integertime_t time_convert_to_integer(const double ti,
const double timeBase) {
integertime_t time_convert_to_integer(const double ti, const double timeBase) {
return ti / timeBase; // should add timebegin
}
......@@ -35,8 +34,8 @@ integertime_t time_convert_to_integer(const double ti,
* @param map file mapping
* @param offset In: position in the file, Out: shifted by the timestamp
*/
int time_read(integertime_t *timestamp, double *time, const struct header *h, void *map,
size_t *offset) {
int time_read(integertime_t *timestamp, double *time, const struct header *h,
void *map, size_t *offset) {
int error_code = 0;
size_t mask = 0;
size_t prev_offset = 0;
......@@ -60,7 +59,8 @@ int time_read(integertime_t *timestamp, double *time, const struct header *h, vo
/* read data */
// TODO
error_code = io_read_data(map, sizeof(unsigned long long int), timestamp, offset);
error_code =
io_read_data(map, sizeof(unsigned long long int), timestamp, offset);
error_code = io_read_data(map, sizeof(double), time, offset);
return error_code;
......@@ -160,7 +160,8 @@ int time_array_init(struct time_array *t, const struct header *h, void *map,
*
* @return integer time of the chunk
*/
integertime_t time_array_get_integertime(struct time_array *t, const size_t offset) {
integertime_t time_array_get_integertime(struct time_array *t,
const size_t offset) {
const struct time_array *tmp = time_array_get_time_array(t, offset);
return tmp->timestamp;
}
......@@ -235,7 +236,8 @@ void time_array_print(const struct time_array *t) {
while (t->next) {
i += 1;
t = t->next;
if (i < threshold || i > up_threshold) printf(", %lli (%g)", t->timestamp, t->time);
if (i < threshold || i > up_threshold)
printf(", %lli (%g)", t->timestamp, t->time);
if (i == threshold) printf(", ...");
}
......
......@@ -26,11 +26,12 @@ struct time_array {
double time_convert_to_double(const integertime_t ti, const double timeBase);
integertime_t time_convert_to_integer(const double ti, const double timeBase);
int time_read(integertime_t *timestamp, double *time, const struct header *h, void *map,
size_t *offset);
int time_read(integertime_t *timestamp, double *time, const struct header *h,
void *map, size_t *offset);
int time_array_init(struct time_array *t, const struct header *h, void *map,
int fd);
integertime_t time_array_get_integertime(struct time_array *t, const size_t offset);
integertime_t time_array_get_integertime(struct time_array *t,
const size_t offset);
double time_array_get_time(struct time_array *t, const size_t offset);
struct time_array *time_array_get_time_array(struct time_array *t,
const size_t offset);
......
Supports Markdown
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