1
- //! Definitions for l4re- uclibc on 64bit systems
2
-
1
+ //! Definitions for uclibc on 64bit systems
2
+ //!
3
3
pub type blkcnt_t = i64 ;
4
4
pub type blksize_t = i64 ;
5
5
pub type clock_t = i64 ;
@@ -14,15 +14,31 @@ pub type nlink_t = ::c_uint;
14
14
pub type off_t = :: c_long ;
15
15
pub type rlim_t = c_ulong ;
16
16
pub type rlim64_t = u64 ;
17
+ // [uClibc docs] Note stat64 has the same shape as stat for x86-64.
18
+ pub type stat64 = stat ;
17
19
pub type suseconds_t = :: c_long ;
18
20
pub type time_t = :: c_int ;
19
21
pub type wchar_t = :: c_int ;
20
22
21
- // ToDo, used?
22
- //pub type d_ino = ::c_ulong;
23
23
pub type nfds_t = :: c_ulong ;
24
24
25
25
s ! {
26
+ pub struct dirent {
27
+ pub d_ino: :: ino64_t,
28
+ pub d_off: :: off64_t,
29
+ pub d_reclen: u16 ,
30
+ pub d_type: u8 ,
31
+ pub d_name: [ :: c_char; 256 ] ,
32
+ }
33
+
34
+ pub struct dirent64 {
35
+ pub d_ino: :: ino64_t,
36
+ pub d_off: :: off64_t,
37
+ pub d_reclen: u16 ,
38
+ pub d_type: u8 ,
39
+ pub d_name: [ :: c_char; 256 ] ,
40
+ }
41
+
26
42
pub struct ipc_perm {
27
43
pub __key: :: key_t,
28
44
pub uid: :: uid_t,
37
53
__unused2: :: c_ulong
38
54
}
39
55
56
+ #[ cfg( not( target_os = "l4re" ) ) ]
57
+ pub struct pthread_attr_t {
58
+ __detachstate: :: c_int,
59
+ __schedpolicy: :: c_int,
60
+ __schedparam: __sched_param,
61
+ __inheritsched: :: c_int,
62
+ __scope: :: c_int,
63
+ __guardsize: :: size_t,
64
+ __stackaddr_set: :: c_int,
65
+ __stackaddr: * mut :: c_void, // better don't use it
66
+ __stacksize: :: size_t,
67
+ }
68
+
69
+ pub struct __sched_param {
70
+ __sched_priority: :: c_int,
71
+ }
72
+
40
73
pub struct siginfo_t {
41
74
si_signo: :: c_int, // signal number
42
75
si_errno: :: c_int, // if not zero: error value of signal, see errno.h
@@ -103,77 +136,33 @@ s! {
103
136
// __align: [u32; 0],
104
137
// }
105
138
106
- pub struct stat { // ToDo
139
+ pub struct stat {
107
140
pub st_dev: :: c_ulong,
108
- st_pad1: [ :: c_long; 2 ] ,
109
141
pub st_ino: :: ino_t,
110
- pub st_mode: :: mode_t,
142
+ // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of
143
+ // nlink and mode are swapped on 64 bit systems.
111
144
pub st_nlink: :: nlink_t,
145
+ pub st_mode: :: mode_t,
112
146
pub st_uid: :: uid_t,
113
147
pub st_gid: :: gid_t,
114
- pub st_rdev: u64 ,
115
- pub st_pad2 : [ u64 ; 1 ] ,
116
- pub st_size : off_t ,
117
- st_pad3 : :: c_long ,
148
+ pub st_rdev: :: c_ulong , // dev_t
149
+ pub st_size : off_t , // file size
150
+ pub st_blksize : :: blksize_t ,
151
+ pub st_blocks : :: blkcnt_t ,
118
152
pub st_atime: :: time_t,
119
- pub st_atime_nsec: :: c_long ,
153
+ pub st_atime_nsec: :: c_ulong ,
120
154
pub st_mtime: :: time_t,
121
- pub st_mtime_nsec: :: c_long ,
155
+ pub st_mtime_nsec: :: c_ulong ,
122
156
pub st_ctime: :: time_t,
123
- pub st_ctime_nsec: :: c_long,
124
- pub st_blksize: :: blksize_t,
125
- st_pad4: :: c_long,
126
- pub st_blocks: :: blkcnt_t,
127
- st_pad5: [ :: c_long; 7 ] ,
157
+ pub st_ctime_nsec: :: c_ulong,
158
+ st_pad4: [ :: c_long; 3 ]
128
159
}
129
160
130
- pub struct statvfs { // ToDo: broken
131
- pub f_bsize: :: c_ulong,
132
- pub f_frsize: :: c_ulong,
133
- pub f_blocks: :: fsblkcnt_t,
134
- pub f_bfree: :: fsblkcnt_t,
135
- pub f_bavail: :: fsblkcnt_t,
136
- pub f_files: :: fsfilcnt_t,
137
- pub f_ffree: :: fsfilcnt_t,
138
- pub f_favail: :: fsfilcnt_t,
139
- #[ cfg( target_endian = "little" ) ]
140
- pub f_fsid: :: c_ulong,
141
- #[ cfg( target_pointer_width = "32" ) ]
142
- __f_unused: :: c_int,
143
- #[ cfg( target_endian = "big" ) ]
144
- pub f_fsid: :: c_ulong,
145
- pub f_flag: :: c_ulong,
146
- pub f_namemax: :: c_ulong,
147
- __f_spare: [ :: c_int; 6 ] ,
148
- }
149
-
150
- pub struct dirent { // Todo
151
- pub d_ino: :: ino64_t,
152
- pub d_off: :: off64_t,
153
- d_reclen: u16 ,
154
- pub d_type: u8 ,
155
- pub d_name: [ i8 ; 256 ] ,
156
- }
157
-
158
- pub struct dirent64 { //
159
- pub d_ino: :: ino64_t,
160
- pub d_off: :: off64_t,
161
- pub d_reclen: u16 ,
162
- pub d_type: u8 ,
163
- pub d_name: [ i8 ; 256 ] ,
164
- }
165
-
166
- pub struct pthread_attr_t { // ToDo
167
- __size: [ u64 ; 7 ]
168
- }
169
-
170
- pub struct sigaction { // TODO!!
171
- pub sa_sigaction: :: sighandler_t,
161
+ pub struct sigaction {
162
+ pub sa_handler: :: sighandler_t,
163
+ pub sa_flags: :: c_ulong,
164
+ pub sa_restorer: * mut :: c_void,
172
165
pub sa_mask: :: sigset_t,
173
- #[ cfg( target_arch = "sparc64" ) ]
174
- __reserved0: :: c_int,
175
- pub sa_flags: :: c_int,
176
- _restorer: * mut :: c_void,
177
166
}
178
167
179
168
pub struct stack_t { // ToDo
@@ -298,27 +287,6 @@ s! {
298
287
__unused5: * mut :: c_void,
299
288
}
300
289
301
- pub struct stat64 { // ToDo
302
- pub st_dev: :: dev_t,
303
- pub st_ino: :: ino64_t,
304
- pub st_nlink: :: nlink_t,
305
- pub st_mode: :: mode_t,
306
- pub st_uid: :: uid_t,
307
- pub st_gid: :: gid_t,
308
- __pad0: :: c_int,
309
- pub st_rdev: :: dev_t,
310
- pub st_size: :: off_t,
311
- pub st_blksize: :: blksize_t,
312
- pub st_blocks: :: blkcnt64_t,
313
- pub st_atime: :: time_t,
314
- pub st_atime_nsec: :: c_long,
315
- pub st_mtime: :: time_t,
316
- pub st_mtime_nsec: :: c_long,
317
- pub st_ctime: :: time_t,
318
- pub st_ctime_nsec: :: c_long,
319
- __reserved: [ :: c_long; 3 ] ,
320
- }
321
-
322
290
pub struct rlimit64 { // ToDo
323
291
pub rlim_cur: rlim64_t,
324
292
pub rlim_max: rlim64_t,
@@ -331,20 +299,32 @@ s! {
331
299
bits: [ u64 ; 16 ] ,
332
300
}
333
301
334
- pub struct timespec { // ToDo
335
- tv_sec: time_t, // seconds
336
- tv_nsec: :: c_ulong, // nanoseconds
337
- }
338
-
339
302
pub struct fsid_t { // ToDo
340
303
__val: [ :: c_int; 2 ] ,
341
304
}
342
305
}
343
306
344
307
// constants
308
+ pub const EADDRINUSE : :: c_int = 98 ; // Address already in use
309
+ pub const EADDRNOTAVAIL : :: c_int = 99 ; // Cannot assign requested address
310
+ pub const ECONNABORTED : :: c_int = 103 ; // Software caused connection abort
311
+ pub const ECONNREFUSED : :: c_int = 111 ; // Connection refused
312
+ pub const ECONNRESET : :: c_int = 104 ; // Connection reset by peer
313
+ pub const EDEADLK : :: c_int = 35 ; // Resource deadlock would occur
314
+ pub const ENOSYS : :: c_int = 38 ; // Function not implemented
315
+ pub const ENOTCONN : :: c_int = 107 ; // Transport endpoint is not connected
316
+ pub const ETIMEDOUT : :: c_int = 110 ; // connection timed out
317
+ pub const O_APPEND : :: c_int = 02000 ;
318
+ pub const O_ACCMODE : :: c_int = 0003 ;
345
319
pub const O_CLOEXEC : :: c_int = 0x80000 ;
320
+ pub const O_CREAT : :: c_int = 0100 ;
346
321
pub const O_DIRECTORY : :: c_int = 0200000 ;
322
+ pub const O_EXCL : :: c_int = 0200 ;
323
+ pub const O_NONBLOCK : :: c_int = 04000 ;
324
+ pub const O_TRUNC : :: c_int = 01000 ;
347
325
pub const NCCS : usize = 32 ;
326
+ pub const SIG_SETMASK : :: c_int = 2 ; // Set the set of blocked signals
327
+ pub const PTHREAD_STACK_MIN : usize = 16384 ;
348
328
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40 ;
349
329
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4 ;
350
330
pub const PTHREAD_MUTEX_NORMAL : :: c_int = 0 ;
@@ -359,3 +339,11 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
359
339
extern {
360
340
pub fn memalign ( align : :: size_t , size : :: size_t ) -> * mut :: c_void ;
361
341
}
342
+
343
+ cfg_if ! {
344
+ if #[ cfg( target_os = "l4re" ) ] {
345
+ mod l4re;
346
+ pub use self :: l4re:: * ;
347
+ } else { }
348
+ }
349
+
0 commit comments