Shared Persistent Heap Data Environment Manual  1.1.0
sphthread.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007-2014 IBM Corporation.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation, Steven Munroe - initial API and implementation
10  * sjm 2010-09-05 Added externs for proc/thread ID
11  * Added fast inline PID/TID get functions *
12  * IBM Corporation, Adhemerval Zanella - documentation
13  */
14 
15 #ifndef __SPHTHREAD_H
16 #define __SPHTHREAD_H
17 
18 #include <unistd.h>
19 
49 #ifdef __cplusplus
50 #define __C__ "C"
51 #else
52 #define __C__
53 #endif
54 
64 extern __C__ pid_t
65 sphdeGetPID (void);
66 
76 extern __C__ pid_t
77 sphdeGetTID (void);
78 
87 extern __C__ char *
88 sphdeGetCmdLine (void);
89 
94 extern pid_t procID;
95 
103 static inline int
105 {
106  int pid = procID;
107  if (__builtin_expect ((!pid), 0))
108  {
109  pid = sphdeGetPID ();
110  }
111  return pid;
112 }
113 
118 extern __thread pid_t threadID __attribute__ ((tls_model ("initial-exec")));
119 
127 static inline int
129 {
130  int tid = threadID;
131  if (__builtin_expect ((!tid), 0))
132  {
133  tid = sphdeGetTID ();
134  }
135  return tid;
136 }
137 
138 #endif
static int sphFastGetPID(void)
Return the process identification.
Definition: sphthread.h:104
pid_t procID
__C__ pid_t sphdeGetTID(void)
Return the thread identification.
__C__ pid_t sphdeGetPID(void)
Return the process identification.
static int sphFastGetTID(void)
Return the thread identification.
Definition: sphthread.h:128
#define __C__
ignore this macro behind the curtain
Definition: sasmsync.h:32
__C__ char * sphdeGetCmdLine(void)
Return the command line string.
__thread pid_t threadID __attribute__((tls_model("initial-exec")))