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