git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] configure.ac: check 'tv_nsec' field in 'struct stat'
@ 2015-01-08 20:00 Reuben Hawkins
  2015-01-08 20:00 ` [PATCH 2/3] configure.ac: check for clock_gettime and CLOCK_MONOTONIC Reuben Hawkins
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Reuben Hawkins @ 2015-01-08 20:00 UTC (permalink / raw)
  To: git; +Cc: Reuben Hawkins

Detect 'tv_nsec' field in 'struct stat' and set Makefile variable
NO_NSEC appropriately.

A side-effect of the above detection is that we also determine
whether 'stat.st_mtimespec' is available, so, as a bonus, set the
Makefile variable USE_ST_TIMESPEC, as well.

Signed-off-by: Reuben Hawkins <reubenhwk@gmail.com>
---
 configure.ac | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/configure.ac b/configure.ac
index 6af9647..210eb4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -754,6 +754,19 @@ AC_CHECK_TYPES([struct itimerval],
 [#include <sys/time.h>])
 GIT_CONF_SUBST([NO_STRUCT_ITIMERVAL])
 #
+# Define USE_ST_TIMESPEC=YesPlease when stat.st_mtimespec.tv_nsec exists.
+# Define NO_NSEC=YesPlease when neither stat.st_mtim.tv_nsec nor
+# stat.st_mtimespec.tv_nsec exists.
+AC_CHECK_MEMBER([struct stat.st_mtimespec.tv_nsec])
+AC_CHECK_MEMBER([struct stat.st_mtim.tv_nsec])
+if test x$ac_cv_member_struct_stat_st_mtimespec_tv_nsec = xyes ; then
+	USE_ST_TIMESPEC=YesPlease
+	GIT_CONF_SUBST([USE_ST_TIMESPEC])
+elif test x$ac_cv_member_struct_stat_st_mtim_tv_nsec != xyes ; then
+	NO_NSEC=YesPlease
+	GIT_CONF_SUBST([NO_NSEC])
+fi
+#
 # 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=],
-- 
2.2.0.68.g8f72f0c.dirty

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] configure.ac,imap-send.c: check HMAC_CTX_cleanup
@ 2014-12-21 21:28 Eric Sunshine
  2015-01-07 20:23 ` v2 patches for fixes on RHEL3 Reuben Hawkins
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Sunshine @ 2014-12-21 21:28 UTC (permalink / raw)
  To: Reuben Hawkins; +Cc: Git List

On Sun, Dec 21, 2014 at 1:53 PM, Reuben Hawkins <reubenhwk@gmail.com> wrote:
> Older versions of OpenSSL have HMAC_cleanup, but not HMAC_CTX_cleanup.
> This change checks for both, uses HMAC_CTX_cleanup on platforms which
> have it, otherwise falls back to HMAC_cleanup.

On this project, imperative mood is preferred. Also, this _is_ a patch
(implying "change"), so it's not necessary to say "This change". An
alternate way to write the above might be:

    Check for both, and use HMAC_CTX_cleanup when available,
    otherwise HMAC_cleanup.

> This changes makes building GIT on older platforms less tedious.

This is implied by the first paragraph, so no need to state it here explicitly.

More below.

> ---
> diff --git a/Makefile b/Makefile
> index 7482a4d..a495d94 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1059,6 +1059,12 @@ ifndef NO_OPENSSL
>         ifdef NEEDS_CRYPTO_WITH_SSL
>                 OPENSSL_LIBSSL += -lcrypto
>         endif
> +       ifdef HAVE_HMAC_CTX_CLEANUP
> +               BASIC_CFLAGS += -DHAVE_HMAC_CTX_CLEANUP
> +       endif
> +       ifdef HAVE_HMAC_CLEANUP
> +               BASIC_CFLAGS += -DHAVE_HMAC_CLEANUP
> +       endif

See discussion below regarding build breakage due to this incomplete change.

>  else
>         BASIC_CFLAGS += -DNO_OPENSSL
>         BLK_SHA1 = 1
> diff --git a/configure.ac b/configure.ac
> index 3900044..b22788c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -899,6 +899,7 @@ GIT_CONF_SUBST([SNPRINTF_RETURNS_BOGUS])
>  ## Checks for library functions.
>  ## (in default C library and libraries checked by AC_CHECK_LIB)
>  AC_MSG_NOTICE([CHECKS for library functions])
> +

Sneaking in unrelated whitespace change.

>  #
>  # Define NO_LIBGEN_H if you don't have libgen.h.
>  AC_CHECK_HEADER([libgen.h],
> @@ -932,6 +933,18 @@ AC_CHECK_LIB([iconv], [locale_charset],
>                       [CHARSET_LIB=-lcharset])])
>  GIT_CONF_SUBST([CHARSET_LIB])
>  #
> +# Define HAVE_HMAC_CTX_CLEANUP=Yes if we have the newer HMAC cleanup function

