From patchwork Fri Apr 28 09:55:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 41393 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp1188197pzb; Fri, 28 Apr 2023 02:55:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6bZo7UAQcGNZ7rp6+WZJuoUwlJEa6s6QselX5onoz0vOBEHc/n7aa0dWWxUgipZzQDLzIr X-Received: by 2002:aa7:dbd2:0:b0:50a:16ab:340e with SMTP id v18-20020aa7dbd2000000b0050a16ab340emr4110551edt.29.1682675723867; Fri, 28 Apr 2023 02:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682675723; cv=none; d=google.com; s=arc-20160816; b=UT6SaYIYE5shtkZEeBwLa7pYlYpZBeBSSGfP+UqyLsp0yq3sfcBPstAxl++oCTeDfa FA7eWYxSw+0E+4lacFuWTJ3cTGuuvK2Q9PzJ57I6GgPoKiUKBDqoyimqMPprHAh9Hkp4 OobpfM8aEiWOTPsRMR7pSiKIIT4xsgLuZsmZNNmv/Hep2CUek0QhvqUwgYvRDs65bT2/ RNYgFnIcB5glu9cG7ItVm6Rv7iDZvsl7wJ6O8cHghFEzomgF1CGR/5UHPV9Zd8hqBBkP tg1sgeBa4rW2doWygpZstK+wWDLX8kfWA5d+g9+ityPP0J0snrRgQ7DUrmRBQAE0tmzb XfBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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 :delivered-to; bh=os2DogV3HtKPrSBl7u48lZwMlHtN8lnwWvjlgCRMHI8=; b=BpYoRogs38iF6GN9Ybt9UV1WSR70pGRXe13MgiwaoIkS+Ptbmo84JPvH+V04+IxeP8 e8jQnhtP3Z/OVzJayDkV75k2oCh4UmVn7SszlnTUQgahB0MmAYEDVl2QVBK/dnYIdsdr 79P7cYxhd3OGtZftSbshefMt5GipdYZsXfDrKgKOwtkHZHAfApRu2SQi6Gh7W5q/+hA2 Nw7kr7aJS58j16djXCjddv1IZNZvRBAAlwEDPG168DF1/23LrmBjzTqz8U7cY3xRNhAG 3MehiopLVWY0v7OF8KGEQDoMLFon0HMNqZ+zdlsCbntHGb0ShXnINFPtKnl2KYbEk7nG 0TDQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i25-20020a056402055900b00506bdb0c581si15854380edx.152.2023.04.28.02.55.23; Fri, 28 Apr 2023 02:55:23 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5211968BF83; Fri, 28 Apr 2023 12:55:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78CA468BF06 for ; Fri, 28 Apr 2023 12:55:11 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 33S9tAKi014762 for ; Fri, 28 Apr 2023 11:55:10 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id A7337EB5BF; Fri, 28 Apr 2023 11:55:10 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Apr 2023 11:55:01 +0200 Message-Id: <20230428095508.221826-1-george@nsup.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Fri, 28 Apr 2023 11:55:10 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 1/8] lavu: add macros to help making future-proof structures 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: FjEs9hAFaDn1 Signed-off-by: Nicolas George --- libavutil/extendable.h | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 libavutil/extendable.h FFReservedPadding is used by the WIP JSON writer. diff --git a/libavutil/extendable.h b/libavutil/extendable.h new file mode 100644 index 0000000000..79980fa202 --- /dev/null +++ b/libavutil/extendable.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2021 The FFmpeg project + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_EXTENDABLE_H +#define AVUTIL_EXTENDABLE_H + +/** + * @defgroup ff_extendable FFExtendable + * + * Types and macros to help designing structures that can be allocated by + * the application, including on the stack, but will not break ABI when + * extendded. + * + * This should not be used outside FFmpeg. + * + * @{ + */ + +/** + * Define a value of type as a compound literal (hidden local variable) + * with the field self_size filled. + */ +#define FF_NEW_SZ(type) ((type){ .self_size = sizeof(type) }) + +/** + * Type suitable for paddign at the end of a structure, with maximum + * alignment. + */ +typedef union FFReservedPadding { + union { + double d; + void *p; + void (*f)(void); + intmax_t i; + } dummy; +} FFReservedPadding; + +/** + * @} + */ + +#endif /* AVUTIL_EXTENDABLE_H */