From patchwork Wed May 12 20:56:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1477834 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=hg3ylVkO; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FgRv83Rz4z9sRR for ; Thu, 13 May 2021 06:57:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7EA243894C1E; Wed, 12 May 2021 20:57:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EA243894C1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620853058; bh=tOtD2ItOjDSJU9AHUg4VbFwEBgpIlKfrWnOh2cTf138=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=hg3ylVkOfewyHIGhydIiGxhTsX1EPlfkD8ccTx6nJxkk/j9brAaRSqmSPsYOIjhpP fqOslnpW5+yCt4WRCzgCgBR6GXDGOQ4uo2h1QZEZ0Hf0xJIFaqisxdy9Adnf3RuQC5 h1v4v+wT92VQIyTHv4YnYGXHNt0WQN+RxP76Buc8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 2AC2C3853821 for ; Wed, 12 May 2021 20:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2AC2C3853821 Received: by mail-wm1-x332.google.com with SMTP id 82-20020a1c01550000b0290142562ff7c9so3685592wmb.3 for ; Wed, 12 May 2021 13:57:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tOtD2ItOjDSJU9AHUg4VbFwEBgpIlKfrWnOh2cTf138=; b=hZE+HX6RnOkMPzgDaoEqkxmsVt/jwkAW1wkmgULil9y+E32WTCYr5tVE3wa2AprhKj 8BL269HwST6KAkIdWgM8s5R+bsrfxMTOxSLZI//IIkszyrk7omn+Vrd8h5hhnmFOzVty RWLZ5bgO2K/MMB8HTXMrlOBIILJOuHElGOBF4Ivo7iMBUyo7oRkQ5GUkRarNbJH1odmM 1bWkoywK8QhPsPacMTQTQTcNKnYJD0I6Jjjb0/wlmdxWd7cCe0RuKOHNP0JyTx6CLMZJ o6Z5Ny0BS3v0JQm8Rx3ivXMkNNvEfiFT6AbeDpjaXHdtnEXVQiwnmqw5NahU3cpmu/1T EOEg== X-Gm-Message-State: AOAM531fPFq4Xfh/NViae85fJPd0pL7VsvgqaAsxtrXOBJ4iwxxe77xy rWy32ff+jQ+A6nlc08ol2Nk= X-Google-Smtp-Source: ABdhPJwRS5uiDqaz3xYJYv1z/5dl5qtc9JSWOJnobJsvXJLfdQDlH5l8IYx4Y/xPwMH6PLR2/ims2w== X-Received: by 2002:a05:600c:3510:: with SMTP id h16mr31118237wmq.38.1620853055238; Wed, 12 May 2021 13:57:35 -0700 (PDT) Received: from localhost.localdomain ([170.253.36.171]) by smtp.googlemail.com with ESMTPSA id b10sm1002750wrr.27.2021.05.12.13.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 13:57:34 -0700 (PDT) To: mtk.manpages@gmail.com Subject: [PATCH v2] MAX.3, MIN.3: New page (and link page) to document MAX() and MIN() Date: Wed, 12 May 2021 22:56:16 +0200 Message-Id: <20210512205615.19985-1-alx.manpages@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512204311.19399-1-alx.manpages@gmail.com> References: <20210512204311.19399-1-alx.manpages@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alejandro Colomar via Libc-alpha From: Alejandro Colomar Reply-To: Alejandro Colomar Cc: Alejandro Colomar , linux-man@vger.kernel.org, libc-alpha@sourceware.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Signed-off-by: Alejandro Colomar --- v2: - Reword paragraph about fmax(3) and fmin(3) in DESCRIPTION. man3/MAX.3 | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ man3/MIN.3 | 1 + 2 files changed, 86 insertions(+) create mode 100644 man3/MAX.3 create mode 100644 man3/MIN.3 diff --git a/man3/MAX.3 b/man3/MAX.3 new file mode 100644 index 000000000..3d69e8ac2 --- /dev/null +++ b/man3/MAX.3 @@ -0,0 +1,85 @@ +.\" Copyright (C) 2021 Alejandro Colomar +.\" +.\" %%%LICENSE_START(VERBATIM) +.\" Permission is granted to make and distribute verbatim copies of this +.\" manual provided the copyright notice and this permission notice are +.\" preserved on all copies. +.\" +.\" Permission is granted to copy and distribute modified versions of this +.\" manual under the conditions for verbatim copying, provided that the +.\" entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" Since the Linux kernel and libraries are constantly changing, this +.\" manual page may be incorrect or out-of-date. The author(s) assume no +.\" responsibility for errors or omissions, or for damages resulting from +.\" the use of the information contained herein. The author(s) may not +.\" have taken the same level of care in the production of this manual, +.\" which is licensed free of charge, as they might when working +.\" professionally. +.\" +.\" Formatted or processed versions of this manual, if unaccompanied by +.\" the source, must acknowledge the copyright and authors of this work. +.\" %%%LICENSE_END +.\" +.TH MAX 3 2020-11-01 "Linux" "Linux Programmer's Manual" +.SH NAME +MAX, MIN \- maximum or minimum of two values +.SH SYNOPSIS +.nf +.B #include +.PP +.BI MAX( a ", " b ); +.BI MIN( a ", " b ); +.fi +.SH DESCRIPTION +These macros return the maximum or minimum of +.I a +and +.IR b . +.PP +If any of the arguments is of a floating-point type, +you might prefer to use +.BR fmax (3) +or +.BR fmin (3), +which can handle NaN. +.PP +The arguments may be evaluated more than once, +and their types might be promoted to a common type +if both arguments aren't of the same type. +.SH RETURN VALUE +These macros return the value of one of their arguments, +according to their relationship. +.SH ERRORS +These macros may raise the "invalid" floating-point exception +when any of the arguments is NaN. +.SH CONFORMING TO +These macros are present in glibc and the BSDs. +.SH EXAMPLES +.EX +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int a, b, x; + + if (argc != 3) { + fprintf(stderr, "Usage: %s \en", argv[0]); + exit(EXIT_FAILURE); + } + + a = atoi(argv[1]); + b = atoi(argv[2]); + x = MAX(a, b); + printf("MAX(%d, %d) is %d\en", a, b, x); + + exit(EXIT_SUCCESS); +} +.EE +.SH SEE ALSO +.BR fmax (3), +.BR fmin (3) diff --git a/man3/MIN.3 b/man3/MIN.3 new file mode 100644 index 000000000..9938abda2 --- /dev/null +++ b/man3/MIN.3 @@ -0,0 +1 @@ +.so man3/MAX.3