File: Pthread.h

package info (click to toggle)
i2util 1.6-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 748 kB
  • ctags: 473
  • sloc: ansic: 5,290; perl: 1,151; makefile: 74; sh: 17
file content (142 lines) | stat: -rw-r--r-- 3,258 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
 *      $Id$
 */
/************************************************************************
*									*
*			     Copyright (C)  2002			*
*				Internet2				*
*			     All Rights Reserved			*
*									*
************************************************************************/
/*
 *	File:		Pthread.h
 *
 *	Author:		Jeff Boote
 *			Internet2
 *
 *	Date:		Tue Apr 23 10:17:50  2002
 *
 *	Description:	
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
#ifndef	_I2Pthread_H_
#define	_I2Pthread_H_
#include <I2util/util.h>

BEGIN_C_DECLS

#ifndef	I2THREADS_ENABLE

typedef	int	I2Thread_T;
typedef	int	I2ThreadAttr_T;
typedef	int	I2ThreadMutex_T;
typedef	int	I2ThreadMutexattr_T;
typedef	int	I2ThreadCond_T;
typedef	int	I2ThreadCondattr_T;

#define	I2PTHREAD_MUTEX_INITIALIZER	0

#define I2ThreadCreate(thread,attr,start,arg,msg)	(void)0
#define	I2ThreadJoin(thread,retval,msg)			(void)0
#define	I2ThreadSelf()					(void)0
#define	I2ThreadMutexInit(mutex,attr)			(void)0
#define	I2ThreadMutexLock(mutex)			((void)(0 != *(mutex)))
#define	I2ThreadMutexUnlock(mutex)			(void)0
#define	I2ThreadAttrInit(attr)				(void)0
#define	I2ThreadAttrSetDetatchState(attr,detach)	(void)0
#define	I2ThreadCondDestroy(cond)			(void)0
#define	I2ThreadMutexDestroy(mutex)			(void)0
#define I2ThreadCondInit(cond,attr)			(void)0
#define	I2ThreadCondSignal(cond)			(void)0
#define	I2ThreadCondWait(cond,mutex)			(void)0

#else	/*	THREADS_ENABLE	*/

#include <pthread.h>

typedef	pthread_t		I2Thread_T;
typedef	pthread_attr_t		I2ThreadAttr_T;
typedef	pthread_mutex_t		I2ThreadMutex_T;
typedef	pthread_mutexattr_t	I2ThreadMutexattr_T;
typedef	pthread_cond_t		I2ThreadCond_T;
typedef	pthread_condattr_t	I2ThreadCondattr_T;

#define	I2PTHREAD_MUTEX_INITIALIZER	PTHREAD_MUTEX_INITIALIZER

extern	int I2ThreadCreate(
	I2Thread_T *thread,
	I2ThreadAttr_T *attr,
        void *(*start)(void *),
	void *arg,
	const char *msg
);

extern int I2ThreadJoin(
	I2Thread_T	thread,
	void		**retval,
	const char	*msg
);

extern I2Thread_T I2ThreadSelf();

extern int	I2ThreadMutexInit(
	I2ThreadMutex_T	*mutex,
	I2ThreadMutexattr_T	*attr
);

extern int	I2ThreadMutexLock(
	I2ThreadMutex_T		*mutex
);

extern int	I2ThreadMutexUnlock(
	I2ThreadMutex_T		*mutex
);

extern int	I2ThreadAttrInit(I2ThreadAttr_T	*attr);

extern int	I2ThreadAttrSetDetatchState(
	I2ThreadAttr_T *attr,
	int		detach
);


extern int	I2ThreadCondDestroy(
	I2ThreadCond_T	*cond
);

extern int	I2ThreadMutexDestroy(
	I2ThreadMutex_T	*mutex
);

extern int	I2ThreadCondInit(
	I2ThreadCond_T		*cond,
	I2ThreadCondattr_T	*attr
);
	

extern int	I2ThreadCondSignal(
	I2ThreadCond_T	*cond
);

extern int	I2ThreadCondWait(
	I2ThreadCond_T	*cond,
	I2ThreadMutex_T	*mutex
);

#endif	/* I2THREADS_ENABLE	*/

END_C_DECLS

#endif