Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
etc
config
src
THREAD_SAFE_ERRNO.cpp
Go to the documentation of this file.
1
// checking if errno is thread safe
2
3
25
#include <
errno.h
>
26
#include "
thread.h
"
27
28
29
void
*
errno_addr
= 0;
30
31
32
extern
"C"
void
*
thread_routine
(
void
*)
33
{
34
errno_addr
= &errno;
35
return
0;
36
}
37
38
39
int
main
()
40
{
41
pthread_t thread;
42
43
int
err;
44
45
// create a thread that gets the address of errno
46
if
((err = pthread_create (&thread, 0,
thread_routine
, 0))) {
47
return
3;
48
}
49
50
if
((err = pthread_join (thread, 0))) {
51
return
2;
52
}
53
54
// compare the address of the (presumably) thread-local
55
// errno variable against that of the global errno and
56
// return 0 if they are different, 1 otherwise
57
return
!(&errno !=
errno_addr
);
58
}
thread_routine
void * thread_routine(void *)
Definition
THREAD_SAFE_ERRNO.cpp:32
errno_addr
void * errno_addr
Definition
THREAD_SAFE_ERRNO.cpp:29
main
int main()
Definition
THREAD_SAFE_ERRNO.cpp:39
errno.h
thread.h
Generated by
1.9.8