pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Atomic operations within spinlocks
Date: Wed, 10 Jun 2020 09:51:13 -0400
Message-ID: <2297028.1591797073@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmoZwihdVft1vehsgP-nG_s8pd+FvtfdMcqDMK_AXqSwdhg@mail.gmail.com>
References: <1141819.1591208385@sss.pgh.pa.us>
	<20200603204542.reuladbmgmjqzoi6@alap3.anarazel.de>
	<1253593.1591293439@sss.pgh.pa.us>
	<20200604185525.wuyjtkluppj4eddr@alap3.anarazel.de>
	<1256701.1591297654@sss.pgh.pa.us>
	<20200605023302.g6v3ydozy5txifji@alap3.anarazel.de>
	<20200606001926.zin5getvvhqppnm2@alap3.anarazel.de>
	<CA+TgmoZwihdVft1vehsgP-nG_s8pd+FvtfdMcqDMK_AXqSwdhg@mail.gmail.com>

Robert Haas <robertmhaas@gmail.com> writes:
> On Fri, Jun 5, 2020 at 8:19 PM Andres Freund <andres@anarazel.de> wrote:
>> Randomly noticed while looking at the code:
>> 	uint64          flagbit = UINT64CONST(1) << (uint64) type;
>> 
>> that shouldn't be 64bit, right?

> I'm going to admit ignorance here. What's the proper coding rule?

The shift distance can't exceed 64, so there's no need for it to be
wider than int.  "type" is an enum, so explicitly casting it to an
integral type seems like good practice, but int is sufficient.

ISTR older compilers insisting that the shift distance not be
wider than int.  But C99 doesn't seem to require that -- it only
restricts the value of the right operand.

			regards, tom lane





view thread (22+ messages)  latest in thread

Message-ID: <2297028.1591797073@sss.pgh.pa.us>
Permalink:  ../2297028.1591797073@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2297028.1591797073@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, robertmhaas@gmail.com, andres@anarazel.de, pgsql-hackers@lists.postgresql.org
  Subject: Re: Atomic operations within spinlocks
  In-Reply-To: <2297028.1591797073@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