Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[project-description] Fix extraction of the ns-3 version.
[simgrid.git] / src / surf / surf_interface.hpp
index af27388..2cdc8f4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2004-2022. 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. */
@@ -6,10 +6,12 @@
 #ifndef SURF_MODEL_H_
 #define SURF_MODEL_H_
 
+#include <xbt/asserts.h>
+#include <xbt/function_types.h>
+
 #include "src/internal_config.h"
-#include "src/surf/surf_private.hpp"
-#include "xbt/function_types.h"
 
+#include <cfloat>
 #include <cmath>
 #include <functional>
 #include <set>
@@ -20,6 +22,8 @@
 /*********
  * Utils *
  *********/
+XBT_PRIVATE FILE* surf_fopen(const std::string& name, const char* mode);
+XBT_PRIVATE std::ifstream* surf_ifsopen(const std::string& name);
 
 /* user-visible parameters */
 XBT_PUBLIC_DATA double sg_maxmin_precision;
@@ -41,11 +45,13 @@ inline auto& watched_hosts() // avoid static initialization order fiasco
 
 static inline void double_update(double* variable, double value, double precision)
 {
-  // printf("Updating %g -= %g +- %g\n",*variable,value,precision);
-  // xbt_assert(value==0  || value>precision);
-  // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may
-  // happen, and the precision mechanism is not active...
-  // xbt_assert(*variable< (2<<DBL_MANT_DIG)*precision && FLT_RADIX==2);
+  if (false) { // debug
+    fprintf(stderr, "Updating %g -= %g +- %g\n", *variable, value, precision);
+    xbt_assert(value == 0.0 || value > precision);
+    // Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may
+    // happen, and the precision mechanism is not active...
+    xbt_assert(FLT_RADIX == 2 && *variable < precision * exp2(DBL_MANT_DIG));
+  }
   *variable -= value;
   if (*variable < precision)
     *variable = 0.0;