s/Yes/YesPease/
s/$/./

> +AC_CHECK_LIB([crypto], [HMAC_CTX_cleanup],
> +       [HAVE_HMAC_CTX_CLEANUP=Yes],
> +       [], [])

No need to pass trailing empty [] arguments explicitly in m4.

> +GIT_CONF_SUBST([HAVE_HMAC_CTX_CLEANUP])

You need to document this new variable in the comment block at the top
of Makefile so that people who build without running the configure
script will know that they may need to tweak it.

> +#
> +# Define HAVE_HMAC_CLEANUP=Yes if we have the older HMAC cleanup function

s/Yes/YesPease/
s/$/./

> +AC_CHECK_LIB([crypto], [HMAC_cleanup],
> +       [HAVE_HMAC_CLEANUP=Yes],
> +       [], [])
> +GIT_CONF_SUBST([HAVE_HMAC_CLEANUP])

This test for HMAC_cleanup() is likely overkill until we encounter a
system which has neither HMAC_CTX_cleanup() nor HMAC_cleanup(). For
the present, it's probably safe to assume that the older
HMAC_cleanup() is available everywhere when HMAC_CTX_cleanup() is not.

> +#
>  # Define NO_CLOCK_GETTIME if you don't have clock_gettime.
>  GIT_CHECK_FUNC(clock_gettime,
>  [HAVE_CLOCK_GETTIME=Yes],
> diff --git a/imap-send.c b/imap-send.c
> index 70bcc7a..eec2378 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -861,7 +861,13 @@ static char *cram(const char *challenge_64, const char *user, const char *pass)
>         HMAC_Init(&hmac, (unsigned char *)pass, strlen(pass), EVP_md5());
>         HMAC_Update(&hmac, (unsigned char *)challenge, decoded_len);
>         HMAC_Final(&hmac, hash, NULL);
> +#if defined(HAVE_HMAC_CTX_CLEANUP)
>         HMAC_CTX_cleanup(&hmac);
> +#elif defined(HAVE_HMAC_CLEANUP)
> +       HMAC_cleanup(&hmac);
> +#else
> +# error "no HMAC_cleanup function"
> +#endif

Several issues:

This change utterly breaks the build for people who do not run the
configure script since neither HAVE_HMAC_CTX_CLEANUP nor
HAVE_HMAC_CLEANUP Makefile variable is set (which means that the
corresponding C #defines are never made).

Somehow, you need to make sure that Makefile variable
HAVE_HMAC_CTX_CLEANUP is set by default since HMAC_CTX_cleanup() is
available on most platforms, and only a few much older ones lack it.
Typically, you would do this in config.make.uname, however, this is
one of those instances in which it is easier to disable a feature for
the rare case than to enable it for the common case. Therefore, it
would be more appropriate to name this variable NO_HMAC_CTX_CLEANUP
(and document it appropriately in Makefile).

Finally, rather than polluting imap-send.c with #if conditionals,
relegate the ugliness to git-compat-util.h. For instance, within the
'#ifndef NO_OPENSSL' conditional, you might add:

    #ifdef NO_HMAC_CTX_CLEANUP
    #define HMAC_CTX_cleanup HMAC_cleanup
    #endif

and then you don't have to touch imap-send.c at all.

>         hex[32] = 0;
>         for (i = 0; i < 16; i++) {
> --
> 2.2.0.GIT

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-01-09  5:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08 20:00 [PATCH 1/3] configure.ac: check 'tv_nsec' field in 'struct stat' Reuben Hawkins
2015-01-08 20:00 ` [PATCH 2/3] configure.ac: check for clock_gettime and CLOCK_MONOTONIC Reuben Hawkins
2015-01-09  5:36   ` Eric Sunshine
2015-01-08 20:00 ` [PATCH 3/3] configure.ac: check for HMAC_CTX_cleanup Reuben Hawkins
2015-01-09  5:37   ` Eric Sunshine
2015-01-09  5:36 ` [PATCH 1/3] configure.ac: check 'tv_nsec' field in 'struct stat' Eric Sunshine
  -- strict thread matches above, loose matches on Subject: below --
2014-12-21 21:28 [PATCH 3/3] configure.ac,imap-send.c: check HMAC_CTX_cleanup Eric Sunshine
2015-01-07 20:23 ` v2 patches for fixes on RHEL3 Reuben Hawkins
2015-01-07 20:23   ` [PATCH 2/3] configure.ac: check for clock_gettime and CLOCK_MONOTONIC Reuben Hawkins
2015-01-07 21:37     ` Eric Sunshine
2015-01-07 22:31       ` Reuben Hawkins
2015-01-08  5:54         ` Eric Sunshine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).