1
1
//@ignore-target-windows: No pthreads on Windows
2
- //@revisions: lock trylock unlock_register unlock_detect init
3
- //@[unlock_register]only-target-linux: recursive initializers are non-standard.
2
+ //@revisions: static_initializer init
4
3
5
4
fn main ( ) {
6
5
check ( ) ;
@@ -17,54 +16,13 @@ fn check() {
17
16
}
18
17
}
19
18
20
- #[ cfg( lock ) ]
19
+ #[ cfg( static_initializer ) ]
21
20
fn check ( ) {
22
21
unsafe {
23
22
let mut m: libc:: pthread_mutex_t = libc:: PTHREAD_MUTEX_INITIALIZER ;
24
23
libc:: pthread_mutex_lock ( & mut m as * mut _ ) ;
25
24
26
25
let mut m2 = m;
27
- libc:: pthread_mutex_lock ( & mut m2 as * mut _ ) ; //~[lock] ERROR: pthread_mutex_t can't be moved after first use
28
- }
29
- }
30
-
31
- #[ cfg( trylock) ]
32
- fn check ( ) {
33
- unsafe {
34
- let mut m: libc:: pthread_mutex_t = libc:: PTHREAD_MUTEX_INITIALIZER ;
35
- libc:: pthread_mutex_trylock ( & mut m as * mut _ ) ;
36
-
37
- let mut m2 = m;
38
- libc:: pthread_mutex_trylock ( & mut m2 as * mut _ ) ; //~[trylock] ERROR: pthread_mutex_t can't be moved after first use
39
- }
40
- }
41
-
42
- #[ cfg( unlock_register) ]
43
- fn check ( ) {
44
- unsafe {
45
- let mut m: libc:: pthread_mutex_t = libc:: PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP ;
46
- libc:: pthread_mutex_unlock ( & mut m as * mut _ ) ;
47
-
48
- let mut m2 = m;
49
- libc:: pthread_mutex_unlock ( & mut m2 as * mut _ ) ; //~[unlock_register] ERROR: pthread_mutex_t can't be moved after first use
50
- }
51
- }
52
-
53
- #[ cfg( unlock_detect) ]
54
- fn check ( ) {
55
- unsafe {
56
- let mut mutexattr: libc:: pthread_mutexattr_t = std:: mem:: zeroed ( ) ;
57
- assert_eq ! (
58
- libc:: pthread_mutexattr_settype(
59
- & mut mutexattr as * mut _,
60
- libc:: PTHREAD_MUTEX_RECURSIVE
61
- ) ,
62
- 0 ,
63
- ) ;
64
- let mut m: libc:: pthread_mutex_t = std:: mem:: zeroed ( ) ;
65
- assert_eq ! ( libc:: pthread_mutex_init( & mut m as * mut _, & mutexattr as * const _) , 0 ) ;
66
-
67
- let mut m2 = m;
68
- libc:: pthread_mutex_unlock ( & mut m2 as * mut _ ) ; //~[unlock_detect] ERROR: pthread_mutex_t can't be moved after first use
26
+ libc:: pthread_mutex_unlock ( & mut m2 as * mut _ ) ; //~[static_initializer] ERROR: pthread_mutex_t can't be moved after first use
69
27
}
70
28
}
0 commit comments