Re: GetRelationPath() vs critical sections
| От | Thomas Munro |
|---|---|
| Тема | Re: GetRelationPath() vs critical sections |
| Дата | |
| Msg-id | CA+hUKGJUB9M9XS+TMzB5oaFpCC+E0m1v8Gf5BN+M7k5E8zZ0PQ@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: GetRelationPath() vs critical sections (Thomas Munro <thomas.munro@gmail.com>) |
| Список | pgsql-hackers |
On Fri, Feb 21, 2025 at 6:20 PM Thomas Munro <thomas.munro@gmail.com> wrote:
> #define PROCNUMBER_BITS 18
> #define MAX_BACKENDS ((1 << PROCNUMBER_BITS) - 1)
> #define PROCNUMBER_CHARS DECIMAL_DIGITS_FOR_BITS(PROCNUMBER_BITS)
>
> ... with a little helper ported to preprocessor hell from Hacker's
> Delight magic[1] for that last bit. See attached. But if that's a
> bit too nuts...
Erm, wait of course you just need:
#define DECIMAL_DIGITS(n) \
((n) < 10 ? 1 : \
(n) < 100 ? 2 : \
(n) < 1000 ? 3 : \
(n) < 10000 ? 4 : \
(n) < 100000 ? 5 : \
(n) < 1000000 ? 6 : \
(n) < 10000000 ? 7 : \
(n) < 100000000 ? 8 : \
(n) < 1000000000 ? 9 : 10)
#define PROCNUMBER_BITS 18
#define MAX_BACKENDS ((1 << PROCNUMBER_BITS) - 1)
#define PROCNUMBER_CHARS DECIMAL_DIGITS(MAX_BACKENDS)
В списке pgsql-hackers по дате отправления: