From: Martin Quinson Date: Mon, 4 Feb 2013 12:12:34 +0000 (+0100) Subject: use our xbt_getline on every platform to ease our cmake mess X-Git-Tag: v3_9_90~510^2~62 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d4f15663c34447bed92582e01f96ae8ba5841fcd use our xbt_getline on every platform to ease our cmake mess Also, as stdio.h is not loaded by root headers of the simgrid tree, we need to explicitely load it in some locations. --- diff --git a/ChangeLog b/ChangeLog index 4b2bc1899a..be7e415760 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,9 @@ SimGrid (3.10) NOT RELEASED; urgency=low XBT: - * Our own implementation of getline is renamed xbt_getline. + * Our own implementation of getline is renamed xbt_getline, and gets + used even if the OS provide a getline(). This should reduce the + configuration complexity by using the same code on all platforms. Java: * Reintegrate Java to the main archive as desynchronizing these diff --git a/buildtools/Cmake/CompleteInFiles.cmake b/buildtools/Cmake/CompleteInFiles.cmake index 00cf1ec6a0..eda5f1be29 100644 --- a/buildtools/Cmake/CompleteInFiles.cmake +++ b/buildtools/Cmake/CompleteInFiles.cmake @@ -691,20 +691,6 @@ foreach(fct ${diff_va}) endforeach(fct ${diff_va}) #-------------------------------------------------------------------------------------------------- -### check for getline -try_compile(COMPILE_RESULT_VAR - ${CMAKE_BINARY_DIR} - ${CMAKE_HOME_DIRECTORY}/buildtools/Cmake/test_prog/prog_getline.c - ) - -if(NOT COMPILE_RESULT_VAR) - SET(need_getline "#define SIMGRID_NEED_GETLINE 1") - SET(SIMGRID_NEED_GETLINE 1) -else() - SET(need_getline "") - SET(SIMGRID_NEED_GETLINE 0) -endif() - ### check for a working snprintf if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32) if(WIN32) diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 1eebce72d7..b49c63cb41 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -861,7 +861,6 @@ set(CMAKE_SOURCE_FILES buildtools/Cmake/src/internal_config.h.in buildtools/Cmake/src/simgrid.nsi.in buildtools/Cmake/test_prog/prog_AC_CHECK_MCSC.c - buildtools/Cmake/test_prog/prog_getline.c buildtools/Cmake/test_prog/prog_gnu_dynlinker.c buildtools/Cmake/test_prog/prog_gtnets.cpp buildtools/Cmake/test_prog/prog_mutex_timedlock.c diff --git a/buildtools/Cmake/PrintArgs.cmake b/buildtools/Cmake/PrintArgs.cmake index de6683b4ca..c1393b9538 100644 --- a/buildtools/Cmake/PrintArgs.cmake +++ b/buildtools/Cmake/PrintArgs.cmake @@ -6,7 +6,6 @@ if(enable_print_message) message("") message("SIZEOF_MAX ..................: ${SIZEOF_MAX}") message("PTH_STACKGROWTH .............: ${PTH_STACKGROWTH}") - message("need_getline ................: ${need_getline}") message("need_asprintf ...............: ${simgrid_need_asprintf}") message("need_vasprintf ..............: ${simgrid_need_vasprintf}") message("PREFER_PORTABLE_SNPRINTF ....: ${PREFER_PORTABLE_SNPRINTF}") diff --git a/buildtools/Cmake/src/internal_config.h.in b/buildtools/Cmake/src/internal_config.h.in index 6bb2129123..1b1a714d5e 100644 --- a/buildtools/Cmake/src/internal_config.h.in +++ b/buildtools/Cmake/src/internal_config.h.in @@ -284,9 +284,6 @@ /* define for stack growth */ #cmakedefine PTH_STACKGROWTH @PTH_STACKGROWTH@ -/* enable the getline replacement */ -#cmakedefine SIMGRID_NEED_GETLINE @SIMGRID_NEED_GETLINE@ - /* The maximal size of any scalar on this arch */ #cmakedefine SIZEOF_MAX @SIZEOF_MAX@ diff --git a/buildtools/Cmake/test_prog/prog_getline.c b/buildtools/Cmake/test_prog/prog_getline.c deleted file mode 100644 index 0c4780c37c..0000000000 --- a/buildtools/Cmake/test_prog/prog_getline.c +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (c) 2010. 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. */ - -#define _GNU_SOURCE -#include -int main(void) -{ - FILE *fp; - char *line = NULL; - size_t len = 0; - getline(&line, &len, fp); -} diff --git a/examples/smpi/MM/2.5D_MM.c b/examples/smpi/MM/2.5D_MM.c index 054cdf170b..bf3c9bb6e3 100644 --- a/examples/smpi/MM/2.5D_MM.c +++ b/examples/smpi/MM/2.5D_MM.c @@ -7,6 +7,7 @@ #include "Summa.h" #include "2.5D_MM.h" #include +#include #include "xbt/log.h" #define CHECK_25D 1 diff --git a/examples/smpi/MM/Summa.c b/examples/smpi/MM/Summa.c index 07ac234ffb..0d0bab99f6 100644 --- a/examples/smpi/MM/Summa.c +++ b/examples/smpi/MM/Summa.c @@ -6,6 +6,8 @@ #include "Matrix_init.h" #include "Summa.h" #include "xbt/log.h" +#include + XBT_LOG_NEW_DEFAULT_CATEGORY(MM_Summa, "Messages specific for this msg example"); diff --git a/include/simgrid_config.h.in b/include/simgrid_config.h.in index 06f6f53134..be5c24da3e 100644 --- a/include/simgrid_config.h.in +++ b/include/simgrid_config.h.in @@ -71,17 +71,11 @@ XBT_PUBLIC_DATA(xbt_dynar_t) sg_cmdline; #cmakedefine HAVE_MMAP @HAVE_MMAP@ /* Get the config */ -#undef SIMGRID_NEED_GETLINE #undef SIMGRID_NEED_ASPRINTF #undef SIMGRID_NEED_VASPRINTF -@need_getline@ @simgrid_need_asprintf@ @simgrid_need_vasprintf@ -#include /* FILE, getline if it exists */ -#include /* size_t, ssize_t */ -XBT_PUBLIC(ssize_t) xbt_getline(char **lineptr, size_t * n, FILE * stream); - #include /* snprintf related functions */ diff --git a/include/xbt/str.h b/include/xbt/str.h index fb2bc397b3..cddd67d724 100644 --- a/include/xbt/str.h +++ b/include/xbt/str.h @@ -21,10 +21,15 @@ SG_BEGIN_DECL() * @brief String manipulation functions * * This module defines several string related functions. We redefine some quite classical - * functions on the platforms were they are not nativaly defined (such as getline() or + * functions on the platforms were they are not nativaly defined (such as xbt_getline() or * asprintf()), while some other are a bit more exotic. * @{ */ +/* Our own implementation of getline, mainly useful on the platforms not enjoying this function */ +#include /* FILE */ +#include /* size_t, ssize_t */ +XBT_PUBLIC(ssize_t) xbt_getline(char **lineptr, size_t * n, FILE * stream); + /* Trim related functions */ XBT_PUBLIC(void) xbt_str_rtrim(char *s, const char *char_list); XBT_PUBLIC(void) xbt_str_ltrim(char *s, const char *char_list); diff --git a/src/xbt/automaton/automaton.c b/src/xbt/automaton/automaton.c index 6cfff43af6..8824c52df9 100644 --- a/src/xbt/automaton/automaton.c +++ b/src/xbt/automaton/automaton.c @@ -1,12 +1,12 @@ /* automaton - representation of büchi automaton */ -/* Copyright (c) 2011. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2011-2013. 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. */ #include "xbt/automaton.h" +#include /* printf */ xbt_automaton_t xbt_automaton_new(){ xbt_automaton_t automaton = NULL; diff --git a/src/xbt/xbt_str.c b/src/xbt/xbt_str.c index 5a2e5a62bb..2fad5bf71b 100644 --- a/src/xbt/xbt_str.c +++ b/src/xbt/xbt_str.c @@ -522,8 +522,7 @@ char *xbt_str_join_array(const char *const *strs, const char *sep) /** @brief Get a single line from the stream (reimplementation of the GNU getline) * - * This is a redefinition of the GNU getline function, used on platforms where - * it does not exists. + * This is a reimplementation of the GNU getline function, so that our code don't depends on the GNU libc. * * xbt_getline() reads an entire line from stream, storing the address of the * buffer containing the text into *buf. The buffer is null-terminated and @@ -542,9 +541,6 @@ char *xbt_str_join_array(const char *const *strs, const char *sep) */ ssize_t xbt_getline(char **buf, size_t * n, FILE * stream) { -#if !defined(SIMGRID_NEED_GETLINE) - return getline(buf, n, stream); -#else size_t i; int ch; @@ -576,7 +572,6 @@ ssize_t xbt_getline(char **buf, size_t * n, FILE * stream) (*buf)[i] = '\0'; return (ssize_t) i; -#endif } /*