From patchwork Fri Apr 25 15:28:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 884409 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4030068wrs; Fri, 25 Apr 2025 08:40:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVfMrYsAnp0DkA0eSzabw83Jg+Ei7sUF3fKW991rHX1zYrH4PHDkPrPMH39C+C+Notmdr/bLw==@linaro.org X-Google-Smtp-Source: AGHT+IEsF2F8CJrEdRXJZcpdxEozdnAUduzdtG9qw4Phimnu6AIKzojJl7/82CaOMZGjnC/qye6j X-Received: by 2002:a05:6102:3f55:b0:4c5:78ae:1e3a with SMTP id ada2fe7eead31-4d545847fbbmr1700169137.23.1745595627354; Fri, 25 Apr 2025 08:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745595627; cv=none; d=google.com; s=arc-20240605; b=kr2hw9X33v9HJnWod2hLD0TO88MJeU9jBKlDYpOzotPTsSYl28/cCNnVCr+GOeGNUl 3KWbAPOZOp9Oj45tsKjXrsDrUE60D5Cmdy9Gu/L0XustuLEtOWOXQ6n5UD2OEPgnNsG9 o5vYSISlK4HA9R5wKweulDMpupk7/o35mGP+TlBKDDtkln9xSKTYCpvLuaIWB40O4aHL W31PsMxvjXcuwvdvMBOUnDRrGYGbqmWXW+KdBc75GpkyDpJknyYlGfBkIjsm89M8k8/C reh20h6yEXQ3wrmPJno0B8AhnYJd6/FKihmBsFEoNm60zAUAiatYVWwr7BKRGrfZXRAm BDAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wWBvK3X5bV3SuKKaFzVoRzC83J1Q7Cori3kEUJfd8m8=; fh=GZJSE/aUbRdovNATdnU5k0t9BY+wSWH68mcL6u6grC0=; b=VpWq6U8AUpLsLofHX+VTSveabg/YqipLych57PfqmrHLLyg5c495PRMiFsImSijRRs 1HOhB3CTcZKx3rJ07jUebTnrLi1PAgl9ZKWs2bJipLAu4yzqnTCqWr/MEcNyA3eAv9iO 6NXHxyGfTxW4sPaXh99aXeHCAogeJqCaL4SCN9BQ70uyioxBQwU76+RxkGI4zIWyvnkc JAmep2pkMpgjz13ngqABbF3W2BdZvhz2gdN2sVVZvrGpE+urP93flKfR5v78M46BvHL4 LQs/E+eKCUjciNsUVd3je6g4/0s5Co8kd0h5gKg6SdNRSnAp+ocKIisrAHIeCkkSObQb DSbQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gSFugjLK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4d3d6de8864si1041745137.226.2025.04.25.08.40.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Apr 2025 08:40:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gSFugjLK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u8L2G-0007Oe-T1; Fri, 25 Apr 2025 11:32:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u8L24-0006bu-4c for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:32:05 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u8L20-00046g-Rc for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:32:03 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-43cf3192f3bso21349185e9.1 for ; Fri, 25 Apr 2025 08:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745595119; x=1746199919; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wWBvK3X5bV3SuKKaFzVoRzC83J1Q7Cori3kEUJfd8m8=; b=gSFugjLKdpF8V7lGkjiU/Vsyywp6S8JqY6mzjtnwUDi0KKRrPzH4Ll9C7VySsMBdJy X0Jt4LvYDbvaMUxF69gFPPok1KwCZnPFuwmHp+RnkEUWlFW8HQvPmprDt1CuKBuEwAp+ I/qX1Jo9k2pzJ7ACleZ3v1CC+sTmJhJWKFKfaOR3y0uUZ7azUpsZNLKMUzzyR8kAUs5A sBFmvEAof7oM1VGSWjoP8dL/NLIqXk4XAgVOcBAOCWlniRz4xLC4pCQ0G+sY8uOCTiU3 jZV3azp4QxGy84JwKSjBSvsw9rB9p9Hn8z52SwhI3MHU0VyO4NDGTKP1aF9NjarCsyRV o3+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745595119; x=1746199919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wWBvK3X5bV3SuKKaFzVoRzC83J1Q7Cori3kEUJfd8m8=; b=m7Zy2LNpM/5WtV2SC+ts6r4AqYKi4J6VZxkZ1FO7nOgoJJq+YIYMpiEHEI4SYRpp1S tS8MIuoA/K60HUS1Rnhya3d2kf/bQOTOGugiGcBRZLzH8tuYlz5Fi13jXPBQtBhvfZ42 1TA+6gRN/QBie8tTBXdfjL5iSVJS9j8HPk92EsQ19llBmKVKCK15WImS7g8wg9MaI7bu rnz+4PuHJBOG5c2yUforYGyM1DXKQFT/6HK66OlyophZegQu+d9CKGZIyh+72pFKhFEs /z47aT3MgeaZPzE3BrYjeCW9JxBobbEDZOFvAsWhct/8syBBJYiZfEPga8TmfbpcYW9h 7xKA== X-Gm-Message-State: AOJu0YzM9udO7TocvKyTz8dSXigsBRA/1OU1rGfhf+RJCnmWMVtVBn5V gAEZZ3hkc1VVZRfwmXEWrcncFcPfgVmhTwB3CktSvljcfdo3CDGDnRaAEFCTfuTDf8rwmoPR6d7 H X-Gm-Gg: ASbGncsRv1VYQWIFC5uMnwuFGYx2DRz78IsbJmtaaR1/g+JWg+Ban0xa5Ev7cbn+1/r 5j1sTKqDqQfQIcAS9oFbxbSysMh8s+WaXbL3kLPoMvXY9/VRaoS3mcUNUkY/RiVwI5UYmJ9vMkc YP4ygNrbamVu/JSEReHUNYGq23OZMdWOMYZW3SdN1Gj5q2MJGsv1Em/eM47ytg9trqYYTS0nLWX NUqop06yK3e3aXl+bxAHrkJNrxQYZkikys6AdJO51ct0GEW5leiYvHhbk0rymrdM3FOgALi1X84 POCb74pYMFihhRUzwJmGfgvghRMROLzynZUscU65LnPgSJqBuo1lYimIoHlocPd7EiC0YaJJYnp L1uHakSraLQDlbDLf6/s2GMXfxw== X-Received: by 2002:a05:600c:a363:b0:43c:f64c:447f with SMTP id 5b1f17b1804b1-440a66ab2bamr25048375e9.29.1745595118661; Fri, 25 Apr 2025 08:31:58 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-440a5311403sm28114225e9.23.2025.04.25.08.31.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 25 Apr 2025 08:31:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 39/58] meson: Share common C source prefixes Date: Fri, 25 Apr 2025 17:28:23 +0200 Message-ID: <20250425152843.69638-40-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250425152843.69638-1-philmd@linaro.org> References: <20250425152843.69638-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki gnu_source_prefix defines _GNU_SOURCE for compiler object functions. The definition is universally available in the code base. docs/devel/style.rst also says that the "qemu/osdep.h" header is always included, so files included in the file is also universally available in the code base. Rename gnu_source_prefix to osdep_prefix, and add #include directives that are referred by the users of gnu_source_prefix and contained in qemu/osdep.h to safely de-duplicate #include directives. Cc: qemu-stable@nongnu.org Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-ID: <20250424-buildsys-v1-3-97655e3b25d7@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- meson.build | 68 +++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/meson.build b/meson.build index 35dcec8ce5c..d93dbde194f 100644 --- a/meson.build +++ b/meson.build @@ -2185,10 +2185,21 @@ if not has_malloc_trim and get_option('malloc_trim').enabled() endif endif -gnu_source_prefix = ''' +osdep_prefix = ''' #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif + + #include + #include + + #include + /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r + * function availability on recentish Mingw-w64 platforms. */ + #include + #include + #include + #include ''' have_vhost_user_blk_server = get_option('vhost_user_blk_server') \ @@ -2703,7 +2714,7 @@ config_host_data.set('CONFIG_FIEMAP', cc.has_header('linux/fiemap.h') and cc.has_header_symbol('linux/fs.h', 'FS_IOC_FIEMAP')) config_host_data.set('CONFIG_GETCPU', - cc.has_header_symbol('sched.h', 'getcpu', prefix: gnu_source_prefix)) + cc.has_header_symbol('sched.h', 'getcpu', prefix: osdep_prefix)) config_host_data.set('CONFIG_GETRANDOM', cc.has_function('getrandom') and cc.has_header_symbol('sys/random.h', 'GRND_NONBLOCK')) @@ -2748,8 +2759,7 @@ config_host_data.set('HAVE_UTMPX', config_host_data.set('CONFIG_EVENTFD', cc.links(''' #include int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }''')) -config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + ''' - #include +config_host_data.set('CONFIG_FDATASYNC', cc.links(osdep_prefix + ''' int main(void) { #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0 return fdatasync(0); @@ -2758,10 +2768,8 @@ config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + ''' #endif }''')) -has_madvise = cc.links(gnu_source_prefix + ''' - #include +has_madvise = cc.links(osdep_prefix + ''' #include - #include int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''') missing_madvise_proto = false if has_madvise @@ -2771,21 +2779,18 @@ if has_madvise # missing-prototype case, we try again with a definitely-bogus prototype. # This will only compile if the system headers don't provide the prototype; # otherwise the conflicting prototypes will cause a compiler error. - missing_madvise_proto = cc.links(gnu_source_prefix + ''' - #include + missing_madvise_proto = cc.links(osdep_prefix + '''> #include - #include extern int madvise(int); int main(void) { return madvise(0); }''') endif config_host_data.set('CONFIG_MADVISE', has_madvise) config_host_data.set('HAVE_MADVISE_WITHOUT_PROTOTYPE', missing_madvise_proto) -config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + ''' +config_host_data.set('CONFIG_MEMFD', cc.links(osdep_prefix + ''' #include int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }''')) -config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + ''' - #include +config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(osdep_prefix + ''' #if !defined(AT_EMPTY_PATH) # error missing definition #else @@ -2796,13 +2801,12 @@ config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + ''' # i.e. errno is set and -1 is returned. That's not really how POSIX defines the # function. On the flip side, it has madvise() which is preferred anyways. if host_os != 'darwin' - config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + ''' + config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(osdep_prefix + ''' #include - #include int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }''')) endif -config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_prefix + ''' +config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(osdep_prefix + ''' #include static void *f(void *p) { return NULL; } @@ -2813,7 +2817,7 @@ config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_pref pthread_setname_np(thread, "QEMU"); return 0; }''', dependencies: threads)) -config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_prefix + ''' +config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(osdep_prefix + ''' #include static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; } @@ -2823,7 +2827,7 @@ config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_pre pthread_create(&thread, 0, f, 0); return 0; }''', dependencies: threads)) -config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix + ''' +config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(osdep_prefix + ''' #include #include @@ -2835,9 +2839,8 @@ config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix + pthread_set_name_np(thread, "QEMU"); return 0; }''', dependencies: threads)) -config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_prefix + ''' +config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(osdep_prefix + ''' #include - #include int main(void) { @@ -2846,7 +2849,7 @@ config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_pre pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); return 0; }''', dependencies: threads)) -config_host_data.set('CONFIG_PTHREAD_AFFINITY_NP', cc.links(gnu_source_prefix + ''' +config_host_data.set('CONFIG_PTHREAD_AFFINITY_NP', cc.links(osdep_prefix + ''' #include static void *f(void *p) { return NULL; } @@ -2863,15 +2866,10 @@ config_host_data.set('CONFIG_PTHREAD_AFFINITY_NP', cc.links(gnu_source_prefix + CPU_FREE(cpuset); return 0; }''', dependencies: threads)) -config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + ''' +config_host_data.set('CONFIG_SIGNALFD', cc.links(osdep_prefix + ''' #include - #include int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }''')) -config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + ''' - #include - #include - #include - +config_host_data.set('CONFIG_SPLICE', cc.links(osdep_prefix + ''' int main(void) { int len, fd = 0; @@ -2880,13 +2878,13 @@ config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + ''' return 0; }''')) -config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + ''' +config_host_data.set('HAVE_MLOCKALL', cc.links(osdep_prefix + ''' #include int main(void) { return mlockall(MCL_FUTURE); }''')) -config_host_data.set('HAVE_MLOCK_ONFAULT', cc.links(gnu_source_prefix + ''' +config_host_data.set('HAVE_MLOCK_ONFAULT', cc.links(osdep_prefix + ''' #include int main(void) { return mlockall(MCL_FUTURE | MCL_ONFAULT); @@ -2895,7 +2893,7 @@ config_host_data.set('HAVE_MLOCK_ONFAULT', cc.links(gnu_source_prefix + ''' have_l2tpv3 = false if get_option('l2tpv3').allowed() and have_system have_l2tpv3 = cc.has_type('struct mmsghdr', - prefix: gnu_source_prefix + ''' + prefix: osdep_prefix + ''' #include #include ''') endif @@ -3011,13 +3009,13 @@ if has_int128_type endif endif -config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + ''' +config_host_data.set('CONFIG_GETAUXVAL', cc.links(osdep_prefix + ''' #include int main(void) { return getauxval(AT_HWCAP) == 0; }''')) -config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(gnu_source_prefix + ''' +config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(osdep_prefix + ''' #include int main(void) { unsigned long hwcap = 0; @@ -3130,9 +3128,7 @@ config_host_data.set('CONFIG_MEMBARRIER', get_option('membarrier') \ .allowed()) have_afalg = get_option('crypto_afalg') \ - .require(cc.compiles(gnu_source_prefix + ''' - #include - #include + .require(cc.compiles(osdep_prefix + ''' #include #include int main(void) {