[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] minor patches + standard compliant inline functions

From: Michael Matz
Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
Date: Mon, 17 Jun 2019 16:34:42 +0000 (UTC)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)


On Mon, 17 Jun 2019, Christian Jullien wrote:

> Your patch gives many new warnings when I do a reproducible tcc build on

Aha!  That is the reason why that warning was conditional on !VT_INLINE 
(which in the abstract doesn't make sense and I removed that).  Gnah, so 
this is all a bit between a rock and a hard place.  The mingw headers do 

  PVOID GetFiberData(void);
  __CRT_INLINE PVOID GetFiberData(void) {}

The mingw headers are (and _mingw.h before the patch was) written with 
gnu-inline behaviour in mind, so __CRT_INLINE is "extern inline 
__attribute__((gnu-inline))", and that's then okay.

Now with C99 inline behaviour __CRT_INLINE has to be "static inline", but 
can't be, and there are actually no valid choices for it anymore:
* it can't be "extern inline", because that emits a global instantiation
  of all these inlines, creating multiple def errors when e.g. linking
  together two .c files that include windows.h
* it can't be "inline" (without extern or static), because in C99 inline 
  semantics there _must_ be an external definition somewhere in a program, 
  when the respective function is used (and the definition in the header 
  would not be one); that could potentially be visible when taking the 
  address of such function.  But mingw isn't written in a way to provide
  such external definition, and we can't change this with only header 
* it can't be "static inline", because that's simply not allowed given
  the above declaration (actually this shouldn't be just a warning but a 
  hard error).

So, ..., hmmm.  Gnah!  But I said that already.

I don't see another way than to add back an implementation for the 
gnu-inline behaviour and activate it via an attribute.  If noone has an 
better idea I'm going to work on that :-/

> But, more annoying it now terminates with:
> ./include/winapi/winnt.h:1141: error: 'ExChange' undeclared

Uhh, that's a nice one.  There are two decls for the function in question:

__CRT_INLINE PVOID InterlockedCompareExchangePointer(
     PVOID volatile *Destination,PVOID ExChange,PVOID Comperand) {}

(the definition) and then later from winbase.h:

PVOID _InterlockedCompareExchangePointer(
     PVOID volatile *Destination,PVOID Exchange,PVOID Comperand);

Spot the difference! ;-)  It's wrong of TCC to take the names from the 
non-definition, I've fixed this in mob.  I've also added back the hack of 
ignoring the warning when inline is given until gnu-inline is implemented 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]