Commit 397f2c7b authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Compile logger_loader with swift

parent 087254a4
......@@ -1008,9 +1008,10 @@ AC_ARG_WITH([python],
)
if test "x$with_python" != "xno"; then
AC_CACHE_CHECK(
"python version",
ac_cv_ver_python,
[ac_cv_ver_python=`python -c 'import sys;print(sys.version[[:3]])' 2> /dev/null`])
"python version",
ac_cv_ver_python,
[ac_cv_ver_python=`python -c 'import sys;print(sys.version[[:3]])' 2> /dev/null`]
)
if test "x$with_python" != "xyes" -a "x$with_python" != "x"; then
PYTHON_LIBS=""
......@@ -1019,6 +1020,7 @@ if test "x$with_python" != "xno"; then
PYTHON_LIBS=""
PYTHON_INCS=""
fi
have_python="yes"
AC_CHECK_PROGS(
......@@ -1033,8 +1035,8 @@ if test "x$with_python" != "xno"; then
[PyArg_ParseTuple],
[AC_DEFINE([HAVE_PYTHON],1,[The python library appears to be present.])
],
[AC_MSG_ERROR(Cannot find python library!)]
)
[AC_MSG_ERROR(Cannot find python library!)],
[$PYTHON_LIBS])
fi
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYTHON_INCS])
......
......@@ -39,11 +39,11 @@ lib_LTLIBRARIES = libswiftlogger.la
# endif
# List required headers
include_HEADERS = header.h io.h particle.h timeline.h tools.h
include_HEADERS = header.h io.h particle.h timeline.h logger_tools.h
# Common source files
AM_SOURCES = header.c io.c logger_loader.c particle.c \
timeline.c tools.c
timeline.c logger_tools.c
# Include files for distribution, not installation.
nobase_noinst_HEADERS =
......
#include "header.h"
#include "io.h"
#include "tools.h"
#include "logger_tools.h"
#include <Python.h>
#include <stdio.h>
......
#ifndef __LOGGER_HEADER_H__
#define __LOGGER_HEADER_H__
#include "tools.h"
#include "logger_tools.h"
#include <Python.h>
#include <stdio.h>
......
#include "io.h"
#include "header.h"
#include "tools.h"
#include "logger_tools.h"
/* file size */
#include <sys/stat.h>
......@@ -24,7 +24,7 @@ int io_open_file(char *filename, int *fd, void **map) {
if (*fd == -1) error(errno, "Unable to open file %s", filename);
/* get file size */
size_t size;
size_t size = 0;
int status = io_get_file_size(*fd, &size);
if (status != 0) return status;
......@@ -38,7 +38,7 @@ int io_open_file(char *filename, int *fd, void **map) {
int io_close_file(int *fd, void **map) {
/* get file size */
size_t size;
size_t size = 0;
int status = io_get_file_size(*fd, &size);
if (status != 0) return status;
......
......@@ -2,7 +2,7 @@
#define __SWIFT_LOGGER_IO_H__
#include "header.h"
#include "tools.h"
#include "logger_tools.h"
#include <stdio.h>
#include <stdlib.h>
......
......@@ -335,7 +335,7 @@ static PyObject *pyReverseOffset(__attribute__((unused)) PyObject *self,
/* definition of the method table */
static PyMethodDef logger_loaderMethods[] = {
static PyMethodDef libswiftloggerMethods[] = {
{"loadFromIndex", loadFromIndex, METH_VARARGS,
"Load snapshot directly from the offset in an index file."},
{"reverseOffset", pyReverseOffset, METH_VARARGS,
......@@ -344,21 +344,21 @@ static PyMethodDef logger_loaderMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
static struct PyModuleDef logger_loadermodule = {
static struct PyModuleDef libswiftloggermodule = {
PyModuleDef_HEAD_INIT,
"logger_loader",
"libswiftlogger",
"Module reading a SWIFTsim logger snapshot",
-1,
logger_loaderMethods,
libswiftloggerMethods,
NULL, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL /* m_free */
};
PyMODINIT_FUNC PyInit_logger_loader(void) {
PyMODINIT_FUNC PyInit_libswiftlogger(void) {
PyObject *m;
m = PyModule_Create(&logger_loadermodule);
m = PyModule_Create(&libswiftloggermodule);
if (m == NULL) return NULL;
import_array();
......
#include "tools.h"
#include "logger_tools.h"
#include "header.h"
#include "io.h"
......@@ -45,7 +45,7 @@ int _tools_get_next_chunk_backward(const struct header *h, void *map,
while (current_offset < file_size) {
size_t mask = 0;
size_t prev_offset;
int test = io_read_mask(h, map, &current_offset, &mask, &prev_offset);
test = io_read_mask(h, map, &current_offset, &mask, &prev_offset);
if (test != 0) return test;
prev_offset = current_offset - prev_offset - chunk_header;
......
......@@ -2,7 +2,7 @@
#include "header.h"
#include "io.h"
#include "timeline.h"
#include "tools.h"
#include "logger_tools.h"
#include <stdio.h>
#include <stdlib.h>
......
......@@ -3,7 +3,7 @@
#include "header.h"
#include "timeline.h"
#include "tools.h"
#include "logger_tools.h"
#include <stdio.h>
#include <stdlib.h>
......
......@@ -14,7 +14,6 @@ int time_read(integertime_t *timestamp, double *time, const struct header *h, vo
size_t *offset) {
int error_code = 0;
size_t mask = 0;
size_t ind = 0;
size_t prev_offset = 0;
*timestamp = 0;
*time = 0;
......@@ -24,6 +23,8 @@ int time_read(integertime_t *timestamp, double *time, const struct header *h, vo
if (error_code != 0) return error_code;
#ifdef SWIFT_DEBUG_CHECKS
size_t ind = 0;
/* check if timestamp is present */
if (!header_is_present_and_get_index(h, "timestamp", &ind))
error(EIO, "Header does not contain a timestamp");
......
......@@ -2,7 +2,7 @@
#define __TIMELINE_H__
#include "header.h"
#include "tools.h"
#include "logger_tools.h"
typedef char timebin_t;
typedef long long integertime_t;
......
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