[CentOS] Problem with gettid() on CentOS 5/gcc 4.1.1

Mon Apr 2 15:58:28 UTC 2007
Alfred von Campe <alfred at 110.net>

I can't get the simple program below to compile on CentOS 5 beta.  It compiles
(and runs) just fine on CentOS 4.4, and I'm using gettid() as described in the
man page.  I wonder if this is a problem with RHEL 5 as well, but I don't have a
system to test on.  I also wonder if this is a gcc 4.1.1 issue or something
missing in CentOS 5.

The issue is that the _syscall0 macro is not defined anywhere.  If I copy and
paste the following definition for _syscall0 from a CentOS 4.4 system into the
test program, it works just fine:

  #define _syscall0(type,name) \
  type name(void) \
  {\
      return syscall(__NR_##name);\
  }

Has anyone else run into this problem?

Alfred


#include <stdio.h>
#include <sys/types.h>
#include <linux/unistd.h>
#include <errno.h>

_syscall0(pid_t, gettid)

int main(int argc, char *argv[])
{
    printf("My tid is 0x%08x\n", gettid());
}