Shared Persistent Heap Data Environment Manual 1.4.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
64extern __C__ pid_t
66
76extern __C__ pid_t
78
87extern __C__ char *
89
94extern pid_t procID;
95
103static inline int
105{
106 int pid = procID;
107 if (__builtin_expect ((!pid), 0))
108 {
109 pid = sphdeGetPID ();
110 }
111 return pid;
112}
113
118extern __thread pid_t threadID __attribute__ ((tls_model ("initial-exec")));
119
127static 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
#define __C__
ignore this macro behind the curtain
Definition: sasmsync.h:32
static int sphFastGetTID(void)
Return the thread identification.
Definition: sphthread.h:128
pid_t procID
static int sphFastGetPID(void)
Return the process identification.
Definition: sphthread.h:104
__C__ pid_t sphdeGetTID(void)
Return the thread identification.
__C__ pid_t sphdeGetPID(void)
Return the process identification.
__C__ char * sphdeGetCmdLine(void)
Return the command line string.
__thread pid_t threadID __attribute__((tls_model("initial-exec")))