From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs,gmane.emacs.devel Subject: bug#32746: setitimer API is obsolescent Date: Mon, 17 Sep 2018 09:06:43 -0700 Organization: UCLA Computer Science Department Message-ID: References: <83musggoyu.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------DCAE0692B10CDDD3EE2198D2" X-Trace: blaine.gmane.org 1537200316 19666 195.159.176.226 (17 Sep 2018 16:05:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Sep 2018 16:05:16 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Cc: Emacs-devel@gnu.org To: Eli Zaretskii , 32746@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 17 18:05:12 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g1w1O-0004yj-Mo for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Sep 2018 18:05:10 +0200 Original-Received: from localhost ([::1]:36371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1w3V-0008VG-2X for geb-bug-gnu-emacs@m.gmane.org; Mon, 17 Sep 2018 12:07:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1w3H-0008T7-Qw for bug-gnu-emacs@gnu.org; Mon, 17 Sep 2018 12:07:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1w3C-0005Jr-DX for bug-gnu-emacs@gnu.org; Mon, 17 Sep 2018 12:07:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39035) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g1w3C-0005JZ-8i for bug-gnu-emacs@gnu.org; Mon, 17 Sep 2018 12:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g1w3C-000892-0M for bug-gnu-emacs@gnu.org; Mon, 17 Sep 2018 12:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Sep 2018 16:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32746 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 32746-submit@debbugs.gnu.org id=B32746.153720041631295 (code B ref 32746); Mon, 17 Sep 2018 16:07:01 +0000 Original-Received: (at 32746) by debbugs.gnu.org; 17 Sep 2018 16:06:56 +0000 Original-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 Original-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 Original-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) Original-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) Original-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 Original-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) Original-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) In-Reply-To: <83musggoyu.fsf@gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:150374 gmane.emacs.devel:229901 Archived-At: 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--