| От | Tom Lane |
|---|---|
| Тема | Re: Atomic operations within spinlocks |
| Дата | |
| Msg-id | 2297028.1591797073@sss.pgh.pa.us обсуждение |
| Ответ на | Re: Atomic operations within spinlocks (Robert Haas <robertmhaas@gmail.com>) |
| Список | pgsql-hackers |
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
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера