A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
typo
[simgrid.git]
/
include
/
xbt
/
system_error.hpp
diff --git
a/include/xbt/system_error.hpp
b/include/xbt/system_error.hpp
index
4a2ae7a
..
c94eaff
100644
(file)
--- a/
include/xbt/system_error.hpp
+++ b/
include/xbt/system_error.hpp
@@
-1,4
+1,4
@@
-/* Copyright (c) 2016. The SimGrid Team.
+/* Copyright (c) 2016
-2023
. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
@@
-11,13
+11,12
@@
#ifndef SIMGRID_MC_SYSTEM_ERROR_HPP
#define SIMGRID_MC_SYSTEM_ERROR_HPP
#ifndef SIMGRID_MC_SYSTEM_ERROR_HPP
#define SIMGRID_MC_SYSTEM_ERROR_HPP
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
/** A `error_category` suitable to be used with `errno`
*
* It is not clear which error we are supposed to generate
/** A `error_category` suitable to be used with `errno`
*
* It is not clear which error we are supposed to generate
- * when getting a errno:
+ * when getting a
n
errno:
*
* * `system_error` clearly cannot be used for this on Windows;
*
*
* * `system_error` clearly cannot be used for this on Windows;
*
@@
-43,6
+42,15
@@
std::error_code errno_code(int errnum)
return std::error_code(errnum, errno_category());
}
return std::error_code(errnum, errno_category());
}
+/** Create an `error_code` from `errno` (and clear it) */
+inline
+std::error_code errno_code()
+{
+ int errnum = errno;
+ errno = 0;
+ return errno_code(errnum);
+}
+
/** Create a `system_error` from an `errno` value
*
* This is expected to to whatever is right to create a
/** Create a `system_error` from an `errno` value
*
* This is expected to to whatever is right to create a
@@
-60,7
+68,19
@@
std::system_error errno_error(int errnum, const char* what)
return std::system_error(errno_code(errnum), what);
}
return std::system_error(errno_code(errnum), what);
}
+/** Create a `system_code` from `errno` (and clear it) */
+inline
+std::system_error errno_error()
+{
+ return std::system_error(errno_code());
}
}
+
+inline
+std::system_error errno_error(const char* what)
+{
+ return std::system_error(errno_code(), what);
}
}
+} // namespace simgrid::xbt
+
#endif
#endif