From patchwork Thu Nov 17 10:09:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39303 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp993857pzb; Thu, 17 Nov 2022 02:10:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ux+OzSdX3S6Lu+N0vz7aRHkKxvXu0YzE1c9ObS5j6TpK1RM2XlMSVUqTlL6WwLxQfvw2Z X-Received: by 2002:a05:6402:294d:b0:467:6b55:3cf5 with SMTP id ed13-20020a056402294d00b004676b553cf5mr1580291edb.22.1668679809224; Thu, 17 Nov 2022 02:10:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668679809; cv=none; d=google.com; s=arc-20160816; b=L81JIYgQgC6+Q27QkKN7+hnW7PlXFktqQE3K9IRvpwWMO4WNWBN2cSAtAB63fmCjhF lYu5Tl1q6Vx/Fk7QFX4vo6HcwODvXYZMKONWtjVbpoQotnbbgqCGorjEGpj6g/MV0nlX dYgkta/kkG1h4Au25QN5F3oXatlrzrwZBWiza5NVFMjbs7/iLmJAPVKHfczcUcInHC8M lkRO/rmOpUzna6bAtPDska2t2rgyZ5acj4sua2Nm1bliYgBSjR5XffDs6qFgcACBcVYF O/CRnd+KlhpNhUnUdP10H7eRBVQoGhpqHN3XZGM9+N0NB17ODWn/1tvi7aIJFO7tqOEL VVew== 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=0VZy9Jvk6lk7NGFYo0vJyx7eQAsqdE3uNrafKynKCx8=; b=khPt6K9BMs/61B9LxueRHy7JG5jNiHPmnFDR86BMEJFx/Wm2NKA5qhNPOMHJid53vw v4mkKnu2dFP/ZBdO0bM5iPKPMVYrOcmfm29UL2RVCKDr/UWMzfZYg5jymfSts0JVhg2K 3i92oG1nPKTRUeY/dwHv26Ch204v9WF3ehEvi4Ai+nE8YVU7jMZrg+kWVwqdqHK2cQCe Xu8MlQJZxEmYbG+HN0sCvMVVSY1JTIKet1qNmC8cVJ+nSYg1aE9IIsHR6jm5u0YWvf97 xZtPG2wFMgIg3x1WchXh/kfy3yJpg2xSYfbMIeMMrRyTNZjrLCigHakF5g2+zXW32V6z sL/g== 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 n2-20020aa7c782000000b00443088b40b7si501204eds.123.2022.11.17.02.10.08; Thu, 17 Nov 2022 02:10:09 -0800 (PST) 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 BFB4C68BBBF; Thu, 17 Nov 2022 12:10:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8730068BA90 for ; Thu, 17 Nov 2022 12:09:57 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 1027B2406C7 for ; Thu, 17 Nov 2022 11:09:57 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id TaCfvz4Ohnoj for ; Thu, 17 Nov 2022 11:09:56 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 789B62400F5 for ; Thu, 17 Nov 2022 11:09:56 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 06E6B3A01E5 for ; Thu, 17 Nov 2022 11:09:50 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Nov 2022 11:09:36 +0100 Message-Id: <20221117100942.6217-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/7] configure: drop support for complex functions 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: 30aAzJJv8rol They are not used since 520a5d33f0ea9f8838dbc7282470db700d248065. --- configure | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/configure b/configure index e6470dc03b..868d11567b 100755 --- a/configure +++ b/configure @@ -1317,21 +1317,6 @@ int main(void){ $func(); } EOF } -check_complexfunc(){ - log check_complexfunc "$@" - func=$1 - narg=$2 - shift 2 - test $narg = 2 && args="f, g" || args="f * I" - disable $func - test_ld "cc" "$@" < -#include -float foo(complex float f, complex float g) { return $func($args); } -int main(void){ return (int) foo; } -EOF -} - check_mathfunc(){ log check_mathfunc "$@" func=$1 @@ -2224,11 +2209,6 @@ INTRINSICS_LIST=" intrinsics_neon " -COMPLEX_FUNCS=" - cabs - cexp -" - MATH_FUNCS=" atanf atan2f @@ -2403,7 +2383,6 @@ HAVE_LIST=" $(add_suffix _inline $ARCH_EXT_LIST) $ARCH_FEATURES $BUILTIN_LIST - $COMPLEX_FUNCS $HAVE_LIST_CMDLINE $HAVE_LIST_PUB $HEADERS_LIST @@ -6541,10 +6520,6 @@ for func in $MATH_FUNCS; do eval check_mathfunc $func \${${func}_args:-1} $libm_extralibs done -for func in $COMPLEX_FUNCS; do - eval check_complexfunc $func \${${func}_args:-1} -done - # these are off by default, so fail if requested and not available enabled avisynth && { require_headers "avisynth/avisynth_c.h avisynth/avs/version.h" && { test_cpp_condition avisynth/avs/version.h "AVS_MAJOR_VER >= 3 && AVS_MINOR_VER >= 7 && AVS_BUGFIX_VER >= 1 || AVS_MAJOR_VER >= 3 && AVS_MINOR_VER > 7 || AVS_MAJOR_VER > 3" || From patchwork Thu Nov 17 10:09:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39308 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp994099pzb; Thu, 17 Nov 2022 02:10:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf62mNtwFCW0qBEwa18WH0sDtj7rDKsraMkLySDnDsQCLeVQ0lY2OrUv+KfR2ss3XoZ4xyup X-Received: by 2002:a50:ee0d:0:b0:458:c339:4229 with SMTP id g13-20020a50ee0d000000b00458c3394229mr1477788eds.393.1668679844299; Thu, 17 Nov 2022 02:10:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668679844; cv=none; d=google.com; s=arc-20160816; b=I8Zxlcrh36TS9ObFYWd6PhFH7ZxlWzrigtGX7i/sOaIu9/n2+WcUu5yP0iNIqlJXh0 AJLj2CtLYtWTd7MCfBvTy/X2ATKSV2HPYM6TGKkfA9jlDJDpjmYaD0sEOUxrC4mU5UQ+ xJHNm1Ji2NWrcU1YHzgoby+BRbKoGLUlLNlZtcovqPH0X/tg9gYQ43jZnExYa+bB8UXk bOaz6XX3KKIkBZXzfBH/Il26RomGhwkv3whC0sEYee+kAB+6nwZ9eqtzpEgDS6TZWA0n BSoHin2fhpN4eCFE7+fcqnGRorAIJwRnpdz075/pC+hEhoINkHPmAjrfBX+L4rqbPBeE 0MJA== 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=GjCtxrCS9VVLJIIDbSFi72Pf06qT9WR25r9DvU/pr/s=; b=NeHafch2aO9bR1ALKG0s6dRrSBDVkPB19JpLI3bAMdAnYKSudib9aNPvmG2NESqpz1 SQA16awClbNkLkGKxwFu2OGz+Aqdv+5nMfa3P8p7RrQFDnPkpPs495FfYBZY2MbGePw7 UFgVpriDNEIRTU4zCx+qY65vUnKDMQpBOaWU3p8U6FD8xBB9lCjhRFSDCJjTiSf+KJWa 9WuZmA0HTdLmWWWkKX5L+f/oVqaYPCSgeOJrwu5jPLdvrGVlyAzaP6mAXhDZUPOFgN0w 6CaPh1JCIWbsRb+AK5HawKgCOIIxo+M4ZJeeGTOEgn1qZAGN0LRKb1PJBS6gdbEi7nP6 Dcxw== 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 ee32-20020a056402292000b0044ebf99d6f9si509762edb.263.2022.11.17.02.10.43; Thu, 17 Nov 2022 02:10:44 -0800 (PST) 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 79DCB68BB78; Thu, 17 Nov 2022 12:10:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2FB9568BA90 for ; Thu, 17 Nov 2022 12:09:59 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E75AA2404F7 for ; Thu, 17 Nov 2022 11:09:58 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id yCf6cOorOGxi for ; Thu, 17 Nov 2022 11:09:58 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 7C22A240499 for ; Thu, 17 Nov 2022 11:09:56 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 135893A02FD for ; Thu, 17 Nov 2022 11:09:50 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Nov 2022 11:09:37 +0100 Message-Id: <20221117100942.6217-2-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221117100942.6217-1-anton@khirnov.net> References: <20221117100942.6217-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/7] doc/developer.texi: move the language feature section higher up 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: OwoMW8Daxd6R It makes more sense to first describe the language we are using and only then document how to format code in it, rather than the reverse. --- doc/developer.texi | 104 ++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index cf918ac6b1..8e6d9d8730 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -56,6 +56,58 @@ and should try to fix issues their commit causes. @anchor{Coding Rules} @chapter Coding Rules +@section C language features + +FFmpeg is programmed in the ISO C90 language with a few additional +features from ISO C99, namely: + +@itemize @bullet +@item +the @samp{inline} keyword; + +@item +@samp{//} comments; + +@item +designated struct initializers (@samp{struct s x = @{ .i = 17 @};}); + +@item +compound literals (@samp{x = (struct s) @{ 17, 23 @};}). + +@item +for loops with variable definition (@samp{for (int i = 0; i < 8; i++)}); + +@item +Variadic macros (@samp{#define ARRAY(nb, ...) (int[nb + 1])@{ nb, __VA_ARGS__ @}}); + +@item +Implementation defined behavior for signed integers is assumed to match the +expected behavior for two's complement. Non representable values in integer +casts are binary truncated. Shift right of signed values uses sign extension. +@end itemize + +These features are supported by all compilers we care about, so we will not +accept patches to remove their use unless they absolutely do not impair +clarity and performance. + +All code must compile with recent versions of GCC and a number of other +currently supported compilers. To ensure compatibility, please do not use +additional C99 features or GCC extensions. Especially watch out for: + +@itemize @bullet +@item +mixing statements and declarations; + +@item +@samp{long long} (use @samp{int64_t} instead); + +@item +@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar; + +@item +GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}). +@end itemize + @section Code formatting conventions There are the following guidelines regarding the indentation in files: @@ -121,58 +173,6 @@ int myfunc(int my_parameter) ... @end example -@section C language features - -FFmpeg is programmed in the ISO C90 language with a few additional -features from ISO C99, namely: - -@itemize @bullet -@item -the @samp{inline} keyword; - -@item -@samp{//} comments; - -@item -designated struct initializers (@samp{struct s x = @{ .i = 17 @};}); - -@item -compound literals (@samp{x = (struct s) @{ 17, 23 @};}). - -@item -for loops with variable definition (@samp{for (int i = 0; i < 8; i++)}); - -@item -Variadic macros (@samp{#define ARRAY(nb, ...) (int[nb + 1])@{ nb, __VA_ARGS__ @}}); - -@item -Implementation defined behavior for signed integers is assumed to match the -expected behavior for two's complement. Non representable values in integer -casts are binary truncated. Shift right of signed values uses sign extension. -@end itemize - -These features are supported by all compilers we care about, so we will not -accept patches to remove their use unless they absolutely do not impair -clarity and performance. - -All code must compile with recent versions of GCC and a number of other -currently supported compilers. To ensure compatibility, please do not use -additional C99 features or GCC extensions. Especially watch out for: - -@itemize @bullet -@item -mixing statements and declarations; - -@item -@samp{long long} (use @samp{int64_t} instead); - -@item -@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar; - -@item -GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}). -@end itemize - @section Naming conventions All names should be composed with underscores (_), not CamelCase. For example, @samp{avfilter_get_video_buffer} is an acceptable function name and From patchwork Thu Nov 17 10:09:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39306 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp994037pzb; Thu, 17 Nov 2022 02:10:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf67NRX5RO8U1IEf7KzpwkYZ6LTLW+H5jW5dTvR4JqD2qkVNYZeyUDivN6UEhF1BpQbF3Gxu X-Received: by 2002:aa7:d803:0:b0:467:f948:6df4 with SMTP id v3-20020aa7d803000000b00467f9486df4mr1480906edq.217.1668679835282; Thu, 17 Nov 2022 02:10:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668679835; cv=none; d=google.com; s=arc-20160816; b=pLId4BJpGR06yZZ3Z/dNphE/YsQuhFffPnHbXxJ6UozYqdBCVUz9Z9h/qiq6vSToj+ 5tcPuQvdDbzdMnhM6VDtickXwST1OhJKdiKGTxv3RGhFNM0JJA5aoAjSTvY9fH+/coJ4 YE1h+kizCIa5aokNhFBrpQHUCHfvshLubGO7ay4A0udJhbZ4L21AJ/6k9gZvLl7U9iFx aWTCfLvv6+P1VKOO2ua9NBDqe8zYQ3MX5HvhUra05dNhLfc929tw6CDrX23F86oBE3tP jYqFWpKjr3xcXzQ1mAEhtpQghVbmCqjZiw30jyundOxye+ONrirgexzEraexdfi0Bogl 09EA== 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=udoTl5Skj8Jo4uSBarhtIew2R5XWzCzt9jMXpvdj6y8=; b=Wh6P9cUQ0oCpC7+42USrBy4PpxOdlXeNoT3tZkniMsGc9k9KCdKv4tv6GrClCOoSkd VIQtsxd5+C7W+kqE+v5RlEyPcG0bTiClRA+Gb1Xy+nnQS+hvg8g6wfjeQ02CURGo9CZy pVGSG0fwdzB4y0fAyM6nT0fq5ZScuFfVfLBF9MnTg6rhgWtPwDUnL/dR5KZljOEGyEuX dpz/XO0OJzCN/ztCQR96suZBvigMNkz1nMCnAp4N+yszKbPIvfYNLbefmkQCkFve2WRY fGlJPzvA8cp2yHYlb7XrkA2EF/JjVXPZBapW0slLOIhRYdJRTdjLWVLmWGe34FrAop1G 2Bgg== 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 di19-20020a170906731300b007aee592fd06si237404ejc.203.2022.11.17.02.10.34; Thu, 17 Nov 2022 02:10:35 -0800 (PST) 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 70DE268BCC1; Thu, 17 Nov 2022 12:10:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DCD0368BA90 for ; Thu, 17 Nov 2022 12:09:58 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A047D240591 for ; Thu, 17 Nov 2022 11:09:58 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id AnqSHWB1uixp for ; Thu, 17 Nov 2022 11:09:56 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 7EAB22404F7 for ; Thu, 17 Nov 2022 11:09:56 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1E9773A0520 for ; Thu, 17 Nov 2022 11:09:50 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Nov 2022 11:09:38 +0100 Message-Id: <20221117100942.6217-3-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221117100942.6217-1-anton@khirnov.net> References: <20221117100942.6217-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/7] doc/developer.texi: update the language feature section 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: xq5/j80zNHBT It is currently very out of touch with reality. * declare we are using C99 fully, rather than C90 plus extensions * mention our use of stdatomic.h * mention forbidden C99 features, like VLAs and complex numbers --- doc/developer.texi | 49 ++++++++++++---------------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 8e6d9d8730..01735e07f5 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -58,54 +58,29 @@ and should try to fix issues their commit causes. @section C language features -FFmpeg is programmed in the ISO C90 language with a few additional -features from ISO C99, namely: - +FFmpeg is programmed in the ISO C99 language, extended with: @itemize @bullet @item -the @samp{inline} keyword; - -@item -@samp{//} comments; - -@item -designated struct initializers (@samp{struct s x = @{ .i = 17 @};}); - -@item -compound literals (@samp{x = (struct s) @{ 17, 23 @};}). - -@item -for loops with variable definition (@samp{for (int i = 0; i < 8; i++)}); - -@item -Variadic macros (@samp{#define ARRAY(nb, ...) (int[nb + 1])@{ nb, __VA_ARGS__ @}}); - -@item -Implementation defined behavior for signed integers is assumed to match the -expected behavior for two's complement. Non representable values in integer -casts are binary truncated. Shift right of signed values uses sign extension. +Atomic operations from C11 @file{stdatomic.h}. They are emulated on +architectures/compilers that do not support them, so all FFmpeg-internal code +may use atomics without any extra checks. However, @file{stdatomic.h} must not +be included in public headers, so they stay C99-compatible. @end itemize -These features are supported by all compilers we care about, so we will not -accept patches to remove their use unless they absolutely do not impair -clarity and performance. - -All code must compile with recent versions of GCC and a number of other -currently supported compilers. To ensure compatibility, please do not use -additional C99 features or GCC extensions. Especially watch out for: +Compiler-specific extensions may be used with good reason, but must not be +depended on, i.e. the code must still compile and work with compilers lacking +the extension. +The following C99 features must not be used anywhere in the codebase: @itemize @bullet @item -mixing statements and declarations; - -@item -@samp{long long} (use @samp{int64_t} instead); +variable-length arrays; @item -@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar; +complex numbers; @item -GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}). +mixed statements and declarations. @end itemize @section Code formatting conventions From patchwork Thu Nov 17 10:09:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39305 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp993982pzb; Thu, 17 Nov 2022 02:10:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf74AJUMBz9b0hFlhA7I3EozMLtwl5ajhqkjkRV96hKT8DCgELMwZSfWEDpv1Ey28Rj8V5cq X-Received: by 2002:a17:907:774e:b0:7ae:39b4:7208 with SMTP id kx14-20020a170907774e00b007ae39b47208mr1483653ejc.766.1668679826418; Thu, 17 Nov 2022 02:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668679826; cv=none; d=google.com; s=arc-20160816; b=OmPct4sW7E07i+L+q6DC60VgybtbG/WS6sE7wvzEeg9xbMafxAGLo9shV2Iw7Zb6zN 95HNDqvTTbyvTjm32dfZ/vP7JU+UN/vZErAaaU5kZsgJPs6Ta47d9AMcOsY9eEMtC2Sb 50O0WwCHQWDcA46pnVfAFJSxR8UiIprYsbsu2op3fomamZ0PxXMJNhH7E2838+MTyICZ 6hUvexw0+MPl8iZyQ+GltV1+blzge3Dtcew0Je89haaEl0AQnw3hhaiUjqSw482or4yI Kgo8xMS5nBEn9hna/BWfxtmyN4S6PWirJ+XKbL2o3QJ2K47V1U9NXIlfD+TOgNHNlzbC Y0Eg== 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=agVlcyzgQbbK/C9awtjyA3bd7RVPYKcs3KLkaD3w9ok=; b=U8EtmDXDNxYyFXN2XR6ObouHrIj/hMemOLQWLoe3FVcvQZutXn+MIaOT4uLjdDzxO6 Rmhk1qQWZcrXIHg1Xa0cCScg+oUU4Ktj4UooInX6zM2WARQO/1+zbXjhv+ts9cg+8tyb SYqHo3iFLdxMk22YxJHzchjkWyS52WZ9UY0Sy+5w27eXimj/utj7Qyp6qIk/TwBCiOhj zU65O/+Yk3TTwbKD+9wy6hKBGui6eaD1zwdPtxwY0TZkyjPjKAEunblPN8IKSUq1Vczj ehdXmP20vft2Juoy/HtA9yf3/8eWx3vQr0mV+6RCkAR7h4ZuDw0hO1HIogKrbJBgZ1Ov QIxQ== 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 x11-20020a056402414b00b0044f2fb68fe6si514897eda.495.2022.11.17.02.10.25; Thu, 17 Nov 2022 02:10:26 -0800 (PST) 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 712BC68BCCB; Thu, 17 Nov 2022 12:10:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 84CD768BA90 for ; Thu, 17 Nov 2022 12:09:58 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 41B0F2404F8 for ; Thu, 17 Nov 2022 11:09:58 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id wo6Momse-QuR for ; Thu, 17 Nov 2022 11:09:57 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 83560240591 for ; Thu, 17 Nov 2022 11:09:56 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 29F943A054D for ; Thu, 17 Nov 2022 11:09:50 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Nov 2022 11:09:39 +0100 Message-Id: <20221117100942.6217-4-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221117100942.6217-1-anton@khirnov.net> References: <20221117100942.6217-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/7] doc/developer.texi: document the use of other languages than C 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: r7Bwa2oHv44x --- doc/developer.texi | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 01735e07f5..44da6e41af 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -56,9 +56,9 @@ and should try to fix issues their commit causes. @anchor{Coding Rules} @chapter Coding Rules -@section C language features +@section Language -FFmpeg is programmed in the ISO C99 language, extended with: +FFmpeg is mainly programmed in the ISO C99 language, extended with: @itemize @bullet @item Atomic operations from C11 @file{stdatomic.h}. They are emulated on @@ -83,6 +83,17 @@ complex numbers; mixed statements and declarations. @end itemize +Other languages than C may be used in special cases: +@itemize @bullet +@item +NASM is preferred for x86 SIMD or other x86 assembly. Inline assembly and +intrinsics should be avoided, unless there is a strong reason to use them (e.g. +code that needs to be inlined). + +@item +Objective-C where required for interacting with macOS-specific interfaces. +@end itemize + @section Code formatting conventions There are the following guidelines regarding the indentation in files: From patchwork Thu Nov 17 10:09:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39304 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp993911pzb; Thu, 17 Nov 2022 02:10:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf5CSmtUqOBoG8D7sSfrYsoiqibdHJ8cN+gRC32fda6KYZcMV5kW9FFc8QxpT4XyzeYqYsTs X-Received: by 2002:a05:6402:1768:b0:463:ce05:c00e with SMTP id da8-20020a056402176800b00463ce05c00emr1532643edb.46.1668679818315; Thu, 17 Nov 2022 02:10:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668679818; cv=none; d=google.com; s=arc-20160816; b=CH0WLHmSzVcAEmoPx8LcEQFzRHjZz+ipxzYtqAxZwalOisR3VenId1URSbn2E1h92l vmPvsWD5t/Tmgr7jWl/zmoiMY/Y9eZb5CB6EbyFjXhENKjiMBZnHvbWgLA7SOsnkwzKb fE8FRqAZcJqz7L9IeSH7UVC1K6JfaAsmnL1TMkg1m308smZ4joJSX+npiuGspZri2jN/ 7x9L6rSoVLIBmtNIuehjO01jwBNb3uMiZ/DyzeyOwptaiU3YDOGzp5S7ySfoVhtQ/Wro pwGiD73LKKQXCYXmYiKkyhepzQEn4bS3aLcXXOeBsmPA+w27EYqkZwlU/9rCeVmQqzrC sm4w== 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=F6KIcOgkFGTKx6FeBB6nsLFGhUanBIygtDgL7zceo2I=; b=EYLxHqTNst2PaEgtB+YXmETZg3KZA6X6Iff883pk6BiNP5p+a+zskpktPkv5ee/Y7V Mn6w4K/BFKAjB64jxAkaqPkY1PbFN5EoDlz4grOeuKiNziZN+XA2PaWVuYMsMUyZXj1L GwrmsscVa8ZAKWb2f7kU7pin+MW/siYVKzYRkdL9tLyxA65nI3yOOGFaQMTvVeXwUUNn ODbJMwQbofA4qjRv5LG7lwI9ZVsjjhghb21LF6LpZ8ZroBPHTMc4LlFsdr+hJIUrjQ3h 5MFvlgoOWfXISP/QwltR8oQqG+5IbjhAh1EuAhg7j064xDqE8psxMVivmNvTil0vMv84 ueaQ== 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 e13-20020a056402190d00b00447a8836a56si618187edz.208.2022.11.17.02.10.17; Thu, 17 Nov 2022 02:10:18 -0800 (PST) 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 8B8F268BCA6; Thu, 17 Nov 2022 12:10:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0FC968BA90 for ; Thu, 17 Nov 2022 12:09:57 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B30092400F5 for ; Thu, 17 Nov 2022 11:09:57 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id jZqeT2rX7f3y for ; Thu, 17 Nov 2022 11:09:57 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 7FF152404F8 for ; Thu, 17 Nov 2022 11:09:56 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 34B973A058F for ; Thu, 17 Nov 2022 11:09:50 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Nov 2022 11:09:40 +0100 Message-Id: <20221117100942.6217-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221117100942.6217-1-anton@khirnov.net> References: <20221117100942.6217-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/7] doc/developer.texi: move editor configuration under formatting 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: 5sRyzYw6b9zp It logically belongs there. --- doc/developer.texi | 67 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index 44da6e41af..d0e2e04a2d 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -119,6 +119,40 @@ The presentation is one inspired by 'indent -i4 -kr -nut'. The main priority in FFmpeg is simplicity and small code size in order to minimize the bug count. +@subsection Vim configuration +In order to configure Vim to follow FFmpeg formatting conventions, paste +the following snippet into your @file{.vimrc}: +@example +" indentation rules for FFmpeg: 4 spaces, no tabs +set expandtab +set shiftwidth=4 +set softtabstop=4 +set cindent +set cinoptions=(0 +" Allow tabs in Makefiles. +autocmd FileType make,automake set noexpandtab shiftwidth=8 softtabstop=8 +" Trailing whitespace and tabs are forbidden, so highlight them. +highlight ForbiddenWhitespace ctermbg=red guibg=red +match ForbiddenWhitespace /\s\+$\|\t/ +" Do not highlight spaces at the end of line while typing on that line. +autocmd InsertEnter * match ForbiddenWhitespace /\t\|\s\+\%#\@@ X-Patchwork-Id: 39309 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp994168pzb; Thu, 17 Nov 2022 02:10:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7dQ/NVuWPAcHx/jHgp6MljViaiKDwElqKCStwB4HbCyrUl9JB4YtGXx0p1o6sgR83A6/M3 X-Received: by 2002:a05:6402:d6:b0:458:b42e:46e6 with SMTP id i22-20020a05640200d600b00458b42e46e6mr1512014edu.375.1668679853346; Thu, 17 Nov 2022 02:10:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668679853; cv=none; d=google.com; s=arc-20160816; b=HXYX1/iuofIeZlQY/DZ80n3lRln41Fx80YAK6o0IHWHb2ktaVQi0s7XJCZZCF2gHIx SYbL0OiPz3bVA8mjAn2ke3BJPDTwCChnumn42PXxIHGLkbUa9Ngo3EfkNueZm/VbLYjV rXvUvcuEyeMu7dvegsPxtuTS0XaQZBFyvGV3cLvFjoHfkF7A9Izau1S637Nb54J/2pr7 h9L+oWE4zG3SK6PWlZy1sORxv6GaguNWdCzIDLU3V+vWbZ9TWF0uZF+dwXwvIm+aX4iI H2znivhAZzm/OO1bE5gXGdea7ljSdDwtK15Y6Qu7ISlPm3wvKi4xynqH66DME1drrpDB EzKw== 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=lylCSV0SLWHP1MvVA6pZ4QyWIXMav7l7IhhYc2iMWGg=; b=VT5hf0mQrO5jt0Xd+Jl1j5asqZXD0FL69CU8N1J+s1dxX6/w9vjR/oOU0jbDPGbXzX sW8l1y8r9YRNz8pTycDihxS6VA4i/jQJTj8XG4RLiX1InpvV9QnoUcBWn7jY2aqFlcTh yaYXNhsHt7xvKIRoLwUhxsaAh2hQiEDzZF1uJzMyM2g941EuEu9fzwxmsRH/Sgn/xRWr Ji2bCv8JSumCEdWCsPvthfb6sNrhuU/OT1jyHv+moXD9/eU83CtlrKu+NITyDaKhrtLt 7L8zcN1aWBg4IBX8E64Rc2rbzH/EwTLTlbUSEWZ1kTOA7ivtl7VevYthHoi3UAPmV7q2 LBLA== 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 f21-20020a056402195500b00461cdda451dsi502938edz.435.2022.11.17.02.10.52; Thu, 17 Nov 2022 02:10:53 -0800 (PST) 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 89B5568BC19; Thu, 17 Nov 2022 12:10:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C43D468BCC3 for ; Thu, 17 Nov 2022 12:10:02 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2F74B240499 for ; Thu, 17 Nov 2022 11:09:59 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id NyXJeuqY3vFh for ; Thu, 17 Nov 2022 11:09:58 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 892FA2405EC for ; Thu, 17 Nov 2022 11:09:56 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3FA433A05F9 for ; Thu, 17 Nov 2022 11:09:50 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Nov 2022 11:09:41 +0100 Message-Id: <20221117100942.6217-6-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221117100942.6217-1-anton@khirnov.net> References: <20221117100942.6217-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/7] doc/developer.texi: drop a misplaced sentence from code formatting section 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: YuEZR/vlUjr2 It describes a general development policy, not code formatting. It is also not true, as these days we tend to prioritize correctness, safety, and completeness over code size. --- doc/developer.texi | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index d0e2e04a2d..a2719e7518 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -116,9 +116,6 @@ K&R coding style is used. @end itemize The presentation is one inspired by 'indent -i4 -kr -nut'. -The main priority in FFmpeg is simplicity and small code size in order to -minimize the bug count. - @subsection Vim configuration In order to configure Vim to follow FFmpeg formatting conventions, paste the following snippet into your @file{.vimrc}: From patchwork Thu Nov 17 10:09:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39310 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp994216pzb; Thu, 17 Nov 2022 02:11:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ZGEGWBzvNXy9/kVuQMqJmkqfEe64JrSAMjfNRzMgzF06/Z+9vPlJNhNO1mwiLHofQap7h X-Received: by 2002:a17:906:1b52:b0:7ad:90dc:b7d4 with SMTP id p18-20020a1709061b5200b007ad90dcb7d4mr1528401ejg.278.1668679861986; Thu, 17 Nov 2022 02:11:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668679861; cv=none; d=google.com; s=arc-20160816; b=kQkBpmMXxupDTS8o4PPkcXIsqD1cKUx6MN0HHtj48Lbg1lu7NOrwX7Rt5E+c+4wSOQ 5Umgs7PgLU2pIcZ2MhkDbO8MK3TDJHXcuwEnzQpInclrw+k3HzdpOSPqsDEEZ2lwbslT iZ98Bs9XYKmu04tO6uA8fwgsM0yFOQ2KnxHDu2cVZvbhiOu489AvowmFMywk7/8REvpH NAzsLK13eGsixA2xaCfLoycidqyVyGEyD7YzvQcO2BjgGpwwZA9Wf4KcFvlf8n5jU0XO y2P6bSUgYD1Y9bo6YB6QnqzetYhV1i0Nydm8d93xvaeYJI0CgoBci2Uyxlx/9vVdIZo8 H2Rw== 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=t3F25Aeu4Khhsv/lDWJj0P4Zu+SQLcFD78dBuyMqyEE=; b=yuG0mB2wAZ66aHAiktBYzhNL2wv92VOqCB0BtAsEq5w3klKAK0yill7irsonhn5tHJ NPPL6JJXPrhU7ZPXDAqKMVBejXLaJG3qdGAVDBVQAnatmpOha9Zj+JKgZpp6G3GB156U PXw65ylOzTujZ5+qCUkCHrw6yYjUkwVXDQbJ7PklZpvSE90h9ugHskEMrGY64YE0EWGx Pc34poYRS9rSnjKQs/DR7aHQdJe7qTYv0Hwgn/ueKPpIOh9Q1APQEo+WeIVRsqy8oVRE MJKMYKLWYYgaFDQNFP7PcDcWC4HcQg3PvMSnSR6W+C/FUx5pSXeiZEQQc4im1b3uqDJp Dy3Q== 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 hc6-20020a170907168600b007addf59b7f5si229570ejc.794.2022.11.17.02.11.01; Thu, 17 Nov 2022 02:11:01 -0800 (PST) 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 7BDEE68BD36; Thu, 17 Nov 2022 12:10:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CABDA68BCFF for ; Thu, 17 Nov 2022 12:10:02 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9E0F62405EC for ; Thu, 17 Nov 2022 11:09:59 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 7nHQ3t9OnnsT for ; Thu, 17 Nov 2022 11:09:58 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id B17282405F9 for ; Thu, 17 Nov 2022 11:09:56 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 4B2E93A0656 for ; Thu, 17 Nov 2022 11:09:50 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 17 Nov 2022 11:09:42 +0100 Message-Id: <20221117100942.6217-7-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221117100942.6217-1-anton@khirnov.net> References: <20221117100942.6217-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/7] doc/developer.texi: extend and update naming conventions 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: P3b+/N/Q1czY Bring it up to date with current practice, as the current text does not cover everything. Drop the reference to unprefixed exported symbols, which do not exist anymore. --- doc/developer.texi | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/doc/developer.texi b/doc/developer.texi index a2719e7518..48c27f3005 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -191,39 +191,50 @@ int myfunc(int my_parameter) @end example @section Naming conventions -All names should be composed with underscores (_), not CamelCase. For example, -@samp{avfilter_get_video_buffer} is an acceptable function name and -@samp{AVFilterGetVideo} is not. The exception from this are type names, like -for example structs and enums; they should always be in CamelCase. -There are the following conventions for naming variables and functions: +Names of functions, variables, and struct members must be lowercase, using +underscores (_) to separate words. For example, @samp{avfilter_get_video_buffer} +is an acceptable function name and @samp{AVFilterGetVideo} is not. -@itemize @bullet -@item -For local variables no prefix is required. +Struct, union, enum, and typedeffed type names must use CamelCase. All structs +and unions should be typedeffed to the same name as the struct/union tag, e.g. +@code{typedef struct AVFoo @{ ... @} AVFoo;}. Enums are typically not +typedeffed. +Enumeration constants and macros must be UPPERCASE, except for macros +masquerading as functions, which should use the function naming convention. + +All identifiers in the libraries should be namespaced as follows: +@itemize @bullet @item -For file-scope variables and functions declared as @code{static}, no prefix -is required. +No namespacing for identifiers with file and lower scope (e.g. local variables, +static functions), and struct and union members, @item -For variables and functions visible outside of file scope, but only used -internally by a library, an @code{ff_} prefix should be used, -e.g. @samp{ff_w64_demuxer}. +The @code{ff_} prefix must be used for variables and functions visible outside +of file scope, but only used internally within a single library, e.g. +@samp{ff_w64_demuxer}. This prevents name collisions when FFmpeg is statically +linked. @item For variables and functions visible outside of file scope, used internally across multiple libraries, use @code{avpriv_} as prefix, for example, @samp{avpriv_report_missing_feature}. +@item +All other internal identifiers, like private type or macro names, should be +namespaced only to avoid possible internal conflicts. E.g. @code{H264_NAL_SPS} +vs. @code{HEVC_NAL_SPS}. + @item Each library has its own prefix for public symbols, in addition to the commonly used @code{av_} (@code{avformat_} for libavformat, @code{avcodec_} for libavcodec, @code{swr_} for libswresample, etc). Check the existing code and choose names accordingly. -Note that some symbols without these prefixes are also exported for -retro-compatibility reasons. These exceptions are declared in the -@code{lib/lib.v} files. + +@item +Other public identifiers (struct, union, enum, macro, type names) must use their +library's public prefix (@code{AV}, @code{Sws}, or @code{Swr}). @end itemize Furthermore, name space reserved for the system should not be invaded.