Re: Centralised architecture detection

From: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Lukas Fittl <lukas(at)fittl(dot)com>, John Naylor <johncnaylorls(at)gmail(dot)com>, Bryan Green <dbryan(dot)green(at)gmail(dot)com>
Subject: Re: Centralised architecture detection
Date: 2026-04-09 10:29:22
Message-ID: 87pl482zr1.fsf@wibble.ilmari.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:

> Instead of repeating compilers' architecture macros throughout the tree
> and sometimes getting it wrong, let's detect them in one central place,
> and define our own macros of the form:
>
> PG_ARCH_{ARM,LOONGARCH,MIPS,PPC,RISCV,S390,SPARC,X86}
> PG_ARCH_{ARM,LOONGARCH,MIPS,PPC,RISCV,S390,SPARC,X86}_{32,64}
[...]
> diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c
> index 5a1b1e10091..9c4e02e428b 100644
> --- a/contrib/pgcrypto/crypt-blowfish.c
> +++ b/contrib/pgcrypto/crypt-blowfish.c
> @@ -38,10 +38,10 @@
> #include "px-crypt.h"
> #include "px.h"
>
> -#ifdef __i386__
> +#if defined(PG_ARCH_X86_32)
> #define BF_ASM 0 /* 1 */
> #define BF_SCALE 1
> -#elif defined(__x86_64__)
> +#elif defined(PG_ARCH_X86_64)
> #define BF_ASM 0
> #define BF_SCALE 1
> #else

These could be combined into a single #ifdef PG_ARCH_X86. Also, BF_ASM
has never been defined to anything but 0 since this file was added in
2001, and the _BF_body_r function it would call in that case has never
existed, so we could get rid of it (but that would be for a separate
patch).

- ilmari

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-04-09 10:42:52 Re: [[deprecated("don't call this, call that")]]
Previous Message Chao Li 2026-04-09 10:25:21 Re: Eliminating SPI / SQL from some RI triggers - take 3