Loading...
Searching...
No Matches
sphthread.h
Go to the documentation of this file.
/*
* Copyright (c) 2007-2014 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation, Steven Munroe - initial API and implementation
* sjm 2010-09-05 Added externs for proc/thread ID
* Added fast inline PID/TID get functions *
* IBM Corporation, Adhemerval Zanella - documentation
*/
#ifndef __SPHTHREAD_H
#define __SPHTHREAD_H
#include <unistd.h>
#ifdef __cplusplus
#define __C__ "C"
#else
#define __C__
#endif
extern __C__ pid_t
sphdeGetPID (void);
extern __C__ pid_t
sphdeGetTID (void);
extern __C__ char *
sphdeGetCmdLine (void);
extern pid_t procID;
static inline int
sphFastGetPID (void)
{
int pid = procID;
if (__builtin_expect ((!pid), 0))
{
pid = sphdeGetPID ();
}
return pid;
}
extern __thread pid_t threadID __attribute__ ((tls_model ("initial-exec")));
static inline int
sphFastGetTID (void)
{
int tid = threadID;
if (__builtin_expect ((!tid), 0))
{
tid = sphdeGetTID ();
}
return tid;
}
#endif
__C__
#define __C__
ignore this macro behind the curtain
Definition sasmsync.h:32
sphFastGetTID
static int sphFastGetTID(void)
Return the thread identification.
Definition sphthread.h:128
procID
pid_t procID
sphFastGetPID
static int sphFastGetPID(void)
Return the process identification.
Definition sphthread.h:104
sphdeGetTID
__C__ pid_t sphdeGetTID(void)
Return the thread identification.
sphdeGetPID
__C__ pid_t sphdeGetPID(void)
Return the process identification.
sphdeGetCmdLine
__C__ char * sphdeGetCmdLine(void)
Return the command line string.
__attribute__
__thread pid_t threadID __attribute__((tls_model("initial-exec")))