From patchwork Fri Sep 27 01:44:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51882 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d8ca:0:b0:48e:c0f8:d0de with SMTP id dy10csp709461vqb; Fri, 27 Sep 2024 15:51:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVWyFxf+Z+JzUvlr59Z5SgCD6RfpYcvwndtMkUJUDZNbCKUB7gpiZ79hqF+ijxrEu2MOkrOAzFESg/6+pTx/sn9@gmail.com X-Google-Smtp-Source: AGHT+IH7w5yeDVlVTO7PBGpaNaGSMH/Pd1AK5XIi6m9Vb9wFU31hDvCE4pviUJED0ntf48NMfIpZ X-Received: by 2002:a05:600c:4592:b0:42c:aeee:e603 with SMTP id 5b1f17b1804b1-42f5e3b1401mr3223295e9.7.1727477473672; Fri, 27 Sep 2024 15:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727477473; cv=none; d=google.com; s=arc-20240605; b=iaZgrjNR4qxl7rdByIalk0rttU2UP3DADlJeO0bCIDez3j/KDNNjfHI5TscIRqnCeM LHRA1++x0aaPZm0USF7oxCbmXkSFfIIWMmgDdVefuzImgAXGXRZIVIvy1IO5/3pIVGzU LtWNVh6f4S8C15TpSWN+v9KThxK18KZtjwqhkJghfxFOClWNERVlKKWRES4eJWtoclBa fEkRj+5gT+rN0lc7hJR563PEURqjiQtn8wTlL+Pi9PGfM1AjVpcbrdyx87Gq8FkuFnnU I8nxAMYywEUOqSTWBnQLBcUCJP89qtpXKrWn1uEAg/hUAAMhKx/y4RxQNjBhRa4kiv2m xeoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=hZNNbMXBHPVll8Q+DCBBiTmEHqhpaoNzBNf6yTO5jPo=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=XLj9oyzO5RoNIOvx8vactsjd0ATA+g+u2XSJhD9MHwZ6igL6+DUifPAOCQz81UpKUI 33xdvyLEjJxfSIww4YopbTnp+d5t/IEvE2YOIaTeNGyZVBAcceRJ+tdoyEBb8h9NY4aM +jtum6rvQU+PdlKTn+8oaFJwS7vl4OyzDzTYp85rI2x+wlWLGVH1Dm9jaBZGWR4h7uE8 vNIQEmE/RXCQFzgBnjxZxtfZT6B9qYUFBd3l84MvTehPMiNN0NGgMUGqW7DWYatHIXRO ELIBxjxQqAKEiOQQ9sXGsmfjELweJfZX0O0hHf+T0P64MBVbpfaVrVUsy61ALEkRVfMt ie1Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=fIycvegJ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5c8824080d4si2170948a12.56.2024.09.27.15.51.12; Fri, 27 Sep 2024 15:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=fIycvegJ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F04E168DA33; Fri, 27 Sep 2024 04:44:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3022A68CCF9 for ; Fri, 27 Sep 2024 04:44:17 +0300 (EEST) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-71b070ff24dso1417922b3a.2 for ; Thu, 26 Sep 2024 18:44:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727401454; x=1728006254; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=a2/MJXAlQiis5/UlI0aiDmkrQTQNH4EaPB9TU1z9EsU=; b=fIycvegJIT9loqC10ol5t4NSDNMMyJ8ioRyKG/ZI8l9iGQPdyie47XMeZAZIQ41mdm 3xlK88BPy06FkAVSZV6Naq+fdoi4lR0vcbWoUp6UhN7ZX4rYlNIcX6E4kBtyJtKNAVnW xfKmAJ2Tp7xs+qVsjw6eKciAugl/YaOgK1VbjNsqFLUIcIxuSBlDVPROBngZfQu1hCd3 rJHbxN/lVda3eJTbS6iwiX6ZMyf2/PaHCdCjmrtJyBAVB5eOVRiMjMvEHny6ORjlZRjt jPQqp8RQMhb2UFWC8AGKj9+lvbj9tQWNqK5KtE1prPWxwBMpfImBB8yVN6WlehbFJmb9 0uxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727401454; x=1728006254; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=a2/MJXAlQiis5/UlI0aiDmkrQTQNH4EaPB9TU1z9EsU=; b=AXll7sDqS2f58PVj2G2dxN2Y4FVz0fCfM/E66+nRIcGRrXvk3V7hsLFfpnIIit5Irv RxuyGaEkZwbMKkECEs/oNikmjlwgAcTEcX82pWIZPihZxuP7qoufrcDbdN+FhGUnX9qg HAFSmUd7beE4EklGs+UHWrDmMWuJ0HmYh2eSNjSEdKxt+BJdeFkNSScon0TAIOYD4yrE kIlntwmWwKV0Lw5e4WFqjPmCW5PiqzIgoFbxXG5VYNirJ81AdAPMfBRV6AEF6uQJFQRz lFA7G2jRfgdzFirpl3HTNZ5PqETf+E7oNmfexI2qyovuaq5Y0asztABHHjy4qqL48RSP /A7Q== X-Gm-Message-State: AOJu0YzY9369oAosmlriVcG/pKgrtC3mWjTjJ/NTaJSFk82pagSF9IK3 Qu2S5eqJ70431atNMpWNzLTs9edrcNrLNEuCsDzfiU+TFsjIW3guuZDm0g== X-Received: by 2002:aa7:888a:0:b0:710:4d3a:2d92 with SMTP id d2e1a72fcca58-71b25f0cba6mr2852298b3a.4.1727401453605; Thu, 26 Sep 2024 18:44:13 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b2649c6a1sm541928b3a.44.2024.09.26.18.44.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 18:44:12 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Sep 2024 22:44:32 -0300 Message-ID: <20240927014436.15622-1-jamrial@gmail.com> X-Mailer: git-send-email 2.46.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] compat: add a fallback implementation of C23 stdckdint.h X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rF3b12qsM/0j From: Justine Tunney Header contents taken from https://github.com/jart/jtckdint/commit/62df1fc0966926299253b7af46c777723e345545 Signed-off-by: James Almer --- compat/stdckdint/stdckdint.h | 663 +++++++++++++++++++++++++++++++++++ tests/ref/fate/source | 1 + 2 files changed, 664 insertions(+) create mode 100644 compat/stdckdint/stdckdint.h diff --git a/compat/stdckdint/stdckdint.h b/compat/stdckdint/stdckdint.h new file mode 100644 index 0000000000..2d36e8ad89 --- /dev/null +++ b/compat/stdckdint/stdckdint.h @@ -0,0 +1,663 @@ +/* + * Copyright 2023 Justine Alexandra Roberts Tunney + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/** + * @fileoverview C23 Checked Arithmetic + * + * This header defines three type generic functions: + * + * - `bool ckd_add(res, a, b)` + * - `bool ckd_sub(res, a, b)` + * - `bool ckd_mul(res, a, b)` + * + * Which allow integer arithmetic errors to be detected. There are many + * kinds of integer errors, e.g. overflow, truncation, etc. These funcs + * catch them all. Here's an example of how it works: + * + * uint32_t c; + * int32_t a = 0x7fffffff; + * int32_t b = 2; + * assert(!ckd_add(&c, a, b)); + * assert(c == 0x80000001u); + * + * Experienced C / C++ users should find this example counter-intuitive + * because the expression `0x7fffffff + 2` not only overflows it's also + * undefined behavior. However here we see it's specified, and does not + * result in an error. That's because C23 checked arithmetic is not the + * arithmetic you're used to. The new standard changes the mathematics. + * + * C23 checked arithmetic is defined as performing the arithmetic using + * infinite precision and then checking if the resulting value will fit + * in the output type. Our example above did not result in an error due + * to `0x80000001` being a legal value for `uint32_t`. + * + * This implementation will use the GNU compiler builtins, when they're + * available, only if you don't use build flags like `-std=c11` because + * they define `__STRICT_ANSI__` and GCC extensions aren't really ANSI. + * Instead, you'll get a pretty good pure C11 and C++11 implementation. + * + * @see https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf + * @version 0.1 (2023-07-22) + */ + +#ifndef JTCKDINT_H_ +#define JTCKDINT_H_ + +#ifdef __has_include +#define __ckd_has_include(x) __has_include(x) +#else +#define __ckd_has_include(x) 0 +#endif + +#if __ckd_has_include() +#include +#else + +#define __STDC_VERSION_STDCKDINT_H__ 202311L + +#if ((defined(__llvm__) || \ + (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 406)) && \ + !defined(__STRICT_ANSI__)) +#define __ckd_have_int128 +#define __ckd_intmax __int128 +#elif ((defined(__cplusplus) && __cplusplus >= 201103L) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)) +#define __ckd_intmax long long +#else +#define __ckd_intmax long +#endif + +typedef signed __ckd_intmax __ckd_intmax_t; +typedef unsigned __ckd_intmax __ckd_uintmax_t; + +#ifdef __has_builtin +#define __ckd_has_builtin(x) __has_builtin(x) +#else +#define __ckd_has_builtin(x) 0 +#endif + +#if (!defined(__STRICT_ANSI__) && \ + ((defined(__GNUC__) && __GNUC__ >= 5 && !defined(__ICC)) || \ + (__ckd_has_builtin(__builtin_add_overflow) && \ + __ckd_has_builtin(__builtin_sub_overflow) && \ + __ckd_has_builtin(__builtin_mul_overflow)))) +#define ckd_add(res, x, y) __builtin_add_overflow((x), (y), (res)) +#define ckd_sub(res, x, y) __builtin_sub_overflow((x), (y), (res)) +#define ckd_mul(res, x, y) __builtin_mul_overflow((x), (y), (res)) + +#elif (defined(__cplusplus) && \ + (__cplusplus >= 201103L || \ + (defined(_MSC_VER) && __cplusplus >= 199711L && \ + __ckd_has_include() && \ + __ckd_has_include()))) +#include +#include + +template +inline bool ckd_add(__T *__res, __U __a, __V __b) { + static_assert(std::is_integral<__T>::value && + std::is_integral<__U>::value && + std::is_integral<__V>::value, + "non-integral types not allowed"); + static_assert(!std::is_same<__T, bool>::value && + !std::is_same<__U, bool>::value && + !std::is_same<__V, bool>::value, + "checked booleans not supported"); + static_assert(!std::is_same<__T, char>::value && + !std::is_same<__U, char>::value && + !std::is_same<__V, char>::value, + "unqualified char type is ambiguous"); + __ckd_uintmax_t __x = __a; + __ckd_uintmax_t __y = __b; + __ckd_uintmax_t __z = __x + __y; + *__res = __z; + if (sizeof(__z) > sizeof(__U) && sizeof(__z) > sizeof(__V)) { + if (sizeof(__z) > sizeof(__T) || std::is_signed<__T>::value) { + return static_cast<__ckd_intmax_t>(__z) != static_cast<__T>(__z); + } else if (!std::is_same<__T, __ckd_uintmax_t>::value) { + return (__z != static_cast<__T>(__z) || + ((std::is_signed<__U>::value || + std::is_signed<__V>::value) && + static_cast<__ckd_intmax_t>(__z) < 0)); + } + } + bool __truncated = false; + if (sizeof(__T) < sizeof(__ckd_intmax_t)) { + __truncated = __z != static_cast<__ckd_uintmax_t>(static_cast<__T>(__z)); + } + switch (std::is_signed<__T>::value << 2 | // + std::is_signed<__U>::value << 1 | // + std::is_signed<__V>::value) { + case 0: // u = u + u + return __truncated | (__z < __x); + case 1: // u = u + s + __y ^= std::numeric_limits<__ckd_intmax_t>::min(); + return __truncated | + (static_cast<__ckd_intmax_t>((__z ^ __x) & + (__z ^ __y)) < 0); + case 2: // u = s + u + __x ^= std::numeric_limits<__ckd_intmax_t>::min(); + return __truncated | + (static_cast<__ckd_intmax_t>((__z ^ __x) & + (__z ^ __y)) < 0); + case 3: // u = s + s + return __truncated | + (static_cast<__ckd_intmax_t>(((__z | __x) & __y) | + ((__z & __x) & ~__y)) < 0); + case 4: // s = u + u + return __truncated | (__z < __x) | (static_cast<__ckd_intmax_t>(__z) < 0); + case 5: // s = u + s + __y ^= std::numeric_limits<__ckd_intmax_t>::min(); + return __truncated | (__x + __y < __y); + case 6: // s = s + u + __x ^= std::numeric_limits<__ckd_intmax_t>::min(); + return __truncated | (__x + __y < __x); + case 7: // s = s + s + return __truncated | + (static_cast<__ckd_intmax_t>((__z ^ __x) & + (__z ^ __y)) < 0); + default: + for (;;) (void)0; + } +} + +template +inline bool ckd_sub(__T *__res, __U __a, __V __b) { + static_assert(std::is_integral<__T>::value && + std::is_integral<__U>::value && + std::is_integral<__V>::value, + "non-integral types not allowed"); + static_assert(!std::is_same<__T, bool>::value && + !std::is_same<__U, bool>::value && + !std::is_same<__V, bool>::value, + "checked booleans not supported"); + static_assert(!std::is_same<__T, char>::value && + !std::is_same<__U, char>::value && + !std::is_same<__V, char>::value, + "unqualified char type is ambiguous"); + __ckd_uintmax_t __x = __a; + __ckd_uintmax_t __y = __b; + __ckd_uintmax_t __z = __x - __y; + *__res = __z; + if (sizeof(__z) > sizeof(__U) && sizeof(__z) > sizeof(__V)) { + if (sizeof(__z) > sizeof(__T) || std::is_signed<__T>::value) { + return static_cast<__ckd_intmax_t>(__z) != static_cast<__T>(__z); + } else if (!std::is_same<__T, __ckd_uintmax_t>::value) { + return (__z != static_cast<__T>(__z) || + ((std::is_signed<__U>::value || + std::is_signed<__V>::value) && + static_cast<__ckd_intmax_t>(__z) < 0)); + } + } + bool __truncated = false; + if (sizeof(__T) < sizeof(__ckd_intmax_t)) { + __truncated = __z != static_cast<__ckd_uintmax_t>(static_cast<__T>(__z)); + } + switch (std::is_signed<__T>::value << 2 | // + std::is_signed<__U>::value << 1 | // + std::is_signed<__V>::value) { + case 0: // u = u - u + return __truncated | (__x < __y); + case 1: // u = u - s + __y ^= std::numeric_limits<__ckd_intmax_t>::min(); + return __truncated | + (static_cast<__ckd_intmax_t>((__x ^ __y) & + (__z ^ __x)) < 0); + case 2: // u = s - u + return __truncated | (__y > __x) | (static_cast<__ckd_intmax_t>(__x) < 0); + case 3: // u = s - s + return __truncated | + (static_cast<__ckd_intmax_t>(((__z & __x) & __y) | + ((__z | __x) & ~__y)) < 0); + case 4: // s = u - u + return __truncated | + ((__x < __y) ^ (static_cast<__ckd_intmax_t>(__z) < 0)); + case 5: // s = u - s + __y ^= std::numeric_limits<__ckd_intmax_t>::min(); + return __truncated | (__x >= __y); + case 6: // s = s - u + __x ^= std::numeric_limits<__ckd_intmax_t>::min(); + return __truncated | (__x < __y); + case 7: // s = s - s + return __truncated | + (static_cast<__ckd_intmax_t>((__x ^ __y) & + (__z ^ __x)) < 0); + default: + for (;;) (void)0; + } +} + +template +inline bool ckd_mul(__T *__res, __U __a, __V __b) { + static_assert(std::is_integral<__T>::value && + std::is_integral<__U>::value && + std::is_integral<__V>::value, + "non-integral types not allowed"); + static_assert(!std::is_same<__T, bool>::value && + !std::is_same<__U, bool>::value && + !std::is_same<__V, bool>::value, + "checked booleans not supported"); + static_assert(!std::is_same<__T, char>::value && + !std::is_same<__U, char>::value && + !std::is_same<__V, char>::value, + "unqualified char type is ambiguous"); + __ckd_uintmax_t __x = __a; + __ckd_uintmax_t __y = __b; + if ((sizeof(__U) * 8 - std::is_signed<__U>::value) + + (sizeof(__V) * 8 - std::is_signed<__V>::value) <= + (sizeof(__T) * 8 - std::is_signed<__T>::value)) { + if (sizeof(__ckd_uintmax_t) > sizeof(__T) || std::is_signed<__T>::value) { + __ckd_intmax_t __z = __x * __y; + return __z != (*__res = __z); + } else if (!std::is_same<__T, __ckd_uintmax_t>::value) { + __ckd_uintmax_t __z = __x * __y; + *__res = __z; + return (__z != static_cast<__T>(__z) || + ((std::is_signed<__U>::value || + std::is_signed<__V>::value) && + static_cast<__ckd_intmax_t>(__z) < 0)); + } + } + switch (std::is_signed<__T>::value << 2 | // + std::is_signed<__U>::value << 1 | // + std::is_signed<__V>::value) { + case 0: { // u = u * u + __ckd_uintmax_t __z = __x * __y; + int __o = __x && __z / __x != __y; + *__res = __z; + return __o | (sizeof(__T) < sizeof(__z) && + __z != static_cast<__ckd_uintmax_t>(*__res)); + } + case 1: { // u = u * s + __ckd_uintmax_t __z = __x * __y; + int __o = __x && __z / __x != __y; + *__res = __z; + return (__o | ((static_cast<__ckd_intmax_t>(__y) < 0) & !!__x) | + (sizeof(__T) < sizeof(__z) && + __z != static_cast<__ckd_uintmax_t>(*__res))); + } + case 2: { // u = s * u + __ckd_uintmax_t __z = __x * __y; + int __o = __x && __z / __x != __y; + *__res = __z; + return (__o | ((static_cast<__ckd_intmax_t>(__x) < 0) & !!__y) | + (sizeof(__T) < sizeof(__z) && + __z != static_cast<__ckd_uintmax_t>(*__res))); + } + case 3: { // u = s * s + int __o = false; + if (static_cast<__ckd_intmax_t>(__x & __y) < 0) { + __x = -__x; + __y = -__y; + } else if (static_cast<__ckd_intmax_t>(__x ^ __y) < 0) { + __o = __x && __y; + } + __ckd_uintmax_t __z = __x * __y; + __o |= __x && __z / __x != __y; + *__res = __z; + return __o | (sizeof(__T) < sizeof(__z) && + __z != static_cast<__ckd_uintmax_t>(*__res)); + } + case 4: { // s = u * u + __ckd_uintmax_t __z = __x * __y; + int __o = __x && __z / __x != __y; + *__res = __z; + return (__o | (static_cast<__ckd_intmax_t>(__z) < 0) | + (sizeof(__T) < sizeof(__z) && + __z != static_cast<__ckd_uintmax_t>(*__res))); + } + case 5: { // s = u * s + __ckd_uintmax_t __t = -__y; + __t = static_cast<__ckd_intmax_t>(__t) < 0 ? __y : __t; + __ckd_uintmax_t __p = __t * __x; + int __o = __t && __p / __t != __x; + int __n = static_cast<__ckd_intmax_t>(__y) < 0; + __ckd_uintmax_t __z = __n ? -__p : __p; + *__res = __z; + __ckd_uintmax_t __m = std::numeric_limits<__ckd_intmax_t>::max(); + return (__o | (__p > __m + __n) | + (sizeof(__T) < sizeof(__z) && + __z != static_cast<__ckd_uintmax_t>(*__res))); + } + case 6: { // s = s * u + __ckd_uintmax_t __t = -__x; + __t = static_cast<__ckd_intmax_t>(__t) < 0 ? __x : __t; + __ckd_uintmax_t __p = __t * __y; + int __o = __t && __p / __t != __y; + int __n = static_cast<__ckd_intmax_t>(__x) < 0; + __ckd_uintmax_t __z = __n ? -__p : __p; + *__res = __z; + __ckd_uintmax_t __m = std::numeric_limits<__ckd_intmax_t>::max(); + return (__o | (__p > __m + __n) | + (sizeof(__T) < sizeof(__z) && + __z != static_cast<__ckd_uintmax_t>(*__res))); + } + case 7: { // s = s * s + __ckd_uintmax_t __z = __x * __y; + *__res = __z; + return ((((static_cast<__ckd_intmax_t>(__y) < 0) && + (static_cast<__ckd_intmax_t>(__x) == + std::numeric_limits<__ckd_intmax_t>::min())) || + (__y && ((static_cast<__ckd_intmax_t>(__z) / + static_cast<__ckd_intmax_t>(__y)) != + static_cast<__ckd_intmax_t>(__x)))) | + (sizeof(__T) < sizeof(__z) && + __z != static_cast<__ckd_uintmax_t>(*__res))); + } + default: + for (;;) (void)0; + } +} + +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + +#define ckd_add(res, a, b) __ckd_expr(add, (res), (a), (b)) +#define ckd_sub(res, a, b) __ckd_expr(sub, (res), (a), (b)) +#define ckd_mul(res, a, b) __ckd_expr(mul, (res), (a), (b)) + +#if defined(__GNUC__) || defined(__llvm__) +#define __ckd_inline \ + extern __inline __attribute__((__gnu_inline__, \ + __always_inline__, \ + __artificial__)) +#else +#define __ckd_inline static inline +#endif + +#ifdef __ckd_have_int128 +#define __ckd_generic_int128(x, y) , signed __int128: x, unsigned __int128: y +#else +#define __ckd_generic_int128(x, y) +#endif + +#define __ckd_sign(T) \ + ((T)1 << (sizeof(T) * 8 - 1)) + +#define __ckd_is_signed(x) \ + _Generic(x, \ + signed char: 1, \ + unsigned char: 0, \ + signed short: 1, \ + unsigned short: 0, \ + signed int: 1, \ + unsigned int: 0, \ + signed long: 1, \ + unsigned long: 0, \ + signed long long: 1, \ + unsigned long long: 0 \ + __ckd_generic_int128(1, 0)) + +#define __ckd_expr(op, res, a, b) \ + (_Generic(*res, \ + signed char: __ckd_##op##_schar, \ + unsigned char: __ckd_##op##_uchar, \ + signed short: __ckd_##op##_sshort, \ + unsigned short: __ckd_##op##_ushort, \ + signed int: __ckd_##op##_sint, \ + unsigned int: __ckd_##op##_uint, \ + signed long: __ckd_##op##_slong, \ + unsigned long: __ckd_##op##_ulong, \ + signed long long: __ckd_##op##_slonger, \ + unsigned long long: __ckd_##op##_ulonger \ + __ckd_generic_int128( \ + __ckd_##op##_sint128, \ + __ckd_##op##_uint128))( \ + res, a, b, \ + __ckd_is_signed(a), \ + __ckd_is_signed(b))) + +#define __ckd_declare_add(S, T) \ + __ckd_inline char S(void *__res, \ + __ckd_uintmax_t __x, \ + __ckd_uintmax_t __y, \ + char __a_signed, \ + char __b_signed) { \ + __ckd_uintmax_t __z = __x + __y; \ + *(T *)__res = __z; \ + char __truncated = 0; \ + if (sizeof(T) < sizeof(__ckd_intmax_t)) { \ + __truncated = __z != (__ckd_uintmax_t)(T)__z; \ + } \ + switch (__ckd_is_signed((T)0) << 2 | \ + __a_signed << 1 | __b_signed) { \ + case 0: /* u = u + u */ \ + return __truncated | (__z < __x); \ + case 1: /* u = u + s */ \ + __y ^= __ckd_sign(__ckd_uintmax_t); \ + return __truncated | \ + ((__ckd_intmax_t)((__z ^ __x) & \ + (__z ^ __y)) < 0); \ + case 2: /* u = s + u */ \ + __x ^= __ckd_sign(__ckd_uintmax_t); \ + return __truncated | \ + ((__ckd_intmax_t)((__z ^ __x) & \ + (__z ^ __y)) < 0); \ + case 3: /* u = s + s */ \ + return __truncated | \ + ((__ckd_intmax_t)(((__z | __x) & __y) | \ + ((__z & __x) & ~__y)) < 0); \ + case 4: /* s = u + u */ \ + return __truncated | (__z < __x) | ((__ckd_intmax_t)__z < 0); \ + case 5: /* s = u + s */ \ + __y ^= __ckd_sign(__ckd_uintmax_t); \ + return __truncated | (__x + __y < __y); \ + case 6: /* s = s + u */ \ + __x ^= __ckd_sign(__ckd_uintmax_t); \ + return __truncated | (__x + __y < __x); \ + case 7: /* s = s + s */ \ + return __truncated | \ + ((__ckd_intmax_t)((__z ^ __x) & \ + (__z ^ __y)) < 0); \ + default: \ + for (;;) (void)0; \ + } \ + } + +__ckd_declare_add(__ckd_add_schar, signed char) +__ckd_declare_add(__ckd_add_uchar, unsigned char) +__ckd_declare_add(__ckd_add_sshort, signed short) +__ckd_declare_add(__ckd_add_ushort, unsigned short) +__ckd_declare_add(__ckd_add_sint, signed int) +__ckd_declare_add(__ckd_add_uint, unsigned int) +__ckd_declare_add(__ckd_add_slong, signed long) +__ckd_declare_add(__ckd_add_ulong, unsigned long) +__ckd_declare_add(__ckd_add_slonger, signed long long) +__ckd_declare_add(__ckd_add_ulonger, unsigned long long) +#ifdef __ckd_have_int128 +__ckd_declare_add(__ckd_add_sint128, signed __int128) +__ckd_declare_add(__ckd_add_uint128, unsigned __int128) +#endif + +#define __ckd_declare_sub(S, T) \ + __ckd_inline char S(void *__res, \ + __ckd_uintmax_t __x, \ + __ckd_uintmax_t __y, \ + char __a_signed, \ + char __b_signed) { \ + __ckd_uintmax_t __z = __x - __y; \ + *(T *)__res = __z; \ + char __truncated = 0; \ + if (sizeof(T) < sizeof(__ckd_intmax_t)) { \ + __truncated = __z != (__ckd_uintmax_t)(T)__z; \ + } \ + switch (__ckd_is_signed((T)0) << 2 | \ + __a_signed << 1 | __b_signed) { \ + case 0: /* u = u - u */ \ + return __truncated | (__x < __y); \ + case 1: /* u = u - s */ \ + __y ^= __ckd_sign(__ckd_uintmax_t); \ + return __truncated | \ + ((__ckd_intmax_t)((__x ^ __y) & \ + (__z ^ __x)) < 0); \ + case 2: /* u = s - u */ \ + return __truncated | (__y > __x) | ((__ckd_intmax_t)__x < 0); \ + case 3: /* u = s - s */ \ + return __truncated | \ + ((__ckd_intmax_t)(((__z & __x) & __y) | \ + ((__z | __x) & ~__y)) < 0); \ + case 4: /* s = u - u */ \ + return __truncated | ((__x < __y) ^ ((__ckd_intmax_t)__z < 0)); \ + case 5: /* s = u - s */ \ + __y ^= __ckd_sign(__ckd_uintmax_t); \ + return __truncated | (__x >= __y); \ + case 6: /* s = s - u */ \ + __x ^= __ckd_sign(__ckd_uintmax_t); \ + return __truncated | (__x < __y); \ + case 7: /* s = s - s */ \ + return __truncated | \ + ((__ckd_intmax_t)((__x ^ __y) & \ + (__z ^ __x)) < 0); \ + default: \ + for (;;) (void)0; \ + } \ + } + +__ckd_declare_sub(__ckd_sub_schar, signed char) +__ckd_declare_sub(__ckd_sub_uchar, unsigned char) +__ckd_declare_sub(__ckd_sub_sshort, signed short) +__ckd_declare_sub(__ckd_sub_ushort, unsigned short) +__ckd_declare_sub(__ckd_sub_sint, signed int) +__ckd_declare_sub(__ckd_sub_uint, unsigned int) +__ckd_declare_sub(__ckd_sub_slong, signed long) +__ckd_declare_sub(__ckd_sub_ulong, unsigned long) +__ckd_declare_sub(__ckd_sub_slonger, signed long long) +__ckd_declare_sub(__ckd_sub_ulonger, unsigned long long) +#ifdef __ckd_have_int128 +__ckd_declare_sub(__ckd_sub_sint128, signed __int128) +__ckd_declare_sub(__ckd_sub_uint128, unsigned __int128) +#endif + +#define __ckd_declare_mul(S, T) \ + __ckd_inline char S(void *__res, \ + __ckd_uintmax_t __x, \ + __ckd_uintmax_t __y, \ + char __a_signed, \ + char __b_signed) { \ + switch (__ckd_is_signed((T)0) << 2 | \ + __a_signed << 1 | __b_signed) { \ + case 0: { /* u = u * u */ \ + __ckd_uintmax_t __z = __x * __y; \ + int __o = __x && __z / __x != __y; \ + *(T *)__res = __z; \ + return __o | (sizeof(T) < sizeof(__z) && \ + __z != (__ckd_uintmax_t)*(T *)__res); \ + } \ + case 1: { /* u = u * s */ \ + __ckd_uintmax_t __z = __x * __y; \ + int __o = __x && __z / __x != __y; \ + *(T *)__res = __z; \ + return (__o | (((__ckd_intmax_t)__y < 0) & !!__x) | \ + (sizeof(T) < sizeof(__z) && \ + __z != (__ckd_uintmax_t)*(T *)__res)); \ + } \ + case 2: { /* u = s * u */ \ + __ckd_uintmax_t __z = __x * __y; \ + int __o = __x && __z / __x != __y; \ + *(T *)__res = __z; \ + return (__o | (((__ckd_intmax_t)__x < 0) & !!__y) | \ + (sizeof(T) < sizeof(__z) && \ + __z != (__ckd_uintmax_t)*(T *)__res)); \ + } \ + case 3: { /* u = s * s */ \ + int __o = 0; \ + if ((__ckd_intmax_t)(__x & __y) < 0) { \ + __x = -__x; \ + __y = -__y; \ + } else if ((__ckd_intmax_t)(__x ^ __y) < 0) { \ + __o = __x && __y; \ + } \ + __ckd_uintmax_t __z = __x * __y; \ + __o |= __x && __z / __x != __y; \ + *(T *)__res = __z; \ + return __o | (sizeof(T) < sizeof(__z) && \ + __z != (__ckd_uintmax_t)*(T *)__res); \ + } \ + case 4: { /* s = u * u */ \ + __ckd_uintmax_t __z = __x * __y; \ + int __o = __x && __z / __x != __y; \ + *(T *)__res = __z; \ + return (__o | ((__ckd_intmax_t)(__z) < 0) | \ + (sizeof(T) < sizeof(__z) && \ + __z != (__ckd_uintmax_t)*(T *)__res)); \ + } \ + case 5: { /* s = u * s */ \ + __ckd_uintmax_t __t = -__y; \ + __t = (__ckd_intmax_t)(__t) < 0 ? __y : __t; \ + __ckd_uintmax_t __p = __t * __x; \ + int __o = __t && __p / __t != __x; \ + int __n = (__ckd_intmax_t)__y < 0; \ + __ckd_uintmax_t __z = __n ? -__p : __p; \ + *(T *)__res = __z; \ + __ckd_uintmax_t __m = __ckd_sign(__ckd_uintmax_t) - 1; \ + return (__o | (__p > __m + __n) | \ + (sizeof(T) < sizeof(__z) && \ + __z != (__ckd_uintmax_t)*(T *)__res)); \ + } \ + case 6: { /* s = s * u */ \ + __ckd_uintmax_t __t = -__x; \ + __t = (__ckd_intmax_t)(__t) < 0 ? __x : __t; \ + __ckd_uintmax_t __p = __t * __y; \ + int __o = __t && __p / __t != __y; \ + int __n = (__ckd_intmax_t)__x < 0; \ + __ckd_uintmax_t __z = __n ? -__p : __p; \ + *(T *)__res = __z; \ + __ckd_uintmax_t __m = __ckd_sign(__ckd_uintmax_t) - 1; \ + return (__o | (__p > __m + __n) | \ + (sizeof(T) < sizeof(__z) && \ + __z != (__ckd_uintmax_t)*(T *)__res)); \ + } \ + case 7: { /* s = s * s */ \ + __ckd_uintmax_t __z = __x * __y; \ + *(T *)__res = __z; \ + return (((((__ckd_intmax_t)__y < 0) && \ + (__x == __ckd_sign(__ckd_uintmax_t))) || \ + (__y && (((__ckd_intmax_t)__z / \ + (__ckd_intmax_t)__y) != \ + (__ckd_intmax_t)__x))) | \ + (sizeof(T) < sizeof(__z) && \ + __z != (__ckd_uintmax_t)*(T *)__res)); \ + } \ + default: \ + for (;;) (void)0; \ + } \ + } + +__ckd_declare_mul(__ckd_mul_schar, signed char) +__ckd_declare_mul(__ckd_mul_uchar, unsigned char) +__ckd_declare_mul(__ckd_mul_sshort, signed short) +__ckd_declare_mul(__ckd_mul_ushort, unsigned short) +__ckd_declare_mul(__ckd_mul_sint, signed int) +__ckd_declare_mul(__ckd_mul_uint, unsigned int) +__ckd_declare_mul(__ckd_mul_slong, signed long) +__ckd_declare_mul(__ckd_mul_ulong, unsigned long) +__ckd_declare_mul(__ckd_mul_slonger, signed long long) +__ckd_declare_mul(__ckd_mul_ulonger, unsigned long long) +#ifdef __ckd_have_int128 +__ckd_declare_mul(__ckd_mul_sint128, signed __int128) +__ckd_declare_mul(__ckd_mul_uint128, unsigned __int128) +#endif + +#else +#pragma message "checked integer arithmetic unsupported in this environment" + +#define ckd_add(res, x, y) (*(res) = (x) + (y), 0) +#define ckd_sub(res, x, y) (*(res) = (x) - (y), 0) +#define ckd_mul(res, x, y) (*(res) = (x) * (y), 0) + +#endif /* GNU */ +#endif /* stdckdint.h */ +#endif /* JTCKDINT_H_ */ diff --git a/tests/ref/fate/source b/tests/ref/fate/source index 78d3a2e0fa..ab6182bf4c 100644 --- a/tests/ref/fate/source +++ b/tests/ref/fate/source @@ -25,6 +25,7 @@ compat/djgpp/math.h compat/float/float.h compat/float/limits.h compat/stdbit/stdbit.h +compat/stdckdint/stdckdint.h libavcodec/bitstream_template.h tools/decode_simple.h Use of av_clip() where av_clip_uintp2() could be used: From patchwork Fri Sep 27 01:44:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51880 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d8ca:0:b0:48e:c0f8:d0de with SMTP id dy10csp653369vqb; Fri, 27 Sep 2024 13:31:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW2a2JXIAfnDBNWmZLIyJGTGQmk9DTs6WpLrLi3qmdLt4r6thcG1tGsYbJ+7d7I1Da8yDojZ2Ky9gGZAqCciP7v@gmail.com X-Google-Smtp-Source: AGHT+IHDrs1MD7CY6/7kZCPRMqSJvFDC/9P8wVQQq9sFlYjrVJPEY+qInmzq1DOGQv3NiKMT9fcs X-Received: by 2002:a05:6512:3e0c:b0:538:9efb:dbe4 with SMTP id 2adb3069b0e04-5389fc6425fmr2996568e87.46.1727469071408; Fri, 27 Sep 2024 13:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727469071; cv=none; d=google.com; s=arc-20240605; b=kFn23g+NlGgqaNUNV1bk5TZrARr5MozfcUQ41aPRR02osX3nEFWV9UUNFBcJ7Lrm6x snOCg7u7kUoP9SfSjr+g83Yitesk3k+rewFOIiknlbMZO7pELGcKLegB2wlHCWVcJQe0 LqcV/RPFlDzyO8B43RpV3b3b6ed4yl7yPv1/4BTkuWeMP4FJwkqmOQ6HfHKUKEOQNNBG NP/TS9hhzMbBjKbZ38ZcENCWI/q32YTzRMXbvZaXuDdkbK4grVkMP0UC0S9DZdocWoqM Nn4yghbuEHsB9VeAdhl46YYUqqkMmLgTo8Jl4rlcgEC96O3BOCe2XObikCwYuOsoldua pdDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=ihMIJHQQ3FtkvaJV1QtPI+vmzdY/bNl5w6cNEf5oKKg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=YgIVfdRhzo4AOBjekNdwBa96Yo92EEoVttnybSpC/KSjIfrRpIeO59imV05WrNu+Mp 02Fl0CVwmp8oA/ZZUdk/O1cj67SjC8Qy8OSYcNwsg5ytnp74cE5Xjdvzb1VjCxUln2BL gIzWOxLI2oSoFhjkB+JKPJpy1tJ3kpFxNMMKjP4iNEjXSF+IFnH6Rbn/B2EWL4K+1pOg QcES66rUAfZlWLHSBAGHmj7SYR8LBq3ABZblBA6k6ScxdVzuLh3lv1g85uMZO9mQpz8P 2NF5fRxH7vfprww3SLOHOj0PTbpb3BpGatw7FJV8SWsjL5rFBvQpAYSGbdQ/JtYxTERW yA+A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=FXOt55WK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-538a0432c7esi913805e87.283.2024.09.27.13.31.10; Fri, 27 Sep 2024 13:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=FXOt55WK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 77F5D68DB02; Fri, 27 Sep 2024 04:44:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A8B6868DA92 for ; Fri, 27 Sep 2024 04:44:21 +0300 (EEST) Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-7db908c9c83so1019070a12.2 for ; Thu, 26 Sep 2024 18:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727401459; x=1728006259; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=BDoPGl0uvAc85Z4QXgDvSYwSaFNAAtRvrpSenREt7v8=; b=FXOt55WKRy1LvMl06mFQEdP4NyJdWxlEnnBT7tk0V7eaB6AY/AEL3B0y4hoqlhLgiO EV73cLYPnsnufJZrfXNRxJDcr9E526wo7J12OMLIasCooE/sIuciebErZdT/Ol1efd2n 7mxdsnshEl8M3Up8INPmRcEMsPrkf4/xpA3+w8GCaQRbXjzLpOHX29MOME4X0c1lnC2c Tamu4GfraKj87sU7uavDCjxofhrBSg+Eofs1A0Z2sS5ObwqPw74k4rpAm0xNI9WlTkgI 0VzmxnEZjKtkaetcBc5u6Rdxg7kc1qp+pu8rAM7ZilU820W99dtobvEe1l6NGTWh2/eH c2jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727401459; x=1728006259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BDoPGl0uvAc85Z4QXgDvSYwSaFNAAtRvrpSenREt7v8=; b=X2QwPm/xJ1cShGcB6q+3wbQ2MyMeri/uIIkDlWlFSam23fopPbdXVFlOSRirnHRrw8 oxL5sAAN6khp1mjftyvfIBvD2SZdy6Wds9T9CrOviVojIBHah6fCjxJSXHblK6mJMBQA Uz9uuspc+q8/ALS6NIe9qxEUKZyV3kJgxUGaWTvoiyD14nacLyLY/V3K2NBHNLNtW3KO UTSEwY3q0v2qVDjku/IG9qB+upV9OfuEDc7aMtPGZzd/iHTqQsieI5NMtKprjGDreo3U 3hLk0r8sW4RftQvgUDH5kj50H/ygu6zRzYnwyk2+fdjjy63lH5tFObvqx/tw6qNS8kor zWwQ== X-Gm-Message-State: AOJu0YykUnhZOG09CUf9gJf/oNM7QLP423eWeVP1d0+gxkwa9SRmxcni utpFYFJfecSTjdLktqbk98LJYINhODUWTVgYJSipjXOGXGfmvGi7Cm8e/w== X-Received: by 2002:a05:6a21:3406:b0:1d4:f6c4:8e7a with SMTP id adf61e73a8af0-1d4fa7ae0e3mr1866947637.31.1727401459257; Thu, 26 Sep 2024 18:44:19 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b2649c6a1sm541928b3a.44.2024.09.26.18.44.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 18:44:18 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Sep 2024 22:44:35 -0300 Message-ID: <20240927014436.15622-4-jamrial@gmail.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20240927014436.15622-1-jamrial@gmail.com> References: <20240927014436.15622-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] configure: include compat/stdckdint.h when required X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qScIZe/BJ+rS Signed-off-by: James Almer --- configure | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure b/configure index 643ffddd19..b87e400fe4 100755 --- a/configure +++ b/configure @@ -7802,6 +7802,10 @@ check_builtin stdbit "stdbit.h assert.h" \ 'static_assert(__STDC_VERSION_STDBIT_H__ >= 202311L, "Compiler lacks stdbit.h")' || \ add_cppflags '-I\$(SRC_PATH)/compat/stdbit' +check_builtin stdckdint "stdckdint.h assert.h" \ + 'static_assert(__STDC_VERSION_STDCKDINT_H__ >= 202311L, "Compiler lacks stdckdint.h")' || \ + add_cppflags '-I\$(SRC_PATH)/compat/stdckdint' + # Check if requested libraries were found. for lib in $AUTODETECT_LIBS; do requested $lib && ! enabled $lib && die "ERROR: $lib requested but not found";