summaryrefslogtreecommitdiff
path: root/src/unix/aix/powerpc64.rs
blob: 1f96ae37ad8506f22dd1b8d4f94a249070b18921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
pub type c_long = i64;
pub type c_ulong = u64;

s! {
    pub struct sigset_t {
        pub ss_set: [c_ulong; 4],
    }

    pub struct fd_set {
        pub fds_bits: [c_long; 1024],
    }

    pub struct flock {
        pub l_type: ::c_short,
        pub l_whence: ::c_short,
        pub l_sysid: ::c_uint,
        pub l_pid: ::pid_t,
        pub l_vfs: ::c_int,
        pub l_start: ::off_t,
        pub l_len: ::off_t,
    }

    pub struct statvfs {
        pub f_bsize: ::c_ulong,
        pub f_frsize: ::c_ulong,
        pub f_blocks: ::fsblkcnt_t,
        pub f_bfree: ::fsblkcnt_t,
        pub f_bavail: ::fsblkcnt_t,
        pub f_files: ::fsfilcnt_t,
        pub f_ffree: ::fsfilcnt_t,
        pub f_favail: ::fsfilcnt_t,
        pub f_fsid: ::c_ulong,
        pub f_basetype: [::c_char; 16],
        pub f_flag: ::c_ulong,
        pub f_namemax: ::c_ulong,
        pub f_fstr: [::c_char; 32],
        pub f_filler: [::c_ulong; 16]
    }

    pub struct pthread_rwlock_t {
        __rw_word: [::c_long; 10],
    }

    pub struct pthread_cond_t {
        __cv_word: [::c_long; 6],
    }

    pub struct pthread_mutex_t {
        __mt_word: [::c_long; 8],
    }

    pub struct stat {
        pub st_dev: ::dev_t,
        pub st_ino: ::ino_t,
        pub st_mode: ::mode_t,
        pub st_nlink: ::nlink_t,
        pub st_flag: ::c_ushort,
        pub st_uid: ::uid_t,
        pub st_gid: ::gid_t,
        pub st_rdev: ::dev_t,
        pub st_ssize: ::c_int,
        pub st_atime: ::st_timespec,
        pub st_mtime: ::st_timespec,
        pub st_ctime: ::st_timespec,
        pub st_blksize: ::blksize_t,
        pub st_blocks: ::blkcnt_t,
        pub st_vfstype: ::c_int,
        pub st_vfs: ::c_uint,
        pub st_type: ::c_uint,
        pub st_gen: ::c_uint,
        pub st_reserved: [::c_uint; 9],
        pub st_padto_ll: ::c_uint,
        pub st_size: ::off_t,
    }

    pub struct statfs {
        pub f_version: ::c_int,
        pub f_type: ::c_int,
        pub f_bsize: ::c_ulong,
        pub f_blocks: ::fsblkcnt_t,
        pub f_bfree: ::fsblkcnt_t,
        pub f_bavail: ::fsblkcnt_t,
        pub f_files: ::fsblkcnt_t,
        pub f_ffree: ::fsblkcnt_t,
        pub f_fsid: ::fsid64_t,
        pub f_vfstype: ::c_int,
        pub f_fsize: ::c_ulong,
        pub f_vfsnumber: ::c_int,
        pub f_vfsoff: ::c_int,
        pub f_vfslen: ::c_int,
        pub f_vfsvers: ::c_int,
        pub f_fname: [::c_char; 32],
        pub f_fpack: [::c_char; 32],
        pub f_name_max: ::c_int,
    }
}

s_no_extra_traits! {
    #[cfg(libc_union)]
    pub union sigval {
        pub sival_ptr: *mut ::c_void,
        pub sival_int: ::c_int,
    }

    pub struct siginfo_t {
        pub si_signo: ::c_int,
        pub si_errno: ::c_int,
        pub si_code: ::c_int,
        pub si_pid: ::pid_t,
        pub si_uid: ::uid_t,
        pub si_status: ::c_int,
        pub si_addr: *mut ::c_void,
        pub si_band: ::c_long,
        #[cfg(libc_union)]
        pub si_value: sigval,
        pub __si_flags: ::c_int,
        pub __pad: [::c_int; 3],
    }

    #[cfg(libc_union)]
    pub union _kernel_simple_lock {
        pub _slock: ::c_long,
        // Should be pointer to 'lock_data_instrumented'
        pub _slockp: *mut ::c_void,
    }

    pub struct fileops_t {
        pub fo_rw: extern fn(file: *mut file, rw: ::uio_rw, io: *mut ::c_void, ext: ::c_long,
                             secattr: *mut ::c_void) -> ::c_int,
        pub fo_ioctl: extern fn(file: *mut file, a: ::c_long, b: ::caddr_t, c: ::c_long,
                                d: ::c_long) -> ::c_int,
        pub fo_select: extern fn(file: *mut file, a: ::c_int, b: *mut ::c_ushort,
                                 c: extern fn()) -> ::c_int,
        pub fo_close: extern fn(file: *mut file) -> ::c_int,
        pub fo_fstat: extern fn(file: *mut file, sstat: *mut ::stat) -> ::c_int,
    }

    pub struct file {
        pub f_flag: ::c_long,
        pub f_count: ::c_int,
        pub f_options: ::c_short,
        pub f_type: ::c_short,
        // Should be pointer to 'vnode'
        pub f_data: *mut ::c_void,
        pub f_offset: ::c_longlong,
        pub f_dir_off: ::c_long,
        // Should be pointer to 'cred'
        pub f_cred: *mut ::c_void,
        #[cfg(libc_union)]
        pub f_lock: _kernel_simple_lock,
        #[cfg(libc_union)]
        pub f_offset_lock: _kernel_simple_lock,
        pub f_vinfo: ::caddr_t,
        pub f_ops: *mut fileops_t,
        pub f_parentp: ::caddr_t,
        pub f_fnamep: ::caddr_t,
        pub f_fdata: [::c_char; 160],
    }

    #[cfg(libc_union)]
    pub union __ld_info_file {
        pub _ldinfo_fd: ::c_int,
        pub _ldinfo_fp: *mut file,
        pub _core_offset: ::c_long,
    }

    pub struct ld_info {
        pub ldinfo_next: ::c_uint,
        pub ldinfo_flags: ::c_uint,
        #[cfg(libc_union)]
        pub _file: __ld_info_file,
        pub ldinfo_textorg: *mut ::c_void,
        pub ldinfo_textsize: ::c_ulong,
        pub ldinfo_dataorg: *mut ::c_void,
        pub ldinfo_datasize: ::c_ulong,
        pub ldinfo_filename: [::c_char; 2],
    }

    #[cfg(libc_union)]
    pub union __pollfd_ext_u {
        pub addr: *mut ::c_void,
        pub data32: u32,
        pub data: u64,
    }

    pub struct pollfd_ext {
        pub fd: ::c_int,
        pub events: ::c_ushort,
        pub revents: ::c_ushort,
        #[cfg(libc_union)]
        pub data: __pollfd_ext_u,
    }
}

cfg_if! {
    if #[cfg(feature = "extra_traits")] {
        #[cfg(libc_union)]
        impl PartialEq for sigval {
            fn eq(&self, other: &sigval) -> bool {
                unsafe {
                    self.sival_ptr == other.sival_ptr
                        && self.sival_int == other.sival_int
                }
            }
        }
        #[cfg(libc_union)]
        impl Eq for sigval {}
        #[cfg(libc_union)]
        impl ::fmt::Debug for sigval {
            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
                f.debug_struct("sigval")
                    .field("sival_ptr", unsafe { &self.sival_ptr })
                    .field("sival_int", unsafe { &self.sival_int })
                    .finish()
            }
        }
        #[cfg(libc_union)]
        impl ::hash::Hash for sigval {
            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
                unsafe {
                    self.sival_ptr.hash(state);
                    self.sival_int.hash(state);
                }
            }
        }

        impl PartialEq for siginfo_t {
            fn eq(&self, other: &siginfo_t) -> bool {
                #[cfg(libc_union)]
                let value_eq = self.si_value == other.si_value;
                #[cfg(not(libc_union))]
                let value_eq = true;
                self.si_signo == other.si_signo
                    && self.si_errno == other.si_errno
                    && self.si_code == other.si_code
                    && self.si_pid == other.si_pid
                    && self.si_uid == other.si_uid
                    && self.si_status == other.si_status
                    && self.si_addr == other.si_addr
                    && self.si_band == other.si_band
                    && self.__si_flags == other.__si_flags
                    && value_eq
            }
        }
        impl Eq for siginfo_t {}
        impl ::fmt::Debug for siginfo_t {
            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
                let mut struct_formatter = f.debug_struct("siginfo_t");
                struct_formatter.field("si_signo", &self.si_signo);
                struct_formatter.field("si_errno", &self.si_errno);
                struct_formatter.field("si_code", &self.si_code);
                struct_formatter.field("si_pid", &self.si_pid);
                struct_formatter.field("si_uid", &self.si_uid);
                struct_formatter.field("si_status", &self.si_status);
                struct_formatter.field("si_addr", &self.si_addr);
                struct_formatter.field("si_band", &self.si_band);
                #[cfg(libc_union)]
                struct_formatter.field("si_value", &self.si_value);
                struct_formatter.field("__si_flags", &self.__si_flags);
                struct_formatter.finish()
            }
        }
        impl ::hash::Hash for siginfo_t {
            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
                self.si_signo.hash(state);
                self.si_errno.hash(state);
                self.si_code.hash(state);
                self.si_pid.hash(state);
                self.si_uid.hash(state);
                self.si_status.hash(state);
                self.si_addr.hash(state);
                self.si_band.hash(state);
                #[cfg(libc_union)]
                self.si_value.hash(state);
                self.__si_flags.hash(state);
            }
        }

        #[cfg(libc_union)]
        impl PartialEq for _kernel_simple_lock {
            fn eq(&self, other: &_kernel_simple_lock) -> bool {
                unsafe {
                    self._slock == other._slock
                        && self._slockp == other._slockp
                }
            }
        }
        #[cfg(libc_union)]
        impl Eq for _kernel_simple_lock {}
        #[cfg(libc_union)]
        impl ::fmt::Debug for _kernel_simple_lock {
            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
                f.debug_struct("sigval")
                    .field("_slock", unsafe { &self._slock })
                    .field("_slockp", unsafe { &self._slockp })
                    .finish()
            }
        }
        #[cfg(libc_union)]
        impl ::hash::Hash for _kernel_simple_lock {
            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
                unsafe {
                    self._slock.hash(state);
                    self._slockp.hash(state);
                }
            }
        }

        impl PartialEq for fileops_t {
            fn eq(&self, other: &fileops_t) -> bool {
                self.fo_rw == other.fo_rw
                    && self.fo_ioctl == other.fo_ioctl
                    && self.fo_select == other.fo_select
                    && self.fo_close == other.fo_close
                    && self.fo_fstat == other.fo_fstat
            }
        }
        impl Eq for fileops_t {}
        impl ::fmt::Debug for fileops_t {
            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
                let mut struct_formatter = f.debug_struct("fileops_t");
                struct_formatter.field("fo_rw", &self.fo_rw);
                struct_formatter.field("fo_ioctl", &self.fo_ioctl);
                struct_formatter.field("fo_select", &self.fo_select);
                struct_formatter.field("fo_close", &self.fo_close);
                struct_formatter.field("fo_fstat", &self.fo_fstat);
                struct_formatter.finish()
            }
        }
        impl ::hash::Hash for fileops_t {
            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
                self.fo_rw.hash(state);
                self.fo_ioctl.hash(state);
                self.fo_select.hash(state);
                self.fo_close.hash(state);
                self.fo_fstat.hash(state);
            }
        }

        impl PartialEq for file {
            fn eq(&self, other: &file) -> bool {
                #[cfg(libc_union)]
                let lock_eq = self.f_lock == other.f_lock
                    && self.f_offset_lock == other.f_offset_lock;
                #[cfg(not(libc_union))]
                let lock_eq = true;
                self.f_flag == other.f_flag
                    && self.f_count == other.f_count
                    && self.f_options == other.f_options
                    && self.f_type == other.f_type
                    && self.f_data == other.f_data
                    && self.f_offset == other.f_offset
                    && self.f_dir_off == other.f_dir_off
                    && self.f_cred == other.f_cred
                    && self.f_vinfo == other.f_vinfo
                    && self.f_ops == other.f_ops
                    && self.f_parentp == other.f_parentp
                    && self.f_fnamep == other.f_fnamep
                    && self.f_fdata == other.f_fdata
                    && lock_eq
            }
        }
        impl Eq for file {}
        impl ::fmt::Debug for file {
            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
                let mut struct_formatter = f.debug_struct("file");
                struct_formatter.field("f_flag", &self.f_flag);
                struct_formatter.field("f_count", &self.f_count);
                struct_formatter.field("f_options", &self.f_options);
                struct_formatter.field("f_type", &self.f_type);
                struct_formatter.field("f_data", &self.f_data);
                struct_formatter.field("f_offset", &self.f_offset);
                struct_formatter.field("f_dir_off", &self.f_dir_off);
                struct_formatter.field("f_cred", &self.f_cred);
                #[cfg(libc_union)]
                struct_formatter.field("f_lock", &self.f_lock);
                #[cfg(libc_union)]
                struct_formatter.field("f_offset_lock", &self.f_offset_lock);
                struct_formatter.field("f_vinfo", &self.f_vinfo);
                struct_formatter.field("f_ops", &self.f_ops);
                struct_formatter.field("f_parentp", &self.f_parentp);
                struct_formatter.field("f_fnamep", &self.f_fnamep);
                struct_formatter.field("f_fdata", &self.f_fdata);
                struct_formatter.finish()
            }
        }
        impl ::hash::Hash for file {
            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
                self.f_flag.hash(state);
                self.f_count.hash(state);
                self.f_options.hash(state);
                self.f_type.hash(state);
                self.f_data.hash(state);
                self.f_offset.hash(state);
                self.f_dir_off.hash(state);
                self.f_cred.hash(state);
                #[cfg(libc_union)]
                self.f_lock.hash(state);
                #[cfg(libc_union)]
                self.f_offset_lock.hash(state);
                self.f_vinfo.hash(state);
                self.f_ops.hash(state);
                self.f_parentp.hash(state);
                self.f_fnamep.hash(state);
                self.f_fdata.hash(state);
            }
        }

        #[cfg(libc_union)]
        impl PartialEq for __ld_info_file {
            fn eq(&self, other: &__ld_info_file) -> bool {
                unsafe {
                    self._ldinfo_fd == other._ldinfo_fd
                        && self._ldinfo_fp == other._ldinfo_fp
                        && self._core_offset == other._core_offset
                }
            }
        }
        #[cfg(libc_union)]
        impl Eq for __ld_info_file {}
        #[cfg(libc_union)]
        impl ::fmt::Debug for __ld_info_file {
            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
                f.debug_struct("__ld_info_file")
                    .field("_ldinfo_fd", unsafe { &self._ldinfo_fd })
                    .field("_ldinfo_fp", unsafe { &self._ldinfo_fp })
                    .field("_core_offset", unsafe { &self._core_offset })
                    .finish()
            }
        }
        #[cfg(libc_union)]
        impl ::hash::Hash for __ld_info_file {
            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
                unsafe {
                    self._ldinfo_fd.hash(state);
                    self._ldinfo_fp.hash(state);
                    self._core_offset.hash(state);
                }
            }
        }

        impl PartialEq for ld_info {
            fn eq(&self, other: &ld_info) -> bool {
                #[cfg(libc_union)]
                let file_eq = self._file == other._file;
                #[cfg(not(libc_union))]
                let file_eq = true;
                self.ldinfo_next == other.ldinfo_next
                    && self.ldinfo_flags == other.ldinfo_flags
                    && self.ldinfo_textorg == other.ldinfo_textorg
                    && self.ldinfo_textsize == other.ldinfo_textsize
                    && self.ldinfo_dataorg == other.ldinfo_dataorg
                    && self.ldinfo_datasize == other.ldinfo_datasize
                    && self.ldinfo_filename == other.ldinfo_filename
                    && file_eq
            }
        }
        impl Eq for ld_info {}
        impl ::fmt::Debug for ld_info {
            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
                let mut struct_formatter = f.debug_struct("ld_info");
                struct_formatter.field("ldinfo_next", &self.ldinfo_next);
                struct_formatter.field("ldinfo_flags", &self.ldinfo_flags);
                struct_formatter.field("ldinfo_textorg", &self.ldinfo_textorg);
                struct_formatter.field("ldinfo_textsize", &self.ldinfo_textsize);
                struct_formatter.field("ldinfo_dataorg", &self.ldinfo_dataorg);
                struct_formatter.field("ldinfo_datasize", &self.ldinfo_datasize);
                struct_formatter.field("ldinfo_filename", &self.ldinfo_filename);
                #[cfg(libc_union)]
                struct_formatter.field("_file", &self._file);
                struct_formatter.finish()
            }
        }
        impl ::hash::Hash for ld_info {
            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
                self.ldinfo_next.hash(state);
                self.ldinfo_flags.hash(state);
                self.ldinfo_textorg.hash(state);
                self.ldinfo_textsize.hash(state);
                self.ldinfo_dataorg.hash(state);
                self.ldinfo_datasize.hash(state);
                self.ldinfo_filename.hash(state);
                #[cfg(libc_union)]
                self._file.hash(state);
            }
        }

        #[cfg(libc_union)]
        impl PartialEq for __pollfd_ext_u {
            fn eq(&self, other: &__pollfd_ext_u) -> bool {
                unsafe {
                    self.addr == other.addr
                        && self.data32 == other.data32
                        && self.data == other.data
                }
            }
        }
        #[cfg(libc_union)]
        impl Eq for __pollfd_ext_u {}
        #[cfg(libc_union)]
        impl ::fmt::Debug for __pollfd_ext_u {
            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
                f.debug_struct("__pollfd_ext_u")
                    .field("addr", unsafe { &self.addr })
                    .field("data32", unsafe { &self.data32 })
                    .field("data", unsafe { &self.data })
                    .finish()
            }
        }
        #[cfg(libc_union)]
        impl ::hash::Hash for __pollfd_ext_u {
            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
                unsafe {
                    self.addr.hash(state);
                    self.data.hash(state);
                    self.data32.hash(state);
                }
            }
        }

        impl PartialEq for pollfd_ext {
            fn eq(&self, other: &pollfd_ext) -> bool {
                #[cfg(libc_union)]
                let data_eq = self.data == other.data;
                #[cfg(not(libc_union))]
                let data_eq = true;
                self.fd == other.fd
                    && self.events == other.events
                    && self.revents == other.revents
                    && data_eq
            }
        }
        impl Eq for pollfd_ext {}
        impl ::fmt::Debug for pollfd_ext {
            fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
                let mut struct_formatter = f.debug_struct("pollfd_ext");
                struct_formatter.field("fd", &self.fd);
                struct_formatter.field("events", &self.events);
                struct_formatter.field("revents", &self.revents);
                #[cfg(libc_union)]
                struct_formatter.field("data", &self.data);
                struct_formatter.finish()
            }
        }
        impl ::hash::Hash for pollfd_ext {
            fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
                self.fd.hash(state);
                self.events.hash(state);
                self.revents.hash(state);
                #[cfg(libc_union)]
                self.data.hash(state);
            }
        }
    }
}

pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
    __mt_word: [0, 2, 0, 0, 0, 0, 0, 0],
};
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
    __cv_word: [0, 0, 0, 0, 2, 0],
};
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
    __rw_word: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0],
};
pub const RLIM_INFINITY: ::c_ulong = 0x7fffffffffffffff;

extern "C" {
    pub fn getsystemcfg(label: ::c_int) -> ::c_ulong;
}