From e215a56471f124e0ec8a9893fd88fe32ecde0c61 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 18 Jun 2018 17:27:19 +0200 Subject: [PATCH] Factorize duplicated declarations. --- include/smpi/smpi_helpers.h | 35 ++++++------------------- include/smpi/smpi_helpers_internal.h | 38 ++++++++++++++++++++++++++++ src/smpi/include/private.hpp | 20 +-------------- tools/cmake/DefinePackages.cmake | 1 + 4 files changed, 48 insertions(+), 46 deletions(-) create mode 100644 include/smpi/smpi_helpers_internal.h diff --git a/include/smpi/smpi_helpers.h b/include/smpi/smpi_helpers.h index 3a87fdefeb..1d92e4afc9 100644 --- a/include/smpi/smpi_helpers.h +++ b/include/smpi/smpi_helpers.h @@ -1,32 +1,16 @@ -#ifndef MPI_HELPERS_H -#define MPI_HELPERS_H +/* Copyright (c) 2018. The SimGrid Team. All rights reserved. */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include /* Load it before the define next line to not mess with the system headers */ -#if _POSIX_TIMERS -#include -#endif +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ -#ifdef __cplusplus -extern "C" { -#endif +#ifndef SMPI_HELPERS_H +#define SMPI_HELPERS_H -int smpi_usleep(useconds_t usecs); -#if _POSIX_TIMERS > 0 -int smpi_nanosleep(const struct timespec* tp, struct timespec* t); -int smpi_clock_gettime(clockid_t clk_id, struct timespec* tp); +#ifndef _GNU_SOURCE +#define _GNU_SOURCE #endif -unsigned int smpi_sleep(unsigned int secs); -int smpi_gettimeofday(struct timeval* tv, struct timezone* tz); -struct option; -int smpi_getopt_long_only (int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index); -int smpi_getopt_long (int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index); -int smpi_getopt (int argc, char *const *argv, const char *options); +#include #define sleep(x) smpi_sleep(x) #define usleep(x) smpi_usleep(x) @@ -40,7 +24,4 @@ int smpi_getopt (int argc, char *const *argv, const char *options); #define getopt_long(x,y,z,a,b) smpi_getopt_long(x,y,z,a,b) #define getopt_long_only(x,y,z,a,b) smpi_getopt_long_only(x,y,z,a,b) -#ifdef __cplusplus -} // extern "C" -#endif #endif diff --git a/include/smpi/smpi_helpers_internal.h b/include/smpi/smpi_helpers_internal.h new file mode 100644 index 0000000000..0c78541146 --- /dev/null +++ b/include/smpi/smpi_helpers_internal.h @@ -0,0 +1,38 @@ +/* Copyright (c) 2018. The SimGrid Team. All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#ifndef SMPI_HELPERS_INTERNAL_H +#define SMPI_HELPERS_INTERNAL_H + +#include + +#include +#if _POSIX_TIMERS +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +int smpi_usleep(useconds_t usecs); +#if _POSIX_TIMERS > 0 +int smpi_nanosleep(const struct timespec* tp, struct timespec* t); +int smpi_clock_gettime(clockid_t clk_id, struct timespec* tp); +#endif +unsigned int smpi_sleep(unsigned int secs); +int smpi_gettimeofday(struct timeval* tv, struct timezone* tz); + +struct option; +int smpi_getopt_long_only(int argc, char* const* argv, const char* options, const struct option* long_options, + int* opt_index); +int smpi_getopt_long(int argc, char* const* argv, const char* options, const struct option* long_options, + int* opt_index); +int smpi_getopt(int argc, char* const* argv, const char* options); + +#ifdef __cplusplus +} // extern "C" +#endif +#endif diff --git a/src/smpi/include/private.hpp b/src/smpi/include/private.hpp index cd267ebe62..2556f4cf81 100644 --- a/src/smpi/include/private.hpp +++ b/src/smpi/include/private.hpp @@ -8,14 +8,11 @@ #include "simgrid/msg.h" // msg_bar_t #include "smpi/smpi.h" +#include "smpi/smpi_helpers_internal.h" #include "src/instr/instr_smpi.hpp" #include "src/internal_config.h" #include #include -#include -#if _POSIX_TIMERS -#include -#endif #define MPI_REQ_PERSISTENT 0x1 #define MPI_REQ_NON_PERSISTENT 0x2 @@ -408,21 +405,6 @@ void mpi_file_set_view_(int* fh, long long int* offset, int* etype, int* filetyp void mpi_file_read_(int* fh, void* buf, int* count, int* datatype, MPI_Status* status, int* ierr); void mpi_file_write_(int* fh, void* buf, int* count, int* datatype, MPI_Status* status, int* ierr); - -XBT_PUBLIC int smpi_usleep(useconds_t usecs); -#if _POSIX_TIMERS > 0 -XBT_PUBLIC int smpi_nanosleep(const struct timespec* tp, struct timespec* t); -XBT_PUBLIC int smpi_clock_gettime(clockid_t clk_id, struct timespec* tp); -#endif -XBT_PUBLIC unsigned int smpi_sleep(unsigned int secs); -XBT_PUBLIC int smpi_gettimeofday(struct timeval* tv, struct timezone* tz); - - -struct option; -XBT_PUBLIC int smpi_getopt_long_only (int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index); -XBT_PUBLIC int smpi_getopt_long (int argc, char *const *argv, const char *options, const struct option *long_options, int *opt_index); -XBT_PUBLIC int smpi_getopt (int argc, char *const *argv, const char *options); - } // extern "C" struct s_smpi_privatization_region_t { diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 6bd826b0fe..0d0ed04d19 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -719,6 +719,7 @@ set(headers_to_install include/smpi/smpi.h include/smpi/smpi_main.h include/smpi/smpi_helpers.h + include/smpi/smpi_helpers_internal.h include/smpi/smpi_extended_traces.h include/smpi/smpi_extended_traces_fortran.h include/smpi/forward.hpp -- 2.20.1