This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v4] MIPS support for GNU hash


On Wed, 28 Aug 2019, Mihailo Stojanovic wrote:

> +		  symndx = ELF_MACHINE_HASH_SYMIDX(match, hasharr);

Missing space before '('.

> +
> +      /* Initialize MIPS xhash translation table.  */
> +      ELF_MACHINE_XHASH_SETUP (hash32, symbias, map)

The normal style is that such macros are written to act syntactically like 
a single statement.  That means using a semicolon after the macro call.  
It means that the macro definition should use the do {} while (0) style 
(with appropriate GNU indentation) so that it does behave as a single 
statement in any context.

> +/* Setup MIPS_XHASH.  */
> +#define ELF_MACHINE_XHASH_SETUP(hash32, symbias, map) \
> +  (hash32) += (map)->l_info[DT_MIPS (SYMTABNO)]->d_un.d_val - (symbias); \
> +  (map)->l_mach.mips_xlat_zero = (hash32) - (symbias);

So you should have

  do
    {
      /* Statements.  */
    }
  while (0)

as the macro definition.

(I think it's best for the default definition at least to use its 
arguments, cast to (void), rather than being completely empty, to improve 
the checking done in the non-MIPS case.  You should also test the patch on 
one non-MIPS platform to verify that case is unaffected.)

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]