From: Francesco Chemolli Date: Wed, 10 Nov 2021 19:07:44 +0000 (+0000) Subject: Fix build on openbsd 7.0 (#929) X-Git-Tag: SQUID_6_0_1~271 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2081cefa236c16b5185a4e8009c218fef4e7e3af;p=thirdparty%2Fsquid.git Fix build on openbsd 7.0 (#929) OpenBSD doesn't offer CPU_SET and CPU_ISSET. Implement their stubs as inline functions to give the compiler proper hints about arguments (non) use. We have a const-correctness bug in std::unordered_map when supplying an allocator that OpenBSD is strict about. Fix it. Update buildtest.sh to try and use relative paths first. This prevents autoconf complaining and failing if the directory path includes characters from an unsafe set. --- diff --git a/compat/cpu.h b/compat/cpu.h index 77ae00def6..730d8079f0 100644 --- a/compat/cpu.h +++ b/compat/cpu.h @@ -36,7 +36,8 @@ inline int sched_getaffinity(int, size_t, cpu_set_t *) { return ENOTSUP; } #endif #if !defined(CPU_SET) -#define CPU_SET(cpu, set) (void)0 +#define CPU_SET(cpunum, cpuset) CpuSet(cpunum, cpuset) +inline void CpuSet(int, const cpu_set_t *) {} #endif #if !defined(CPU_CLR) @@ -44,7 +45,8 @@ inline int sched_getaffinity(int, size_t, cpu_set_t *) { return ENOTSUP; } #endif #if !defined(CPU_ISSET) -#define CPU_ISSET(cpu, set) false +#define CPU_ISSET(cpunum, cpuset) CpuIsSet(cpunum, cpuset) +inline bool CpuIsSet(int, const cpu_set_t *) { return false; } #endif // glibc prior to 2.6 lacks CPU_COUNT diff --git a/src/base/ClpMap.h b/src/base/ClpMap.h index 046bf7775f..12be45cad6 100644 --- a/src/base/ClpMap.h +++ b/src/base/ClpMap.h @@ -105,7 +105,7 @@ private: using Entries = std::list >; using EntriesIterator = typename Entries::iterator; - using IndexItem = std::pair; + using IndexItem = std::pair; /// key:entry_position mapping for fast entry lookups by key using Index = std::unordered_map, std::equal_to, PoolingAllocator >; using IndexIterator = typename Index::iterator; diff --git a/src/cache_cf.cc b/src/cache_cf.cc index afd58f42da..175c7aa169 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -4149,6 +4149,7 @@ static void parse_CpuAffinityMap(CpuAffinityMap **const cpuAffinityMap) { #if !HAVE_CPU_AFFINITY + (void)cpuAffinityMap; debugs(3, DBG_CRITICAL, "FATAL: Squid built with no CPU affinity " << "support, do not set 'cpu_affinity_map'"); self_destruct(); diff --git a/src/comm.cc b/src/comm.cc index 49d1dcd1ef..8b7f0147b0 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -112,6 +112,8 @@ comm_empty_os_read_buffers(int fd) if (fd_table[fd].flags.nonblocking && fd_table[fd].type != FD_MSGHDR) { while (FD_READ_METHOD(fd, buf, SQUID_TCP_SO_RCVBUF) > 0) {}; } +#else + (void)fd; #endif } diff --git a/src/log/access_log.cc b/src/log/access_log.cc index 8b811da318..2dca36b8ea 100644 --- a/src/log/access_log.cc +++ b/src/log/access_log.cc @@ -57,7 +57,7 @@ static void mcast_encode(unsigned int *, size_t, const unsigned int *); #if USE_FORW_VIA_DB -using HeaderValueCountsElement = std::pair; +using HeaderValueCountsElement = std::pair; /// counts the number of header field value occurrences using HeaderValueCounts = std::unordered_map, std::equal_to, PoolingAllocator >; diff --git a/test-suite/buildtest.sh b/test-suite/buildtest.sh index 15c039756e..343e37c1cb 100755 --- a/test-suite/buildtest.sh +++ b/test-suite/buildtest.sh @@ -15,7 +15,6 @@ action="${1}" config="${2}" -base="`dirname ${0}`" # cache_file may be set by environment variable configcache="" @@ -66,9 +65,17 @@ fi # do not build any of the install's ... # # eval is need to correctly handle quoted arguments - eval "$base/../configure ${DISTCHECK_CONFIGURE_FLAGS} ${configcache}" \ - 2>&1 && \ - ${MAKE:-make} ${pjobs} ${MAKETEST} 2>&1 +if test -x "../configure" ; then + base="." +else + base="`dirname ${0}`" +fi + +echo "PWD: $PWD" +echo "$base/../configure ${DISTCHECK_CONFIGURE_FLAGS} ${configcache} ..." +eval "$base/../configure ${DISTCHECK_CONFIGURE_FLAGS} ${configcache}" \ + 2>&1 && \ + ${MAKE:-make} ${pjobs} ${MAKETEST} 2>&1 # Remember and then explicitly return the result of the last command # to the script caller. Probably not needed on most or all platforms.