** operations: reset_watch, get_time
*/
-#define INLINE EXTERN_INLINE
#include <config.h>
#include <inttypes.h>
#include <stdlib.h>
#include <intprops.h>
-#include <systime.h>
+#include <timespec.h>
#include <unlocked-io.h>
static struct timespec TV1;
void
gettime (struct timespec *ts)
{
-#if HAVE_NANOTIME
+#if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME
+ clock_gettime (CLOCK_REALTIME, ts);
+#elif HAVE_NANOTIME
nanotime (ts);
#else
+ struct timeval tv;
+ gettimeofday (&tv, NULL);
+ ts->tv_sec = tv.tv_sec;
+ ts->tv_nsec = tv.tv_usec * 1000;
+#endif
+}
-# if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME
- if (clock_gettime (CLOCK_REALTIME, ts) == 0)
- return;
-# endif
-
- {
- struct timeval tv;
- gettimeofday (&tv, NULL);
- ts->tv_sec = tv.tv_sec;
- ts->tv_nsec = tv.tv_usec * 1000;
- }
+/* Return the current system time as a struct timespec. */
-#endif
+struct timespec
+current_timespec (void)
+{
+ struct timespec ts;
+ gettime (&ts);
+ return ts;
}
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#if ! defined TIMESPEC_H
-# define TIMESPEC_H
+#define TIMESPEC_H
-# include <time.h>
+#include <time.h>
#ifndef _GL_INLINE_HEADER_BEGIN
#error "Please include config.h first."
extern "C" {
#endif
+#include "arg-nonnull.h"
#include "verify.h"
/* Inverse resolution of timespec timestamps (in units per second),
return a.tv_sec + a.tv_nsec / 1e9;
}
-void gettime (struct timespec *);
-int settime (struct timespec const *);
+struct timespec current_timespec (void);
+void gettime (struct timespec *) _GL_ARG_NONNULL ((1));
+int settime (struct timespec const *) _GL_ARG_NONNULL ((1));
#ifdef __cplusplus
}
INLINE_HEADER_BEGIN
-#ifdef emacs
-# ifdef HAVE_X_WINDOWS
-# include <X11/X.h>
-# else
+#ifdef HAVE_X_WINDOWS
+# include <X11/X.h>
+#else
typedef unsigned long Time;
-# endif
#endif
/* On some configurations (hpux8.0, X11R4), sys/time.h and X11/Xos.h
return t.tv_nsec >= 0;
}
-/* Return current system time. */
-INLINE struct timespec
-current_timespec (void)
-{
- struct timespec r;
- gettime (&r);
- return r;
-}
-
/* defined in sysdep.c */
extern int set_file_times (int, const char *, struct timespec, struct timespec);
extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST;
/* defined in keyboard.c */
extern void set_waiting_for_input (struct timespec *);
-/* When lisp.h is not included Lisp_Object is not defined (this can
- happen when this file is used outside the src directory). */
-#ifdef emacs
-
/* Emacs uses the integer list (HI LO US PS) to represent the time
(HI << LO_TIME_BITS) + LO + US / 1e6 + PS / 1e12. */
enum { LO_TIME_BITS = 16 };
Lisp_Object, struct lisp_time *, double *);
extern struct timespec lisp_to_timespec (struct lisp_time);
extern struct timespec lisp_time_argument (Lisp_Object);
-#endif
INLINE_HEADER_END