mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
mhd_check_decls.m4: implemented and used new macro
This commit is contained in:
+7
-8
@@ -2859,7 +2859,7 @@ AS_IF([test "$os_is_native_w32" != "yes"],
|
||||
AS_VAR_IF([have_poll],["yes"],
|
||||
[
|
||||
AC_DEFINE([[HAVE_POLL]],[[1]],[Define to '1' if poll() is supported on your platform])
|
||||
AC_CHECK_DECLS([POLLRDNORM,POLLIN,POLLRDBAND,POLLWRNORM,POLLOUT,POLLWRBAND,POLLPRI],[],[],[[
|
||||
MHD_CHECK_DECLS([POLLRDNORM POLLIN POLLRDBAND POLLWRNORM POLLOUT POLLWRBAND POLLPRI],[[
|
||||
#ifdef HAVE_POLL_H
|
||||
#include <poll.h>
|
||||
#endif
|
||||
@@ -3203,8 +3203,8 @@ AS_VAR_IF([[os_is_native_w32]], [["yes"]],[],
|
||||
]
|
||||
)
|
||||
|
||||
AC_CHECK_DECLS([AF_UNIX,AF_LOCAL,SOMAXCONN,IPV6_V6ONLY,SO_REUSEADDR,SO_REUSEPORT,\
|
||||
TCP_NODELAY,TCP_FASTOPEN],[],[],
|
||||
MHD_CHECK_DECLS([AF_UNIX AF_LOCAL SOMAXCONN IPV6_V6ONLY SO_REUSEADDR SO_REUSEPORT \
|
||||
TCP_NODELAY TCP_FASTOPEN SOL_SOCKET SO_LINGER SHUT_WR SD_SEND],
|
||||
[[
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
@@ -3874,7 +3874,7 @@ MHD_CHECK_FUNC([[sysctl]], [[
|
||||
i][f (sysctl(mib, 2, NULL, NULL, NULL, 0)) return 1;
|
||||
]],
|
||||
[
|
||||
AC_CHECK_DECLS([CTL_NET,PF_INET,IPPROTO_ICMP,ICMPCTL_ICMPLIM],[],[],
|
||||
MHD_CHECK_DECLS([CTL_NET PF_INET IPPROTO_ICMP ICMPCTL_ICMPLIM],
|
||||
[[
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
@@ -5931,9 +5931,8 @@ AM_CONDITIONAL([USE_IPV6_TESTING], [[test "x$mhd_cv_ipv6_for_testing" = "xyes"]]
|
||||
AS_VAR_IF([enable_tools],["yes"],
|
||||
[
|
||||
AC_CHECK_HEADERS([features.h sys/pstat.h vxCpuLib.h],[],[],[AC_INCLUDES_DEFAULT])
|
||||
AC_CHECK_DECLS(
|
||||
[_SC_NPROCESSORS_ONLN,_SC_NPROC_ONLN,_SC_CRAY_NCPU,_SC_NPROCESSORS_CONF,CTL_HW,HW_NCPUONLINE,HW_NCPU,HW_AVAILCPU],
|
||||
[],[],
|
||||
MHD_CHECK_DECLS([_SC_NPROCESSORS_ONLN _SC_NPROC_ONLN _SC_CRAY_NCPU _SC_NPROCESSORS_CONF \
|
||||
CTL_HW HW_NCPUONLINE HW_NCPU HW_AVAILCPU],
|
||||
[[
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
@@ -6027,7 +6026,7 @@ AS_VAR_IF([enable_tools],["yes"],
|
||||
}
|
||||
CPU_FREE(p_set);
|
||||
]],
|
||||
[AC_CHECK_DECLS([CPU_SETSIZE],[],[],[#include <sched.h>])]
|
||||
[MHD_CHECK_DECLS([CPU_SETSIZE],[],[],[#include <sched.h>])]
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# SYNOPSIS
|
||||
#
|
||||
# MHD_CHECK_DECLS([SYMBOLS-TO-TEST], [INCLUDES])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro checks whether specific symbols is defined in the headers.
|
||||
# SYMBOLS-TO-TEST is s space-separated list of symbols to check.
|
||||
# The symbol could be a macro, a variable, a constant, a enum value,
|
||||
# a function name or other kind of symbols recognisable by compiler (or
|
||||
# preprocessor).
|
||||
# For every found symbol a relevant preprocessor macro is defined.
|
||||
# Unlike AC_CHECK_DECLS this m4 macro does not define preprocossor macro if
|
||||
# symbol is NOT found.
|
||||
#
|
||||
# Example usage:
|
||||
#
|
||||
# MHD_CHECK_DECLS([SSIZE_MAX OFF_T_MAX], [[#include <limits.h>]])
|
||||
#
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2025 Karlson2k (Evgeny Grin) <k2k@drgrin.dev>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 1
|
||||
|
||||
AC_DEFUN([MHD_CHECK_DECLS],[dnl
|
||||
m4_newline([[# Expansion of $0 macro starts here]])
|
||||
m4_if(m4_index([$1], [(]),[-1],[],[dnl
|
||||
m4_fatal([SYMBOLS-TO-TEST parameter (first macro argument) contains '('])])dnl m4_if
|
||||
m4_if(m4_index([$1], [)]),[-1],[],[dnl
|
||||
m4_fatal([SYMBOLS-TO-TEST parameter (first macro argument) contains ')'])])dnl m4_if
|
||||
m4_if(m4_index([$1], [,]),[-1],[],[dnl
|
||||
m4_fatal([SYMBOLS-TO-TEST parameter (first macro argument) contains ','])])dnl m4_if
|
||||
m4_foreach_w([check_Symbol],[$1],
|
||||
[AC_CHECK_DECL(check_Symbol,[dnl
|
||||
AC_DEFINE([HAVE_DCLR_]m4_toupper(check_Symbol),[1],[Define to '1' if you have the declaration of ']check_Symbol['])dnl
|
||||
],[],[$2])
|
||||
])dnl
|
||||
m4_newline([[# Expansion of $0 macro ends here]])
|
||||
])
|
||||
@@ -507,83 +507,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Un-define some HAVE_DECL_* macro if they equal zero.
|
||||
This should allow safely use #ifdef in the code.
|
||||
Define HAS_DECL_* macros only if matching HAVE_DECL_* macro
|
||||
has non-zero value. Unlike HAVE_DECL_*, macros HAS_DECL_*
|
||||
cannot have zero value. */
|
||||
#ifdef HAVE_DECL__SC_NPROCESSORS_ONLN
|
||||
# if 0 == HAVE_DECL__SC_NPROCESSORS_ONLN
|
||||
# undef HAVE_DECL__SC_NPROCESSORS_ONLN
|
||||
# else /* 0 != HAVE_DECL__SC_NPROCESSORS_ONLN */
|
||||
# define HAS_DECL__SC_NPROCESSORS_ONLN 1
|
||||
# endif /* 0 != HAVE_DECL__SC_NPROCESSORS_ONLN */
|
||||
#endif /* HAVE_DECL__SC_NPROCESSORS_ONLN */
|
||||
|
||||
#ifdef HAVE_DECL__SC_NPROCESSORS_CONF
|
||||
# if 0 == HAVE_DECL__SC_NPROCESSORS_CONF
|
||||
# undef HAVE_DECL__SC_NPROCESSORS_CONF
|
||||
# else /* 0 != HAVE_DECL__SC_NPROCESSORS_CONF */
|
||||
# define HAS_DECL__SC_NPROCESSORS_CONF 1
|
||||
# endif /* 0 != HAVE_DECL__SC_NPROCESSORS_CONF */
|
||||
#endif /* HAVE_DECL__SC_NPROCESSORS_CONF */
|
||||
|
||||
#ifdef HAVE_DECL__SC_NPROC_ONLN
|
||||
# if 0 == HAVE_DECL__SC_NPROC_ONLN
|
||||
# undef HAVE_DECL__SC_NPROC_ONLN
|
||||
# else /* 0 != HAVE_DECL__SC_NPROC_ONLN */
|
||||
# define HAS_DECL__SC_NPROC_ONLN 1
|
||||
# endif /* 0 != HAVE_DECL__SC_NPROC_ONLN */
|
||||
#endif /* HAVE_DECL__SC_NPROC_ONLN */
|
||||
|
||||
#ifdef HAVE_DECL__SC_CRAY_NCPU
|
||||
# if 0 == HAVE_DECL__SC_CRAY_NCPU
|
||||
# undef HAVE_DECL__SC_CRAY_NCPU
|
||||
# else /* 0 != HAVE_DECL__SC_CRAY_NCPU */
|
||||
# define HAS_DECL__SC_CRAY_NCPU 1
|
||||
# endif /* 0 != HAVE_DECL__SC_CRAY_NCPU */
|
||||
#endif /* HAVE_DECL__SC_CRAY_NCPU */
|
||||
|
||||
#ifdef HAVE_DECL_CTL_HW
|
||||
# if 0 == HAVE_DECL_CTL_HW
|
||||
# undef HAVE_DECL_CTL_HW
|
||||
# else /* 0 != HAVE_DECL_CTL_HW */
|
||||
# define HAS_DECL_CTL_HW 1
|
||||
# endif /* 0 != HAVE_DECL_CTL_HW */
|
||||
#endif /* HAVE_DECL_CTL_HW */
|
||||
|
||||
#ifdef HAVE_DECL_HW_NCPUONLINE
|
||||
# if 0 == HAVE_DECL_HW_NCPUONLINE
|
||||
# undef HAVE_DECL_HW_NCPUONLINE
|
||||
# else /* 0 != HAVE_DECL_HW_NCPUONLINE */
|
||||
# define HAS_DECL_HW_NCPUONLINE 1
|
||||
# endif /* 0 != HAVE_DECL_HW_NCPUONLINE */
|
||||
#endif /* HAVE_DECL_HW_NCPUONLINE */
|
||||
|
||||
#ifdef HAVE_DECL_HW_AVAILCPU
|
||||
# if 0 == HAVE_DECL_HW_AVAILCPU
|
||||
# undef HAVE_DECL_HW_AVAILCPU
|
||||
# else /* 0 != HAVE_DECL_HW_AVAILCPU */
|
||||
# define HAS_DECL_HW_AVAILCPU 1
|
||||
# endif /* 0 != HAVE_DECL_HW_AVAILCPU */
|
||||
#endif /* HAVE_DECL_HW_AVAILCPU */
|
||||
|
||||
#ifdef HAVE_DECL_HW_NCPU
|
||||
# if 0 == HAVE_DECL_HW_NCPU
|
||||
# undef HAVE_DECL_HW_NCPU
|
||||
# else /* 0 != HAVE_DECL_HW_NCPU */
|
||||
# define HAS_DECL_HW_NCPU 1
|
||||
# endif /* 0 != HAVE_DECL_HW_NCPU */
|
||||
#endif /* HAVE_DECL_HW_NCPU */
|
||||
|
||||
#ifdef HAVE_DECL_CPU_SETSIZE
|
||||
# if 0 == HAVE_DECL_CPU_SETSIZE
|
||||
# undef HAVE_DECL_CPU_SETSIZE
|
||||
# else /* 0 != HAVE_DECL_CPU_SETSIZE */
|
||||
# define HAS_DECL_CPU_SETSIZE 1
|
||||
# endif /* 0 != HAVE_DECL_CPU_SETSIZE */
|
||||
#endif /* HAVE_DECL_CPU_SETSIZE */
|
||||
|
||||
#ifndef MHD_AUTH_DIGEST_DEF_TIMEOUT
|
||||
# define MHD_AUTH_DIGEST_DEF_TIMEOUT 90
|
||||
#endif /* ! MHD_AUTH_DIGEST_DEF_TIMEOUT */
|
||||
|
||||
+10
-10
@@ -413,7 +413,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
#ifdef HAVE_INET6
|
||||
else
|
||||
{
|
||||
#ifdef IPV6_V6ONLY // TODO: detect constants declarations in configure
|
||||
#ifdef HAVE_DCLR_IPV6_V6ONLY
|
||||
sk_type = mhd_SKT_IP_DUAL_REQUIRED;
|
||||
#else /* ! IPV6_V6ONLY */
|
||||
mhd_LOG_MSG (d, \
|
||||
@@ -454,7 +454,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
return MHD_SC_INTERNAL_ERROR;
|
||||
case MHD_AF_AUTO:
|
||||
#ifdef HAVE_INET6
|
||||
#ifdef IPV6_V6ONLY // TODO: detect constants declarations in configure
|
||||
#ifdef HAVE_DCLR_IPV6_V6ONLY
|
||||
if (force_v6_any_dual)
|
||||
sk_type = mhd_SKT_IP_V6_WITH_V4_OPT;
|
||||
else if (v6_tried)
|
||||
@@ -493,7 +493,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
mhd_assert (! v6_tried);
|
||||
mhd_assert (! force_v6_any_dual);
|
||||
#ifdef HAVE_INET6
|
||||
#ifdef IPV6_V6ONLY // TODO: detect constants declarations in configure
|
||||
#ifdef HAVE_DCLR_IPV6_V6ONLY
|
||||
sk_type = mhd_SKT_IP_DUAL_REQUIRED;
|
||||
#else /* ! IPV6_V6ONLY */
|
||||
mhd_LOG_MSG (d,
|
||||
@@ -513,7 +513,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
mhd_assert (! v6_tried);
|
||||
mhd_assert (! force_v6_any_dual);
|
||||
#ifdef HAVE_INET6
|
||||
#ifdef IPV6_V6ONLY // TODO: detect constants declarations in configure
|
||||
#ifdef HAVE_DCLR_IPV6_V6ONLY
|
||||
sk_type = mhd_SKT_IP_V6_WITH_V4_OPT;
|
||||
#else /* ! IPV6_V6ONLY */
|
||||
sk_type = mhd_SKT_IP_V6_ONLY;
|
||||
@@ -528,7 +528,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
case MHD_AF_DUAL_v6_OPTIONAL:
|
||||
mhd_assert (! force_v6_any_dual);
|
||||
#ifdef HAVE_INET6
|
||||
#ifdef IPV6_V6ONLY // TODO: detect constants declarations in configure
|
||||
#ifdef HAVE_DCLR_IPV6_V6ONLY
|
||||
sk_type = (! v6_tried) ?
|
||||
mhd_SKT_IP_V4_WITH_V6_OPT : mhd_SKT_IP_V4_ONLY;
|
||||
#else /* ! IPV6_V6ONLY */
|
||||
@@ -689,7 +689,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
if (! sk_already_listening)
|
||||
{
|
||||
#ifdef HAVE_INET6
|
||||
#ifdef IPV6_V6ONLY // TODO: detect constants declarations in configure
|
||||
#ifdef HAVE_DCLR_IPV6_V6ONLY
|
||||
if ((mhd_SKT_IP_V6_ONLY == sk_type) ||
|
||||
(mhd_SKT_IP_DUAL_REQUIRED == sk_type) ||
|
||||
(mhd_SKT_IP_V4_WITH_V6_OPT == sk_type) ||
|
||||
@@ -783,7 +783,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
|
||||
if (MHD_FOM_AUTO <= d->settings->tcp_fastopen.v_option)
|
||||
{
|
||||
#if defined(TCP_FASTOPEN)
|
||||
#if defined(HAVE_DCLR_TCP_FASTOPEN)
|
||||
int fo_param;
|
||||
#ifdef __linux__
|
||||
/* The parameter is the queue length */
|
||||
@@ -820,7 +820,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
if (MHD_D_OPTION_BIND_TYPE_NOT_SHARED >= d->settings->listen_addr_reuse)
|
||||
{
|
||||
#ifndef MHD_SOCKETS_KIND_WINSOCK
|
||||
#ifdef SO_REUSEADDR
|
||||
#ifdef HAVE_DCLR_SO_REUSEADDR
|
||||
mhd_SCKT_OPT_BOOL on_val1 = 1;
|
||||
if (0 != setsockopt (sk, SOL_SOCKET, SO_REUSEADDR,
|
||||
(const void *) &on_val1, sizeof (on_val1)))
|
||||
@@ -836,7 +836,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
#endif /* ! MHD_SOCKETS_KIND_WINSOCK */
|
||||
if (MHD_D_OPTION_BIND_TYPE_NOT_SHARED > d->settings->listen_addr_reuse)
|
||||
{
|
||||
#if defined(SO_REUSEPORT) || defined(MHD_SOCKETS_KIND_WINSOCK)
|
||||
#if defined(HAVE_DCLR_SO_REUSEPORT) || defined(MHD_SOCKETS_KIND_WINSOCK)
|
||||
mhd_SCKT_OPT_BOOL on_val2 = 1;
|
||||
if (0 != setsockopt (sk, SOL_SOCKET,
|
||||
#ifndef MHD_SOCKETS_KIND_WINSOCK
|
||||
@@ -912,7 +912,7 @@ create_bind_listen_stream_socket (struct MHD_Daemon *restrict d,
|
||||
accept_queue_len = 0;
|
||||
if (0 == accept_queue_len)
|
||||
{
|
||||
#ifdef SOMAXCONN
|
||||
#if defined(SOMAXCONN) || defined(HAVE_DCLR_SOMAXCONN)
|
||||
accept_queue_len = SOMAXCONN;
|
||||
#else /* ! SOMAXCONN */
|
||||
accept_queue_len = 127; /* Should be the safe value */
|
||||
|
||||
+1
-1
@@ -198,7 +198,7 @@ MHD_INTERNAL MHD_FN_PAR_NONNULL_ALL_ bool
|
||||
mhd_connection_set_nodelay_state (struct MHD_Connection *connection,
|
||||
bool nodelay_state)
|
||||
{
|
||||
#ifdef TCP_NODELAY
|
||||
#ifdef HAVE_DCLR_TCP_NODELAY
|
||||
static const mhd_SCKT_OPT_BOOL off_val = 0;
|
||||
static const mhd_SCKT_OPT_BOOL on_val = 1;
|
||||
int err_code;
|
||||
|
||||
@@ -111,8 +111,7 @@ MHD_INTERNAL bool
|
||||
mhd_socket_set_nodelay (MHD_Socket sckt,
|
||||
bool on)
|
||||
{
|
||||
// TODO: detect constants in configure
|
||||
#ifdef TCP_NODELAY
|
||||
#ifdef HAVE_DCLR_TCP_NODELAY
|
||||
mhd_SCKT_OPT_BOOL value;
|
||||
|
||||
value = on ? 1 : 0;
|
||||
@@ -120,7 +119,7 @@ mhd_socket_set_nodelay (MHD_Socket sckt,
|
||||
return 0 == setsockopt (sckt, IPPROTO_TCP, TCP_NODELAY,
|
||||
(const void *) &value, sizeof (value));
|
||||
#else /* ! TCP_NODELAY */
|
||||
(void) sock; (void) on;
|
||||
(void) sckt; (void) on;
|
||||
return false;
|
||||
#endif /* ! TCP_NODELAY */
|
||||
}
|
||||
@@ -129,8 +128,7 @@ mhd_socket_set_nodelay (MHD_Socket sckt,
|
||||
MHD_INTERNAL bool
|
||||
mhd_socket_set_hard_close (MHD_Socket sckt)
|
||||
{
|
||||
// TODO: detect constants in configure
|
||||
#if defined(SOL_SOCKET) && defined(SO_LINGER)
|
||||
#if defined(HAVE_DCLR_SOL_SOCKET) && defined(HAVE_DCLR_SO_LINGER)
|
||||
struct linger par;
|
||||
|
||||
par.l_onoff = 1;
|
||||
@@ -138,19 +136,19 @@ mhd_socket_set_hard_close (MHD_Socket sckt)
|
||||
|
||||
return 0 == setsockopt (sckt, SOL_SOCKET, SO_LINGER,
|
||||
(const void *) &par, sizeof (par));
|
||||
#else /* ! TCP_NODELAY */
|
||||
(void) sock;
|
||||
#else /* ! SOL_SOCKET || ! SO_LINGER */
|
||||
(void) sckt;
|
||||
return false;
|
||||
#endif /* ! TCP_NODELAY */
|
||||
#endif /* ! SOL_SOCKET || ! SO_LINGER */
|
||||
}
|
||||
|
||||
|
||||
MHD_INTERNAL bool
|
||||
mhd_socket_shut_wr (MHD_Socket sckt)
|
||||
{
|
||||
#if defined(SHUT_WR) // TODO: detect constants in configure
|
||||
#if defined(HAVE_DCLR_SHUT_WR)
|
||||
return 0 == shutdown (sckt, SHUT_WR);
|
||||
#elif defined(SD_SEND) // TODO: detect constants in configure
|
||||
#elif defined(HAVE_DCLR_SD_SEND)
|
||||
return 0 == shutdown (sckt, SD_SEND);
|
||||
#else
|
||||
return false;
|
||||
|
||||
@@ -53,6 +53,16 @@
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#if ! defined(HAVE_DCLR_IPV6_V6ONLY) && defined(IPV6_V6ONLY)
|
||||
/* Mis-deteted by configure */
|
||||
# define HAVE_DCLR_IPV6_V6ONLY 1
|
||||
#endif
|
||||
|
||||
#if ! defined(HAVE_DCLR_TCP_NODELAY) && defined(TCP_NODELAY)
|
||||
/* Mis-deteted by configure */
|
||||
# define HAVE_DCLR_TCP_NODELAY 1
|
||||
#endif
|
||||
|
||||
#ifdef IPPROTO_TCP
|
||||
# if defined(TCP_CORK)
|
||||
/**
|
||||
|
||||
+5
-10
@@ -44,36 +44,31 @@
|
||||
#error Uknown sockets type
|
||||
# endif
|
||||
|
||||
# if (defined(HAVE_DECL_POLLRDNORM) && (0 != HAVE_DECL_POLLRDNORM + 0)) || \
|
||||
defined(POLLRDNORM)
|
||||
# if defined(HAVE_DCLR_POLLRDNORM) || defined(POLLRDNORM)
|
||||
# define MHD_POLL_IN POLLRDNORM
|
||||
# else
|
||||
# define MHD_POLL_IN POLLIN
|
||||
# endif
|
||||
|
||||
# if (defined(HAVE_DECL_POLLWRNORM) && (0 != HAVE_DECL_POLLWRNORM + 0)) || \
|
||||
defined(POLLWRNORM)
|
||||
# if defined(HAVE_DCLR_POLLWRNORM) || defined(POLLWRNORM)
|
||||
# define MHD_POLL_OUT POLLWRNORM
|
||||
# else
|
||||
# define MHD_POLL_OUT POLLOUT
|
||||
# endif
|
||||
|
||||
# if (defined(HAVE_DECL_POLLRDBAND) && (0 != HAVE_DECL_POLLRDBAND + 0)) || \
|
||||
defined(POLLRDBAND)
|
||||
# if defined(HAVE_DCLR_POLLRDBAND) || defined(POLLRDBAND)
|
||||
# define MHD_POLLRDBAND POLLRDBAND
|
||||
# else
|
||||
# define MHD_POLLRDBAND (0)
|
||||
# endif
|
||||
|
||||
# if (defined(HAVE_DECL_POLLWRBAND) && (0 != HAVE_DECL_POLLWRBAND + 0)) || \
|
||||
defined(POLLWRBAND)
|
||||
# if defined(HAVE_DCLR_POLLWRBAND) || defined(POLLWRBAND)
|
||||
# define MHD_POLLWRBAND POLLWRBAND
|
||||
# else
|
||||
# define MHD_POLLWRBAND (0)
|
||||
# endif
|
||||
|
||||
# if (defined(HAVE_DECL_POLLPRI) && (0 != HAVE_DECL_POLLPRI + 0)) || \
|
||||
defined(POLLWRBAND)
|
||||
# if defined(HAVE_DCLR_POLLPRI) || defined(POLLWRBAND)
|
||||
# define MHD_POLLPRI POLLPRI
|
||||
# else
|
||||
# define MHD_POLLPRI (0)
|
||||
|
||||
@@ -121,11 +121,9 @@ typedef int mhd_SCKT_SEND_SIZE;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(AF_UNIX) || \
|
||||
(defined(HAVE_DECL_AF_UNIX) && (HAVE_DECL_AF_UNIX + 0 != 0))
|
||||
#if defined(AF_UNIX) || defined(HAVE_DCLR_AF_UNIX)
|
||||
# define MHD_AF_UNIX AF_UNIX
|
||||
#elif defined(AF_LOCAL) || \
|
||||
(defined(HAVE_DECL_AF_LOCAL) && (HAVE_DECL_AF_LOCAL + 0 != 0))
|
||||
#elif defined(AF_LOCAL) || defined(HAVE_DCLR_AF_LOCAL)
|
||||
# define MHD_AF_UNIX AF_LOCAL
|
||||
#endif /* AF_UNIX */
|
||||
|
||||
|
||||
@@ -74,45 +74,45 @@
|
||||
# include <stdbool.h>
|
||||
#endif /* HAVE_STDBOOL_H */
|
||||
|
||||
#if ! defined(HAS_DECL_CPU_SETSIZE) && ! defined(CPU_SETSIZE)
|
||||
#if ! defined(HAVE_DCLR_CPU_SETSIZE) && ! defined(CPU_SETSIZE)
|
||||
# define CPU_SETSIZE (1024)
|
||||
# define CPU_SETSIZE_SAFE (64)
|
||||
#else /* HAS_DECL_CPU_SETSIZE || CPU_SETSIZE */
|
||||
#else /* HAVE_DCLR_CPU_SETSIZE || CPU_SETSIZE */
|
||||
# define CPU_SETSIZE_SAFE CPU_SETSIZE
|
||||
#endif /* HAS_DECL_CPU_SETSIZE || CPU_SETSIZE */
|
||||
#endif /* HAVE_DCLR_CPU_SETSIZE || CPU_SETSIZE */
|
||||
|
||||
/* Check and fix possible missing macros */
|
||||
#if ! defined(HAS_DECL_CTL_HW) && defined(CTL_HW)
|
||||
# define HAS_DECL_CTL_HW 1
|
||||
#endif /* ! HAS_DECL_CTL_HW && CTL_HW */
|
||||
#if ! defined(HAVE_DCLR_CTL_HW) && defined(CTL_HW)
|
||||
# define HAVE_DCLR_CTL_HW 1
|
||||
#endif /* ! HAVE_DCLR_CTL_HW && CTL_HW */
|
||||
|
||||
#if ! defined(HAS_DECL_HW_NCPUONLINE) && defined(HW_NCPUONLINE)
|
||||
# define HAS_DECL_HW_NCPUONLINE 1
|
||||
#endif /* ! HAS_DECL_HW_NCPUONLINE && HW_NCPUONLINE */
|
||||
#if ! defined(HAVE_DCLR_HW_NCPUONLINE) && defined(HW_NCPUONLINE)
|
||||
# define HAVE_DCLR_HW_NCPUONLINE 1
|
||||
#endif /* ! HAVE_DCLR_HW_NCPUONLINE && HW_NCPUONLINE */
|
||||
|
||||
#if ! defined(HAS_DECL_HW_AVAILCPU) && defined(HW_AVAILCPU)
|
||||
# define HAS_DECL_HW_AVAILCPU 1
|
||||
#endif /* ! HAS_DECL_HW_AVAILCPU && HW_AVAILCPU */
|
||||
#if ! defined(HAVE_DCLR_HW_AVAILCPU) && defined(HW_AVAILCPU)
|
||||
# define HAVE_DCLR_HW_AVAILCPU 1
|
||||
#endif /* ! HAVE_DCLR_HW_AVAILCPU && HW_AVAILCPU */
|
||||
|
||||
#if ! defined(HAS_DECL_HW_NCPU) && defined(HW_NCPU)
|
||||
# define HAS_DECL_HW_NCPU 1
|
||||
#endif /* ! HAS_DECL_HW_NCPU && HW_NCPU */
|
||||
#if ! defined(HAVE_DCLR_HW_NCPU) && defined(HW_NCPU)
|
||||
# define HAVE_DCLR_HW_NCPU 1
|
||||
#endif /* ! HAVE_DCLR_HW_NCPU && HW_NCPU */
|
||||
|
||||
#if ! defined(HAS_DECL__SC_NPROCESSORS_ONLN) && defined(_SC_NPROCESSORS_ONLN)
|
||||
# define HAS_DECL__SC_NPROCESSORS_ONLN 1
|
||||
#endif /* ! HAS_DECL__SC_NPROCESSORS_ONLN && _SC_NPROCESSORS_ONLN */
|
||||
#if ! defined(HAVE_DCLR__SC_NPROCESSORS_ONLN) && defined(_SC_NPROCESSORS_ONLN)
|
||||
# define HAVE_DCLR__SC_NPROCESSORS_ONLN 1
|
||||
#endif /* ! HAVE_DCLR__SC_NPROCESSORS_ONLN && _SC_NPROCESSORS_ONLN */
|
||||
|
||||
#if ! defined(HAS_DECL__SC_NPROC_ONLN) && defined(_SC_NPROC_ONLN)
|
||||
# define HAS_DECL__SC_NPROC_ONLN 1
|
||||
#endif /* ! HAS_DECL__SC_NPROC_ONLN && _SC_NPROC_ONLN */
|
||||
#if ! defined(HAVE_DCLR__SC_NPROC_ONLN) && defined(_SC_NPROC_ONLN)
|
||||
# define HAVE_DCLR__SC_NPROC_ONLN 1
|
||||
#endif /* ! HAVE_DCLR__SC_NPROC_ONLN && _SC_NPROC_ONLN */
|
||||
|
||||
#if ! defined(HAS_DECL__SC_CRAY_NCPU) && defined(_SC_CRAY_NCPU)
|
||||
# define HAS_DECL__SC_CRAY_NCPU 1
|
||||
#endif /* ! HAS_DECL__SC_CRAY_NCPU && _SC_CRAY_NCPU */
|
||||
#if ! defined(HAVE_DCLR__SC_CRAY_NCPU) && defined(_SC_CRAY_NCPU)
|
||||
# define HAVE_DCLR__SC_CRAY_NCPU 1
|
||||
#endif /* ! HAVE_DCLR__SC_CRAY_NCPU && _SC_CRAY_NCPU */
|
||||
|
||||
#if ! defined(HAS_DECL__SC_NPROCESSORS_CONF) && defined(_SC_NPROCESSORS_CONF)
|
||||
# define HAS_DECL__SC_NPROCESSORS_CONF 1
|
||||
#endif /* ! HAVE_DECL__SC_NPROCESSORS_CONF && _SC_NPROCESSORS_CONF */
|
||||
#if ! defined(HAVE_DCLR__SC_NPROCESSORS_CONF) && defined(_SC_NPROCESSORS_CONF)
|
||||
# define HAVE_DCLR__SC_NPROCESSORS_CONF 1
|
||||
#endif /* ! HAVE_DCLR__SC_NPROCESSORS_CONF && _SC_NPROCESSORS_CONF */
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
@@ -269,7 +269,7 @@ mhd_tool_get_proc_cpu_count_sched_getaffinity_np_ (void)
|
||||
cpuset_ptr))
|
||||
{
|
||||
cpuid_t cpu_num;
|
||||
#if defined(HAVE_SYSCONF) && defined(HAVE_DECL__SC_NPROCESSORS_CONF)
|
||||
#if defined(HAVE_SYSCONF) && defined(HAVE_DCLR__SC_NPROCESSORS_CONF)
|
||||
unsigned int max_num = 0;
|
||||
long sc_value;
|
||||
sc_value = sysconf (_SC_NPROCESSORS_ONLN);
|
||||
@@ -283,7 +283,7 @@ mhd_tool_get_proc_cpu_count_sched_getaffinity_np_ (void)
|
||||
++ret;
|
||||
}
|
||||
else /* Combined with the next 'if' */
|
||||
#endif /* HAVE_SYSCONF && HAVE_DECL__SC_NPROCESSORS_CONF */
|
||||
#endif /* HAVE_SYSCONF && HAVE_DCLR__SC_NPROCESSORS_CONF */
|
||||
if (1)
|
||||
{
|
||||
int res;
|
||||
@@ -719,8 +719,8 @@ mhd_tool_get_sys_cpu_count_sysctl_ (void)
|
||||
}
|
||||
#endif /* HAVE_SYSCTLBYNAME */
|
||||
#if defined(HAVE_SYSCTL) && \
|
||||
defined(HAS_DECL_CTL_HW) && \
|
||||
defined(HAS_DECL_HW_NCPUONLINE)
|
||||
defined(HAVE_DCLR_CTL_HW) && \
|
||||
defined(HAVE_DCLR_HW_NCPUONLINE)
|
||||
if (0 >= ret)
|
||||
{
|
||||
/* OpenBSD, NetBSD: The number of online CPUs */
|
||||
@@ -730,10 +730,10 @@ mhd_tool_get_sys_cpu_count_sysctl_ (void)
|
||||
|| (sizeof (ret) != value_size))
|
||||
ret = -1;
|
||||
}
|
||||
#endif /* HAVE_SYSCTL && HAS_DECL_CTL_HW && HAS_DECL_HW_NCPUONLINE */
|
||||
#endif /* HAVE_SYSCTL && HAVE_DCLR_CTL_HW && HAVE_DCLR_HW_NCPUONLINE */
|
||||
#if defined(HAVE_SYSCTL) && \
|
||||
defined(HAS_DECL_CTL_HW) && \
|
||||
defined(HAS_DECL_HW_AVAILCPU)
|
||||
defined(HAVE_DCLR_CTL_HW) && \
|
||||
defined(HAVE_DCLR_HW_AVAILCPU)
|
||||
if (0 >= ret)
|
||||
{
|
||||
/* Darwin: The MIB name for "hw.activecpu" */
|
||||
@@ -743,7 +743,7 @@ mhd_tool_get_sys_cpu_count_sysctl_ (void)
|
||||
|| (sizeof (ret) != value_size))
|
||||
ret = -1;
|
||||
}
|
||||
#endif /* HAVE_SYSCTL && HAS_DECL_CTL_HW && HAS_DECL_HW_AVAILCPU */
|
||||
#endif /* HAVE_SYSCTL && HAVE_DCLR_CTL_HW && HAVE_DCLR_HW_AVAILCPU */
|
||||
#endif /* ! __linux__ */
|
||||
if (0 >= ret)
|
||||
return -1;
|
||||
@@ -781,8 +781,8 @@ mhd_tool_get_sys_cpu_count_sysctl_fallback_ (void)
|
||||
}
|
||||
#endif /* HAVE_SYSCTLBYNAME */
|
||||
#if defined(HAVE_SYSCTL) && \
|
||||
defined(HAS_DECL_CTL_HW) && \
|
||||
defined(HAS_DECL_HW_NCPU)
|
||||
defined(HAVE_DCLR_CTL_HW) && \
|
||||
defined(HAVE_DCLR_HW_NCPU)
|
||||
if (0 >= ret)
|
||||
{
|
||||
/* FreeBSD, OpenBSD, NetBSD, Darwin (and others?): The number of CPUs */
|
||||
@@ -792,7 +792,7 @@ mhd_tool_get_sys_cpu_count_sysctl_fallback_ (void)
|
||||
|| (sizeof (ret) != value_size))
|
||||
ret = -1;
|
||||
}
|
||||
#endif /* HAVE_SYSCTL && HAS_DECL_CTL_HW && HAS_DECL_HW_NCPU */
|
||||
#endif /* HAVE_SYSCTL && HAVE_DCLR_CTL_HW && HAVE_DCLR_HW_NCPU */
|
||||
#endif /* ! __linux__ */
|
||||
if (0 >= ret)
|
||||
return -1;
|
||||
@@ -813,23 +813,23 @@ mhd_tool_get_sys_cpu_count_sysconf_ (void)
|
||||
{
|
||||
int ret = -1;
|
||||
#if defined(HAVE_SYSCONF) && \
|
||||
(defined(HAS_DECL__SC_NPROCESSORS_ONLN) || defined(HAS_DECL__SC_NPROC_ONLN))
|
||||
(defined(HAVE_DCLR__SC_NPROCESSORS_ONLN) || defined(HAVE_DCLR__SC_NPROC_ONLN))
|
||||
long value = -1;
|
||||
#ifdef HAS_DECL__SC_NPROCESSORS_ONLN
|
||||
#ifdef HAVE_DCLR__SC_NPROCESSORS_ONLN
|
||||
if (0 >= value)
|
||||
value = sysconf (_SC_NPROCESSORS_ONLN);
|
||||
#endif /* HAS_DECL__SC_NPROCESSORS_ONLN */
|
||||
#ifdef HAS_DECL__SC_NPROC_ONLN
|
||||
#endif /* HAVE_DCLR__SC_NPROCESSORS_ONLN */
|
||||
#ifdef HAVE_DCLR__SC_NPROC_ONLN
|
||||
if (0 >= value)
|
||||
value = sysconf (_SC_NPROC_ONLN);
|
||||
#endif /* HAS_DECL__SC_NPROC_ONLN */
|
||||
#endif /* HAVE_DCLR__SC_NPROC_ONLN */
|
||||
if (0 >= value)
|
||||
return -1;
|
||||
ret = (int) value;
|
||||
if ((long) ret != value)
|
||||
return -1; /* Overflow */
|
||||
#endif /* HAVE_SYSCONF &&
|
||||
(HAS_DECL__SC_NPROCESSORS_ONLN || HAS_DECL__SC_NPROC_ONLN) */
|
||||
(HAVE_DCLR__SC_NPROCESSORS_ONLN || HAVE_DCLR__SC_NPROC_ONLN) */
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -849,23 +849,23 @@ mhd_tool_get_sys_cpu_count_sysconf_fallback_ (void)
|
||||
{
|
||||
int ret = -1;
|
||||
#if defined(HAVE_SYSCONF) && \
|
||||
(defined(HAS_DECL__SC_CRAY_NCPU) || defined(HAS_DECL__SC_NPROCESSORS_CONF))
|
||||
(defined(HAVE_DCLR__SC_CRAY_NCPU) || defined(HAVE_DCLR__SC_NPROCESSORS_CONF))
|
||||
long value = -1;
|
||||
#ifdef HAS_DECL__SC_CRAY_NCPU
|
||||
#ifdef HAVE_DCLR__SC_CRAY_NCPU
|
||||
if (0 >= value)
|
||||
value = sysconf (_SC_CRAY_NCPU);
|
||||
#endif /* HAS_DECL__SC_CRAY_NCPU */
|
||||
#ifdef HAS_DECL__SC_NPROCESSORS_CONF
|
||||
#endif /* HAVE_DCLR__SC_CRAY_NCPU */
|
||||
#ifdef HAVE_DCLR__SC_NPROCESSORS_CONF
|
||||
if (0 >= value)
|
||||
value = sysconf (_SC_NPROCESSORS_CONF);
|
||||
#endif /* HAS_DECL__SC_NPROCESSORS_CONF */
|
||||
#endif /* HAVE_DCLR__SC_NPROCESSORS_CONF */
|
||||
if (0 >= value)
|
||||
return -1;
|
||||
ret = (int) value;
|
||||
if ((long) ret != value)
|
||||
return -1; /* Overflow */
|
||||
#endif /* HAVE_SYSCONF &&
|
||||
(HAS_DECL__SC_CRAY_NCPU || HAS_DECL__SC_NPROCESSORS_CONF) */
|
||||
(HAVE_DCLR__SC_CRAY_NCPU || HAVE_DCLR__SC_NPROCESSORS_CONF) */
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user