Merge branch 'km/bsd-sysctl'
authorJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2015 20:11:49 +0000 (13:11 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2015 20:11:49 +0000 (13:11 -0700)
We now detect number of CPUs on older BSD-derived systems.

* km/bsd-sysctl:
thread-utils.c: detect CPU count on older BSD-like systems
configure: support HAVE_BSD_SYSCTL option

1  2 
Makefile
git-compat-util.h
diff --combined Makefile
index 44f1dd10ff508c03d10704f497c32868762243ce,fdac1b980377a178d0202c339c0d8241e7dbab91..5f3987fe3bd945fb5a84c9f45a8de7da5581f79a
+++ b/Makefile
@@@ -349,14 -349,7 +349,16 @@@ all:
  # Define NO_HMAC_CTX_CLEANUP if your OpenSSL is version 0.9.6b or earlier to
  # cleanup the HMAC context with the older HMAC_cleanup function.
  #
 +# Define USE_PARENS_AROUND_GETTEXT_N to "yes" if your compiler happily
 +# compiles the following initialization:
 +#
 +#   static const char s[] = ("FOO");
 +#
 +# and define it to "no" if you need to remove the parentheses () around the
 +# constant.  The default is "auto", which means to use parentheses if your
 +# compiler is detected to support it.
++#
+ # Define HAVE_BSD_SYSCTL if your platform has a BSD-compatible sysctl function.
  
  GIT-VERSION-FILE: FORCE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
@@@ -964,14 -957,6 +966,14 @@@ ifneq (,$(SOCKLEN_T)
        BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
  endif
  
 +ifeq (yes,$(USE_PARENS_AROUND_GETTEXT_N))
 +      BASIC_CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=1
 +else
 +ifeq (no,$(USE_PARENS_AROUND_GETTEXT_N))
 +      BASIC_CFLAGS += -DUSE_PARENS_AROUND_GETTEXT_N=0
 +endif
 +endif
 +
  ifeq ($(uname_S),Darwin)
        ifndef NO_FINK
                ifeq ($(shell test -d /sw/lib && echo y),y)
        REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
        PROGRAM_OBJS += http-fetch.o
        PROGRAMS += $(REMOTE_CURL_NAMES)
 -      curl_check := $(shell (echo 070908; curl-config --vernum) 2>/dev/null | sort -r | sed -ne 2p)
 +      curl_check := $(shell (echo 070908; curl-config --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
        ifeq "$(curl_check)" "070908"
                ifndef NO_EXPAT
                        PROGRAM_OBJS += http-push.o
                endif
        endif
 -      curl_check := $(shell (echo 072200; curl-config --vernum) 2>/dev/null | sort -r | sed -ne 2p)
 +      curl_check := $(shell (echo 072200; curl-config --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
        ifeq "$(curl_check)" "072200"
                USE_CURL_FOR_IMAP_SEND = YesPlease
        endif
@@@ -1431,6 -1416,10 +1433,10 @@@ ifdef HAVE_CLOCK_MONOTONI
        BASIC_CFLAGS += -DHAVE_CLOCK_MONOTONIC
  endif
  
+ ifdef HAVE_BSD_SYSCTL
+       BASIC_CFLAGS += -DHAVE_BSD_SYSCTL
+ endif
  ifeq ($(TCLTK_PATH),)
  NO_TCLTK = NoThanks
  endif
diff --combined git-compat-util.h
index fbfd10dadc0352b5699eaab164959d68a52c9aa6,4ead8c8fdd3bfd7d345f5187d82447f2071a3991..bc8fc8cf854e96badfdf4d96673d33b799207ff3
  #else
  #include <poll.h>
  #endif
+ #ifdef HAVE_BSD_SYSCTL
+ #include <sys/sysctl.h>
+ #endif
  
  #if defined(__MINGW32__)
  /* pull in Windows compatibility stuff */
  typedef long intptr_t;
  typedef unsigned long uintptr_t;
  #endif
 -#if defined(__CYGWIN__)
 -#undef _XOPEN_SOURCE
 -#include <grp.h>
 -#define _XOPEN_SOURCE 600
 -#else
  #undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */
  #include <grp.h>
  #define _ALL_SOURCE 1
  #endif
 -#endif
  
  /* used on Mac OS X */
  #ifdef PRECOMPOSE_UNICODE
@@@ -206,15 -215,12 +209,15 @@@ extern char *gitbasename(char *)
  #endif
  
  #ifndef NO_OPENSSL
 +#ifdef __APPLE__
  #define __AVAILABILITY_MACROS_USES_AVAILABILITY 0
 -#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6
 +#include <AvailabilityMacros.h>
 +#undef DEPRECATED_ATTRIBUTE
 +#define DEPRECATED_ATTRIBUTE
 +#undef __AVAILABILITY_MACROS_USES_AVAILABILITY
 +#endif
  #include <openssl/ssl.h>
  #include <openssl/err.h>
 -#undef MAC_OS_X_VERSION_MIN_REQUIRED
 -#undef __AVAILABILITY_MACROS_USES_AVAILABILITY
  #ifdef NO_HMAC_CTX_CLEANUP
  #define HMAC_CTX_cleanup HMAC_cleanup
  #endif
@@@ -675,11 -681,6 +678,11 @@@ extern char *xgetcwd(void)
  
  #define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), (alloc) * sizeof(*(x)))
  
 +static inline char *xstrdup_or_null(const char *str)
 +{
 +      return str ? xstrdup(str) : NULL;
 +}
 +
  static inline size_t xsize_t(off_t len)
  {
        if (len > (size_t) len)
  }
  
  /* in ctype.c, for kwset users */
 -extern const char tolower_trans_tbl[256];
 +extern const unsigned char tolower_trans_tbl[256];
  
  /* Sane ctype - no locale, and works with signed chars */
  #undef isascii
@@@ -872,12 -873,4 +875,12 @@@ struct tm *git_gmtime_r(const time_t *
  #define gmtime_r git_gmtime_r
  #endif
  
 +#if !defined(USE_PARENS_AROUND_GETTEXT_N) && defined(__GNUC__)
 +#define USE_PARENS_AROUND_GETTEXT_N 1
 +#endif
 +
 +#ifndef SHELL_PATH
 +# define SHELL_PATH "/bin/sh"
 +#endif
 +
  #endif