From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KwJVIh0v; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 5FCE45A004C for ; Wed, 06 Nov 2024 20:11:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730920258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hjBExFwDv5ulu3djuVSqfLqY1bLDi6DN0XeGNB72Ks4=; b=KwJVIh0vhK2jFN1n6amVgs2vOQ1ekIf5gvT/cepal2cNpllh/yBwew7JBi/1JPKCKxR1J1 i9uxMtbGWFvXnYvsCdEO2W6y2KQImIV5uojQ7Nr2AqqdQXChXSmBqZeWvwjuhMud4bTjxR a52NBq0A4y+2R9IcOOIR0KWXkj7Pq7o= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-V5427miuNmOhr2_6eEUlbQ-1; Wed, 06 Nov 2024 14:10:57 -0500 X-MC-Unique: V5427miuNmOhr2_6eEUlbQ-1 X-Mimecast-MFC-AGG-ID: V5427miuNmOhr2_6eEUlbQ Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43151a9ea95so6705885e9.1 for ; Wed, 06 Nov 2024 11:10:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730920255; x=1731525055; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=hjBExFwDv5ulu3djuVSqfLqY1bLDi6DN0XeGNB72Ks4=; b=Ez01Khaksxy19gKkwdCeSuOWBpc9d99d24JLwO3tgwhKMRW+BUBXdIoYsDgWWWDbFa jTTU7JLB5jqyFn6jIo6MsasdYpzSI3BmFGVSwIxx7xrFq+529Vdv1r9RUFaFINkz+SCB 2vxVLh6RGBj5DbKvZ86Cmzef9yaxURk2nZFGAzVmIQFZr8W15DcUWwMkBuZchvhtHhJq 7f6xF71YTUd7AzQXTny2Zn8YXpnG2p71jvnjyybsMsDZc6lF3fu1nGAi73bl6qaU/hD8 cGyLAOsjZBTe7ljzhfkrOntmY4zPtXlHFSlRfeLq7WONhdEFya551YoK/cgKVQrV/KA/ BCug== X-Gm-Message-State: AOJu0YxZxafxnuDtG0yUfWQWuRo0ztGS2SQ6j965pnpbzHW8O5tDQxqk ZRSwFoPzQuThTtNM6ZvFiB20MfezwR36Xm4wqaubD8++T+F3wPqeIASvwY5QhW1qu4QHWMdbP6K ulD0q3LWWttba35JdDnfxpw8stKobUsgTURz3wm5KOnK0cyENErdpNDCwYw== X-Received: by 2002:a05:600c:358b:b0:431:3b80:6ca7 with SMTP id 5b1f17b1804b1-432af36d872mr3053985e9.13.1730920255649; Wed, 06 Nov 2024 11:10:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+Y1rMhkvpzbHNOW7JyJfB0IlP/Kqb7vu7yBD20rJnsbgPErQI48/b8NieqKwi+/M5pEH3Tg== X-Received: by 2002:a05:600c:358b:b0:431:3b80:6ca7 with SMTP id 5b1f17b1804b1-432af36d872mr3053775e9.13.1730920255261; Wed, 06 Nov 2024 11:10:55 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432aa5b5e56sm35552605e9.2.2024.11.06.11.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 11:10:54 -0800 (PST) Date: Wed, 6 Nov 2024 20:10:53 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 3/8] linux_dep: Move close_range() conditional handling to linux_dep.h Message-ID: <20241106201053.5eab2fd2@elisabeth> In-Reply-To: <20241106065421.2568179-4-david@gibson.dropbear.id.au> References: <20241106065421.2568179-1-david@gibson.dropbear.id.au> <20241106065421.2568179-4-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: d7ZcWDm3RzLepK78VlLJUNWtLpbiMCZ1j95k0Bmjdqk_1730920256 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: I3OKM5UX7M2BUL7FO5LIVEK2Q2DNZFPT X-Message-ID-Hash: I3OKM5UX7M2BUL7FO5LIVEK2Q2DNZFPT X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 6 Nov 2024 17:54:16 +1100 David Gibson wrote: > util.h has some #ifdefs and weak definitions to handle compatibility with > various kernel versions. Move this to linux_dep.h which handles several > other similar cases. > > Signed-off-by: David Gibson > --- > linux_dep.h | 20 ++++++++++++++++++++ > util.h | 19 ------------------- > 2 files changed, 20 insertions(+), 19 deletions(-) > > diff --git a/linux_dep.h b/linux_dep.h > index eae9c3c..3a41e42 100644 > --- a/linux_dep.h > +++ b/linux_dep.h > @@ -125,4 +125,24 @@ struct tcp_info_linux { > #define FALLOC_FL_COLLAPSE_RANGE 0x08 > #endif > > +#include > + > +#ifdef CLOSE_RANGE_UNSHARE /* Linux kernel >= 5.9 */ > +/* glibc < 2.34 and musl as of 1.2.5 need these */ > +#ifndef SYS_close_range > +#define SYS_close_range 436 > +#endif > +__attribute__ ((weak)) > +/* cppcheck-suppress funcArgNamesDifferent */ > +int close_range(unsigned int first, unsigned int last, int flags) { > + return syscall(SYS_close_range, first, last, flags); > +} > +#else > +/* No reasonable fallback option */ > +/* cppcheck-suppress funcArgNamesDifferent */ > +int close_range(unsigned int first, unsigned int last, int flags) { > + return 0; > +} > +#endif > + > #endif /* LINUX_DEP_H */ > diff --git a/util.h b/util.h > index 2858b10..fdc3af8 100644 > --- a/util.h > +++ b/util.h > @@ -17,7 +17,6 @@ > #include > #include > #include > -#include > > #include "log.h" > > @@ -158,24 +157,6 @@ int do_clone(int (*fn)(void *), char *stack_area, size_t stack_size, int flags, > > struct ctx; > > -#ifdef CLOSE_RANGE_UNSHARE /* Linux kernel >= 5.9 */ > -/* glibc < 2.34 and musl as of 1.2.5 need these */ > -#ifndef SYS_close_range > -#define SYS_close_range 436 > -#endif > -__attribute__ ((weak)) > -/* cppcheck-suppress funcArgNamesDifferent */ > -int close_range(unsigned int first, unsigned int last, int flags) { > - return syscall(SYS_close_range, first, last, flags); > -} > -#else > -/* No reasonable fallback option */ > -/* cppcheck-suppress funcArgNamesDifferent */ > -int close_range(unsigned int first, unsigned int last, int flags) { > - return 0; > -} > -#endif > - This breaks the build on Alpine as well: util.c: In function 'close_open_files': util.c:729:22: error: implicit declaration of function 'close_range'; did you mean 'SYS_close_range'? [-Wimplicit-function-declaration] 729 | rc = close_range(STDERR_FILENO + 1, ~0U, CLOSE_RANGE_UNSHARE); | ^~~~~~~~~~~ | SYS_close_range util.c:729:58: error: 'CLOSE_RANGE_UNSHARE' undeclared (first use in this function) 729 | rc = close_range(STDERR_FILENO + 1, ~0U, CLOSE_RANGE_UNSHARE); | ^~~~~~~~~~~~~~~~~~~ and is fixed by including "linux_dep.h" from util.c. -- Stefano