diff options
| author | Paul Eggert | 2018-09-16 21:24:04 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-09-16 21:28:08 -0700 |
| commit | 295bacba61bd681798b55599551116db197b3388 (patch) | |
| tree | 167fe2864edc58f5f847c6a64133ad3463201986 /src | |
| parent | 75ab41d00d97c4de1ca343ce5273d1aad4975f37 (diff) | |
| download | emacs-295bacba61bd681798b55599551116db197b3388.tar.gz emacs-295bacba61bd681798b55599551116db197b3388.zip | |
Move current_timespec decl to timespec.h
This change was motivated by the desire to remove the weird
dependency of lib-src/profile.o on src/systime.h. profile.c
included systime.h only for current_timespec, and this
inclusion required systime.h to have #ifdef emacs in multiple
places and complicated further changes I have in mind.
The current_timespec decl belongs in timespec.h anyway,
and the main effect of this change is to move it there.
* lib-src/profile.c (INLINE): Remove.
Include timespec.h, not systime.h.
* lib/gettime.c (gettime): Prefer clock_gettime to nanotime,
and don’t worry about it failing on a CLOCK_REALTIME arg.
POSIX requires it to succeed and I don’t know of any
counterexamples where the fallbacks would work.
(current_timespec): Move here from src/systime.h.
Nowadays it seems to be better to not have this function
be inline.
* lib/timespec.h: Include arg-nonnull.h.
(current_timespec): New declaration.
(gettime, settime): Declare args to be nonnull.
* lib/gettime.c, lib/timespec.h: Copy from Gnulib.
* src/systime.h: Simplify by assuming ‘emacs’ is defined,
which it always is now.
(current_timespec): Move to lib/timespec.h.
Diffstat (limited to 'src')
| -rw-r--r-- | src/systime.h | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/src/systime.h b/src/systime.h index ede3d4eb12d..ad5ab857308 100644 --- a/src/systime.h +++ b/src/systime.h | |||
| @@ -23,12 +23,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 23 | 23 | ||
| 24 | INLINE_HEADER_BEGIN | 24 | INLINE_HEADER_BEGIN |
| 25 | 25 | ||
| 26 | #ifdef emacs | 26 | #ifdef HAVE_X_WINDOWS |
| 27 | # ifdef HAVE_X_WINDOWS | 27 | # include <X11/X.h> |
| 28 | # include <X11/X.h> | 28 | #else |
| 29 | # else | ||
| 30 | typedef unsigned long Time; | 29 | typedef unsigned long Time; |
| 31 | # endif | ||
| 32 | #endif | 30 | #endif |
| 33 | 31 | ||
| 34 | /* On some configurations (hpux8.0, X11R4), sys/time.h and X11/Xos.h | 32 | /* On some configurations (hpux8.0, X11R4), sys/time.h and X11/Xos.h |
| @@ -66,15 +64,6 @@ timespec_valid_p (struct timespec t) | |||
| 66 | return t.tv_nsec >= 0; | 64 | return t.tv_nsec >= 0; |
| 67 | } | 65 | } |
| 68 | 66 | ||
| 69 | /* Return current system time. */ | ||
| 70 | INLINE struct timespec | ||
| 71 | current_timespec (void) | ||
| 72 | { | ||
| 73 | struct timespec r; | ||
| 74 | gettime (&r); | ||
| 75 | return r; | ||
| 76 | } | ||
| 77 | |||
| 78 | /* defined in sysdep.c */ | 67 | /* defined in sysdep.c */ |
| 79 | extern int set_file_times (int, const char *, struct timespec, struct timespec); | 68 | extern int set_file_times (int, const char *, struct timespec, struct timespec); |
| 80 | extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST; | 69 | extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST; |
| @@ -82,10 +71,6 @@ extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST; | |||
| 82 | /* defined in keyboard.c */ | 71 | /* defined in keyboard.c */ |
| 83 | extern void set_waiting_for_input (struct timespec *); | 72 | extern void set_waiting_for_input (struct timespec *); |
| 84 | 73 | ||
| 85 | /* When lisp.h is not included Lisp_Object is not defined (this can | ||
| 86 | happen when this file is used outside the src directory). */ | ||
| 87 | #ifdef emacs | ||
| 88 | |||
| 89 | /* Emacs uses the integer list (HI LO US PS) to represent the time | 74 | /* Emacs uses the integer list (HI LO US PS) to represent the time |
| 90 | (HI << LO_TIME_BITS) + LO + US / 1e6 + PS / 1e12. */ | 75 | (HI << LO_TIME_BITS) + LO + US / 1e6 + PS / 1e12. */ |
| 91 | enum { LO_TIME_BITS = 16 }; | 76 | enum { LO_TIME_BITS = 16 }; |
| @@ -103,7 +88,6 @@ extern int decode_time_components (Lisp_Object, Lisp_Object, Lisp_Object, | |||
| 103 | Lisp_Object, struct lisp_time *, double *); | 88 | Lisp_Object, struct lisp_time *, double *); |
| 104 | extern struct timespec lisp_to_timespec (struct lisp_time); | 89 | extern struct timespec lisp_to_timespec (struct lisp_time); |
| 105 | extern struct timespec lisp_time_argument (Lisp_Object); | 90 | extern struct timespec lisp_time_argument (Lisp_Object); |
| 106 | #endif | ||
| 107 | 91 | ||
| 108 | INLINE_HEADER_END | 92 | INLINE_HEADER_END |
| 109 | 93 | ||