@@ -31,12 +31,6 @@ cfg_if! {
31
31
// not actually here, but brings in line with freebsd
32
32
pub l_sysid: libc:: c_int,
33
33
}
34
-
35
- pub const F_RDLCK : libc:: c_short = 0 ;
36
- pub const F_WRLCK : libc:: c_short = 1 ;
37
- pub const F_UNLCK : libc:: c_short = 2 ;
38
- pub const F_SETLK : libc:: c_int = 6 ;
39
- pub const F_SETLKW : libc:: c_int = 7 ;
40
34
}
41
35
42
36
#[ cfg( target_os = "freebsd" ) ]
@@ -52,12 +46,6 @@ cfg_if! {
52
46
pub l_whence: libc:: c_short,
53
47
pub l_sysid: libc:: c_int,
54
48
}
55
-
56
- pub const F_RDLCK : libc:: c_short = 1 ;
57
- pub const F_UNLCK : libc:: c_short = 2 ;
58
- pub const F_WRLCK : libc:: c_short = 3 ;
59
- pub const F_SETLK : libc:: c_int = 12 ;
60
- pub const F_SETLKW : libc:: c_int = 13 ;
61
49
}
62
50
63
51
#[ cfg( any( target_os = "dragonfly" ,
@@ -78,12 +66,6 @@ cfg_if! {
78
66
// not actually here, but brings in line with freebsd
79
67
pub l_sysid: libc:: c_int,
80
68
}
81
-
82
- pub const F_RDLCK : libc:: c_short = 1 ;
83
- pub const F_UNLCK : libc:: c_short = 2 ;
84
- pub const F_WRLCK : libc:: c_short = 3 ;
85
- pub const F_SETLK : libc:: c_int = 8 ;
86
- pub const F_SETLKW : libc:: c_int = 9 ;
87
69
}
88
70
89
71
#[ cfg( target_os = "haiku" ) ]
@@ -101,12 +83,6 @@ cfg_if! {
101
83
// not actually here, but brings in line with freebsd
102
84
pub l_sysid: libc:: c_int,
103
85
}
104
-
105
- pub const F_RDLCK : libc:: c_short = 0x0040 ;
106
- pub const F_UNLCK : libc:: c_short = 0x0200 ;
107
- pub const F_WRLCK : libc:: c_short = 0x0400 ;
108
- pub const F_SETLK : libc:: c_int = 0x0080 ;
109
- pub const F_SETLKW : libc:: c_int = 0x0100 ;
110
86
}
111
87
112
88
#[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
@@ -124,12 +100,6 @@ cfg_if! {
124
100
// not actually here, but brings in line with freebsd
125
101
pub l_sysid: libc:: c_int,
126
102
}
127
-
128
- pub const F_RDLCK : libc:: c_short = 1 ;
129
- pub const F_UNLCK : libc:: c_short = 2 ;
130
- pub const F_WRLCK : libc:: c_short = 3 ;
131
- pub const F_SETLK : libc:: c_int = 8 ;
132
- pub const F_SETLKW : libc:: c_int = 9 ;
133
103
}
134
104
135
105
#[ cfg( target_os = "solaris" ) ]
@@ -145,12 +115,6 @@ cfg_if! {
145
115
pub l_sysid: libc:: c_int,
146
116
pub l_pid: libc:: pid_t,
147
117
}
148
-
149
- pub const F_RDLCK : libc:: c_short = 1 ;
150
- pub const F_WRLCK : libc:: c_short = 2 ;
151
- pub const F_UNLCK : libc:: c_short = 3 ;
152
- pub const F_SETLK : libc:: c_int = 6 ;
153
- pub const F_SETLKW : libc:: c_int = 7 ;
154
118
}
155
119
156
120
#[ derive( Debug ) ]
@@ -182,9 +146,9 @@ cfg_if! {
182
146
}
183
147
184
148
let lock_type = if exclusive {
185
- os :: F_WRLCK
149
+ libc :: F_WRLCK as libc :: c_short
186
150
} else {
187
- os :: F_RDLCK
151
+ libc :: F_RDLCK as libc :: c_short
188
152
} ;
189
153
190
154
let flock = os:: flock {
@@ -195,7 +159,7 @@ cfg_if! {
195
159
l_type: lock_type,
196
160
l_sysid: 0 ,
197
161
} ;
198
- let cmd = if wait { os :: F_SETLKW } else { os :: F_SETLK } ;
162
+ let cmd = if wait { libc :: F_SETLKW } else { libc :: F_SETLK } ;
199
163
let ret = unsafe {
200
164
libc:: fcntl( fd, cmd, & flock)
201
165
} ;
@@ -216,11 +180,11 @@ cfg_if! {
216
180
l_len: 0 ,
217
181
l_pid: 0 ,
218
182
l_whence: libc:: SEEK_SET as libc:: c_short,
219
- l_type: os :: F_UNLCK ,
183
+ l_type: libc :: F_UNLCK as libc :: c_short ,
220
184
l_sysid: 0 ,
221
185
} ;
222
186
unsafe {
223
- libc:: fcntl( self . fd, os :: F_SETLK , & flock) ;
187
+ libc:: fcntl( self . fd, libc :: F_SETLK , & flock) ;
224
188
libc:: close( self . fd) ;
225
189
}
226
190
}
0 commit comments