chiark / gitweb /
Shun time(), since on Linux it is not monotonic with gettimeofday().
[disorder] / lib / syscalls.c
index 0415a2d9eaa6bb3ae0986097e555878c85a43aa2..b1756667fe22386283ea81f7054e2e7c9fcaf653 100644 (file)
@@ -15,7 +15,9 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-
+/** @file lib/syscalls.c
+ * @brief Error-checking library call wrappers
+ */
 #include "common.h"
 
 #include <unistd.h>
@@ -146,6 +148,15 @@ void xgettimeofday(struct timeval *tv, struct timezone *tz) {
   mustnotbeminus1("gettimeofday", gettimeofday(tv, tz));
 }
 
+time_t xtime(time_t *whenp) {
+  struct timeval tv;
+
+  xgettimeofday(&tv, NULL);
+  if(whenp)
+    *whenp = tv.tv_sec;
+  return tv.tv_sec;
+}
+
 /*
 Local Variables:
 c-basic-offset:2