Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use our xbt_getline on every platform to ease our cmake mess
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 4 Feb 2013 12:12:34 +0000 (13:12 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 4 Feb 2013 12:14:36 +0000 (13:14 +0100)
Also, as stdio.h is not loaded by root headers of the simgrid tree, we
need to explicitely load it in some locations.

12 files changed:
ChangeLog
buildtools/Cmake/CompleteInFiles.cmake
buildtools/Cmake/DefinePackages.cmake
buildtools/Cmake/PrintArgs.cmake
buildtools/Cmake/src/internal_config.h.in
buildtools/Cmake/test_prog/prog_getline.c [deleted file]
examples/smpi/MM/2.5D_MM.c
examples/smpi/MM/Summa.c
include/simgrid_config.h.in
include/xbt/str.h
src/xbt/automaton/automaton.c
src/xbt/xbt_str.c

index 4b2bc18..be7e415 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,9 @@
 SimGrid (3.10) NOT RELEASED; urgency=low
 
  XBT:
 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
 
  Java:
  * Reintegrate Java to the main archive as desynchronizing these
index 00cf1ec..eda5f1b 100644 (file)
@@ -691,20 +691,6 @@ foreach(fct ${diff_va})
 endforeach(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)
 ### check for a working snprintf
 if(HAVE_SNPRINTF AND HAVE_VSNPRINTF OR WIN32)
   if(WIN32)
index 1eebce7..b49c63c 100644 (file)
@@ -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/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
   buildtools/Cmake/test_prog/prog_gnu_dynlinker.c
   buildtools/Cmake/test_prog/prog_gtnets.cpp
   buildtools/Cmake/test_prog/prog_mutex_timedlock.c
index de6683b..c1393b9 100644 (file)
@@ -6,7 +6,6 @@ if(enable_print_message)
   message("")
   message("SIZEOF_MAX ..................: ${SIZEOF_MAX}")
   message("PTH_STACKGROWTH .............: ${PTH_STACKGROWTH}")
   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}")
   message("need_asprintf ...............: ${simgrid_need_asprintf}")
   message("need_vasprintf ..............: ${simgrid_need_vasprintf}")
   message("PREFER_PORTABLE_SNPRINTF ....: ${PREFER_PORTABLE_SNPRINTF}")
index 6bb2129..1b1a714 100644 (file)
 /* define for stack growth */
 #cmakedefine PTH_STACKGROWTH @PTH_STACKGROWTH@
 
 /* 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@
 
 /* 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 (file)
index 0c4780c..0000000
+++ /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 <stdio.h>
-int main(void)
-{
-  FILE *fp;
-  char *line = NULL;
-  size_t len = 0;
-  getline(&line, &len, fp);
-}
index 054cdf1..bf3c9bb 100644 (file)
@@ -7,6 +7,7 @@
 #include "Summa.h"
 #include "2.5D_MM.h"
 #include <stdlib.h>
 #include "Summa.h"
 #include "2.5D_MM.h"
 #include <stdlib.h>
+#include <stdio.h>
 #include "xbt/log.h"
 #define CHECK_25D 1
 
 #include "xbt/log.h"
 #define CHECK_25D 1
 
index 07ac234..0d0bab9 100644 (file)
@@ -6,6 +6,8 @@
 #include "Matrix_init.h"
 #include "Summa.h"
 #include "xbt/log.h"
 #include "Matrix_init.h"
 #include "Summa.h"
 #include "xbt/log.h"
+#include <stdio.h>
+
  XBT_LOG_NEW_DEFAULT_CATEGORY(MM_Summa,
                              "Messages specific for this msg example");
 
  XBT_LOG_NEW_DEFAULT_CATEGORY(MM_Summa,
                              "Messages specific for this msg example");
 
index 06f6f53..be5c24d 100644 (file)
@@ -71,17 +71,11 @@ XBT_PUBLIC_DATA(xbt_dynar_t) sg_cmdline;
 #cmakedefine HAVE_MMAP @HAVE_MMAP@
 
 /* Get the config */
 #cmakedefine HAVE_MMAP @HAVE_MMAP@
 
 /* Get the config */
-#undef SIMGRID_NEED_GETLINE
 #undef SIMGRID_NEED_ASPRINTF
 #undef SIMGRID_NEED_VASPRINTF
 #undef SIMGRID_NEED_ASPRINTF
 #undef SIMGRID_NEED_VASPRINTF
-@need_getline@
 @simgrid_need_asprintf@
 @simgrid_need_vasprintf@
 
 @simgrid_need_asprintf@
 @simgrid_need_vasprintf@
 
-#include <stdio.h>  /* FILE, getline if it exists  */
-#include <stdlib.h> /* size_t, ssize_t */
-XBT_PUBLIC(ssize_t) xbt_getline(char **lineptr, size_t * n, FILE * stream);
-
 #include <stdarg.h>
 
 /* snprintf related functions */
 #include <stdarg.h>
 
 /* snprintf related functions */
index fb2bc39..cddd67d 100644 (file)
@@ -21,10 +21,15 @@ SG_BEGIN_DECL()
  *  @brief String manipulation functions
  *
  * This module defines several string related functions. We redefine some quite classical
  *  @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.
  * @{
  */
  * asprintf()), while some other are a bit more exotic.
  * @{
  */
+/* Our own implementation of getline, mainly useful on the platforms not enjoying this function */
+#include <stdio.h>  /* FILE */
+#include <stdlib.h> /* 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);
 /* 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);
index 6cfff43..8824c52 100644 (file)
@@ -1,12 +1,12 @@
 /* automaton - representation of büchi automaton */
 
 /* 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"
 
 /* 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 <stdio.h> /* printf */
 
 xbt_automaton_t xbt_automaton_new(){
   xbt_automaton_t automaton = NULL;
 
 xbt_automaton_t xbt_automaton_new(){
   xbt_automaton_t automaton = NULL;
index 5a2e5a6..2fad5bf 100644 (file)
@@ -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)
  *
 
 /** @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
  *
  * 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)
 {
  */
 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;
 
   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;
   (*buf)[i] = '\0';
 
   return (ssize_t) i;
-#endif
 }
 
 /*
 }
 
 /*