Back to index

glibc  2.9
Functions
getpid.c File Reference
#include <unistd.h>
#include <tls.h>
#include <sysdep.h>

Go to the source code of this file.

Functions

static __attribute__ ((always_inline))
pid_t __getpid (void)

Function Documentation

static __attribute__ ( (always_inline)  ) [inline, static]

Definition at line 26 of file getpid.c.

{
  if (__builtin_expect (oldval == 0, 1))
    {
      pid_t selftid = THREAD_GETMEM (THREAD_SELF, tid);
      if (__builtin_expect (selftid != 0, 1))
       return selftid;
    }

  INTERNAL_SYSCALL_DECL (err);
  pid_t result = INTERNAL_SYSCALL (getpid, err, 0);

  /* We do not set the PID field in the TID here since we might be
     called from a signal handler while the thread executes fork.  */
  if (oldval == 0)
    THREAD_SETMEM (THREAD_SELF, tid, result);
  return result;
}

Here is the call graph for this function:

pid_t __getpid ( void  )

Definition at line 50 of file getpid.c.

{
#ifdef NOT_IN_libc
  INTERNAL_SYSCALL_DECL (err);
  pid_t result = INTERNAL_SYSCALL (getpid, err, 0);
#else
  pid_t result = THREAD_GETMEM (THREAD_SELF, pid);
  if (__builtin_expect (result <= 0, 0))
    result = really_getpid (result);
#endif
  return result;
}

Here is the call graph for this function: