From patchwork Wed May 12 20:43:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1477832 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=2620:52:3:1:0:246e:9693:128c; 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=JzKfNPqp; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4FgRkg3zsHz9sW4 for ; Thu, 13 May 2021 06:50:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EC3053894C09; Wed, 12 May 2021 20:50:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC3053894C09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620852617; bh=Y4muQDVjYJpKj6XORLi7IH4U5SHevv6wfFaCAP2n8C0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=JzKfNPqpIEre/yl5nyyreP96t9cOD1LatJdSfutEOnhFGRmAt1NMDSXB2rYrzqNSa JUjtisrT+zql/5R7INpRvYr0gXCEvg+mnno2wMO9Z2XZDBs3jEokSSxL236GrGFxyb zVNJfrgEMF3HhsrPmMa9RJaBgit4VlcYzz5C+STg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 147EE385382F for ; Wed, 12 May 2021 20:50:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 147EE385382F Received: by mail-wr1-x429.google.com with SMTP id e7so6427096wrc.11 for ; Wed, 12 May 2021 13:50:14 -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:mime-version :content-transfer-encoding; bh=Y4muQDVjYJpKj6XORLi7IH4U5SHevv6wfFaCAP2n8C0=; b=Cx3MyrhIg4GUXS1qjTaupy4RBarJvI6HVagodZl/zhL09Pi7LPR/TxwuydF5yIks8M L+4Wc7qCFk3+ddqP3LUSCkjL+JwOxDS1XdNeg5aeiGouJ3yFHl2oivUVi7H+F1HxCIF3 +WEaoEGE5+2taehTvJ4OEh3nPiecsGY1h6VXaq+4ufa4qdbabuE0rErKAniscz+mOYLK IC9+mwqbPVzosOg+dLlX8btzRTAFbtoXa3gp6h04if36N7in6LJOiGcHJNGEwcOaJABz JacoNbdPs2cIL69KZprACIm0X3tp3PQg0fvCnrkPUQP4YUuf2DvAe/3VVi8luDQxcpW4 04aw== X-Gm-Message-State: AOAM533soHf0rp6MmehvX9VJC5Ekx0g9gN1e9CJZe7GEe+0guzsAawNP ANpcqqeZi3kR4a/zPiWQsH4= X-Google-Smtp-Source: ABdhPJw0YGsi47QyzJJJDW6JHEa4UoHxNOyHN4g6RtgudD3hkOYvuT3LbIShLYbddvXXsEbMeWDB2Q== X-Received: by 2002:adf:8bd4:: with SMTP id w20mr11735266wra.192.1620852613159; Wed, 12 May 2021 13:50:13 -0700 (PDT) Received: from localhost.localdomain ([170.253.36.171]) by smtp.googlemail.com with ESMTPSA id b17sm777917wrt.71.2021.05.12.13.50.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 13:50:12 -0700 (PDT) To: mtk.manpages@gmail.com Subject: [PATCH] MAX.3, MIN.3: New page (and link page) to document MAX() and MIN() Date: Wed, 12 May 2021 22:43:12 +0200 Message-Id: <20210512204311.19399-1-alx.manpages@gmail.com> X-Mailer: git-send-email 2.31.1 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 --- Example tested: $ man max \ | sed -n /^EXAMPLES/,/^[[:alpha:]]/p \ | grep -v '^[[:alpha:]]' \ | cc -Wall -Wextra -Werror -x c -; $ ./a.out 65 38 MAX(65, 38) is 65 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..e203b5ca4 --- /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, +these macros shouldn't be used; see +.BR fmax (3) +or +.BR fmin (3) +instead. +.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