Linux Manual Pages development
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: linux-man@vger.kernel.org, JeanHeyd Meneide <wg14@soasis.org>,
	"G. Branden Robinson" <g.branden.robinson@gmail.com>,
	Ingo Schwarze <schwarze@usta.de>
Subject: Re: [PATCH v2] _Generic.3: New page documenting _Generic()
Date: Tue, 23 Aug 2022 15:24:45 +0200	[thread overview]
Message-ID: <3ff26f4d-1f07-6a0c-0fc3-9c32dd9fd92c@gmail.com> (raw)
In-Reply-To: <ba5cd1b5-eadb-3f63-ba69-8a7bd8c2c105@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 797 bytes --]

On 8/23/22 15:16, Alejandro Colomar wrote:
> I.e., AFAIK, my_imaxabs(++x) would only do the ++ once, right?  Is that 
> what you were suggesting?

If that's what you meant, the macro seems safe:

$ cat imaxabs.c
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

#define my_imaxabs(j)  _Generic(INTMAX_C(0),  \
     long:           labs(j),                  \
     long long:      llabs(j)                  \
  /* long long long: lllabs(j) */              \
)

int
main(void)
{
     off_t  a;

     a = (intmax_t) -1;
     printf("imaxabs(%jd) == %jd\n", (intmax_t) -2, my_imaxabs(--a));

     exit(EXIT_SUCCESS);
}

$ cc -Wall -Wextra imaxabs.c
$ ./a.out
imaxabs(-2) == 2


Cheers,

Alex

-- 
Alejandro Colomar
<http://www.alejandro-colomar.es/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-08-23 16:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-20 17:10 [PATCH] _Generic.3: New page documenting _Generic() Alejandro Colomar
2022-08-21 11:55 ` [PATCH v2] " Alejandro Colomar
2022-08-23  7:58   ` Florian Weimer
2022-08-23 13:16     ` Alejandro Colomar
2022-08-23 13:24       ` Alejandro Colomar [this message]
2022-08-23 13:32     ` Alejandro Colomar
2022-08-23 13:34       ` Alejandro Colomar
2022-09-04 21:16     ` Alejandro Colomar
2022-09-04 22:06       ` Alejandro Colomar
2022-09-09 12:31       ` Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ff26f4d-1f07-6a0c-0fc3-9c32dd9fd92c@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=g.branden.robinson@gmail.com \
    --cc=linux-man@vger.kernel.org \
    --cc=schwarze@usta.de \
    --cc=wg14@soasis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox