Support for setitimer() on platforms lacking it
HP NonStop (currently) doesn't have setitimer(). The previous attempt of an emulation (reverted by this commit) was not a real substitute for a recurring itimer (as here we also don't have SA_RESTART, so can't re-arm the timer). As setitimer() is only used in cases of perceived latency and it doesn't affect correctness, it now gets disabled entirely, if NO_SETITIMER is set. HP NonStop does provide struct itimerval, but other platforms may not, so this is taken care of in this commit too, by setting NO_STRUCT_ITIMERVAL.
--- Makefile | 5 +++++ compat/itimer.c | 50 -------------------------------------------------- git-compat-util.h | 11 +++++++++-- 3 files changed, 14 insertions(+), 52 deletions(-) delete mode 100644 compat/itimer.c
Makefile +5 -0
@@ -157,6 +157,11 @@ all:: # Define NO_PREAD if you have a problem with pread() system call (e.g. # cygwin1.dll before v1.5.22). # +# Define NO_SETITIMER if you don't have setitimer() +# +# Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval +# This also implies NO_SETITIMER +# # Define NO_THREAD_SAFE_PREAD if your pread() implementation is not # thread-safe. (e.g. compat/pread.c or cygwin) #
compat/itimer.c deleted +0 -50
50 lines not on this page · raw message
git-compat-util.h +9 -2
@@ -162,9 +162,16 @@#define probe_utf8_pathname_composition (a,b)#endif +#ifdef NO_STRUCT_ITIMERVAL +struct itimerval { +struct timeval it_interval; +struct timeval it_value; +} +#define NO_SETITIMER +#endif +#ifdef NO_SETITIMER -#define setitimer (a,b,c) git_setitimer((a),(b),(c)) -extern int git_setitimer (int ,const struct itimerval *,struct itimerval *); +#define setitimer (which,value,ovalue)#endif #ifdef MKDIR_WO_TRAILING_SLASH
Signature · 1 line
1.7.12
Quoted 9 lines · Joachim Schmitz
HP NonStop (currently) doesn't have
setitimer(). The previous attempt of an emulation (reverted by this commit) was not a real substitute for a recurring itimer (as here we also don't haveSA_RESTART, so can't re-arm the timer). Assetitimer()is only used in cases of perceived latency and it doesn't affect correctness, it now gets disabled entirely, ifNO_SETITIMERis set. HP NonStop does provide struct itimerval, but other platforms may not, so this is taken care of in this commit too, by settingNO_STRUCT_ITIMERVAL.Signed-off-by Joachim Schmitz <[email protected]>
The end-result looks simple and nice (thanks for NO_STRUCT_ITIMERVAL).
As we are not going to include the earlier failed attempt in our longer-term history (i.e. 'master', that never rewinds), however, I would prefer to see a replacement patch (as opposed to this one that incrementally updates the previous failed attempt). I could squash this into the previous one myself though ;-)
Thanks.
Quoted 102 lines
--- Makefile | 5 +++++ compat/itimer.c | 50 -------------------------------------------------- git-compat-util.h | 11 +++++++++-- 3 files changed, 14 insertions(+), 52 deletions(-) delete mode 100644 compat/itimer.cMakefile +5
-0@@ -157,6 +157,11 @@ all:: # Define NO_PREAD if you have a problem with pread() system call (e.g. # cygwin1.dll before v1.5.22). # +# Define NO_SETITIMER if you don't have setitimer() +# +# Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval +# This also implies NO_SETITIMER +# # Define NO_THREAD_SAFE_PREAD if your pread() implementation is not # thread-safe. (e.g. compat/pread.c or cygwin) #compat/itimer.c deleted +0
-50@@ -1,50 +0,0 @@ -#include "../git-compat-util.h" - -static int git_getitimer (int which,struct itimerval *value) -{ -int ret =0 ; - -switch (which) { -case ITIMER_REAL : - value->it_value.tv_usec =0 ; - value->it_value.tv_sec =alarm (0 ); - ret =0 ;/* if alarm() fails, we get a SIGLIMIT */ -break ; -case ITIMER_VIRTUAL :/* FALLTHRU */ -case ITIMER_PROF : errno =ENOTSUP ; ret =-1 ;break ; -default : errno =EINVAL ; ret =-1 ; - } -return ret; -} - -int git_setitimer (int which,const struct itimerval *value, -struct itimerval *ovalue) -{ -int ret =0 ; - -if (!value - || value->it_value.tv_usec <0 - || value->it_value.tv_usec >1000000 - || value->it_value.tv_sec <0 ) { - errno =EINVAL ; -return -1 ; - } - -else if (ovalue) -if (!git_getitimer (which, ovalue)) -return -1 ;/* errno set in git_getitimer() */ - -else -switch (which) { -case ITIMER_REAL : -alarm (value->it_value.tv_sec + - (value->it_value.tv_usec >0 ) ?1 :0 ); - ret =0 ;/* if alarm() fails, we get a SIGLIMIT */ -break ; -case ITIMER_VIRTUAL :/* FALLTHRU */ -case ITIMER_PROF : errno =ENOTSUP ; ret =-1 ;break ; -default : errno =EINVAL ; ret =-1 ; - } - -return ret; -}git-compat-util.h +9
-2@@ -162,9 +162,16 @@#define probe_utf8_pathname_composition (a,b)#endif +#ifdef NO_STRUCT_ITIMERVAL +struct itimerval { +struct timeval it_interval; +struct timeval it_value; +} +#define NO_SETITIMER +#endif +#ifdef NO_SETITIMER -#define setitimer (a,b,c) git_setitimer((a),(b),(c)) -extern int git_setitimer (int ,const struct itimerval *,struct itimerval *); +#define setitimer (which,value,ovalue)#endif #ifdef MKDIR_WO_TRAILING_SLASH
Quoted 18 lines
From: Junio C Hamano [mailto:[email protected]]
Sent: Friday, September 07, 2012 6:41 PM
To: Joachim Schmitz
Cc: [email protected]
Subject: Re: [PATCH v3] Support forsetitimer()on platforms lacking itQuoted 9 lines · Joachim Schmitz
HP NonStop (currently) doesn't have
setitimer(). The previous attempt of an emulation (reverted by this commit) was not a real substitute for a recurring itimer (as here we also don't haveSA_RESTART, so can't re-arm the timer). Assetitimer()is only used in cases of perceived latency and it doesn't affect correctness, it now gets disabled entirely, ifNO_SETITIMERis set. HP NonStop does provide struct itimerval, but other platforms may not, so this is taken care of in this commit too, by settingNO_STRUCT_ITIMERVAL.Signed-off-by Joachim Schmitz <[email protected]>
Quoted 7 lines
The end-result looks simple and nice (thanks for
NO_STRUCT_ITIMERVAL).As we are not going to include the earlier failed attempt in our longer-term history (i.e. 'master', that never rewinds), however, I would prefer to see a replacement patch (as opposed to this one that incrementally updates the previous failed attempt). I could squash this into the previous one myself though ;-)
Yes, please ;-)
Bye, Jojo