Skip to content

Commit

Permalink
winnt.h: FORCELINLINE inline-only definitions
Browse files Browse the repository at this point in the history
The following test application fails to build on i686 when building
without optimization:

  $ cat foo.c
  #include <windows.h>

  int
  main ()
  {
    MEMORY_BASIC_INFORMATION m;
    NT_TIB *tib = (NT_TIB *) NtCurrentTeb ();
    VirtualQuery (tib, &m, sizeof m);
  }
  $ gcc -g -O foo.c -o foo
  $ gcc -g foo.c -o foo
  /tmp/ccnnAEl3.o: In function `main':
  /home/corinna/foo.c:7: undefined reference to `NtCurrentTeb'
  collect2: error: ld returned 1 exit status

There's no way around that, except for building with optimization, which
is often not prudent when debugging.

In winnt.h, NtCurrentTeb is using __CRT_INLINE which, depending on C
standard, expandes into

  extern inline __attribute__((__gnu_inline__))

or

  extern __inline__

However, that's not sufficient for NtCurrentTeb, nor for GetCurrentFiber,
nor for GetFiberData, since these are inline-only functions not backed by
non-inlined library versions.

This patch fixes that by using FORCEINLINE in place of __CRT_INLINE.

Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
  • Loading branch information
github-cygwin committed Aug 30, 2015
1 parent 67bb96f commit 8da1aae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mingw-w64-headers/include/winnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1995,15 +1995,15 @@ __buildmemorybarrier()

#define DbgRaiseAssertionFailure __int2c

__CRT_INLINE struct _TEB *NtCurrentTeb(void)
FORCEINLINE struct _TEB *NtCurrentTeb(void)
{
return (struct _TEB *)__readfsdword(PcTeb);
}
__CRT_INLINE PVOID GetCurrentFiber(void)
FORCEINLINE PVOID GetCurrentFiber(void)
{
return(PVOID)__readfsdword(0x10);
}
__CRT_INLINE PVOID GetFiberData(void)
FORCEINLINE PVOID GetFiberData(void)
{
return *(PVOID *)GetCurrentFiber();
}
Expand Down

0 comments on commit 8da1aae

Please sign in to comment.