Commit 079f0ea3 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'cpp' into 'master'

Cpp

See merge request !505
parents b1bdba54 2814ffdc
......@@ -34,13 +34,17 @@ directory. See README for run parameters.
SWIFT has been successfully built and tested with the following compilers:
- GCC 4.8.x
- GCC 4.8.x
- Intel ICC 15.0.x
- clang 3.4.x
- clang 3.4.x
More recent versions and slightly older ones should also be able to
build the software.
It has also been built with Intel and GNU C++ compilers, but that currently
requires the --disable-vec and, for Intel, --disable-compiler-warnings
configure options.
By default an attempt to choose suitable set of optimizing compiler flags
will be made, targeted for the host machine of the build. If this doesn't
work or the binaries will for another architecture then you can stop the
......@@ -61,7 +65,7 @@ You could also add some additional flags:
./configure --enable-debug --disable-optimization CFLAGS="-O2"
for instance. GCC address sanitizer flags can be included using the
for instance. GCC address sanitizer flags can be included using the
./configure --enable-sanitizer
......@@ -113,7 +117,7 @@ before you can build it.
none-standard name.
- libtool: The build system relies on libtool.
- libtool: The build system relies on libtool as well as the other autotools.
Optional Dependencies
......
......@@ -54,6 +54,9 @@ AC_USE_SYSTEM_EXTENSIONS
AX_COMPILER_VENDOR
AX_COMPILER_VERSION
# Restrict support.
AC_C_RESTRICT
# Interprocedural optimization support. Needs special handling for linking and
# archiving as well as compilation with Intels, needs to be done before
# libtool is configured (to use correct LD).
......@@ -454,6 +457,14 @@ AC_SUBST([METIS_LIBS])
AC_SUBST([METIS_INCS])
AM_CONDITIONAL([HAVEMETIS],[test -n "$METIS_LIBS"])
# METIS fixed width integer printing can require this, so define. Only needed
# for some non C99 compilers, i.e. C++ pre C++11.
AH_VERBATIM([__STDC_FORMAT_MACROS],
[/* Needed to get PRIxxx macros from stdint.h when not using C99 */
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1
#endif])
# Check for grackle.
have_grackle="no"
AC_ARG_WITH([grackle],
......
......@@ -432,7 +432,8 @@ int main(int argc, char *argv[]) {
}
/* Read the parameter file */
struct swift_params *params = malloc(sizeof(struct swift_params));
struct swift_params *params =
(struct swift_params *)malloc(sizeof(struct swift_params));
if (params == NULL) error("Error allocating memory for the parameter file.");
if (myrank == 0) {
message("Reading runtime parameters from file '%s'", paramFileName);
......
......@@ -49,11 +49,11 @@
* @param alignment The alignment in bytes of the array.
*/
#if defined(__ICC)
#define swift_align_information(array, alignment) \
#define swift_align_information(type, array, alignment) \
__assume_aligned(array, alignment);
#elif defined(__GNUC__)
#define swift_align_information(array, alignment) \
array = __builtin_assume_aligned(array, alignment);
#define swift_align_information(type, array, alignment) \
array = (type *)__builtin_assume_aligned(array, alignment);
#else
#define swift_align_information(array, alignment) ;
#endif
......@@ -72,7 +72,7 @@
*/
#define swift_declare_aligned_ptr(type, array, ptr, alignment) \
type *restrict array = ptr; \
swift_align_information(array, alignment);
swift_align_information(type, array, alignment);
/**
* @brief Macro to tell the compiler that a given number is 0 modulo a given
......
......@@ -26,9 +26,10 @@
#include "inline.h"
#define atomic_add(v, i) __sync_fetch_and_add(v, i)
#define atomic_sub(v, i) __sync_fetch_and_sub(v, i)
#define atomic_or(v, i) __sync_fetch_and_or(v, i)
#define atomic_inc(v) atomic_add(v, 1)
#define atomic_dec(v) atomic_add(v, -1)
#define atomic_dec(v) atomic_sub(v, 1)
#define atomic_cas(v, o, n) __sync_val_compare_and_swap(v, o, n)
#define atomic_swap(v, n) __sync_lock_test_and_set(v, n)
......
......@@ -45,7 +45,7 @@ static unsigned long long clocks_cpufreq = 0;
static ticks clocks_start = 0;
/* The units of any returned times. */
static char *clocks_units[] = {"ms", "~ms"};
static const char *clocks_units[] = {"ms", "~ms"};
static int clocks_units_index = 0;
static double clocks_units_scale = 1000.0;
......
......@@ -142,7 +142,7 @@ int io_is_double_precision(enum IO_DATA_TYPE type) {
*
* Calls #error() if an error occurs.
*/
void io_read_attribute(hid_t grp, char* name, enum IO_DATA_TYPE type,
void io_read_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type,
void* data) {
hid_t h_attr = 0, h_err = 0;
......@@ -173,7 +173,7 @@ void io_read_attribute(hid_t grp, char* name, enum IO_DATA_TYPE type,
void io_write_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type,
void* data, int num) {
hid_t h_space = 0, h_attr = 0, h_err = 0;
hsize_t dim[1] = {num};
hsize_t dim[1] = {(hsize_t)num};
h_space = H5Screate(H5S_SIMPLE);
if (h_space < 0) {
......@@ -418,7 +418,7 @@ void io_copy_mapper(void* restrict temp, int N, void* restrict extra_data) {
const size_t copySize = typeSize * props.dimension;
/* How far are we with this chunk? */
char* restrict temp_c = temp;
char* restrict temp_c = (char*)temp;
const ptrdiff_t delta = (temp_c - props.start_temp_c) / copySize;
for (int k = 0; k < N; k++) {
......@@ -440,7 +440,7 @@ void io_convert_part_f_mapper(void* restrict temp, int N,
const size_t dim = props.dimension;
/* How far are we with this chunk? */
float* restrict temp_f = temp;
float* restrict temp_f = (float*)temp;
const ptrdiff_t delta = (temp_f - props.start_temp_f) / dim;
for (int i = 0; i < N; i++)
......@@ -460,7 +460,7 @@ void io_convert_part_d_mapper(void* restrict temp, int N,
const size_t dim = props.dimension;
/* How far are we with this chunk? */
double* restrict temp_d = temp;
double* restrict temp_d = (double*)temp;
const ptrdiff_t delta = (temp_d - props.start_temp_d) / dim;
for (int i = 0; i < N; i++)
......@@ -480,7 +480,7 @@ void io_convert_gpart_f_mapper(void* restrict temp, int N,
const size_t dim = props.dimension;
/* How far are we with this chunk? */
float* restrict temp_f = temp;
float* restrict temp_f = (float*)temp;
const ptrdiff_t delta = (temp_f - props.start_temp_f) / dim;
for (int i = 0; i < N; i++)
......@@ -500,7 +500,7 @@ void io_convert_gpart_d_mapper(void* restrict temp, int N,
const size_t dim = props.dimension;
/* How far are we with this chunk? */
double* restrict temp_d = temp;
double* restrict temp_d = (double*)temp;
const ptrdiff_t delta = (temp_d - props.start_temp_d) / dim;
for (int i = 0; i < N; i++)
......@@ -531,7 +531,7 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
if (props.conversion == 0) { /* No conversion */
/* Prepare some parameters */
char* temp_c = temp;
char* temp_c = (char*)temp;
props.start_temp_c = temp_c;
/* Copy the whole thing into a buffer */
......@@ -543,8 +543,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
if (props.convert_part_f != NULL) {
/* Prepare some parameters */
float* temp_f = temp;
props.start_temp_f = temp;
float* temp_f = (float*)temp;
props.start_temp_f = (float*)temp;
props.e = e;
/* Copy the whole thing into a buffer */
......@@ -555,8 +555,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
} else if (props.convert_part_d != NULL) {
/* Prepare some parameters */
double* temp_d = temp;
props.start_temp_d = temp;
double* temp_d = (double*)temp;
props.start_temp_d = (double*)temp;
props.e = e;
/* Copy the whole thing into a buffer */
......@@ -567,8 +567,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
} else if (props.convert_gpart_f != NULL) {
/* Prepare some parameters */
float* temp_f = temp;
props.start_temp_f = temp;
float* temp_f = (float*)temp;
props.start_temp_f = (float*)temp;
props.e = e;
/* Copy the whole thing into a buffer */
......@@ -579,8 +579,8 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
} else if (props.convert_gpart_d != NULL) {
/* Prepare some parameters */
double* temp_d = temp;
props.start_temp_d = temp;
double* temp_d = (double*)temp;
props.start_temp_d = (double*)temp;
props.e = e;
/* Copy the whole thing into a buffer */
......@@ -601,10 +601,12 @@ void io_copy_temp_buffer(void* temp, const struct engine* e,
/* message("Converting ! factor=%e", factor); */
if (io_is_double_precision(props.type)) {
swift_declare_aligned_ptr(double, temp_d, temp, IO_BUFFER_ALIGNMENT);
swift_declare_aligned_ptr(double, temp_d, (double*)temp,
IO_BUFFER_ALIGNMENT);
for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor;
} else {
swift_declare_aligned_ptr(float, temp_f, temp, IO_BUFFER_ALIGNMENT);
swift_declare_aligned_ptr(float, temp_f, (float*)temp,
IO_BUFFER_ALIGNMENT);
for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor;
}
}
......
......@@ -60,7 +60,7 @@ hid_t io_hdf5_type(enum IO_DATA_TYPE type);
size_t io_sizeof_type(enum IO_DATA_TYPE type);
int io_is_double_precision(enum IO_DATA_TYPE type);
void io_read_attribute(hid_t grp, char* name, enum IO_DATA_TYPE type,
void io_read_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type,
void* data);
void io_write_attribute(hid_t grp, const char* name, enum IO_DATA_TYPE type,
......
......@@ -2070,7 +2070,8 @@ void engine_exchange_proxy_multipoles(struct engine *e) {
/* Also allocate the MPI requests */
const int count_requests = count_send_requests + count_recv_requests;
MPI_Request *requests = malloc(sizeof(MPI_Request) * count_requests);
MPI_Request *requests =
(MPI_Request *)malloc(sizeof(MPI_Request) * count_requests);
if (requests == NULL) error("Unable to allocate memory for MPI requests");
int this_request = 0;
......@@ -2121,7 +2122,7 @@ void engine_exchange_proxy_multipoles(struct engine *e) {
}
/* Wait for all the requests to arrive home */
MPI_Status *stats = malloc(count_requests * sizeof(MPI_Status));
MPI_Status *stats = (MPI_Status *)malloc(count_requests * sizeof(MPI_Status));
int res;
if ((res = MPI_Waitall(count_requests, requests, stats)) != MPI_SUCCESS) {
for (int k = 0; k < count_requests; ++k) {
......@@ -2311,7 +2312,8 @@ void engine_make_self_gravity_tasks(struct engine *e) {
task_subtype_none, 0, 0, NULL, NULL);
/* Create a grid of ghosts to deal with the dependencies */
if ((ghosts = malloc(n_ghosts * sizeof(struct task *))) == 0)
if ((ghosts = (struct task **)malloc(n_ghosts * sizeof(struct task *))) ==
0)
error("Error allocating memory for gravity fft ghosts");
/* Make the ghosts implicit and add the dependencies */
......@@ -3022,7 +3024,8 @@ void engine_maketasks(struct engine *e) {
e->size_links += s->tot_cells * self_grav_tasks_per_cell;
/* Allocate the new list */
if ((e->links = malloc(sizeof(struct link) * e->size_links)) == NULL)
if ((e->links = (struct link *)malloc(sizeof(struct link) * e->size_links)) ==
NULL)
error("Failed to allocate cell-task links.");
e->nr_links = 0;
......@@ -3489,7 +3492,7 @@ int engine_marktasks(struct engine *e) {
int rebuild_space = 0;
/* Run through the tasks and mark as skip or not. */
size_t extra_data[3] = {(size_t)e, rebuild_space, (size_t)&e->sched};
size_t extra_data[3] = {(size_t)e, (size_t)rebuild_space, (size_t)&e->sched};
threadpool_map(&e->threadpool, engine_marktasks_mapper, s->tasks, s->nr_tasks,
sizeof(struct task), 0, extra_data);
rebuild_space = extra_data[1];
......@@ -5208,7 +5211,7 @@ void engine_init(
parser_get_param_string(params, "Snapshots:basename", e->snapshotBaseName);
e->snapshotCompression =
parser_get_opt_param_int(params, "Snapshots:compression", 0);
e->snapshotUnits = malloc(sizeof(struct unit_system));
e->snapshotUnits = (struct unit_system *)malloc(sizeof(struct unit_system));
units_init_default(e->snapshotUnits, params, "Snapshots", internal_units);
e->snapshotOutputCount = 0;
e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min");
......@@ -5309,7 +5312,7 @@ void engine_config(int restart, struct engine *e,
if (nr_cores > CPU_SETSIZE) /* Unlikely, except on e.g. SGI UV. */
error("must allocate dynamic cpu_set_t (too many cores per node)");
char *buf = malloc((nr_cores + 1) * sizeof(char));
char *buf = (char *)malloc((nr_cores + 1) * sizeof(char));
buf[nr_cores] = '\0';
for (int j = 0; j < nr_cores; ++j) {
/* Reversed bit order from convention, but same as e.g. Intel MPI's
......@@ -5324,7 +5327,7 @@ void engine_config(int restart, struct engine *e,
if (with_aff) {
cpuid = malloc(nr_affinity_cores * sizeof(int));
cpuid = (int *)malloc(nr_affinity_cores * sizeof(int));
int skip = 0;
for (int k = 0; k < nr_affinity_cores; k++) {
......@@ -5342,7 +5345,7 @@ void engine_config(int restart, struct engine *e,
if (nodeID == 0) message("prefer NUMA-distant CPUs");
/* Get list of numa nodes of all available cores. */
int *nodes = malloc(nr_affinity_cores * sizeof(int));
int *nodes = (int *)malloc(nr_affinity_cores * sizeof(int));
int nnodes = 0;
for (int i = 0; i < nr_affinity_cores; i++) {
nodes[i] = numa_node_of_cpu(cpuid[i]);
......@@ -5351,7 +5354,7 @@ void engine_config(int restart, struct engine *e,
nnodes += 1;
/* Count cores per node. */
int *core_counts = malloc(nnodes * sizeof(int));
int *core_counts = (int *)malloc(nnodes * sizeof(int));
for (int i = 0; i < nr_affinity_cores; i++) {
core_counts[nodes[i]] = 0;
}
......@@ -5360,7 +5363,7 @@ void engine_config(int restart, struct engine *e,
}
/* Index cores within each node. */
int *core_indices = malloc(nr_affinity_cores * sizeof(int));
int *core_indices = (int *)malloc(nr_affinity_cores * sizeof(int));
for (int i = nr_affinity_cores - 1; i >= 0; i--) {
core_indices[i] = core_counts[nodes[i]];
core_counts[nodes[i]] -= 1;
......@@ -5434,7 +5437,7 @@ void engine_config(int restart, struct engine *e,
if (e->nodeID == 0) {
/* When restarting append to these files. */
char *mode;
const char *mode;
if (restart)
mode = "a";
else
......@@ -5843,53 +5846,60 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
/* Now for the other pointers, these use their own restore functions. */
/* Note all this memory leaks, but is used once. */
struct space *s = malloc(sizeof(struct space));
struct space *s = (struct space *)malloc(sizeof(struct space));
space_struct_restore(s, stream);
e->s = s;
s->e = e;
struct unit_system *us = malloc(sizeof(struct unit_system));
struct unit_system *us =
(struct unit_system *)malloc(sizeof(struct unit_system));
units_struct_restore(us, stream);
e->internal_units = us;
us = malloc(sizeof(struct unit_system));
us = (struct unit_system *)malloc(sizeof(struct unit_system));
units_struct_restore(us, stream);
e->snapshotUnits = us;
#ifdef WITH_MPI
struct repartition *reparttype = malloc(sizeof(struct repartition));
struct repartition *reparttype =
(struct repartition *)malloc(sizeof(struct repartition));
partition_struct_restore(reparttype, stream);
e->reparttype = reparttype;
#endif
struct phys_const *physical_constants = malloc(sizeof(struct phys_const));
struct phys_const *physical_constants =
(struct phys_const *)malloc(sizeof(struct phys_const));
phys_const_struct_restore(physical_constants, stream);
e->physical_constants = physical_constants;
struct hydro_props *hydro_properties = malloc(sizeof(struct hydro_props));
struct hydro_props *hydro_properties =
(struct hydro_props *)malloc(sizeof(struct hydro_props));
hydro_props_struct_restore(hydro_properties, stream);
e->hydro_properties = hydro_properties;
struct gravity_props *gravity_properties =
malloc(sizeof(struct gravity_props));
(struct gravity_props *)malloc(sizeof(struct gravity_props));
gravity_props_struct_restore(gravity_properties, stream);
e->gravity_properties = gravity_properties;
struct external_potential *external_potential =
malloc(sizeof(struct external_potential));
(struct external_potential *)malloc(sizeof(struct external_potential));
potential_struct_restore(external_potential, stream);
e->external_potential = external_potential;
struct cooling_function_data *cooling_func =
malloc(sizeof(struct cooling_function_data));
(struct cooling_function_data *)malloc(
sizeof(struct cooling_function_data));
cooling_struct_restore(cooling_func, stream);
e->cooling_func = cooling_func;
struct sourceterms *sourceterms = malloc(sizeof(struct sourceterms));
struct sourceterms *sourceterms =
(struct sourceterms *)malloc(sizeof(struct sourceterms));
sourceterms_struct_restore(sourceterms, stream);
e->sourceterms = sourceterms;
struct swift_params *parameter_file = malloc(sizeof(struct swift_params));
struct swift_params *parameter_file =
(struct swift_params *)malloc(sizeof(struct swift_params));
parser_struct_restore(parameter_file, stream);
e->parameter_file = parameter_file;
......
......@@ -187,8 +187,9 @@ __attribute__((always_inline)) INLINE static void gravity_cache_populate(
/* Particles used for padding should get impossible positions
* that have a reasonable magnitude. We use the cell width for this */
const float pos_padded[3] = {-2. * cell->width[0], -2. * cell->width[1],
-2. * cell->width[2]};
const float pos_padded[3] = {-2.f * (float)cell->width[0],
-2.f * (float)cell->width[1],
-2.f * (float)cell->width[2]};
const float eps_padded = epsilon[0];
/* Pad the caches */
......@@ -247,8 +248,9 @@ gravity_cache_populate_no_mpole(timebin_t max_active_bin,
/* Particles used for padding should get impossible positions
* that have a reasonable magnitude. We use the cell width for this */
const float pos_padded[3] = {-2. * cell->width[0], -2. * cell->width[1],
-2. * cell->width[2]};
const float pos_padded[3] = {-2.f * (float)cell->width[0],
-2.f * (float)cell->width[1],
-2.f * (float)cell->width[2]};
const float eps_padded = epsilon[0];
/* Pad the caches */
......
......@@ -47,6 +47,5 @@ __attribute__((always_inline)) INLINE void hydro_space_init(
}
}
#else
__attribute__((always_inline)) INLINE void hydro_space_init(
struct hydro_space *hs, const struct space *s) {}
void hydro_space_init(struct hydro_space *hs, const struct space *s) {}
#endif
......@@ -27,11 +27,15 @@
* @brief Defines inline
*/
#ifndef INLINE
#ifdef __cplusplus
#define INLINE inline
#else
#if __GNUC__ && !__GNUC_STDC_INLINE__
#define INLINE extern inline
#else
#define INLINE inline
#endif
#endif
#endif
#endif /* SWIFT_INLINE_H */
......@@ -113,7 +113,7 @@ struct io_props {
* Do not call this function directly. Use the macro defined above.
*/
INLINE static struct io_props io_make_input_field_(
char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum DATA_IMPORTANCE importance, enum unit_conversion_factor units,
char* field, size_t partSize) {
struct io_props r;
......@@ -155,7 +155,7 @@ INLINE static struct io_props io_make_input_field_(
* Do not call this function directly. Use the macro defined above.
*/
INLINE static struct io_props io_make_output_field_(
char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, char* field, size_t partSize) {
struct io_props r;
strcpy(r.name, name);
......@@ -198,7 +198,7 @@ INLINE static struct io_props io_make_output_field_(
* Do not call this function directly. Use the macro defined above.
*/
INLINE static struct io_props io_make_output_field_convert_part_FLOAT(
char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t partSize,
const struct part* parts, conversion_func_part_float functionPtr) {
......@@ -235,7 +235,7 @@ INLINE static struct io_props io_make_output_field_convert_part_FLOAT(
* Do not call this function directly. Use the macro defined above.
*/
INLINE static struct io_props io_make_output_field_convert_part_DOUBLE(
char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t partSize,
const struct part* parts, conversion_func_part_double functionPtr) {
......@@ -280,7 +280,7 @@ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE(
* Do not call this function directly. Use the macro defined above.
*/
INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT(
char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t gpartSize,
const struct gpart* gparts, conversion_func_gpart_float functionPtr) {
......@@ -317,7 +317,7 @@ INLINE static struct io_props io_make_output_field_convert_gpart_FLOAT(
* Do not call this function directly. Use the macro defined above.
*/
INLINE static struct io_props io_make_output_field_convert_gpart_DOUBLE(
char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
const char name[FIELD_BUFFER_SIZE], enum IO_DATA_TYPE type, int dimension,
enum unit_conversion_factor units, size_t gpartSize,
const struct gpart* gparts, conversion_func_gpart_double functionPtr) {
......
......@@ -108,7 +108,7 @@ void logger_log_part(struct part *p, unsigned int mask, size_t *offset,
/* Allocate a chunk of memory in the dump of the right size. */
size_t offset_new;
char *buff = dump_get(dump, size, &offset_new);
char *buff = (char *)dump_get(dump, size, &offset_new);
/* Write the header. */
uint64_t temp = (((uint64_t)(offset_new - *offset)) & 0xffffffffffffffULL) |
......@@ -192,7 +192,7 @@ void logger_log_gpart(struct gpart *p, unsigned int mask, size_t *offset,
/* Allocate a chunk of memory in the dump of the right size. */
size_t offset_new;
char *buff = dump_get(dump, size, &offset_new);
char *buff = (char *)dump_get(dump, size, &offset_new);
/* Write the header. */
uint64_t temp = (((uint64_t)(offset_new - *offset)) & 0xffffffffffffffULL) |
......@@ -244,7 +244,7 @@ void logger_log_timestamp(unsigned long long int timestamp, size_t *offset,
/* Allocate a chunk of memory in the dump of the right size. */
size_t offset_new;
char *buff = dump_get(dump, size, &offset_new);
char *buff = (char *)dump_get(dump, size, &offset_new);
/* Write the header. */
uint64_t temp = (((uint64_t)(offset_new - *offset)) & 0xffffffffffffffULL) |
......
......@@ -128,16 +128,16 @@ void readArray_chunk(hid_t h_data, hid_t h_plist_id,
/* message("Converting ! factor=%e", factor); */
if (io_is_double_precision(props.type)) {
double* temp_d = temp;
double* temp_d = (double*)temp;
for (size_t i = 0; i < num_elements; ++i) temp_d[i] *= factor;
} else {
float* temp_f = temp;
float* temp_f = (float*)temp;
for (size_t i = 0; i < num_elements; ++i) temp_f[i] *= factor;
}
}
/* Copy temporary buffer to particle data */
char* temp_c = temp;
char* temp_c = (char*)temp;
for (size_t i = 0; i < N; ++i)
memcpy(props.field + i * props.partSize, &temp_c[i * copySize], copySize);
......@@ -640,7 +640,8 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units,
H5Gclose(h_grp);
/* Read the unit system used in the ICs */
struct unit_system* ic_units = malloc(sizeof(struct unit_system));
struct unit_system* ic_units =
(struct unit_system*)malloc(sizeof(struct unit_system));
if (ic_units == NULL) error("Unable to allocate memory for IC unit system");
io_read_unit_system(h_file, ic_units, mpi_rank);
......@@ -683,7 +684,7 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units,
/* Allocate memory to store SPH particles */
if (with_hydro) {
*Ngas = N[0];
if (posix_memalign((void*)parts, part_align,
if (posix_memalign((void**)parts, part_align,
(*Ngas) * sizeof(struct part)) != 0)
error("Error while allocating memory for particles");
bzero(*parts, *Ngas * sizeof(struct part));
......@@ -692,7 +693,7 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units,
/* Allocate memory to store star particles */
if (with_stars) {
*Nstars = N[swift_type_star];
if (posix_memalign((void*)sparts, spart_align,
if (posix_memalign((void**)sparts, spart_align,
*Nstars * sizeof(struct spart)) != 0)
error("Error while allocating memory for star particles");
bzero(*sparts, *Nstars * sizeof(struct spart));
......@@ -704,7 +705,7 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units,
*Ngparts = (with_hydro ? N[swift_type_gas] : 0) +
N[swift_type_dark_matter] +
(with_stars ? N[swift_type_star] : 0);
if (posix_memalign((void*)gparts, gpart_align,