pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Michael Meskes <meskes@postgresql.org>
Subject: Re: define bool in pgtypeslib_extern.h
Date: Mon, 28 Oct 2019 13:57:19 -0400
Message-ID: <28364.1572285439@sss.pgh.pa.us> (raw)
In-Reply-To: <CAA4eK1JfbrGNT-b=hkp5eWra0=mKM2jEA_qANugV9FqXuJeTOg@mail.gmail.com>
References: <CAA4eK1LmaKO7Du9M9Lo=kxGU8sB6aL8fa3sF6z6d5yYYVe3BuQ@mail.gmail.com>
	<16583.1572010913@sss.pgh.pa.us>
	<18578.1572020755@sss.pgh.pa.us>
	<CAA4eK1LUFKhiq4vfrvG089wtSvnbfAs3sdTFdbuq428bQ7wCzg@mail.gmail.com>
	<32373.1572110364@sss.pgh.pa.us>
	<CAA4eK1JfbrGNT-b=hkp5eWra0=mKM2jEA_qANugV9FqXuJeTOg@mail.gmail.com>

Amit Kapila <amit.kapila16@gmail.com> writes:
> On Sat, Oct 26, 2019 at 10:49 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I'm inclined to think that we need to make ecpglib.h's bool-related
>> definitions exactly match c.h, which will mean that it has to pull in
>> <stdbool.h> on most platforms, which will mean adding a control symbol
>> for that to ecpg_config.h.  I do not think we should export
>> HAVE_STDBOOL_H and SIZEOF_BOOL there though; probably better to have
>> configure make the choice and export something named like PG_USE_STDBOOL.

> This sounds reasonable to me, but we also might want to do something
> for probes.d.  To be clear, I am not immediately planning to write a
> patch for this.

As far as probes.d goes, it seems to work to do

@@ -20,7 +20,7 @@
 #define BlockNumber unsigned int
 #define Oid unsigned int
 #define ForkNumber int
-#define bool char
+#define bool _Bool
 
 provider postgresql {
 
although removing the macro altogether leads to compilation failures.
I surmise that dtrace is trying to compile the generated code without
any #include's, so that only compiler built-in types will do.

(I tried this on macOS, FreeBSD, and NetBSD, to the extent of seeing
whether a build with --enable-dtrace goes through.  I don't know
enough about dtrace to test the results easily, but I suppose that
if it compiles then this is OK.)

This would, of course, not work on any platform where we're not
using <stdbool.h>, but I doubt that the set of platforms where
dtrace works includes any such.

A plausible alternative is to do

-#define bool char
+#define bool unsigned char

which is correct on platforms where we don't use <stdbool.h>,
and is at least no worse than now on those where we do.  In
practice, since we know sizeof(_Bool) == 1 on platforms where
we use it, this is probably just fine for dtrace's purposes.

Anyone have a preference?

			regards, tom lane





view thread (15+ messages)  latest in thread

Message-ID: <28364.1572285439@sss.pgh.pa.us>
Permalink:  ../28364.1572285439@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28364.1572285439@sss.pgh.pa.us

 · 

reply

Reply instructions:

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

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, amit.kapila16@gmail.com, pgsql-hackers@lists.postgresql.org, andrew@tao11.riddles.org.uk, meskes@postgresql.org
  Subject: Re: define bool in pgtypeslib_extern.h
  In-Reply-To: <28364.1572285439@sss.pgh.pa.us>

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

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox