Merge branch 'km/bsd-sysctl'
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 optionmaint
						commit
						551fc7aec1
					
				
							
								
								
									
										6
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										6
									
								
								Makefile
								
								
								
								
							|  | @ -357,6 +357,8 @@ all:: | ||||||
| # and define it to "no" if you need to remove the parentheses () around the | # 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 | # constant.  The default is "auto", which means to use parentheses if your | ||||||
| # compiler is detected to support it. | # compiler is detected to support it. | ||||||
|  | # | ||||||
|  | # Define HAVE_BSD_SYSCTL if your platform has a BSD-compatible sysctl function. | ||||||
|  |  | ||||||
| GIT-VERSION-FILE: FORCE | GIT-VERSION-FILE: FORCE | ||||||
| 	@$(SHELL_PATH) ./GIT-VERSION-GEN | 	@$(SHELL_PATH) ./GIT-VERSION-GEN | ||||||
|  | @ -1431,6 +1433,10 @@ ifdef HAVE_CLOCK_MONOTONIC | ||||||
| 	BASIC_CFLAGS += -DHAVE_CLOCK_MONOTONIC | 	BASIC_CFLAGS += -DHAVE_CLOCK_MONOTONIC | ||||||
| endif | endif | ||||||
|  |  | ||||||
|  | ifdef HAVE_BSD_SYSCTL | ||||||
|  | 	BASIC_CFLAGS += -DHAVE_BSD_SYSCTL | ||||||
|  | endif | ||||||
|  |  | ||||||
| ifeq ($(TCLTK_PATH),) | ifeq ($(TCLTK_PATH),) | ||||||
| NO_TCLTK = NoThanks | NO_TCLTK = NoThanks | ||||||
| endif | endif | ||||||
|  |  | ||||||
|  | @ -107,6 +107,7 @@ ifeq ($(uname_S),Darwin) | ||||||
| 	COMPAT_OBJS += compat/precompose_utf8.o | 	COMPAT_OBJS += compat/precompose_utf8.o | ||||||
| 	BASIC_CFLAGS += -DPRECOMPOSE_UNICODE | 	BASIC_CFLAGS += -DPRECOMPOSE_UNICODE | ||||||
| 	BASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1 | 	BASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1 | ||||||
|  | 	HAVE_BSD_SYSCTL = YesPlease | ||||||
| endif | endif | ||||||
| ifeq ($(uname_S),SunOS) | ifeq ($(uname_S),SunOS) | ||||||
| 	NEEDS_SOCKET = YesPlease | 	NEEDS_SOCKET = YesPlease | ||||||
|  | @ -199,6 +200,7 @@ ifeq ($(uname_S),FreeBSD) | ||||||
| 	PYTHON_PATH = /usr/local/bin/python | 	PYTHON_PATH = /usr/local/bin/python | ||||||
| 	HAVE_PATHS_H = YesPlease | 	HAVE_PATHS_H = YesPlease | ||||||
| 	GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes | 	GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes | ||||||
|  | 	HAVE_BSD_SYSCTL = YesPlease | ||||||
| endif | endif | ||||||
| ifeq ($(uname_S),OpenBSD) | ifeq ($(uname_S),OpenBSD) | ||||||
| 	NO_STRCASESTR = YesPlease | 	NO_STRCASESTR = YesPlease | ||||||
|  | @ -208,6 +210,7 @@ ifeq ($(uname_S),OpenBSD) | ||||||
| 	BASIC_CFLAGS += -I/usr/local/include | 	BASIC_CFLAGS += -I/usr/local/include | ||||||
| 	BASIC_LDFLAGS += -L/usr/local/lib | 	BASIC_LDFLAGS += -L/usr/local/lib | ||||||
| 	HAVE_PATHS_H = YesPlease | 	HAVE_PATHS_H = YesPlease | ||||||
|  | 	HAVE_BSD_SYSCTL = YesPlease | ||||||
| endif | endif | ||||||
| ifeq ($(uname_S),MirBSD) | ifeq ($(uname_S),MirBSD) | ||||||
| 	NO_STRCASESTR = YesPlease | 	NO_STRCASESTR = YesPlease | ||||||
|  | @ -215,6 +218,7 @@ ifeq ($(uname_S),MirBSD) | ||||||
| 	USE_ST_TIMESPEC = YesPlease | 	USE_ST_TIMESPEC = YesPlease | ||||||
| 	NEEDS_LIBICONV = YesPlease | 	NEEDS_LIBICONV = YesPlease | ||||||
| 	HAVE_PATHS_H = YesPlease | 	HAVE_PATHS_H = YesPlease | ||||||
|  | 	HAVE_BSD_SYSCTL = YesPlease | ||||||
| endif | endif | ||||||
| ifeq ($(uname_S),NetBSD) | ifeq ($(uname_S),NetBSD) | ||||||
| 	ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2) | 	ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2) | ||||||
|  | @ -225,6 +229,7 @@ ifeq ($(uname_S),NetBSD) | ||||||
| 	USE_ST_TIMESPEC = YesPlease | 	USE_ST_TIMESPEC = YesPlease | ||||||
| 	NO_MKSTEMPS = YesPlease | 	NO_MKSTEMPS = YesPlease | ||||||
| 	HAVE_PATHS_H = YesPlease | 	HAVE_PATHS_H = YesPlease | ||||||
|  | 	HAVE_BSD_SYSCTL = YesPlease | ||||||
| endif | endif | ||||||
| ifeq ($(uname_S),AIX) | ifeq ($(uname_S),AIX) | ||||||
| 	DEFAULT_PAGER = more | 	DEFAULT_PAGER = more | ||||||
|  |  | ||||||
							
								
								
									
										23
									
								
								configure.ac
								
								
								
								
							
							
						
						
									
										23
									
								
								configure.ac
								
								
								
								
							|  | @ -1046,6 +1046,29 @@ GIT_CONF_SUBST([NO_INITGROUPS]) | ||||||
| # | # | ||||||
| # Define NO_ICONV if your libc does not properly support iconv. | # Define NO_ICONV if your libc does not properly support iconv. | ||||||
|  |  | ||||||
|  | AC_DEFUN([BSD_SYSCTL_SRC], [ | ||||||
|  | AC_LANG_PROGRAM([[ | ||||||
|  | #include <stddef.h> | ||||||
|  | #include <sys/types.h> | ||||||
|  | #include <sys/sysctl.h> | ||||||
|  | ]],[[ | ||||||
|  | int val, mib[2]; | ||||||
|  | size_t len; | ||||||
|  | mib[0] = CTL_HW; | ||||||
|  | mib[1] = 1; | ||||||
|  | len = sizeof(val); | ||||||
|  | return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0; | ||||||
|  | ]])]) | ||||||
|  |  | ||||||
|  | # | ||||||
|  | # Define HAVE_BSD_SYSCTL=YesPlease if a BSD-compatible sysctl function is available. | ||||||
|  | AC_MSG_CHECKING([for BSD sysctl]) | ||||||
|  | AC_COMPILE_IFELSE([BSD_SYSCTL_SRC], | ||||||
|  | 	[AC_MSG_RESULT([yes]) | ||||||
|  | 	HAVE_BSD_SYSCTL=YesPlease], | ||||||
|  | 	[AC_MSG_RESULT([no]) | ||||||
|  | 	HAVE_BSD_SYSCTL=]) | ||||||
|  | GIT_CONF_SUBST([HAVE_BSD_SYSCTL]) | ||||||
|  |  | ||||||
| ## Other checks. | ## Other checks. | ||||||
| # Define USE_PIC if you need the main git objects to be built with -fPIC | # Define USE_PIC if you need the main git objects to be built with -fPIC | ||||||
|  |  | ||||||
|  | @ -127,6 +127,9 @@ | ||||||
| #else | #else | ||||||
| #include <poll.h> | #include <poll.h> | ||||||
| #endif | #endif | ||||||
|  | #ifdef HAVE_BSD_SYSCTL | ||||||
|  | #include <sys/sysctl.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #if defined(__MINGW32__) | #if defined(__MINGW32__) | ||||||
| /* pull in Windows compatibility stuff */ | /* pull in Windows compatibility stuff */ | ||||||
|  |  | ||||||
|  | @ -35,7 +35,23 @@ int online_cpus(void) | ||||||
|  |  | ||||||
| 	if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0)) | 	if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0)) | ||||||
| 		return (int)psd.psd_proc_cnt; | 		return (int)psd.psd_proc_cnt; | ||||||
| #endif | #elif defined(HAVE_BSD_SYSCTL) && defined(HW_NCPU) | ||||||
|  | 	int mib[2]; | ||||||
|  | 	size_t len; | ||||||
|  | 	int cpucount; | ||||||
|  |  | ||||||
|  | 	mib[0] = CTL_HW; | ||||||
|  | #  ifdef HW_AVAILCPU | ||||||
|  | 	mib[1] = HW_AVAILCPU; | ||||||
|  | 	len = sizeof(cpucount); | ||||||
|  | 	if (!sysctl(mib, 2, &cpucount, &len, NULL, 0)) | ||||||
|  | 		return cpucount; | ||||||
|  | #  endif /* HW_AVAILCPU */ | ||||||
|  | 	mib[1] = HW_NCPU; | ||||||
|  | 	len = sizeof(cpucount); | ||||||
|  | 	if (!sysctl(mib, 2, &cpucount, &len, NULL, 0)) | ||||||
|  | 		return cpucount; | ||||||
|  | #endif /* defined(HAVE_BSD_SYSCTL) && defined(HW_NCPU) */ | ||||||
|  |  | ||||||
| #ifdef _SC_NPROCESSORS_ONLN | #ifdef _SC_NPROCESSORS_ONLN | ||||||
| 	if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0) | 	if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano