From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 16 16:20:08 2018 Received: (at submit) by debbugs.gnu.org; 16 Sep 2018 20:20:08 +0000 Received: from localhost ([127.0.0.1]:42325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1dWZ-0001vk-Cx for submit@debbugs.gnu.org; Sun, 16 Sep 2018 16:20:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44379) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1dWW-0001v7-E8 for submit@debbugs.gnu.org; Sun, 16 Sep 2018 16:20:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1dWP-00036g-9r for submit@debbugs.gnu.org; Sun, 16 Sep 2018 16:19:59 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:41574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g1dWP-00036Y-4l for submit@debbugs.gnu.org; Sun, 16 Sep 2018 16:19:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1dWM-00007E-Ui for bug-gnu-emacs@gnu.org; Sun, 16 Sep 2018 16:19:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1dWH-00030F-Rp for bug-gnu-emacs@gnu.org; Sun, 16 Sep 2018 16:19:54 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:49244) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g1dWH-0002ys-AC for bug-gnu-emacs@gnu.org; Sun, 16 Sep 2018 16:19:49 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 513E11614C4 for ; Sun, 16 Sep 2018 13:19:48 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 1Bq5-6zz8Zni for ; Sun, 16 Sep 2018 13:19:45 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 98ED5161511 for ; Sun, 16 Sep 2018 13:19:45 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id GH7pxcVai4SR for ; Sun, 16 Sep 2018 13:19:45 -0700 (PDT) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 69A631614C4 for ; Sun, 16 Sep 2018 13:19:45 -0700 (PDT) To: Emacs bug reports and feature requests From: Paul Eggert Subject: stop using obsolescent setitimer API Organization: UCLA Computer Science Department Message-ID: <3c8e16a0-bae6-4ee7-d8e1-5da307ff6e84@cs.ucla.edu> Date: Sun, 16 Sep 2018 13:19:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------7B671F95A44ECB3DC958A8C3" Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is a multi-part message in MIME format. --------------7B671F95A44ECB3DC958A8C3 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit POSIX obsoleted the getitimer/setitimer API a decade ago, and now's a good time for Emacs to stop using this obsolescent API, partly to simplify other timestamp improvements that I have in mind, partly to head off any other lurking bugs like the problem I just fixed in commit 238c7cd730819ddba2dbde3c46ee36136575695b relating to a mistaken assumption about the old API. Attached please find two proposed patches. The first simplifies Emacs proper to just use the current timer_gettime/timer_settime API instead (this is the standard replacement for the obsolescent API). The second patch affects only the MS-Windows code, modifying it to use the new API instead of the old one; I haven't tested it as I don't use MS-Windows. --------------7B671F95A44ECB3DC958A8C3 Content-Type: text/x-patch; name="0001-Simplify-by-not-worrying-about-setitimer.patch" Content-Disposition: attachment; filename="0001-Simplify-by-not-worrying-about-setitimer.patch" Content-Transfer-Encoding: quoted-printable >From 57c9f6a9dfd070fba31da73bfaa14769324be668 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 16 Sep 2018 09:02:15 -0700 Subject: [PATCH 1/2] Simplify by not worrying about setitimer MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit For a decade, POSIX has recommended that applications use timer_settime, not the obsolescent setitimer function. By now support for timer_settime is universal on POSIXish platforms, so it=E2=80=99s time to drop attempts to use setitimer. * configure.ac: Do not check for setitimer. * src/atimer.c (start_atimer, set_alarm) (debug_timer_callback): * src/profiler.c (setup_cpu_timer, Fprofiler_cpu_stop): * src/syssignal.h (PROFILER_CPU_SUPPORT): Simplify by not worrying about setitimer. * src/profiler.c (SETITIMER_RUNNING): Remove. All uses removed. --- admin/CPP-DEFINES | 1 - configure.ac | 2 +- src/atimer.c | 15 ++------------- src/profiler.c | 20 +------------------- src/syssignal.h | 3 +-- 5 files changed, 5 insertions(+), 36 deletions(-) diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index 04d1ff76f3..86a9a3c820 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -251,7 +251,6 @@ HAVE_RSVG HAVE_SELECT HAVE_SENDTO HAVE_SEQPACKET -HAVE_SETITIMER HAVE_SETLOCALE HAVE_SETRLIMIT HAVE_SHARED_GAME_DIR diff --git a/configure.ac b/configure.ac index 6f3d7338c3..9277f3789f 100644 --- a/configure.ac +++ b/configure.ac @@ -4013,7 +4013,7 @@ AC_DEFUN lrand48 random rint trunc \ select getpagesize setlocale newlocale \ getrlimit setrlimit shutdown \ -pthread_sigmask strsignal setitimer \ +pthread_sigmask strsignal \ sendto recvfrom getsockname getifaddrs freeifaddrs \ gai_strerror sync \ getpwent endpwent getgrent endgrent \ diff --git a/src/atimer.c b/src/atimer.c index 505f6bcea1..5848627d45 100644 --- a/src/atimer.c +++ b/src/atimer.c @@ -113,7 +113,7 @@ start_atimer (enum atimer_type type, struct timespec = timestamp, sigset_t oldset; =20 /* Round TIMESTAMP up to the next full second if we don't have itimers= . */ -#if ! (defined HAVE_ITIMERSPEC || defined HAVE_SETITIMER) +#ifndef HAVE_ITIMERSPEC if (timestamp.tv_nsec !=3D 0 && timestamp.tv_sec < TYPE_MAXIMUM (time_= t)) timestamp =3D make_timespec (timestamp.tv_sec + 1, 0); #endif @@ -295,9 +295,6 @@ set_alarm (void) { if (atimers) { -#ifdef HAVE_SETITIMER - struct itimerval it; -#endif struct timespec now, interval; =20 #ifdef HAVE_ITIMERSPEC @@ -325,15 +322,7 @@ set_alarm (void) interval =3D (timespec_cmp (atimers->expiration, now) <=3D 0 ? make_timespec (0, 1000 * 1000) : timespec_sub (atimers->expiration, now)); - -#ifdef HAVE_SETITIMER - - memset (&it, 0, sizeof it); - it.it_value =3D make_timeval (interval); - setitimer (ITIMER_REAL, &it, 0); -#else /* not HAVE_SETITIMER */ alarm (max (interval.tv_sec, 1)); -#endif /* not HAVE_SETITIMER */ } } =20 @@ -495,7 +484,7 @@ debug_timer_callback (struct atimer *t) else if (result >=3D 0) { bool intime =3D true; -#if defined HAVE_ITIMERSPEC || defined HAVE_SETITIMER +#ifdef HAVE_ITIMERSPEC struct timespec delta =3D timespec_sub (now, r->expected); /* Too late if later than expected + 0.02s. FIXME: this should depend from system clock resolution. */ diff --git a/src/profiler.c b/src/profiler.c index 7330f8861f..23b82600f3 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -202,9 +202,8 @@ static bool profiler_timer_ok; static enum profiler_cpu_running { NOT_RUNNING, #ifdef HAVE_ITIMERSPEC - TIMER_SETTIME_RUNNING, + TIMER_SETTIME_RUNNING #endif - SETITIMER_RUNNING } profiler_cpu_running; =20 @@ -262,7 +261,6 @@ static int setup_cpu_timer (Lisp_Object sampling_interval) { struct sigaction action; - struct itimerval timer; struct timespec interval; int billion =3D 1000000000; =20 @@ -318,12 +316,6 @@ setup_cpu_timer (Lisp_Object sampling_interval) } #endif =20 -#ifdef HAVE_SETITIMER - timer.it_value =3D timer.it_interval =3D make_timeval (interval); - if (setitimer (ITIMER_PROF, &timer, 0) =3D=3D 0) - return SETITIMER_RUNNING; -#endif - return NOT_RUNNING; } =20 @@ -380,16 +372,6 @@ Return non-nil if the profiler was running. */) } break; #endif - -#ifdef HAVE_SETITIMER - case SETITIMER_RUNNING: - { - struct itimerval disable; - memset (&disable, 0, sizeof disable); - setitimer (ITIMER_PROF, &disable, 0); - } - break; -#endif } =20 signal (SIGPROF, SIG_IGN); diff --git a/src/syssignal.h b/src/syssignal.h index 0887eacb05..790413178e 100644 --- a/src/syssignal.h +++ b/src/syssignal.h @@ -47,8 +47,7 @@ extern void unblock_tty_out_signal (sigset_t const *); # define HAVE_ITIMERSPEC #endif =20 -#if (defined SIGPROF && !defined PROFILING \ - && (defined HAVE_SETITIMER || defined HAVE_ITIMERSPEC)) +#if defined SIGPROF && !defined PROFILING && defined HAVE_ITIMERSPEC # define PROFILER_CPU_SUPPORT #endif =20 --=20 2.17.1 --------------7B671F95A44ECB3DC958A8C3 Content-Type: text/x-patch; name="0002-Adjust-w32-to-emulate-timer_settime-not-setitimer.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0002-Adjust-w32-to-emulate-timer_settime-not-setitimer.patch" >From aeec1bcc629a722cba7413287f965e4ab3dc9495 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 16 Sep 2018 12:35:58 -0700 Subject: [PATCH 2/2] Adjust w32 to emulate timer_settime, not setitimer This adjusts the w32 code to emulate the current timer_settime etc. functions instead of the obsolescent setitimer etc. functions. * nt/inc/sys/time.h (ITIMER_REAL, ITIMER_PROF): Remove. All uses removed. (struct itimerspec, pthread_attr_t, union sigval, struct sigevent) (SIGEV_SIGNAL, TIMER_ABSTIME, CLOCK_REALTIME) (CLOCK_THREAD_CPUTIME_ID, timer_t): New definitions. * src/w32proc.c (struct itimer_data, stop_timer_thread): (start_timer_thread): Clock type is now clockid_t, not int. All uses changed. (timer_create, timer_gettime, timer_settime): New functions, replacing getitimer and setitimer. All uses changed. --- nt/inc/sys/time.h | 38 +++++++++--- src/w32proc.c | 143 ++++++++++++++++++++++++---------------------- 2 files changed, 106 insertions(+), 75 deletions(-) diff --git a/nt/inc/sys/time.h b/nt/inc/sys/time.h index 6f67e5db4e..d03bc456ea 100644 --- a/nt/inc/sys/time.h +++ b/nt/inc/sys/time.h @@ -3,19 +3,41 @@ #include_next -#define ITIMER_REAL 0 -#define ITIMER_PROF 1 +struct itimerspec +{ + struct timespec it_interval; /* timer interval */ + struct timespec it_value; /* current value */ +}; -struct itimerval +typedef struct pthread_attr_t *pthread_attr_t; +union sigval +{ + int sival_int; + void *sival_ptr; +}; +struct sigevent { - struct timeval it_interval; /* timer interval */ - struct timeval it_value; /* current value */ + int sigev_notify; + int sigev_signo; + union sigval sigev_value; + void (*sigev_notify_function) (union sigval); + pthread_attr_t *sigev_notify_attributes; }; +#define SIGEV_SIGNAL 0 -int getitimer (int, struct itimerval *); -int setitimer (int, struct itimerval *, struct itimerval *); +#define TIMER_ABSTIME 1 +typedef enum { CLOCK_REALTIME, CLOCK_THREAD_CPUTIME_ID } clockid_t; +#define CLOCK_REALTIME CLOCK_REALTIME +#define CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID +typedef struct +{ + clockid_t clockid; +} timer_t; +int timer_create (clockid_t, struct sigevent *restrict, timer_t *restrict); +int timer_settime (timer_t, int, struct itimerspec const *, + struct itimerspec *restrict); +int timer_getoverrun (timer_t); #endif /* SYS_TIME_H_INCLUDED */ /* end of sys/time.h */ - diff --git a/src/w32proc.c b/src/w32proc.c index cb02ba6341..23869768cf 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -89,7 +89,7 @@ sys_signal (int sig, signal_handler handler) signal_handler old; /* SIGCHLD is needed for supporting subprocesses, see sys_kill - below. SIGALRM and SIGPROF are used by setitimer. All the + below. SIGALRM and SIGPROF are used by timer_settime. All the others are the only ones supported by the MS runtime. */ if (!(sig == SIGINT || sig == SIGSEGV || sig == SIGILL || sig == SIGFPE || sig == SIGABRT || sig == SIGTERM @@ -261,7 +261,8 @@ setsid (void) /* Emulations of interval timers. - Limitations: only ITIMER_REAL and ITIMER_PROF are supported. + Limitations: only CLOCK_REALTIME and CLOCK_THREAD_CPUTIME_ID are + supported, and only a single timer of each time is supported. Implementation: a separate thread is started for each timer type, the thread calls the appropriate signal handler when the timer @@ -271,7 +272,7 @@ struct itimer_data { volatile ULONGLONG expire; volatile ULONGLONG reload; volatile int terminate; - int type; + clockid_t type; HANDLE caller_thread; HANDLE timer_thread; }; @@ -357,11 +358,11 @@ static DWORD WINAPI timer_loop (LPVOID arg) { struct itimer_data *itimer = (struct itimer_data *)arg; - int which = itimer->type; - int sig = (which == ITIMER_REAL) ? SIGALRM : SIGPROF; - CRITICAL_SECTION *crit = (which == ITIMER_REAL) ? &crit_real : &crit_prof; + bool realtime = itimer->type == CLOCK_REALTIME; + int sig = realtime ? SIGALRM : SIGPROF; + CRITICAL_SECTION *crit = realtime ? &crit_real : &crit_prof; const DWORD max_sleep = MAX_SINGLE_SLEEP * 1000 / TIMER_TICKS_PER_SEC; - HANDLE hth = (which == ITIMER_REAL) ? NULL : itimer->caller_thread; + HANDLE hth = realtime ? NULL : itimer->caller_thread; while (1) { @@ -369,7 +370,7 @@ timer_loop (LPVOID arg) signal_handler handler; ULONGLONG now, expire, reload; - /* Load new values if requested by setitimer. */ + /* Load new values if requested by timer_settime. */ EnterCriticalSection (crit); expire = itimer->expire; reload = itimer->reload; @@ -480,10 +481,10 @@ timer_loop (LPVOID arg) } static void -stop_timer_thread (int which) +stop_timer_thread (clockid_t clockid) { struct itimer_data *itimer = - (which == ITIMER_REAL) ? &real_itimer : &prof_itimer; + clockid == CLOCK_REALTIME ? &real_itimer : &prof_itimer; int i; DWORD err = 0, exit_code = 255; BOOL status; @@ -526,9 +527,9 @@ void term_timers (void) { if (real_itimer.timer_thread) - stop_timer_thread (ITIMER_REAL); + stop_timer_thread (CLOCK_REALTIME); if (prof_itimer.timer_thread) - stop_timer_thread (ITIMER_PROF); + stop_timer_thread (CLOCK_THREAD_CPUTIME_ID); /* We are going to delete the critical sections, so timers cannot work after this. */ @@ -564,12 +565,12 @@ init_timers (void) } static int -start_timer_thread (int which) +start_timer_thread (clockid_t clockid) { DWORD exit_code, tid; HANDLE th; struct itimer_data *itimer = - (which == ITIMER_REAL) ? &real_itimer : &prof_itimer; + clockid == CLOCK_REALTIME ? &real_itimer : &prof_itimer; if (itimer->timer_thread && GetExitCodeThread (itimer->timer_thread, &exit_code) @@ -597,7 +598,7 @@ start_timer_thread (int which) return -1; } itimer->terminate = 0; - itimer->type = which; + itimer->type = clockid; itimer->caller_thread = th; /* Request that no more than 64KB of stack be reserved for this thread, to avoid reserving too much memory, which would get in @@ -616,24 +617,42 @@ start_timer_thread (int which) /* This is needed to make sure that the timer thread running for profiling gets CPU as soon as the Sleep call terminates. */ - if (which == ITIMER_PROF) + if (clockid == CLOCK_THREAD_CPUTIME_ID) SetThreadPriority (itimer->timer_thread, THREAD_PRIORITY_TIME_CRITICAL); return 0; } -/* Most of the code of getitimer and setitimer (but not of their +int +timer_create (clockid_t clockid, struct sigevent *restrict evp, + timer_t *restrict timerid) +{ + if ((clockid == CLOCK_REALTIME || clockid == CLOCK_THREAD_CPUTIME_ID) + && (!evp || (evp->sigev_notify == SIGEV_SIGNAL + && evp->sigev_signo == (clockid == CLOCK_REALTIME + ? SIGALRM : SIGPROF) + && evp->sigev_value.sival_ptr == timerid))) + { + timerid->clockid = clockid; + return 0; + } + errno = EINVAL; + return -1; +} + +/* Most of the code of timer_gettime and timer_settime (but not of their subroutines) was shamelessly stolen from itimer.c in the DJGPP library, see www.delorie.com/djgpp. */ int -getitimer (int which, struct itimerval *value) +timer_gettime (timer_t timerid, struct itimerspec *value) { volatile ULONGLONG *t_expire; volatile ULONGLONG *t_reload; ULONGLONG expire, reload; - __int64 usecs; CRITICAL_SECTION *crit; struct itimer_data *itimer; + HANDLE thread_hand; + bool realtime = timerid.clockid == CLOCK_REALTIME; if (disable_itimers) return -1; @@ -644,21 +663,18 @@ getitimer (int which, struct itimerval *value) return -1; } - if (which != ITIMER_REAL && which != ITIMER_PROF) - { - errno = EINVAL; - return -1; - } - - itimer = (which == ITIMER_REAL) ? &real_itimer : &prof_itimer; + itimer = realtime ? &real_itimer : &prof_itimer; - ticks_now = w32_get_timer_time ((which == ITIMER_REAL) + ticks_now = w32_get_timer_time (realtime ? NULL : GetCurrentThread ()); + itimer = realtime ? &real_itimer : &prof_itimer; + + ticks_now = w32_get_timer_time (thread_hand); t_expire = &itimer->expire; t_reload = &itimer->reload; - crit = (which == ITIMER_REAL) ? &crit_real : &crit_prof; + crit = realtime ? &crit_real : &crit_prof; EnterCriticalSection (crit); reload = *t_reload; @@ -669,25 +685,25 @@ getitimer (int which, struct itimerval *value) expire -= ticks_now; value->it_value.tv_sec = expire / TIMER_TICKS_PER_SEC; - usecs = - (expire % TIMER_TICKS_PER_SEC) * (__int64)1000000 / TIMER_TICKS_PER_SEC; - value->it_value.tv_usec = usecs; + value->it_value.tv_nsec = (expire % TIMER_TICKS_PER_SEC + * (1000000000 / TIMER_TICKS_PER_SEC)); value->it_interval.tv_sec = reload / TIMER_TICKS_PER_SEC; - usecs = - (reload % TIMER_TICKS_PER_SEC) * (__int64)1000000 / TIMER_TICKS_PER_SEC; - value->it_interval.tv_usec= usecs; - + value->it_interval.tv_nsec= (reload % TIMER_TICKS_PER_SEC + * (1000000000 / TIMER_TICKS_PER_SEC)); return 0; } int -setitimer(int which, struct itimerval *value, struct itimerval *ovalue) +timer_settime (timer_t timerid, int flags, + struct itimerspec const *restrict value, + struct itimerspec *restrict ovalue) { volatile ULONGLONG *t_expire, *t_reload; ULONGLONG expire, reload, expire_old, reload_old; - __int64 usecs; + int ns; CRITICAL_SECTION *crit; - struct itimerval tem, *ptem; + struct itimerspec tem, *ptem; + bool realtime = timerid.clockid == CLOCK_REALTIME; if (disable_itimers) return -1; @@ -710,18 +726,15 @@ setitimer(int which, struct itimerval *value, struct itimerval *ovalue) else ptem = &tem; - if (getitimer (which, ptem)) /* also sets ticks_now */ + if (timer_gettime (timerid, ptem)) /* also sets ticks_now */ return -1; /* errno already set */ - t_expire = - (which == ITIMER_REAL) ? &real_itimer.expire : &prof_itimer.expire; - t_reload = - (which == ITIMER_REAL) ? &real_itimer.reload : &prof_itimer.reload; - - crit = (which == ITIMER_REAL) ? &crit_real : &crit_prof; + t_expire = realtime ? &real_itimer.expire : &prof_itimer.expire; + t_reload = realtime ? &real_itimer.reload : &prof_itimer.reload; + crit = realtime ? &crit_real : &crit_prof; if (!value - || (value->it_value.tv_sec == 0 && value->it_value.tv_usec == 0)) + || (value->it_value.tv_sec == 0 && value->it_value.tv_nsec == 0)) { EnterCriticalSection (crit); /* Disable the timer. */ @@ -733,28 +746,23 @@ setitimer(int which, struct itimerval *value, struct itimerval *ovalue) reload = value->it_interval.tv_sec * TIMER_TICKS_PER_SEC; - usecs = value->it_interval.tv_usec; + ns = value->it_interval.tv_nsec; if (value->it_interval.tv_sec == 0 - && usecs && usecs * TIMER_TICKS_PER_SEC < clocks_min * 1000000) + && 0 < ns && ns < clocks_min * (1000000000 / TIMER_TICKS_PER_SEC)) reload = clocks_min; else - { - usecs *= TIMER_TICKS_PER_SEC; - reload += usecs / 1000000; - } + reload += ns / (1000000000 / TIMER_TICKS_PER_SEC); - expire = value->it_value.tv_sec * TIMER_TICKS_PER_SEC; - usecs = value->it_value.tv_usec; - if (value->it_value.tv_sec == 0 - && usecs * TIMER_TICKS_PER_SEC < clocks_min * 1000000) + expire = ex.tv_sec * TIMER_TICKS_PER_SEC; + ns = ex.tv_nsec; + if (ex.tv_sec == 0 + && 0 < ns && ns < clocks_min * (1000000000 / TIMER_TICKS_PER_SEC)) expire = clocks_min; else - { - usecs *= TIMER_TICKS_PER_SEC; - expire += usecs / 1000000; - } + reload += ns / (1000000000 / TIMER_TICKS_PER_SEC); - expire += ticks_now; + if (flags & TIMER_ABSTIME) + expire += ticks_now; EnterCriticalSection (crit); expire_old = *t_expire; @@ -766,20 +774,21 @@ setitimer(int which, struct itimerval *value, struct itimerval *ovalue) } LeaveCriticalSection (crit); - return start_timer_thread (which); + return start_timer_thread (timerid.clockid); } int alarm (int seconds) { -#ifdef HAVE_SETITIMER - struct itimerval new_values, old_values; +#ifdef HAVE_ITIMERSPEC + struct itimerspec new_values, old_values; new_values.it_value.tv_sec = seconds; - new_values.it_value.tv_usec = 0; - new_values.it_interval.tv_sec = new_values.it_interval.tv_usec = 0; + new_values.it_value.tv_nsec = 0; + new_values.it_interval.tv_sec = new_values.it_interval.tv_nsec = 0; - if (setitimer (ITIMER_REAL, &new_values, &old_values) < 0) + timer_t id = { .clockid = CLOCK_REALTIME }; + if (timer_settime (id, 0, &new_values, &old_values) < 0) return 0; return old_values.it_value.tv_sec; #else -- 2.17.1 --------------7B671F95A44ECB3DC958A8C3-- From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 16 16:24:11 2018 Received: (at control) by debbugs.gnu.org; 16 Sep 2018 20:24:11 +0000 Received: from localhost ([127.0.0.1]:42330 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1daV-00022V-IJ for submit@debbugs.gnu.org; Sun, 16 Sep 2018 16:24:11 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41870) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1daU-00022I-11 for control@debbugs.gnu.org; Sun, 16 Sep 2018 16:24:10 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 38AAA1614C4 for ; Sun, 16 Sep 2018 13:24:04 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id zOktGIyCW3Ly for ; Sun, 16 Sep 2018 13:24:03 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 943AE161511 for ; Sun, 16 Sep 2018 13:24:03 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0r46g6BQNm_H for ; Sun, 16 Sep 2018 13:24:03 -0700 (PDT) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 766631614C4 for ; Sun, 16 Sep 2018 13:24:03 -0700 (PDT) To: control@debbugs.gnu.org From: Paul Eggert Subject: 32746 has a patch Organization: UCLA Computer Science Department Message-ID: Date: Sun, 16 Sep 2018 13:24:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tags 32746 patch From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 17 10:48:14 2018 Received: (at 32746) by debbugs.gnu.org; 17 Sep 2018 14:48:14 +0000 Received: from localhost ([127.0.0.1]:43248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1uov-0006Av-VU for submit@debbugs.gnu.org; Mon, 17 Sep 2018 10:48:14 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1uou-0006Ai-Pr for 32746@debbugs.gnu.org; Mon, 17 Sep 2018 10:48:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1uoo-0006Ab-Tc for 32746@debbugs.gnu.org; Mon, 17 Sep 2018 10:48:07 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1uof-00061D-6V; Mon, 17 Sep 2018 10:47:57 -0400 Received: from [176.228.60.248] (port=1637 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1g1uoe-0000rB-N3; Mon, 17 Sep 2018 10:47:57 -0400 Date: Mon, 17 Sep 2018 17:47:53 +0300 Message-Id: <83musggoyu.fsf@gnu.org> From: Eli Zaretskii To: 32746@debbugs.gnu.org In-reply-to: (message from Paul Eggert on Sun, 16 Sep 2018 13:32:33 -0700) Subject: Re: setitimer API is obsolescent References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32746 Cc: Emacs-devel@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) > From: Paul Eggert > Date: Sun, 16 Sep 2018 13:32:33 -0700 > > POSIX made the getitimer/setitimer API obsolescent a decade ago, and now's a > good time for Emacs to rely on the current timer_gettime/timer_settime API > instead. I've proposed patches for this in Bug#32746. If you know a platform > that is a current porting target of Emacs and lacks timer_gettime/timer_settime > but has getitimer/setitimer, please send email to <32746@debbugs.gnu.org> about > it. (MS-Windows lacks both APIs; the proposed patches attempt to address that > special case.) Thanks, I will send my comments to the MS-Windows part of the patch in a moment. However, I think it might be too early to remove support for setitimer, because some platforms have problems with it. AFAIK, macOS and some *BSD version either don't have that family or have buggy implementations. Supporting the old APIs only needs a couple of #ifdef's in 3 files, so it doesn't sound like a terrible maintenance burden. Btw, it would be good to have some tests for these facilities, as currently we don't have any practical means to make sure we don't introduce bugs when we switch to alternative APIs. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 17 11:02:21 2018 Received: (at 32746) by debbugs.gnu.org; 17 Sep 2018 15:02:22 +0000 Received: from localhost ([127.0.0.1]:43263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1v2b-0006XD-LM for submit@debbugs.gnu.org; Mon, 17 Sep 2018 11:02:21 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33935) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1v2Z-0006Wz-Ok for 32746@debbugs.gnu.org; Mon, 17 Sep 2018 11:02:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1v2K-0007Eg-8W for 32746@debbugs.gnu.org; Mon, 17 Sep 2018 11:02:09 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1v2G-0007D3-OO; Mon, 17 Sep 2018 11:02:02 -0400 Received: from [176.228.60.248] (port=2495 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1g1v2G-0007sV-9f; Mon, 17 Sep 2018 11:02:00 -0400 Date: Mon, 17 Sep 2018 18:01:56 +0300 Message-Id: <83lg80gobf.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <3c8e16a0-bae6-4ee7-d8e1-5da307ff6e84@cs.ucla.edu> (message from Paul Eggert on Sun, 16 Sep 2018 13:19:45 -0700) Subject: Re: bug#32746: stop using obsolescent setitimer API References: <3c8e16a0-bae6-4ee7-d8e1-5da307ff6e84@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 32746 Cc: 32746@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) > From: Paul Eggert > Date: Sun, 16 Sep 2018 13:19:45 -0700 > > POSIX obsoleted the getitimer/setitimer API a decade ago, and now's a good time > for Emacs to stop using this obsolescent API, partly to simplify other timestamp > improvements that I have in mind, partly to head off any other lurking bugs like > the problem I just fixed in commit 238c7cd730819ddba2dbde3c46ee36136575695b > relating to a mistaken assumption about the old API. > > Attached please find two proposed patches. The first simplifies Emacs proper to > just use the current timer_gettime/timer_settime API instead (this is the > standard replacement for the obsolescent API). The second patch affects only the > MS-Windows code, modifying it to use the new API instead of the old one; I > haven't tested it as I don't use MS-Windows. Thanks, I have a couple of comments/questions about the MS-Windows changes (thanks for working on that): > +struct sigevent > { > - struct timeval it_interval; /* timer interval */ > - struct timeval it_value; /* current value */ > + int sigev_notify; > + int sigev_signo; > + union sigval sigev_value; > + void (*sigev_notify_function) (union sigval); > + pthread_attr_t *sigev_notify_attributes; I'd prefer not to use pthread_attr_t, as that could clash with some MinGW header. > +typedef enum { CLOCK_REALTIME, CLOCK_THREAD_CPUTIME_ID } clockid_t; Some versions of MinGW have clockid_t (for clock_gettime and clock_settime), so this might cause conflicts. > +#define CLOCK_REALTIME CLOCK_REALTIME > +#define CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID Some of these are declared/defined in MinGW headers in some versions. > + HANDLE thread_hand; This seems to be unused, and is probably related to the other issues below. > - itimer = (which == ITIMER_REAL) ? &real_itimer : &prof_itimer; > + itimer = realtime ? &real_itimer : &prof_itimer; > > - ticks_now = w32_get_timer_time ((which == ITIMER_REAL) > + ticks_now = w32_get_timer_time (realtime > ? NULL > : GetCurrentThread ()); > > + itimer = realtime ? &real_itimer : &prof_itimer; > + > + ticks_now = w32_get_timer_time (thread_hand); This seems to do the same stuff twicer, using thread_hand that is uninitialized. > - expire = value->it_value.tv_sec * TIMER_TICKS_PER_SEC; > - usecs = value->it_value.tv_usec; > - if (value->it_value.tv_sec == 0 > - && usecs * TIMER_TICKS_PER_SEC < clocks_min * 1000000) > + expire = ex.tv_sec * TIMER_TICKS_PER_SEC; > + ns = ex.tv_nsec; > + if (ex.tv_sec == 0 > + && 0 < ns && ns < clocks_min * (1000000000 / TIMER_TICKS_PER_SEC)) > expire = clocks_min; This seems to use an undefined variable 'ex'. > - expire += ticks_now; > + if (flags & TIMER_ABSTIME) > + expire += ticks_now; I don't think I understand the reason for the condition you added. > +#ifdef HAVE_ITIMERSPEC If we will have a test for itimerspec, we will probably need to edit nt/mingw-cfg.site to keep the configure script happy. Thanks again for working on this. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 17 12:06:56 2018 Received: (at 32746) by debbugs.gnu.org; 17 Sep 2018 16:06:56 +0000 Received: from localhost ([127.0.0.1]:43293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1w35-00088h-OD for submit@debbugs.gnu.org; Mon, 17 Sep 2018 12:06:56 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:54088) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1w33-00088U-Ui for 32746@debbugs.gnu.org; Mon, 17 Sep 2018 12:06:54 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0CFA4160EBD; Mon, 17 Sep 2018 09:06:48 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id lsKCcs-mSjk1; Mon, 17 Sep 2018 09:06:46 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E0650160DFC; Mon, 17 Sep 2018 09:06:46 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Y8sm88AdlhGz; Mon, 17 Sep 2018 09:06:46 -0700 (PDT) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id B601D160EBD; Mon, 17 Sep 2018 09:06:46 -0700 (PDT) Subject: Re: setitimer API is obsolescent To: Eli Zaretskii , 32746@debbugs.gnu.org References: <83musggoyu.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Mon, 17 Sep 2018 09:06:43 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <83musggoyu.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------DCAE0692B10CDDD3EE2198D2" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 32746 Cc: Emacs-devel@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------DCAE0692B10CDDD3EE2198D2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Eli Zaretskii wrote: > However, I think it might be too early to remove support for > setitimer, because some platforms have problems with it. AFAIK, macOS > and some *BSD version either don't have that family or have buggy > implementations. In that case never mind about removing use of setitimer. I'm attaching a patch against my previous proposal for fixup on the MS-Windows side, in the light of your other comments; good luck with it, and feel free to ignore the whole thing if it doesn't work. As before, it's untested and no doubt it has problems. --------------DCAE0692B10CDDD3EE2198D2 Content-Type: text/x-patch; name="0001-Patch-inspired-by-Eli-s-review-Bug-32764-10.patch" Content-Disposition: attachment; filename="0001-Patch-inspired-by-Eli-s-review-Bug-32764-10.patch" Content-Transfer-Encoding: quoted-printable >From b52b0505bb53fa00943847eabc60b096bbbdfb80 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 17 Sep 2018 09:04:06 -0700 Subject: [PATCH] =3D?UTF-8?q?Patch=3D20inspired=3D20by=3D20Eli=3DE2=3D80=3D= 99s=3D20review?=3D =3D?UTF-8?q?=3D20(Bug#32764#10)?=3D MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * nt/inc/sys/time.h (pthread_attr_t): Remove. (struct sigevent): Remove sigev_notify_attributes. (CLOCK_REALTIME, clockid_t): Define only if CLOCK_REALTIME isn=E2=80=99t already defined. (clockid_t): Just use int rather than getting fancy. (CLOCK_REALTIME, CLOCK_THREAD_CPUTIME_ID): Just use a macro rather than getting fancy. (CLOCK_THREAD_CPUTIME_ID): Define to an unlikely int instead of getting fancy. * nt/mingw-cfg.site (ac_cv_func_timer_settime): Set to yes. * src/w32proc.c (timer_gettime): Remove unused local and stray use of it. (timer_settime): Fix use of undeclared var. Reverse sense of TIMER_ABSTIME. --- nt/inc/sys/time.h | 15 ++++++++++----- nt/mingw-cfg.site | 2 ++ src/w32proc.c | 10 ++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/nt/inc/sys/time.h b/nt/inc/sys/time.h index d03bc456ea..b238e36967 100644 --- a/nt/inc/sys/time.h +++ b/nt/inc/sys/time.h @@ -9,7 +9,6 @@ struct itimerspec struct timespec it_value; /* current value */ }; =20 -typedef struct pthread_attr_t *pthread_attr_t; union sigval { int sival_int; @@ -21,14 +20,20 @@ struct sigevent int sigev_signo; union sigval sigev_value; void (*sigev_notify_function) (union sigval); - pthread_attr_t *sigev_notify_attributes; + /* Although POSIX requires 'pthread_attr_t *sigev_notify_attributes;', + that might clash with MinGW and Emacs *doesn=E2=80=99t need it. */ }; #define SIGEV_SIGNAL 0 =20 #define TIMER_ABSTIME 1 -typedef enum { CLOCK_REALTIME, CLOCK_THREAD_CPUTIME_ID } clockid_t; -#define CLOCK_REALTIME CLOCK_REALTIME -#define CLOCK_THREAD_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID + +#ifndef CLOCK_REALTIME +typedef int clockid_t; +# define CLOCK_REALTIME 0 +#endif +#ifndef CLOCK_THREAD_CPUTIME_ID +# define CLOCK_THREAD_CPUTIME_ID 106 /* unlikely to clash */ +#endif typedef struct { clockid_t clockid; diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site index d9a824008c..25d5a40eb1 100644 --- a/nt/mingw-cfg.site +++ b/nt/mingw-cfg.site @@ -132,5 +132,7 @@ gl_cv_func_svid_putenv=3Dyes ac_cv_func_sbrk=3Dyes ac_cv_func_getrlimit=3Dyes ac_cv_func_setrlimit=3Dyes +# Implemented in w32proc.c +ac_cv_func_timer_settime=3Dyes # GCC warnings that produce too much noise gl_cv_warn_c__Wredundant_decls=3Dno diff --git a/src/w32proc.c b/src/w32proc.c index 23869768cf..20b7d6a220 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -651,7 +651,6 @@ timer_gettime (timer_t timerid, struct itimerspec *va= lue) ULONGLONG expire, reload; CRITICAL_SECTION *crit; struct itimer_data *itimer; - HANDLE thread_hand; bool realtime =3D timerid.clockid =3D=3D CLOCK_REALTIME; =20 if (disable_itimers) @@ -671,7 +670,6 @@ timer_gettime (timer_t timerid, struct itimerspec *va= lue) =20 itimer =3D realtime ? &real_itimer : &prof_itimer; =20 - ticks_now =3D w32_get_timer_time (thread_hand); t_expire =3D &itimer->expire; t_reload =3D &itimer->reload; crit =3D realtime ? &crit_real : &crit_prof; @@ -753,15 +751,15 @@ timer_settime (timer_t timerid, int flags, else reload +=3D ns / (1000000000 / TIMER_TICKS_PER_SEC); =20 - expire =3D ex.tv_sec * TIMER_TICKS_PER_SEC; - ns =3D ex.tv_nsec; - if (ex.tv_sec =3D=3D 0 + expire =3D value->it_value.tv_sec * TIMER_TICKS_PER_SEC; + ns =3D value->it_value.tv_nsec; + if (value->it_value.tv_sec =3D=3D 0 && 0 < ns && ns < clocks_min * (1000000000 / TIMER_TICKS_PER_SEC)) expire =3D clocks_min; else reload +=3D ns / (1000000000 / TIMER_TICKS_PER_SEC); =20 - if (flags & TIMER_ABSTIME) + if (! (flags & TIMER_ABSTIME)) expire +=3D ticks_now; =20 EnterCriticalSection (crit); --=20 2.17.1 --------------DCAE0692B10CDDD3EE2198D2-- From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 10 08:12:54 2020 Received: (at 32746) by debbugs.gnu.org; 10 Aug 2020 12:12:54 +0000 Received: from localhost ([127.0.0.1]:34777 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k56fd-0001Sj-Rh for submit@debbugs.gnu.org; Mon, 10 Aug 2020 08:12:54 -0400 Received: from quimby.gnus.org ([95.216.78.240]:47026) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k56fb-0001SS-AU for 32746@debbugs.gnu.org; Mon, 10 Aug 2020 08:12:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=YUUKgSZZccZW10s1Asrx5A0xBnkTw04fHdoVhx6e3AY=; b=iFOmpz2OR9rLRCm3aJtUo1wr2A mvm7XcqE3xfL5WlygR65FRzHke7HoMWOD+vBRFN5HJGo/cudWydzjyrqXJ6JbeXJKVMl3T1+fehG2 HgBKeEIPibg8unKz976dpovfxaPGZ4hTZLpVDMGIYzMCjT8r0XynP/COjqtyO0qxYmVo=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k56fJ-0003gu-Ru; Mon, 10 Aug 2020 14:12:44 +0200 From: Lars Ingebrigtsen To: Paul Eggert Subject: Re: bug#32746: setitimer API is obsolescent References: <83musggoyu.fsf@gnu.org> Date: Mon, 10 Aug 2020 14:12:32 +0200 In-Reply-To: (Paul Eggert's message of "Mon, 17 Sep 2018 09:06:43 -0700") Message-ID: <87lfim66of.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Paul Eggert writes: > Eli Zaretskii wrote: > >> However, I think it might be too early to remove support for >> setitimer, because some platforms have problems with it. AFAIK, macOS >> and some *BSD version either don't [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 32746 Cc: Eli Zaretskii , 32746@debbugs.gnu.org, Emacs-devel@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Paul Eggert writes: > Eli Zaretskii wrote: > >> However, I think it might be too early to remove support for >> setitimer, because some platforms have problems with it. AFAIK, macOS >> and some *BSD version either don't have that family or have buggy >> implementations. > > In that case never mind about removing use of setitimer. OK; it sounds like the decision was to not do this change any time soon, so I'm closing this bug report. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 10 08:13:02 2020 Received: (at control) by debbugs.gnu.org; 10 Aug 2020 12:13:03 +0000 Received: from localhost ([127.0.0.1]:34781 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k56fm-0001TI-2K for submit@debbugs.gnu.org; Mon, 10 Aug 2020 08:13:02 -0400 Received: from quimby.gnus.org ([95.216.78.240]:47042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k56fk-0001Sr-03 for control@debbugs.gnu.org; Mon, 10 Aug 2020 08:13:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lgsv8uuIHkRLdcXS6Z9TKsk5z2VWsIswmfu2pslSgMw=; b=UZ3MG6AL0z/2mvE1/QbfHU3wki TZaF+nbR97RDGhlubhAPVnKJyYRuByF6ct45hU8+q3oJnIbpWf5zq4ygKEb/bx9aBzLb62G6i8v3t Hv6My2FtJoS2RsdD8Ub74dAzLTw0C1cfxSvKapU/ua+9GwluQTWMCZqqibplzkiStppc=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k56fc-0003h2-6D for control@debbugs.gnu.org; Mon, 10 Aug 2020 14:12:54 +0200 Date: Mon, 10 Aug 2020 14:12:50 +0200 Message-Id: <87k0y666nx.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #32746 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 32746 wontfix close 32746 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 32746 wontfix close 32746 quit From unknown Fri Aug 15 15:35:31 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 08 Sep 2020 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator