1- //! Definitions for l4re- uclibc on 64bit systems
2-
1+ //! Definitions for uclibc on 64bit systems
2+ //!
33pub type blkcnt_t = i64 ;
44pub type blksize_t = i64 ;
55pub type clock_t = i64 ;
@@ -14,15 +14,31 @@ pub type nlink_t = ::c_uint;
1414pub type off_t = :: c_long ;
1515pub type rlim_t = c_ulong ;
1616pub type rlim64_t = u64 ;
17+ // [uClibc docs] Note stat64 has the same shape as stat for x86-64.
18+ pub type stat64 = stat ;
1719pub type suseconds_t = :: c_long ;
1820pub type time_t = :: c_int ;
1921pub type wchar_t = :: c_int ;
2022
21- // ToDo, used?
22- //pub type d_ino = ::c_ulong;
2323pub type nfds_t = :: c_ulong ;
2424
2525s ! {
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+
2642 pub struct ipc_perm {
2743 pub __key: :: key_t,
2844 pub uid: :: uid_t,
3753 __unused2: :: c_ulong
3854 }
3955
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+
4073 pub struct siginfo_t {
4174 si_signo: :: c_int, // signal number
4275 si_errno: :: c_int, // if not zero: error value of signal, see errno.h
@@ -103,77 +136,33 @@ s! {
103136// __align: [u32; 0],
104137// }
105138
106- pub struct stat { // ToDo
139+ pub struct stat {
107140 pub st_dev: :: c_ulong,
108- st_pad1: [ :: c_long; 2 ] ,
109141 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.
111144 pub st_nlink: :: nlink_t,
145+ pub st_mode: :: mode_t,
112146 pub st_uid: :: uid_t,
113147 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 ,
118152 pub st_atime: :: time_t,
119- pub st_atime_nsec: :: c_long ,
153+ pub st_atime_nsec: :: c_ulong ,
120154 pub st_mtime: :: time_t,
121- pub st_mtime_nsec: :: c_long ,
155+ pub st_mtime_nsec: :: c_ulong ,
122156 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 ]
128159 }
129160
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,
172165 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,
177166 }
178167
179168 pub struct stack_t { // ToDo
@@ -298,27 +287,6 @@ s! {
298287 __unused5: * mut :: c_void,
299288 }
300289
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-
322290 pub struct rlimit64 { // ToDo
323291 pub rlim_cur: rlim64_t,
324292 pub rlim_max: rlim64_t,
@@ -331,20 +299,32 @@ s! {
331299 bits: [ u64 ; 16 ] ,
332300 }
333301
334- pub struct timespec { // ToDo
335- tv_sec: time_t, // seconds
336- tv_nsec: :: c_ulong, // nanoseconds
337- }
338-
339302 pub struct fsid_t { // ToDo
340303 __val: [ :: c_int; 2 ] ,
341304 }
342305}
343306
344307// 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 ;
345319pub const O_CLOEXEC : :: c_int = 0x80000 ;
320+ pub const O_CREAT : :: c_int = 0100 ;
346321pub 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 ;
347325pub 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 ;
348328pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40 ;
349329pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4 ;
350330pub const PTHREAD_MUTEX_NORMAL : :: c_int = 0 ;
@@ -359,3 +339,11 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
359339extern {
360340 pub fn memalign ( align : :: size_t , size : :: size_t ) -> * mut :: c_void ;
361341}
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