git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/9] autoconf: Check for struct itimerspec

From
Jonas 'Sortie' Termansen <sortie@maxsi.org>
Date
Aug 28, 2014, 01:04 UTC
Message-ID
<1409187862-21257-7-git-send-email-sortie@maxsi.org>
In-Reply-To
<1409187862-21257-1-git-send-email-sortie@maxsi.org>
This type will be used in a following commit.

This type was not previously used by git. This can cause trouble for people on systems without struct itimerspec if they only rely on config.mak.uname. They will need to set NO_STRUCT_ITIMERSPEC manually.

Signed-off-by: Jonas 'Sortie' Termansen <sortie@maxsi.org>
---

This patch can be improved by finding out which systems doesn't have struct itimerspec and adding entries for them to config.mak.uname.

 Makefile          | 5 +++++
 config.mak.uname  | 3 +++
 configure.ac      | 7 +++++++
 git-compat-util.h | 7 +++++++
 4 files changed, 22 insertions(+)
diff --git a/Makefile b/Makefile
index b76dc43..66329e4 100644
--- a/Makefile
+++ b/Makefile
@@ -191,6 +191,8 @@ all::
 # Define NO_STRUCT_ITIMERVAL if you don't have struct itimerval
 # This also implies NO_SETITIMER
 #
+# Define NO_STRUCT_ITIMERSPEC if you don't have struct itimerspec
+#
 # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
 # generally faster on your platform than accessing the working directory.
 #
@@ -1357,6 +1359,9 @@ ifdef NO_STRUCT_ITIMERVAL
 	COMPAT_CFLAGS += -DNO_STRUCT_ITIMERVAL
 	NO_SETITIMER = YesPlease
 endif
+ifdef NO_STRUCT_ITIMERSPEC
+	COMPAT_CFLAGS += -DNO_STRUCT_ITIMERSPEC
+endif
 ifdef NO_SETITIMER
 	COMPAT_CFLAGS += -DNO_SETITIMER
 endif
diff --git a/config.mak.uname b/config.mak.uname
index 892afc5..f0d93ef 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -98,6 +98,7 @@ ifeq ($(uname_S),Darwin)
 	NO_MEMMEM = YesPlease
 	USE_ST_TIMESPEC = YesPlease
 	HAVE_DEV_TTY = YesPlease
+	NO_STRUCT_ITIMERSPEC = UnfortunatelyYes
 	COMPAT_OBJS += compat/precompose_utf8.o
 	BASIC_CFLAGS += -DPRECOMPOSE_UNICODE
 endif
@@ -358,6 +359,7 @@ ifeq ($(uname_S),Windows)
 	NO_TIMER_T = UnfortunatelyYes
 	NO_STRUCT_TIMESPEC = UnfortunatelyYes
 	NO_STRUCT_SIGEVENT = UnfortunatelyYes
+	NO_STRUCT_ITIMERSPEC = UnfortunatelyYes
 
 	CC = compat/vcbuild/scripts/clink.pl
 	AR = compat/vcbuild/scripts/lib.pl
@@ -510,6 +512,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_TIMER_T = UnfortunatelyYes
 	NO_STRUCT_TIMESPEC = UnfortunatelyYes
 	NO_STRUCT_SIGEVENT = UnfortunatelyYes
+	NO_STRUCT_ITIMERSPEC = UnfortunatelyYes
 	COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32
 	COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
 	COMPAT_OBJS += compat/mingw.o compat/winansi.o \
diff --git a/configure.ac b/configure.ac
index 00842ae..3c64251 100644
--- a/configure.ac
+++ b/configure.ac
@@ -768,6 +768,13 @@ AC_CHECK_TYPES([struct itimerval],
 [#include <sys/time.h>])
 GIT_CONF_SUBST([NO_STRUCT_ITIMERVAL])
 #
+# Define NO_STRUCT_ITIMERSPEC if you don't have struct itimerspec.
+AC_CHECK_TYPES([struct itimerspec],
+[NO_STRUCT_ITIMERSPEC=],
+[NO_STRUCT_ITIMERSPEC=UnfortunatelyYes],
+[#include <time.h>])
+GIT_CONF_SUBST([NO_STRUCT_ITIMERSPEC])
+#
 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
 AC_CHECK_MEMBER(struct dirent.d_ino,
 [NO_D_INO_IN_DIRENT=],
diff --git a/git-compat-util.h b/git-compat-util.h
index 195eda6..4ef17df 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -217,6 +217,13 @@ struct itimerval {
 };
 #endif
 
+#ifdef NO_STRUCT_ITIMERSPEC
+struct itimerspec {
+	struct timespec it_interval;
+	struct timespec it_value;
+};
+#endif
+
 #ifdef NO_SETITIMER
 #define setitimer(which,value,ovalue)
 #endif
-- 
2.1.0
Previous: Junio C HamanoNext: Jonas 'Sortie' Termansen
Message 9 of 16 in “Use timer_settime for new platforms”
  1. 0/9 Use timer_settime for new platformsJonas 'Sortie' Termansen, Aug 28, 2014
  2. 1/9 git-compat-util.h: Add missing semicolon after struct itimervalJonas 'Sortie' Termansen, Aug 28, 2014
  3. 2/9 autoconf: Check for timer_tJonas 'Sortie' Termansen, Aug 28, 2014
  4. Jonas 'Sortie' TermansenAug 28, 2014
  5. 3/9 autoconf: Check for struct timespecJonas 'Sortie' Termansen, Aug 28, 2014
  6. 4/9 autoconf: Check for struct sigeventJonas 'Sortie' Termansen, Aug 28, 2014
  7. 5/9 autoconf: Check for struct itimervalJonas 'Sortie' Termansen, Aug 28, 2014
  8. Junio C HamanoAug 28, 2014
  9. 6/9 autoconf: Check for struct itimerspecJonas 'Sortie' Termansen, Aug 28, 2014
  10. 7/9 autoconf: Check for setitimerJonas 'Sortie' Termansen, Aug 28, 2014
  11. 8/9 autoconf: Check for timer_settimeJonas 'Sortie' Termansen, Aug 28, 2014
  12. Keller, Jacob EAug 29, 2014
  13. Jonas 'Sortie' TermansenAug 29, 2014
  14. 9/9 Use timer_settime for new platformsJonas 'Sortie' Termansen, Aug 28, 2014
  15. Junio C HamanoAug 28, 2014
  16. Keller, Jacob EAug 29, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.