{"thread":{"id":"37432","subject":"[PATCH 4/9] autoconf: Check for struct sigevent","startedAt":"2014-08-28T01:04:13Z","lastAt":"2014-08-29T16:11:51Z","messageCount":16,"participants":["Jonas 'Sortie' Termansen","Junio C Hamano","Keller, Jacob E"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"248460","messageId":"1409187862-21257-1-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":null,"subject":"[PATCH 0/9] Use timer_settime for new platforms","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:13Z","receivedAt":"2014-08-28T01:04:13Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"Hi,\n\nI have ported git to my homemade custom operating system. It implements the\nmodern core POSIX interface and by design doesn't implement older\nobsolescent interfaces that has standardized superior replacements. This\ncauses some problems here and there, this patch series fixes one of them.\n\nGit uses the setitimer() function to deliver a steady supply of signals,\nwhich cause nice progress bars to show when operations take a long time.\nHowever, this function is part of the XSI option (i.e. not core POSIX) and\nhas been marked as obsolescent in the latest standard revision (it will\nlikely be removed in the next revision). Application developers are instead\nencouraged to use the timer_settime functions instead as they are more\npowerful and are part of core POSIX (added in POSIX 2001).\n\nThis patch series transitions git to use the timer_settime function instead\nof the setitimer function. The function is widely, but not universally\navailable on the platforms git current supports, so I need to be careful not\nto introduce regressions.\n\nI handle compatibility by checking if setitimer and timer_settime are\navailable (as well as the structures and types they need). git-compat-util.h\nprovides stubs for anything that is missing. The real code can then simply\ntry to use timer_create, and if it fails (such as with ENOSYS on platforms\nthat has the function, but no real implementation) it falls back on the\nolder setitimer function.\n\nMy first attempt at compatibility was simply adding #ifdef around all the\ntimer_settime calls, but this proved to be an unmaintainable maze of\npreprocessor conditionals. Instead I adopted the approach already used when\nsetitimer is missing: Just using a preprocessor function macro that expands\ncalls to nothing, allowing code to pretend it's always there.\n\nTo properly pretend timer_settime is available when it's not, I had to stub\nthe timer_t, struct timespec, struct itimerspec, and struct sigevent types\nif they were missing.\n\nI have attempted to properly add make variables for each compatibility case\nas well as proper configure tests. Autoconf is not my strong suit, but the\ntests appears to be working.\n\nThis patch series breaks the build for people using just config.mak.uname\n(and not the configure script) on platforms that doesn't have the used types\nand functions (timer_t, timespec, itimerspec, sigevent, timer_settime) as\nconfig.mak.uname doesn't yet have NO_FOO cases for those systems. That's\njust because I don't have that all of those systems available. It does look\nlike Cygwin, FreeBSD, Linux, NetBSD, Minix, and OpenBSD have the API at\nleast. I believe I added the required NO_FOO variables for Darwin, MinGW and\nWindows. If you have other systems available, you can help me by telling me\nif they need some NO_FOO love in config.mak.uname as well. :-)\n\nJonas 'Sortie' Termansen\n"},{"id":"248462","messageId":"1409187862-21257-2-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-1-git-send-email-sortie@maxsi.org","subject":"[PATCH 1/9] git-compat-util.h: Add missing semicolon after struct itimerval","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:14Z","receivedAt":"2014-08-28T01:04:14Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"This hasn't been a problem in practice as almost all systems have the\nsetitimer() API (or it is provided by git in the case of mingw). This code\nwasn't used in any default circumstances, as the build system never sets\nNO_STRUCT_ITIMERVAL - this breakage only occured if the user asked for it.\n\nWe repair this case so we can rely on it in the following commits.\n\nSigned-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n---\n git-compat-util.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex f587749..f7fae20 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -191,7 +191,7 @@ extern int compat_mkdir_wo_trailing_slash(const char*, mode_t);\n struct itimerval {\n \tstruct timeval it_interval;\n \tstruct timeval it_value;\n-}\n+};\n #endif\n \n #ifdef NO_SETITIMER\n-- \n2.1.0\n"},{"id":"248463","messageId":"1409187862-21257-3-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-1-git-send-email-sortie@maxsi.org","subject":"[PATCH 2/9] autoconf: Check for timer_t","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:15Z","receivedAt":"2014-08-28T01:04:15Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"This type will be used in a following commit.\n\nThis type was not previously used by git. This can cause trouble for\npeople on systems without timer_t if they only rely on config.mak.uname.\nThey will need to set NO_TIMER_T manually.\n\nSigned-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n\n---\n\nThis patch can be improved by finding out which systems doesn't have\ntimer_t and adding entries for them to config.mak.uname.\n\n Makefile          |  5 +++++\n config.mak.uname  |  2 ++\n configure.ac      | 10 +++++++++-\n git-compat-util.h |  4 ++++\n 4 files changed, 20 insertions(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 9f984a9..54266fd 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -182,6 +182,8 @@ all::\n #\n # Define NO_SETITIMER if you don't have setitimer()\n #\n+# Define NO_TIMER_T if you don't have timer_t.\n+#\n # Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval\n # This also implies NO_SETITIMER\n #\n@@ -1338,6 +1340,9 @@ endif\n ifdef OBJECT_CREATION_USES_RENAMES\n \tCOMPAT_CFLAGS += -DOBJECT_CREATION_MODE=1\n endif\n+ifdef NO_TIMER_T\n+\tCOMPAT_CFLAGS += -DNO_TIMER_T\n+endif\n ifdef NO_STRUCT_ITIMERVAL\n \tCOMPAT_CFLAGS += -DNO_STRUCT_ITIMERVAL\n \tNO_SETITIMER = YesPlease\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 15ee15e..a5297a2 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -355,6 +355,7 @@ ifeq ($(uname_S),Windows)\n \tNATIVE_CRLF = YesPlease\n \tDEFAULT_HELP_FORMAT = html\n \tNO_D_INO_IN_DIRENT = YesPlease\n+\tNO_TIMER_T = UnfortunatelyYes\n \n \tCC = compat/vcbuild/scripts/clink.pl\n \tAR = compat/vcbuild/scripts/lib.pl\n@@ -504,6 +505,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tNO_POSIX_GOODIES = UnfortunatelyYes\n \tDEFAULT_HELP_FORMAT = html\n \tNO_D_INO_IN_DIRENT = YesPlease\n+\tNO_TIMER_T = UnfortunatelyYes\n \tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\ndiff --git a/configure.ac b/configure.ac\nindex 4b1ae7c..c57fd25 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -745,7 +745,15 @@ case $ac_cv_type_socklen_t in\n   *)  \tSOCKLEN_T=$git_cv_socklen_t_equiv;;\n esac\n GIT_CONF_SUBST([SOCKLEN_T])\n-\n+#\n+# Define NO_TIMER_T if you don't have timer_t.\n+AC_CHECK_TYPES([timer_t],\n+[NO_TIMER_T=],\n+[NO_TIMER_T=UnfortunatelyYes],\n+[#include <sys/types.h>\n+ #include <time.h>])\n+GIT_CONF_SUBST([NO_TIMER_T])\n+#\n # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.\n AC_CHECK_MEMBER(struct dirent.d_ino,\n [NO_D_INO_IN_DIRENT=],\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex f7fae20..e0e7a62 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -187,6 +187,10 @@ typedef unsigned long uintptr_t;\n extern int compat_mkdir_wo_trailing_slash(const char*, mode_t);\n #endif\n \n+#ifdef NO_TIMER_T\n+typedef int timer_t;\n+#endif\n+\n #ifdef NO_STRUCT_ITIMERVAL\n struct itimerval {\n \tstruct timeval it_interval;\n-- \n2.1.0\n"},{"id":"248461","messageId":"1409187862-21257-4-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-1-git-send-email-sortie@maxsi.org","subject":"[PATCH 3/9] autoconf: Check for struct timespec","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:16Z","receivedAt":"2014-08-28T01:04:16Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"This type will be used in a following commit.\n\nThis type was not previously used by git. This can cause trouble for\npeople on systems without struct timespec if they only rely on\nconfig.mak.uname. They will need to set NO_STRUCT_TIMESPEC manually.\n\nSigned-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n\n---\n\nThis patch can be improved by finding out which systems doesn't have\nstruct timespec and adding entries for them to config.mak.uname.\n\n Makefile          | 5 +++++\n config.mak.uname  | 2 ++\n configure.ac      | 7 +++++++\n git-compat-util.h | 7 +++++++\n 4 files changed, 21 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex 54266fd..0dd3e35 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -184,6 +184,8 @@ all::\n #\n # Define NO_TIMER_T if you don't have timer_t.\n #\n+# Define NO_STRUCT_TIMESPEC if you don't have struct timespec\n+#\n # Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval\n # This also implies NO_SETITIMER\n #\n@@ -1343,6 +1345,9 @@ endif\n ifdef NO_TIMER_T\n \tCOMPAT_CFLAGS += -DNO_TIMER_T\n endif\n+ifdef NO_STRUCT_TIMESPEC\n+\tCOMPAT_CFLAGS += -DNO_STRUCT_TIMESPEC\n+endif\n ifdef NO_STRUCT_ITIMERVAL\n \tCOMPAT_CFLAGS += -DNO_STRUCT_ITIMERVAL\n \tNO_SETITIMER = YesPlease\ndiff --git a/config.mak.uname b/config.mak.uname\nindex a5297a2..8121791 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -356,6 +356,7 @@ ifeq ($(uname_S),Windows)\n \tDEFAULT_HELP_FORMAT = html\n \tNO_D_INO_IN_DIRENT = YesPlease\n \tNO_TIMER_T = UnfortunatelyYes\n+\tNO_STRUCT_TIMESPEC = UnfortunatelyYes\n \n \tCC = compat/vcbuild/scripts/clink.pl\n \tAR = compat/vcbuild/scripts/lib.pl\n@@ -506,6 +507,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tDEFAULT_HELP_FORMAT = html\n \tNO_D_INO_IN_DIRENT = YesPlease\n \tNO_TIMER_T = UnfortunatelyYes\n+\tNO_STRUCT_TIMESPEC = UnfortunatelyYes\n \tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\ndiff --git a/configure.ac b/configure.ac\nindex c57fd25..5a5b167 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -754,6 +754,13 @@ AC_CHECK_TYPES([timer_t],\n  #include <time.h>])\n GIT_CONF_SUBST([NO_TIMER_T])\n #\n+# Define NO_STRUCT_TIMESPEC if you don't have struct timespec.\n+AC_CHECK_TYPES([struct timespec],\n+[NO_STRUCT_TIMESPEC=],\n+[NO_STRUCT_TIMESPEC=UnfortunatelyYes],\n+[#include <sys/time.h>])\n+GIT_CONF_SUBST([NO_STRUCT_TIMESPEC])\n+#\n # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.\n AC_CHECK_MEMBER(struct dirent.d_ino,\n [NO_D_INO_IN_DIRENT=],\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex e0e7a62..e9e7e54 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -191,6 +191,13 @@ extern int compat_mkdir_wo_trailing_slash(const char*, mode_t);\n typedef int timer_t;\n #endif\n \n+#ifdef NO_STRUCT_TIMESPEC\n+struct timespec {\n+\ttime_t tv_sec;\n+\tlong tv_nsec;\n+};\n+#endif\n+\n #ifdef NO_STRUCT_ITIMERVAL\n struct itimerval {\n \tstruct timeval it_interval;\n-- \n2.1.0\n"},{"id":"248459","messageId":"1409187862-21257-5-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-1-git-send-email-sortie@maxsi.org","subject":"[PATCH 4/9] autoconf: Check for struct sigevent","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:17Z","receivedAt":"2014-08-28T01:04:17Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"This type will be used in a following commit.\n\nThis type was not previously used by git. This can cause trouble for\npeople on systems without struct sigevent if they only rely on\nconfig.mak.uname. They will need to set NO_STRUCT_SIGEVENT manually.\n\nSigned-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n\n---\n\nThis patch can be improved by finding out which systems doesn't have\nstruct sigevent and adding entries for them to config.mak.uname.\n\n Makefile          |  5 +++++\n config.mak.uname  |  2 ++\n configure.ac      |  7 +++++++\n git-compat-util.h | 12 ++++++++++++\n 4 files changed, 26 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex 0dd3e35..b76dc43 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -186,6 +186,8 @@ all::\n #\n # Define NO_STRUCT_TIMESPEC if you don't have struct timespec\n #\n+# Define NO_STRUCT_SIGEVENT if you don't have struct sigevent\n+#\n # Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval\n # This also implies NO_SETITIMER\n #\n@@ -1348,6 +1350,9 @@ endif\n ifdef NO_STRUCT_TIMESPEC\n \tCOMPAT_CFLAGS += -DNO_STRUCT_TIMESPEC\n endif\n+ifdef NO_STRUCT_SIGEVENT\n+\tCOMPAT_CFLAGS += -DNO_STRUCT_SIGEVENT\n+endif\n ifdef NO_STRUCT_ITIMERVAL\n \tCOMPAT_CFLAGS += -DNO_STRUCT_ITIMERVAL\n \tNO_SETITIMER = YesPlease\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 8121791..892afc5 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -357,6 +357,7 @@ ifeq ($(uname_S),Windows)\n \tNO_D_INO_IN_DIRENT = YesPlease\n \tNO_TIMER_T = UnfortunatelyYes\n \tNO_STRUCT_TIMESPEC = UnfortunatelyYes\n+\tNO_STRUCT_SIGEVENT = UnfortunatelyYes\n \n \tCC = compat/vcbuild/scripts/clink.pl\n \tAR = compat/vcbuild/scripts/lib.pl\n@@ -508,6 +509,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tNO_D_INO_IN_DIRENT = YesPlease\n \tNO_TIMER_T = UnfortunatelyYes\n \tNO_STRUCT_TIMESPEC = UnfortunatelyYes\n+\tNO_STRUCT_SIGEVENT = UnfortunatelyYes\n \tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\ndiff --git a/configure.ac b/configure.ac\nindex 5a5b167..31b3218 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -768,6 +768,13 @@ AC_CHECK_MEMBER(struct dirent.d_ino,\n [#include <dirent.h>])\n GIT_CONF_SUBST([NO_D_INO_IN_DIRENT])\n #\n+# Define NO_STRUCT_SIGEVENT if you don't have struct sigevent.\n+AC_CHECK_TYPES([struct sigevent],\n+[NO_STRUCT_SIGEVENT=],\n+[NO_STRUCT_SIGEVENT=UnfortunatelyYes],\n+[#include <signal.h>])\n+GIT_CONF_SUBST([NO_STRUCT_SIGEVENT])\n+#\n # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks\n # d_type in struct dirent (latest Cygwin -- will be fixed soonish).\n AC_CHECK_MEMBER(struct dirent.d_type,\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex e9e7e54..195eda6 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -198,6 +198,18 @@ struct timespec {\n };\n #endif\n \n+#ifndef SIGEV_SIGNAL\n+#define SIGEV_SIGNAL 1 /* dummy */\n+#endif\n+\n+#ifdef NO_STRUCT_SIGEVENT\n+struct sigevent /* dummy */\n+{\n+\tint sigev_notify;\n+\tint sigev_signo;\n+};\n+#endif\n+\n #ifdef NO_STRUCT_ITIMERVAL\n struct itimerval {\n \tstruct timeval it_interval;\n-- \n2.1.0\n"},{"id":"248464","messageId":"1409187862-21257-6-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-1-git-send-email-sortie@maxsi.org","subject":"[PATCH 5/9] autoconf: Check for struct itimerval","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:18Z","receivedAt":"2014-08-28T01:04:18Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"The makefile has provisions for this case, so let's detect it in\nthe configure script as well.\n\nSigned-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n---\n configure.ac | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/configure.ac b/configure.ac\nindex 31b3218..00842ae 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -761,6 +761,13 @@ AC_CHECK_TYPES([struct timespec],\n [#include <sys/time.h>])\n GIT_CONF_SUBST([NO_STRUCT_TIMESPEC])\n #\n+# Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval.\n+AC_CHECK_TYPES([struct itimerval],\n+[NO_STRUCT_ITIMERVAL=],\n+[NO_STRUCT_ITIMERVAL=UnfortunatelyYes],\n+[#include <sys/time.h>])\n+GIT_CONF_SUBST([NO_STRUCT_ITIMERVAL])\n+#\n # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.\n AC_CHECK_MEMBER(struct dirent.d_ino,\n [NO_D_INO_IN_DIRENT=],\n-- \n2.1.0\n"},{"id":"248467","messageId":"1409187862-21257-7-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-1-git-send-email-sortie@maxsi.org","subject":"[PATCH 6/9] autoconf: Check for struct itimerspec","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:19Z","receivedAt":"2014-08-28T01:04:19Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"This type will be used in a following commit.\n\nThis type was not previously used by git. This can cause trouble for\npeople on systems without struct itimerspec if they only rely on\nconfig.mak.uname. They will need to set NO_STRUCT_ITIMERSPEC manually.\n\nSigned-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n\n---\n\nThis patch can be improved by finding out which systems doesn't have\nstruct itimerspec and adding entries for them to config.mak.uname.\n\n Makefile          | 5 +++++\n config.mak.uname  | 3 +++\n configure.ac      | 7 +++++++\n git-compat-util.h | 7 +++++++\n 4 files changed, 22 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex b76dc43..66329e4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -191,6 +191,8 @@ all::\n # Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval\n # This also implies NO_SETITIMER\n #\n+# Define NO_STRUCT_ITIMERSPEC if you don't have struct itimerspec\n+#\n # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is\n # generally faster on your platform than accessing the working directory.\n #\n@@ -1357,6 +1359,9 @@ ifdef NO_STRUCT_ITIMERVAL\n \tCOMPAT_CFLAGS += -DNO_STRUCT_ITIMERVAL\n \tNO_SETITIMER = YesPlease\n endif\n+ifdef NO_STRUCT_ITIMERSPEC\n+\tCOMPAT_CFLAGS += -DNO_STRUCT_ITIMERSPEC\n+endif\n ifdef NO_SETITIMER\n \tCOMPAT_CFLAGS += -DNO_SETITIMER\n endif\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 892afc5..f0d93ef 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -98,6 +98,7 @@ ifeq ($(uname_S),Darwin)\n \tNO_MEMMEM = YesPlease\n \tUSE_ST_TIMESPEC = YesPlease\n \tHAVE_DEV_TTY = YesPlease\n+\tNO_STRUCT_ITIMERSPEC = UnfortunatelyYes\n \tCOMPAT_OBJS += compat/precompose_utf8.o\n \tBASIC_CFLAGS += -DPRECOMPOSE_UNICODE\n endif\n@@ -358,6 +359,7 @@ ifeq ($(uname_S),Windows)\n \tNO_TIMER_T = UnfortunatelyYes\n \tNO_STRUCT_TIMESPEC = UnfortunatelyYes\n \tNO_STRUCT_SIGEVENT = UnfortunatelyYes\n+\tNO_STRUCT_ITIMERSPEC = UnfortunatelyYes\n \n \tCC = compat/vcbuild/scripts/clink.pl\n \tAR = compat/vcbuild/scripts/lib.pl\n@@ -510,6 +512,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tNO_TIMER_T = UnfortunatelyYes\n \tNO_STRUCT_TIMESPEC = UnfortunatelyYes\n \tNO_STRUCT_SIGEVENT = UnfortunatelyYes\n+\tNO_STRUCT_ITIMERSPEC = UnfortunatelyYes\n \tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\ndiff --git a/configure.ac b/configure.ac\nindex 00842ae..3c64251 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -768,6 +768,13 @@ AC_CHECK_TYPES([struct itimerval],\n [#include <sys/time.h>])\n GIT_CONF_SUBST([NO_STRUCT_ITIMERVAL])\n #\n+# Define NO_STRUCT_ITIMERSPEC if you don't have struct itimerspec.\n+AC_CHECK_TYPES([struct itimerspec],\n+[NO_STRUCT_ITIMERSPEC=],\n+[NO_STRUCT_ITIMERSPEC=UnfortunatelyYes],\n+[#include <time.h>])\n+GIT_CONF_SUBST([NO_STRUCT_ITIMERSPEC])\n+#\n # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.\n AC_CHECK_MEMBER(struct dirent.d_ino,\n [NO_D_INO_IN_DIRENT=],\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 195eda6..4ef17df 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -217,6 +217,13 @@ struct itimerval {\n };\n #endif\n \n+#ifdef NO_STRUCT_ITIMERSPEC\n+struct itimerspec {\n+\tstruct timespec it_interval;\n+\tstruct timespec it_value;\n+};\n+#endif\n+\n #ifdef NO_SETITIMER\n #define setitimer(which,value,ovalue)\n #endif\n-- \n2.1.0\n"},{"id":"248465","messageId":"1409187862-21257-8-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-1-git-send-email-sortie@maxsi.org","subject":"[PATCH 7/9] autoconf: Check for setitimer","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:20Z","receivedAt":"2014-08-28T01:04:20Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"The makefile has provisions for this case, so let's detect it in the\nconfigure script as well.\n\nSigned-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n---\n configure.ac | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/configure.ac b/configure.ac\nindex 3c64251..89eb48f 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -939,6 +939,12 @@ AC_CHECK_LIB([iconv], [locale_charset],\n                      [CHARSET_LIB=-lcharset])])\n GIT_CONF_SUBST([CHARSET_LIB])\n #\n+# Define NO_SETITIMER if you don't have setitimer.\n+GIT_CHECK_FUNC(setitimer,\n+[NO_SETITIMER=],\n+[NO_SETITIMER=YesPlease])\n+GIT_CONF_SUBST([NO_SETITIMER])\n+#\n # Define NO_STRCASESTR if you don't have strcasestr.\n GIT_CHECK_FUNC(strcasestr,\n [NO_STRCASESTR=],\n-- \n2.1.0\n"},{"id":"248466","messageId":"1409187862-21257-9-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-1-git-send-email-sortie@maxsi.org","subject":"[PATCH 8/9] autoconf: Check for timer_settime","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:21Z","receivedAt":"2014-08-28T01:04:21Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"This function will be used in a following commit.\n\nThe timer_settime function is provided in librt on some systems. We\nalready use this library sometimes to get clock_gettime, so rework the\nlogic so we don't link with it twice.\n\nThis function was not previously used by git. This can cause trouble for\npeople on systems without timer_settime if they only rely on\nconfig.mak.uname. They will need to set NO_TIMER_SETTIME manually.\n\nAdd proper replacement function macros for setitimer and timer_settime\nthat evaluates the arguments and fails with ENOSYS to simulate stub\nimplementations. This will be useful in a following commit.\n\nSigned-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n\n---\n\nThis patch can be improved by finding out which systems doesn't have\ntimer_settime and adding entries for them to config.mak.uname.\n\n Makefile          | 21 +++++++++++++++++++++\n config.mak.uname  |  3 +++\n configure.ac      |  8 ++++++++\n git-compat-util.h |  8 +++++++-\n 4 files changed, 39 insertions(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 66329e4..5609e44 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -182,16 +182,22 @@ all::\n #\n # Define NO_SETITIMER if you don't have setitimer()\n #\n+# Define NO_TIMER_SETTIME if you don't have timer_settime()\n+#\n # Define NO_TIMER_T if you don't have timer_t.\n+# This also implies NO_SETITIMER\n #\n # Define NO_STRUCT_TIMESPEC if you don't have struct timespec\n+# This also implies NO_SETITIMER\n #\n # Define NO_STRUCT_SIGEVENT if you don't have struct sigevent\n+# This also implies NO_SETITIMER\n #\n # Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval\n # This also implies NO_SETITIMER\n #\n # Define NO_STRUCT_ITIMERSPEC if you don't have struct itimerspec\n+# This also implies NO_TIMER_SETTIME\n #\n # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is\n # generally faster on your platform than accessing the working directory.\n@@ -1348,12 +1354,15 @@ ifdef OBJECT_CREATION_USES_RENAMES\n endif\n ifdef NO_TIMER_T\n \tCOMPAT_CFLAGS += -DNO_TIMER_T\n+\tNO_TIMER_SETTIME = YesPlease\n endif\n ifdef NO_STRUCT_TIMESPEC\n \tCOMPAT_CFLAGS += -DNO_STRUCT_TIMESPEC\n+\tNO_TIMER_SETTIME = YesPlease\n endif\n ifdef NO_STRUCT_SIGEVENT\n \tCOMPAT_CFLAGS += -DNO_STRUCT_SIGEVENT\n+\tNO_TIMER_SETTIME = YesPlease\n endif\n ifdef NO_STRUCT_ITIMERVAL\n \tCOMPAT_CFLAGS += -DNO_STRUCT_ITIMERVAL\n@@ -1361,10 +1370,14 @@ ifdef NO_STRUCT_ITIMERVAL\n endif\n ifdef NO_STRUCT_ITIMERSPEC\n \tCOMPAT_CFLAGS += -DNO_STRUCT_ITIMERSPEC\n+\tNO_TIMER_SETTIME = YesPlease\n endif\n ifdef NO_SETITIMER\n \tCOMPAT_CFLAGS += -DNO_SETITIMER\n endif\n+ifdef NO_TIMER_SETTIME\n+\tCOMPAT_CFLAGS += -DNO_TIMER_SETTIME\n+endif\n ifdef NO_PREAD\n \tCOMPAT_CFLAGS += -DNO_PREAD\n \tCOMPAT_OBJS += compat/pread.o\n@@ -1524,6 +1537,14 @@ endif\n \n ifdef HAVE_CLOCK_GETTIME\n \tBASIC_CFLAGS += -DHAVE_CLOCK_GETTIME\n+\tLINK_WITH_LIBRT = YesPlease\n+endif\n+\n+ifndef NO_TIMER_SETTIME\n+\tLINK_WITH_LIBRT = YesPlease\n+endif\n+\n+ifdef LINK_WITH_LIBRT\n \tEXTLIBS += -lrt\n endif\n \ndiff --git a/config.mak.uname b/config.mak.uname\nindex f0d93ef..d04deab 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -99,6 +99,7 @@ ifeq ($(uname_S),Darwin)\n \tUSE_ST_TIMESPEC = YesPlease\n \tHAVE_DEV_TTY = YesPlease\n \tNO_STRUCT_ITIMERSPEC = UnfortunatelyYes\n+\tNO_TIMER_SETTIME = UnfortunatelyYes\n \tCOMPAT_OBJS += compat/precompose_utf8.o\n \tBASIC_CFLAGS += -DPRECOMPOSE_UNICODE\n endif\n@@ -360,6 +361,7 @@ ifeq ($(uname_S),Windows)\n \tNO_STRUCT_TIMESPEC = UnfortunatelyYes\n \tNO_STRUCT_SIGEVENT = UnfortunatelyYes\n \tNO_STRUCT_ITIMERSPEC = UnfortunatelyYes\n+\tNO_TIMER_SETTIME = UnfortunatelyYes\n \n \tCC = compat/vcbuild/scripts/clink.pl\n \tAR = compat/vcbuild/scripts/lib.pl\n@@ -513,6 +515,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tNO_STRUCT_TIMESPEC = UnfortunatelyYes\n \tNO_STRUCT_SIGEVENT = UnfortunatelyYes\n \tNO_STRUCT_ITIMERSPEC = UnfortunatelyYes\n+\tNO_TIMER_SETTIME = UnfortunatelyYes\n \tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32\n \tCOMPAT_CFLAGS += -DSTRIP_EXTENSION=\\\".exe\\\"\n \tCOMPAT_OBJS += compat/mingw.o compat/winansi.o \\\ndiff --git a/configure.ac b/configure.ac\nindex 89eb48f..354bd38 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -945,6 +945,14 @@ GIT_CHECK_FUNC(setitimer,\n [NO_SETITIMER=YesPlease])\n GIT_CONF_SUBST([NO_SETITIMER])\n #\n+# Define NO_TIMER_SETTIME if you don't have timer_settime\n+GIT_CHECK_FUNC(timer_settime,\n+[NO_TIMER_SETTIME=],\n+[AC_SEARCH_LIBS(timer_settime,[rt],\n+  [NO_TIMER_SETTIME=],\n+  [NO_TIMER_SETTIME=YesPlease])])\n+GIT_CONF_SUBST([NO_TIMER_SETTIME])\n+#\n # Define NO_STRCASESTR if you don't have strcasestr.\n GIT_CHECK_FUNC(strcasestr,\n [NO_STRCASESTR=],\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 4ef17df..91bbf6d 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -225,7 +225,13 @@ struct itimerspec {\n #endif\n \n #ifdef NO_SETITIMER\n-#define setitimer(which,value,ovalue)\n+#define setitimer(which,value,ovalue) ((void) (which), (void) (value), (void) (ovalue), errno = ENOSYS, -1)\n+#endif\n+\n+#ifdef NO_TIMER_SETTIMER\n+#define timer_create(clockid, sevp, timerp) ((void) (clockid), (void) (sevp), (void) (timerp), errno = ENOSYS, -1)\n+#define timer_settime(timer, flags, value, ovalue) ((void) (timer), (void) (flags), (void) (value), (void) (ovalue), errno = ENOSYS, -1)\n+#define timer_delete(timer) ((void) (timer), errno = ENOSYS, -1)\n #endif\n \n #ifndef NO_LIBGEN_H\n-- \n2.1.0\n"},{"id":"248468","messageId":"1409187862-21257-10-git-send-email-sortie@maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-1-git-send-email-sortie@maxsi.org","subject":"[PATCH 9/9] Use timer_settime for new platforms","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T01:04:22Z","receivedAt":"2014-08-28T01:04:22Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"setitimer() is an obsolescent XSI interface and may be removed in a\nfuture standard. Applications should use the core POSIX timer_settime()\ninstead.\n\nThis patch cleans up the progress reporting and changes it to try using\ntimer_settime, or if that fails, setitimer. If either function is not\nprovided by the system, then git-compat-util.h provides replacements\nthat always fail with ENOSYS.\n\nIt's important that code doesn't simply check if timer_settime is\navailable as it can give false positives. Some systems like contemporary\nOpenBSD provides the function, but it unconditionally fails with ENOSYS\nat runtime.\n\nThis approach allows the code using timer_settime() and setitimer() to\nbe simple and readable. My first attempt used #ifdef around each use of\ntimer_settime(), this quickly turned a into unmaintainable maze of\npreprocessor conditionals.\n\nSigned-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n---\n builtin/log.c | 47 ++++++++++++++++++++++++++++++++++++++++-------\n progress.c    | 34 +++++++++++++++++++++++++++-------\n 2 files changed, 67 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 4389722..54c85a6 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -229,7 +229,8 @@ static void show_early_header(struct rev_info *rev, const char *stage, int nr)\n \tprintf(_(\"Final output: %d %s\\n\"), nr, stage);\n }\n \n-static struct itimerval early_output_timer;\n+static int is_using_timer_settime;\n+static timer_t early_output_timer;\n \n static void log_show_early(struct rev_info *revs, struct commit_list *list)\n {\n@@ -271,9 +272,21 @@ static void log_show_early(struct rev_info *revs, struct commit_list *list)\n \t * trigger every second even if we're blocked on a\n \t * reader!\n \t */\n-\tearly_output_timer.it_value.tv_sec = 0;\n-\tearly_output_timer.it_value.tv_usec = 500000;\n-\tsetitimer(ITIMER_REAL, &early_output_timer, NULL);\n+\tif (is_using_timer_settime) {\n+\t\tstruct itimerspec value;\n+\t\tvalue.it_value.tv_sec = 0;\n+\t\tvalue.it_value.tv_nsec = 500000L * 1000L;\n+\t\tvalue.it_interval.tv_sec = 0;\n+\t\tvalue.it_interval.tv_nsec = 0;\n+\t\ttimer_settime(early_output_timer, 0, &value, NULL);\n+\t} else {\n+\t\tstruct itimerval value;\n+\t\tvalue.it_value.tv_sec = 0;\n+\t\tvalue.it_value.tv_usec = 500000;\n+\t\tvalue.it_interval.tv_sec = 0;\n+\t\tvalue.it_interval.tv_usec = 0;\n+\t\tsetitimer(ITIMER_REAL, &value, NULL);\n+\t}\n }\n \n static void early_output(int signal)\n@@ -284,6 +297,7 @@ static void early_output(int signal)\n static void setup_early_output(struct rev_info *rev)\n {\n \tstruct sigaction sa;\n+\tstruct sigevent sev;\n \n \t/*\n \t * Set up the signal handler, minimally intrusively:\n@@ -305,14 +319,33 @@ static void setup_early_output(struct rev_info *rev)\n \t *\n \t * This is a one-time-only trigger.\n \t */\n-\tearly_output_timer.it_value.tv_sec = 0;\n-\tearly_output_timer.it_value.tv_usec = 100000;\n-\tsetitimer(ITIMER_REAL, &early_output_timer, NULL);\n+\tmemset(&sev, 0, sizeof(sev));\n+\tsev.sigev_notify = SIGEV_SIGNAL;\n+\tsev.sigev_signo = SIGALRM;\n+\tif (!timer_create(CLOCK_MONOTONIC, &sev, &early_output_timer)) {\n+\t\tstruct itimerspec value;\n+\t\tvalue.it_value.tv_sec = 0;\n+\t\tvalue.it_value.tv_nsec = 100000L * 1000L;\n+\t\tvalue.it_interval.tv_sec = 0;\n+\t\tvalue.it_interval.tv_nsec = 0;\n+\t\ttimer_settime(early_output_timer, 0, &value, NULL);\n+\t\tis_using_timer_settime = 1;\n+\t} else {\n+\t\tstruct itimerval value;\n+\t\tvalue.it_value.tv_sec = 0;\n+\t\tvalue.it_value.tv_usec = 100000;\n+\t\tvalue.it_interval.tv_sec = 0;\n+\t\tvalue.it_interval.tv_usec = 0;\n+\t\tsetitimer(ITIMER_REAL, &value, NULL);\n+\t\tis_using_timer_settime = 0;\n+\t}\n }\n \n static void finish_early_output(struct rev_info *rev)\n {\n \tint n = estimate_commit_count(rev, rev->commits);\n+\tif (is_using_timer_settime)\n+\t\ttimer_delete(early_output_timer);\n \tsignal(SIGALRM, SIG_IGN);\n \tshow_early_header(rev, \"done\", n);\n }\ndiff --git a/progress.c b/progress.c\nindex 412e6b1..b396ee1 100644\n--- a/progress.c\n+++ b/progress.c\n@@ -38,6 +38,8 @@ struct progress {\n \tstruct throughput *throughput;\n };\n \n+static int is_using_timer_settime;\n+static timer_t progress_timer;\n static volatile sig_atomic_t progress_update;\n \n static void progress_interval(int signum)\n@@ -48,7 +50,7 @@ static void progress_interval(int signum)\n static void set_progress_signal(void)\n {\n \tstruct sigaction sa;\n-\tstruct itimerval v;\n+\tstruct sigevent sev;\n \n \tprogress_update = 0;\n \n@@ -58,16 +60,34 @@ static void set_progress_signal(void)\n \tsa.sa_flags = SA_RESTART;\n \tsigaction(SIGALRM, &sa, NULL);\n \n-\tv.it_interval.tv_sec = 1;\n-\tv.it_interval.tv_usec = 0;\n-\tv.it_value = v.it_interval;\n-\tsetitimer(ITIMER_REAL, &v, NULL);\n+\tmemset(&sev, 0, sizeof(sev));\n+\tsev.sigev_notify = SIGEV_SIGNAL;\n+\tsev.sigev_signo = SIGALRM;\n+\tif (!timer_create(CLOCK_MONOTONIC, &sev, &progress_timer)) {\n+\t\tstruct itimerspec value;\n+\t\tvalue.it_interval.tv_sec = 1;\n+\t\tvalue.it_interval.tv_nsec = 0;\n+\t\tvalue.it_value = value.it_interval;\n+\t\ttimer_settime(progress_timer, 0, &value, NULL);\n+\t\tis_using_timer_settime = 1;\n+\t} else {\n+\t\tstruct itimerval value;\n+\t\tvalue.it_interval.tv_sec = 1;\n+\t\tvalue.it_interval.tv_usec = 0;\n+\t\tvalue.it_value = value.it_interval;\n+\t\tsetitimer(ITIMER_REAL, &value, NULL);\n+\t\tis_using_timer_settime = 0;\n+\t}\n }\n \n static void clear_progress_signal(void)\n {\n-\tstruct itimerval v = {{0,},};\n-\tsetitimer(ITIMER_REAL, &v, NULL);\n+\tif (is_using_timer_settime) {\n+\t\ttimer_delete(progress_timer);\n+\t} else {\n+\t\tstruct itimerval v = {{0,},};\n+\t\tsetitimer(ITIMER_REAL, &v, NULL);\n+\t}\n \tsignal(SIGALRM, SIG_IGN);\n \tprogress_update = 0;\n }\n-- \n2.1.0\n"},{"id":"248478","messageId":"53FF1A7A.6000808@Maxsi.org","threadId":"37432","inReplyTo":"1409187862-21257-3-git-send-email-sortie@maxsi.org","subject":"Re: [PATCH 2/9] autoconf: Check for timer_t","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-28T12:03:06Z","receivedAt":"2014-08-28T12:03:06Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"It would appear that Darwin does not have timer_t, at least from looking\nat the public libc and XNU headers online.\n\nA quick additional change is needed in config.mak.uname:\n\nifeq ($(uname_S),Darwin)\n...\n \tHAVE_DEV_TTY = YesPlease\n+\tNO_TIMER_T = UnfortunatelyYes\n \tCOMPAT_OBJS += compat/precompose_utf8.o\n...\nendif\n\nI'll include that proper in V2 of my patch series.\n\nJonas\n"},{"id":"248516","messageId":"xmqqd2bk9zgd.fsf@gitster.dls.corp.google.com","threadId":"37432","inReplyTo":"1409187862-21257-6-git-send-email-sortie@maxsi.org","subject":"Re: [PATCH 5/9] autoconf: Check for struct itimerval","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-08-28T19:38:42Z","receivedAt":"2014-08-28T19:38:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonas 'Sortie' Termansen <sortie@maxsi.org> writes:\n\n> The makefile has provisions for this case, so let's detect it in\n> the configure script as well.\n>\n> Signed-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n> ---\n\nThis, 1/9 and later 7/9, are independently good changes to the\ncurrent codebase, unlike all the other patches that become only\nnecessary if/when we want to migrate to timer_settime().\n\nAs such, we would prefer to have these \"fixes to the current system\"\nat the beginning of the series before \"enhancements to the current\nsystem\" patches.\n\nThanks.\n\n>  configure.ac | 7 +++++++\n>  1 file changed, 7 insertions(+)\n>\n> diff --git a/configure.ac b/configure.ac\n> index 31b3218..00842ae 100644\n> --- a/configure.ac\n> +++ b/configure.ac\n> @@ -761,6 +761,13 @@ AC_CHECK_TYPES([struct timespec],\n>  [#include <sys/time.h>])\n>  GIT_CONF_SUBST([NO_STRUCT_TIMESPEC])\n>  #\n> +# Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval.\n> +AC_CHECK_TYPES([struct itimerval],\n> +[NO_STRUCT_ITIMERVAL=],\n> +[NO_STRUCT_ITIMERVAL=UnfortunatelyYes],\n> +[#include <sys/time.h>])\n> +GIT_CONF_SUBST([NO_STRUCT_ITIMERVAL])\n> +#\n>  # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.\n>  AC_CHECK_MEMBER(struct dirent.d_ino,\n>  [NO_D_INO_IN_DIRENT=],\n"},{"id":"248517","messageId":"xmqq61hc9z94.fsf@gitster.dls.corp.google.com","threadId":"37432","inReplyTo":"1409187862-21257-10-git-send-email-sortie@maxsi.org","subject":"Re: [PATCH 9/9] Use timer_settime for new platforms","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-08-28T19:43:03Z","receivedAt":"2014-08-28T19:43:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonas 'Sortie' Termansen <sortie@maxsi.org> writes:\n\n> setitimer() is an obsolescent XSI interface and may be removed in a\n> future standard. Applications should use the core POSIX timer_settime()\n> instead.\n>\n> This patch cleans up the progress reporting and changes it to try using\n> timer_settime, or if that fails, setitimer. If either function is not\n> provided by the system, then git-compat-util.h provides replacements\n> that always fail with ENOSYS.\n>\n> It's important that code doesn't simply check if timer_settime is\n> available as it can give false positives. Some systems like contemporary\n> OpenBSD provides the function, but it unconditionally fails with ENOSYS\n> at runtime.\n>\n> This approach allows the code using timer_settime() and setitimer() to\n> be simple and readable. My first attempt used #ifdef around each use of\n> timer_settime(), this quickly turned a into unmaintainable maze of\n> preprocessor conditionals.\n>\n> Signed-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n> ---\n>  builtin/log.c | 47 ++++++++++++++++++++++++++++++++++++++++-------\n>  progress.c    | 34 +++++++++++++++++++++++++++-------\n>  2 files changed, 67 insertions(+), 14 deletions(-)\n\nYuck.  I didn't look at the change very carefully, but are the two\ninterface so vastly different that you cannot emulate one in terms\nof the other, and use a single API at the callsites, isolating the\nknowledge of which kind of API is used to interact with the system\ntimer in one place (perhaps in compat/itimer.c)?\n\nHaving to sprinkle \"if (is_using_timer_settime)\" around means we\nneed to support two APIs at each and every callsite that wants timer\ninterrupt actions.\n"},{"id":"248545","messageId":"1409325810.18778.6.camel@jekeller-desk1.amr.corp.intel.com","threadId":"37432","inReplyTo":"1409187862-21257-9-git-send-email-sortie@maxsi.org","subject":"Re: [PATCH 8/9] autoconf: Check for timer_settime","fromName":"Keller, Jacob E","fromEmail":"jacob.e.keller@intel.com","sentAt":"2014-08-29T15:23:31Z","receivedAt":"2014-08-29T15:23:31Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Thu, 2014-08-28 at 03:04 +0200, Jonas 'Sortie' Termansen wrote:\n> This function will be used in a following commit.\n> \n> The timer_settime function is provided in librt on some systems. We\n> already use this library sometimes to get clock_gettime, so rework the\n> logic so we don't link with it twice.\n> \n> This function was not previously used by git. This can cause trouble for\n> people on systems without timer_settime if they only rely on\n> config.mak.uname. They will need to set NO_TIMER_SETTIME manually.\n> \n> Add proper replacement function macros for setitimer and timer_settime\n> that evaluates the arguments and fails with ENOSYS to simulate stub\n> implementations. This will be useful in a following commit.\n> \n> Signed-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n> \n> ---\n> \n> This patch can be improved by finding out which systems doesn't have\n> timer_settime and adding entries for them to config.mak.uname.\n> \n>  Makefile          | 21 +++++++++++++++++++++\n>  config.mak.uname  |  3 +++\n>  configure.ac      |  8 ++++++++\n>  git-compat-util.h |  8 +++++++-\n>  4 files changed, 39 insertions(+), 1 deletion(-)\n> \n> diff --git a/Makefile b/Makefile\n> index 66329e4..5609e44 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -182,16 +182,22 @@ all::\n>  #\n>  # Define NO_SETITIMER if you don't have setitimer()\n>  #\n> +# Define NO_TIMER_SETTIME if you don't have timer_settime()\n> +#\n>  # Define NO_TIMER_T if you don't have timer_t.\n> +# This also implies NO_SETITIMER\n\nDon't you mean it implies NO_TIMER_SETTIME?\n\nIt seems to me that these were all added for TIMER_SETTIME, and not\nNO_SETTIMER? Or am I just thoroughly confused?\n\nRegards,\nJake\n"},{"id":"248548","messageId":"5400A428.9000202@Maxsi.org","threadId":"37432","inReplyTo":"1409325810.18778.6.camel@jekeller-desk1.amr.corp.intel.com","subject":"Re: [PATCH 8/9] autoconf: Check for timer_settime","fromName":"Jonas 'Sortie' Termansen","fromEmail":"sortie@maxsi.org","sentAt":"2014-08-29T16:02:48Z","receivedAt":"2014-08-29T16:02:48Z","isPatch":true,"sender":{"key":"sortie@maxsi.org","avatar":"https://avatars.githubusercontent.com/u/3636196?v=4"},"body":"> Don't you mean it implies NO_TIMER_SETTIME?\n> \n> It seems to me that these were all added for TIMER_SETTIME, and not\n> NO_SETTIMER? Or am I just thoroughly confused?\n\nThanks, that's a mistake. I copy-pasted the wrong line. :P\n\nAll of those additions should just be:\n# This also implies NO_TIMER_SETTIME\n\nJonas\n"},{"id":"248549","messageId":"1409328711.18778.12.camel@jekeller-desk1.amr.corp.intel.com","threadId":"37432","inReplyTo":"xmqq61hc9z94.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 9/9] Use timer_settime for new platforms","fromName":"Keller, Jacob E","fromEmail":"jacob.e.keller@intel.com","sentAt":"2014-08-29T16:11:51Z","receivedAt":"2014-08-29T16:11:51Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Thu, 2014-08-28 at 12:43 -0700, Junio C Hamano wrote:\n> Jonas 'Sortie' Termansen <sortie@maxsi.org> writes:\n> \n> > setitimer() is an obsolescent XSI interface and may be removed in a\n> > future standard. Applications should use the core POSIX timer_settime()\n> > instead.\n> >\n> > This patch cleans up the progress reporting and changes it to try using\n> > timer_settime, or if that fails, setitimer. If either function is not\n> > provided by the system, then git-compat-util.h provides replacements\n> > that always fail with ENOSYS.\n> >\n> > It's important that code doesn't simply check if timer_settime is\n> > available as it can give false positives. Some systems like contemporary\n> > OpenBSD provides the function, but it unconditionally fails with ENOSYS\n> > at runtime.\n> >\n> > This approach allows the code using timer_settime() and setitimer() to\n> > be simple and readable. My first attempt used #ifdef around each use of\n> > timer_settime(), this quickly turned a into unmaintainable maze of\n> > preprocessor conditionals.\n> >\n> > Signed-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>\n> > ---\n> >  builtin/log.c | 47 ++++++++++++++++++++++++++++++++++++++++-------\n> >  progress.c    | 34 +++++++++++++++++++++++++++-------\n> >  2 files changed, 67 insertions(+), 14 deletions(-)\n> \n> Yuck.  I didn't look at the change very carefully, but are the two\n> interface so vastly different that you cannot emulate one in terms\n> of the other, and use a single API at the callsites, isolating the\n> knowledge of which kind of API is used to interact with the system\n> timer in one place (perhaps in compat/itimer.c)?\n> \n> Having to sprinkle \"if (is_using_timer_settime)\" around means we\n> need to support two APIs at each and every callsite that wants timer\n> interrupt actions.\n> \n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\nAgreed! The biggest difference is that timer_settime() uses nanoseconds\nvalue, which is very easy to convert microseconds into nanoseconds.\n\nIn fact, you could probably easily provide a wrapper for timer_settime\nthat works for settimer by simply converting it. This is a much better\napproach. (though settimer \"could\" lose some precision since you ahve to\ndivide by 1000)...\n\nThe other big difference is abstracting away the timer_create aspect\nwhich is ok, since we would always call timer create, and use the\ncorrect timer, but we just fall back to setitimer to use the default\ntimer.\n\nI'll submit a patch series which does what I think should work, and will\nresult in less if checks.\n\nRegards,\nJake\n\n\n"}]}