Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jj18Y-0001q2-C4 for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2020 13:51:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jj18X-0006KA-6x for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2020 13:51:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jj18W-0006K2-WB for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2020 13:51:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jj18Q-0001lp-Le for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2020 13:51:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 05ADpDHf2297029; Wed, 10 Jun 2020 09:51:13 -0400 From: Tom Lane To: Robert Haas cc: Andres Freund , PostgreSQL Hackers Subject: Re: Atomic operations within spinlocks In-reply-to: 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> Comments: In-reply-to Robert Haas message dated "Wed, 10 Jun 2020 07:26:32 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2297027.1591797073.1@sss.pgh.pa.us> Date: Wed, 10 Jun 2020 09:51:13 -0400 Message-ID: <2297028.1591797073@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas writes: > On Fri, Jun 5, 2020 at 8:19 PM Andres Freund 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