From patchwork Wed Apr 21 12:27:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 27200 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp349548iob; Wed, 21 Apr 2021 05:27:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyUEy8heOG1qIJoSAn8RyvYfs/WWMSyHtYJMif9fTr0c/hXKjUlPqXI8PvCOwjRY6LeXBD X-Received: by 2002:a17:907:c0b:: with SMTP id ga11mr32103958ejc.545.1619008055517; Wed, 21 Apr 2021 05:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619008055; cv=none; d=google.com; s=arc-20160816; b=PjZMO7diGp7LhcxGVOdwXpbPvyHuA9xexoKPMOG6Lewuu3TahYQw20p+Vm3ZWXkeaL V+4WrIdDsJqBrJtXFXOjGi+kpB2BPUKdUx2IkZjZkgo0uXLVMyZDL3BPk68ATKDZiw9q v+5j17xMSCcIOBFn/v/Eifpd0aktzUt+cscUbkbeGir0+uRgMyDMzZjlHzbANsY+8S+a L+X1243lnOWCNYbxJD8FNilE45J8ZAdJdACtXd5RcpOXPfvSz3TxuDHdobGF2Tw1MyIj CKQYc7FVZOCVbehN/HpkF1HrZEJ3HQGjAKR2HJ7NUxsWjjp/9lb2GXGQxDL0YjkKxFaf q1sA== 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:references:in-reply-to:message-id :date:to:from:delivered-to; bh=V/IFK248cKxIbrsSv0UMooSGADYe5TUBBv6Gcj2zzCc=; b=h9RNjJRWS+T3hNnpg6c3D4p3oaX9yCD+VkwSi/IwI2e8zmYvuqi6vSYq1WIL/fFVNV x6Z8zpcsXhyoC3hTtSWX3gz1FcZTC/yTNNcThS6Nfb17iWSmb5/wnR2zM7H8xRZf7qey N0Mbvym7nfpM2UYJmnzIfR1Qa5H5kFGurM181ATFLHiJMaR4RlBTb6/cNm9JRK6gvM+E EVOcjOYH+xw+N8VedRWdnZIx9AyLiEkQ3YlY4OjOS2BjjyKkhVIU9fny8rsWudr2TBLK NZpGQK7XaRS8hEzimTEaoTsfZTCjzobxlhFsCO2KUz6RyASFxv1cHr7U7Z09r7YWE9/e sodA== 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 q14si1641444eju.317.2021.04.21.05.27.35; Wed, 21 Apr 2021 05:27:35 -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 62C9C6899A8; Wed, 21 Apr 2021 15:27:17 +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 EE7286897C2 for ; Wed, 21 Apr 2021 15:27:09 +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 13LCR83t006268 for ; Wed, 21 Apr 2021 14:27:09 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id B5476EB5BD; Wed, 21 Apr 2021 14:27:08 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 21 Apr 2021 14:27:00 +0200 Message-Id: <20210421122706.9002-2-george@nsup.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210421122706.9002-1-george@nsup.org> References: <20210421122706.9002-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Wed, 21 Apr 2021 14:27:09 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 1/7] 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: ZJHXWrcFSM8m Signed-off-by: Nicolas George --- libavutil/extendable.h | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 libavutil/extendable.h 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 */