-
Notifications
You must be signed in to change notification settings - Fork 13k
/
Copy pathlibc.rs
4166 lines (3803 loc) · 169 KB
/
libc.rs
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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
/*!
* Bindings for the C standard library and other platform libraries
*
* This module contains bindings to the C standard library,
* organized into modules by their defining standard.
* Additionally, it contains some assorted platform-specific definitions.
* For convenience, most functions and types are reexported from `std::libc`,
* so `pub use std::libc::*` will import the available
* C bindings as appropriate for the target platform. The exact
* set of functions available are platform specific.
*
* *Note* Because these definitions are platform-specific, some may not appear in
* the generated documentation.
*
* We consider the following specs reasonably normative with respect
* to interoperating with the C standard library (libc/msvcrt):
*
* * ISO 9899:1990 ('C95', 'ANSI C', 'Standard C'), NA1, 1995.
* * ISO 9899:1999 ('C99' or 'C9x').
* * ISO 9945:1988 / IEEE 1003.1-1988 ('POSIX.1').
* * ISO 9945:2001 / IEEE 1003.1-2001 ('POSIX:2001', 'SUSv3').
* * ISO 9945:2008 / IEEE 1003.1-2008 ('POSIX:2008', 'SUSv4').
*
* Note that any reference to the 1996 revision of POSIX, or any revs
* between 1990 (when '88 was approved at ISO) and 2001 (when the next
* actual revision-revision happened), are merely additions of other
* chapters (1b and 1c) outside the core interfaces.
*
* Despite having several names each, these are *reasonably* coherent
* point-in-time, list-of-definition sorts of specs. You can get each under a
* variety of names but will wind up with the same definition in each case.
*
* See standards(7) in linux-manpages for more details.
*
* Our interface to these libraries is complicated by the non-universality of
* conformance to any of them. About the only thing universally supported is
* the first (C95), beyond that definitions quickly become absent on various
* platforms.
*
* We therefore wind up dividing our module-space up (mostly for the sake of
* sanity while editing, filling-in-details and eliminating duplication) into
* definitions common-to-all (held in modules named c95, c99, posix88, posix01
* and posix08) and definitions that appear only on *some* platforms (named
* 'extra'). This would be things like significant OSX foundation kit, or
* win32 library kernel32.dll, or various fancy glibc, linux or BSD
* extensions.
*
* In addition to the per-platform 'extra' modules, we define a module of
* 'common BSD' libc routines that never quite made it into POSIX but show up
* in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the
* final one from Berkeley after the lawsuits died down and the CSRG
* dissolved.
*/
#[allow(non_camel_case_types)];
#[allow(non_uppercase_statics)];
#[allow(missing_doc)];
// Initial glob-exports mean that all the contents of all the modules
// wind up exported, if you're interested in writing platform-specific code.
pub use libc::types::common::c95::*;
pub use libc::types::common::c99::*;
pub use libc::types::common::posix88::*;
pub use libc::types::common::posix01::*;
pub use libc::types::common::posix08::*;
pub use libc::types::common::bsd44::*;
pub use libc::types::os::common::posix01::*;
pub use libc::types::os::common::bsd44::*;
pub use libc::types::os::arch::c95::*;
pub use libc::types::os::arch::c99::*;
pub use libc::types::os::arch::posix88::*;
pub use libc::types::os::arch::posix01::*;
pub use libc::types::os::arch::posix08::*;
pub use libc::types::os::arch::bsd44::*;
pub use libc::types::os::arch::extra::*;
pub use libc::consts::os::c95::*;
pub use libc::consts::os::c99::*;
pub use libc::consts::os::posix88::*;
pub use libc::consts::os::posix01::*;
pub use libc::consts::os::posix08::*;
pub use libc::consts::os::bsd44::*;
pub use libc::consts::os::extra::*;
pub use libc::consts::os::sysconf::*;
pub use libc::funcs::c95::ctype::*;
pub use libc::funcs::c95::stdio::*;
pub use libc::funcs::c95::stdlib::*;
pub use libc::funcs::c95::string::*;
pub use libc::funcs::posix88::stat_::*;
pub use libc::funcs::posix88::stdio::*;
pub use libc::funcs::posix88::fcntl::*;
pub use libc::funcs::posix88::dirent::*;
pub use libc::funcs::posix88::unistd::*;
pub use libc::funcs::posix88::mman::*;
pub use libc::funcs::posix01::stat_::*;
pub use libc::funcs::posix01::unistd::*;
pub use libc::funcs::posix01::glob::*;
pub use libc::funcs::posix01::mman::*;
pub use libc::funcs::posix08::unistd::*;
pub use libc::funcs::bsd43::*;
pub use libc::funcs::bsd44::*;
pub use libc::funcs::extra::*;
#[cfg(target_os = "win32")]
pub use libc::funcs::extra::kernel32::*;
#[cfg(target_os = "win32")]
pub use libc::funcs::extra::msvcrt::*;
// Explicit export lists for the intersection (provided here) mean that
// you can write more-platform-agnostic code if you stick to just these
// symbols.
pub use libc::types::common::c95::{FILE, c_void, fpos_t};
pub use libc::types::common::posix88::{DIR, dirent_t};
pub use libc::types::os::arch::c95::{c_char, c_double, c_float, c_int};
pub use libc::types::os::arch::c95::{c_long, c_short, c_uchar, c_ulong};
pub use libc::types::os::arch::c95::{c_ushort, clock_t, ptrdiff_t};
pub use libc::types::os::arch::c95::{size_t, time_t};
pub use libc::types::os::arch::c99::{c_longlong, c_ulonglong, intptr_t};
pub use libc::types::os::arch::c99::{uintptr_t};
pub use libc::types::os::arch::posix88::{dev_t, dirent_t, ino_t, mode_t};
pub use libc::types::os::arch::posix88::{off_t, pid_t, ssize_t};
pub use libc::consts::os::c95::{_IOFBF, _IOLBF, _IONBF, BUFSIZ, EOF};
pub use libc::consts::os::c95::{EXIT_FAILURE, EXIT_SUCCESS};
pub use libc::consts::os::c95::{FILENAME_MAX, FOPEN_MAX, L_tmpnam};
pub use libc::consts::os::c95::{RAND_MAX, SEEK_CUR, SEEK_END};
pub use libc::consts::os::c95::{SEEK_SET, TMP_MAX};
pub use libc::consts::os::posix88::{F_OK, O_APPEND, O_CREAT, O_EXCL};
pub use libc::consts::os::posix88::{O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
pub use libc::consts::os::posix88::{R_OK, S_IEXEC, S_IFBLK, S_IFCHR};
pub use libc::consts::os::posix88::{S_IFDIR, S_IFIFO, S_IFMT, S_IFREG, S_IFLNK};
pub use libc::consts::os::posix88::{S_IREAD, S_IRUSR, S_IRWXU, S_IWUSR};
pub use libc::consts::os::posix88::{STDERR_FILENO, STDIN_FILENO};
pub use libc::consts::os::posix88::{STDOUT_FILENO, W_OK, X_OK};
pub use libc::funcs::c95::ctype::{isalnum, isalpha, iscntrl, isdigit};
pub use libc::funcs::c95::ctype::{islower, isprint, ispunct, isspace};
pub use libc::funcs::c95::ctype::{isupper, isxdigit, tolower, toupper};
pub use libc::funcs::c95::stdio::{fclose, feof, ferror, fflush, fgetc};
pub use libc::funcs::c95::stdio::{fgetpos, fgets, fopen, fputc, fputs};
pub use libc::funcs::c95::stdio::{fread, freopen, fseek, fsetpos, ftell};
pub use libc::funcs::c95::stdio::{fwrite, perror, puts, remove, rewind};
pub use libc::funcs::c95::stdio::{setbuf, setvbuf, tmpfile, ungetc};
pub use libc::funcs::c95::stdlib::{abs, atof, atoi, calloc, exit};
pub use libc::funcs::c95::stdlib::{free, getenv, labs, malloc, rand};
pub use libc::funcs::c95::stdlib::{realloc, srand, strtod, strtol};
pub use libc::funcs::c95::stdlib::{strtoul, system};
pub use libc::funcs::c95::string::{memchr, memcmp};
pub use libc::funcs::c95::string::{strcat, strchr, strcmp};
pub use libc::funcs::c95::string::{strcoll, strcpy, strcspn, strerror};
pub use libc::funcs::c95::string::{strlen, strncat, strncmp, strncpy};
pub use libc::funcs::c95::string::{strpbrk, strrchr, strspn, strstr};
pub use libc::funcs::c95::string::{strtok, strxfrm};
pub use libc::funcs::posix88::fcntl::{open, creat};
pub use libc::funcs::posix88::stat_::{chmod, fstat, mkdir, stat};
pub use libc::funcs::posix88::stdio::{fdopen, fileno, pclose, popen};
pub use libc::funcs::posix88::unistd::{access, chdir, close, dup, dup2};
pub use libc::funcs::posix88::unistd::{execv, execve, execvp, getcwd};
pub use libc::funcs::posix88::unistd::{getpid, isatty, lseek, pipe, read};
pub use libc::funcs::posix88::unistd::{rmdir, unlink, write};
pub mod types {
// Types tend to vary *per architecture* so we pull their definitions out
// into this module.
// Standard types that are opaque or common, so are not per-target.
pub mod common {
pub mod c95 {
/**
Type used to construct void pointers for use with C.
This type is only useful as a pointer target. Do not use it as a
return type for FFI functions which have the `void` return type in
C. Use the unit type `()` or omit the return type instead.
For LLVM to recognize the void pointer type and by extension
functions like malloc(), we need to have it represented as i8* in
LLVM bitcode. The enum used here ensures this and prevents misuse
of the "raw" type by only having private variants.. We need two
variants, because the compiler complains about the repr attribute
otherwise.
*/
#[repr(u8)]
pub enum c_void {
priv variant1,
priv variant2
}
pub enum FILE {}
pub enum fpos_t {}
}
pub mod c99 {
pub type int8_t = i8;
pub type int16_t = i16;
pub type int32_t = i32;
pub type int64_t = i64;
pub type uint8_t = u8;
pub type uint16_t = u16;
pub type uint32_t = u32;
pub type uint64_t = u64;
}
pub mod posix88 {
pub enum DIR {}
pub enum dirent_t {}
}
pub mod posix01 {}
pub mod posix08 {}
pub mod bsd44 {}
}
// Standard types that are scalar but vary by OS and arch.
#[cfg(target_os = "linux")]
#[cfg(target_os = "android")]
pub mod os {
pub mod common {
pub mod posix01 {
use libc::types::common::c95::{c_void};
use libc::types::os::arch::c95::{c_char, c_ulong, size_t,
time_t, suseconds_t, c_long};
pub type pthread_t = c_ulong;
pub struct glob_t {
gl_pathc: size_t,
gl_pathv: **c_char,
gl_offs: size_t,
__unused1: *c_void,
__unused2: *c_void,
__unused3: *c_void,
__unused4: *c_void,
__unused5: *c_void,
}
pub struct timeval {
tv_sec: time_t,
tv_usec: suseconds_t,
}
pub struct timespec {
tv_sec: time_t,
tv_nsec: c_long,
}
pub enum timezone {}
}
pub mod bsd44 {
use libc::types::os::arch::c95::{c_char, c_int, c_uint};
pub type socklen_t = u32;
pub type sa_family_t = u16;
pub type in_port_t = u16;
pub type in_addr_t = u32;
pub struct sockaddr {
sa_family: sa_family_t,
sa_data: [u8, ..14],
}
pub struct sockaddr_storage {
ss_family: sa_family_t,
__ss_align: i64,
__ss_pad2: [u8, ..112],
}
pub struct sockaddr_in {
sin_family: sa_family_t,
sin_port: in_port_t,
sin_addr: in_addr,
sin_zero: [u8, ..8],
}
pub struct in_addr {
s_addr: in_addr_t,
}
pub struct sockaddr_in6 {
sin6_family: sa_family_t,
sin6_port: in_port_t,
sin6_flowinfo: u32,
sin6_addr: in6_addr,
sin6_scope_id: u32,
}
pub struct in6_addr {
s6_addr: [u16, ..8]
}
pub struct ip_mreq {
imr_multiaddr: in_addr,
imr_interface: in_addr,
}
pub struct ip6_mreq {
ipv6mr_multiaddr: in6_addr,
ipv6mr_interface: c_uint,
}
pub struct addrinfo {
ai_flags: c_int,
ai_family: c_int,
ai_socktype: c_int,
ai_protocol: c_int,
ai_addrlen: socklen_t,
ai_addr: *sockaddr,
ai_canonname: *c_char,
ai_next: *addrinfo
}
}
}
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "arm")]
#[cfg(target_arch = "mips")]
pub mod arch {
pub mod c95 {
pub type c_char = i8;
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
pub type c_ushort = u16;
pub type c_int = i32;
pub type c_uint = u32;
pub type c_long = i32;
pub type c_ulong = u32;
pub type c_float = f32;
pub type c_double = f64;
pub type size_t = u32;
pub type ptrdiff_t = i32;
pub type clock_t = i32;
pub type time_t = i32;
pub type suseconds_t = i32;
pub type wchar_t = i32;
}
pub mod c99 {
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type intptr_t = int;
pub type uintptr_t = uint;
}
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "mips")]
pub mod posix88 {
pub type off_t = i32;
pub type dev_t = u64;
pub type ino_t = u32;
pub type pid_t = i32;
pub type uid_t = u32;
pub type gid_t = u32;
pub type useconds_t = u32;
pub type mode_t = u32;
pub type ssize_t = i32;
}
#[cfg(target_arch = "arm")]
pub mod posix88 {
pub type off_t = i32;
pub type dev_t = u32;
pub type ino_t = u32;
pub type pid_t = i32;
pub type uid_t = u32;
pub type gid_t = u32;
pub type useconds_t = u32;
pub type mode_t = u16;
pub type ssize_t = i32;
}
#[cfg(target_arch = "x86")]
pub mod posix01 {
use libc::types::os::arch::c95::{c_short, c_long, time_t};
use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
use libc::types::os::arch::posix88::{mode_t, off_t};
use libc::types::os::arch::posix88::{uid_t};
pub type nlink_t = u32;
pub type blksize_t = i32;
pub type blkcnt_t = i32;
pub struct stat {
st_dev: dev_t,
__pad1: c_short,
st_ino: ino_t,
st_mode: mode_t,
st_nlink: nlink_t,
st_uid: uid_t,
st_gid: gid_t,
st_rdev: dev_t,
__pad2: c_short,
st_size: off_t,
st_blksize: blksize_t,
st_blocks: blkcnt_t,
st_atime: time_t,
st_atime_nsec: c_long,
st_mtime: time_t,
st_mtime_nsec: c_long,
st_ctime: time_t,
st_ctime_nsec: c_long,
__unused4: c_long,
__unused5: c_long,
}
pub struct utimbuf {
actime: time_t,
modtime: time_t,
}
pub struct pthread_attr_t {
__size: [u32, ..9]
}
}
#[cfg(target_arch = "arm")]
pub mod posix01 {
use libc::types::os::arch::c95::{c_uchar, c_uint, c_ulong, time_t};
use libc::types::os::arch::c99::{c_longlong, c_ulonglong};
use libc::types::os::arch::posix88::{uid_t, gid_t, ino_t};
pub type nlink_t = u16;
pub type blksize_t = u32;
pub type blkcnt_t = u32;
pub struct stat {
st_dev: c_ulonglong,
__pad0: [c_uchar, ..4],
__st_ino: ino_t,
st_mode: c_uint,
st_nlink: c_uint,
st_uid: uid_t,
st_gid: gid_t,
st_rdev: c_ulonglong,
__pad3: [c_uchar, ..4],
st_size: c_longlong,
st_blksize: blksize_t,
st_blocks: c_ulonglong,
st_atime: time_t,
st_atime_nsec: c_ulong,
st_mtime: time_t,
st_mtime_nsec: c_ulong,
st_ctime: time_t,
st_ctime_nsec: c_ulong,
st_ino: c_ulonglong
}
pub struct utimbuf {
actime: time_t,
modtime: time_t,
}
pub struct pthread_attr_t {
__size: [u32, ..9]
}
}
#[cfg(target_arch = "mips")]
pub mod posix01 {
use libc::types::os::arch::c95::{c_long, c_ulong, time_t};
use libc::types::os::arch::posix88::{gid_t, ino_t};
use libc::types::os::arch::posix88::{mode_t, off_t};
use libc::types::os::arch::posix88::{uid_t};
pub type nlink_t = u32;
pub type blksize_t = i32;
pub type blkcnt_t = i32;
pub struct stat {
st_dev: c_ulong,
st_pad1: [c_long, ..3],
st_ino: ino_t,
st_mode: mode_t,
st_nlink: nlink_t,
st_uid: uid_t,
st_gid: gid_t,
st_rdev: c_ulong,
st_pad2: [c_long, ..2],
st_size: off_t,
st_pad3: c_long,
st_atime: time_t,
st_atime_nsec: c_long,
st_mtime: time_t,
st_mtime_nsec: c_long,
st_ctime: time_t,
st_ctime_nsec: c_long,
st_blksize: blksize_t,
st_blocks: blkcnt_t,
st_pad5: [c_long, ..14],
}
pub struct utimbuf {
actime: time_t,
modtime: time_t,
}
pub struct pthread_attr_t {
__size: [u32, ..9]
}
}
pub mod posix08 {}
pub mod bsd44 {}
pub mod extra {}
}
#[cfg(target_arch = "x86_64")]
pub mod arch {
pub mod c95 {
pub type c_char = i8;
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
pub type c_ushort = u16;
pub type c_int = i32;
pub type c_uint = u32;
pub type c_long = i64;
pub type c_ulong = u64;
pub type c_float = f32;
pub type c_double = f64;
pub type size_t = u64;
pub type ptrdiff_t = i64;
pub type clock_t = i64;
pub type time_t = i64;
pub type suseconds_t = i64;
pub type wchar_t = i32;
}
pub mod c99 {
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type intptr_t = int;
pub type uintptr_t = uint;
}
pub mod posix88 {
pub type off_t = i64;
pub type dev_t = u64;
pub type ino_t = u64;
pub type pid_t = i32;
pub type uid_t = u32;
pub type gid_t = u32;
pub type useconds_t = u32;
pub type mode_t = u32;
pub type ssize_t = i64;
}
pub mod posix01 {
use libc::types::os::arch::c95::{c_int, c_long, time_t};
use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
use libc::types::os::arch::posix88::{mode_t, off_t};
use libc::types::os::arch::posix88::{uid_t};
pub type nlink_t = u64;
pub type blksize_t = i64;
pub type blkcnt_t = i64;
pub struct stat {
st_dev: dev_t,
st_ino: ino_t,
st_nlink: nlink_t,
st_mode: mode_t,
st_uid: uid_t,
st_gid: gid_t,
__pad0: c_int,
st_rdev: dev_t,
st_size: off_t,
st_blksize: blksize_t,
st_blocks: blkcnt_t,
st_atime: time_t,
st_atime_nsec: c_long,
st_mtime: time_t,
st_mtime_nsec: c_long,
st_ctime: time_t,
st_ctime_nsec: c_long,
__unused: [c_long, ..3],
}
pub struct utimbuf {
actime: time_t,
modtime: time_t,
}
pub struct pthread_attr_t {
__size: [u64, ..7]
}
}
pub mod posix08 {
}
pub mod bsd44 {
}
pub mod extra {
}
}
}
#[cfg(target_os = "freebsd")]
pub mod os {
pub mod common {
pub mod posix01 {
use libc::types::common::c95::{c_void};
use libc::types::os::arch::c95::{c_char, c_int, size_t,
time_t, suseconds_t, c_long};
use libc::types::os::arch::c99::{uintptr_t};
pub type pthread_t = uintptr_t;
pub struct glob_t {
gl_pathc: size_t,
__unused1: size_t,
gl_offs: size_t,
__unused2: c_int,
gl_pathv: **c_char,
__unused3: *c_void,
__unused4: *c_void,
__unused5: *c_void,
__unused6: *c_void,
__unused7: *c_void,
__unused8: *c_void,
}
pub struct timeval {
tv_sec: time_t,
tv_usec: suseconds_t,
}
pub struct timespec {
tv_sec: time_t,
tv_nsec: c_long,
}
pub enum timezone {}
}
pub mod bsd44 {
use libc::types::os::arch::c95::{c_char, c_int, c_uint};
pub type socklen_t = u32;
pub type sa_family_t = u8;
pub type in_port_t = u16;
pub type in_addr_t = u32;
pub struct sockaddr {
sa_len: u8,
sa_family: sa_family_t,
sa_data: [u8, ..14],
}
pub struct sockaddr_storage {
ss_len: u8,
ss_family: sa_family_t,
__ss_pad1: [u8, ..6],
__ss_align: i64,
__ss_pad2: [u8, ..112],
}
pub struct sockaddr_in {
sin_len: u8,
sin_family: sa_family_t,
sin_port: in_port_t,
sin_addr: in_addr,
sin_zero: [u8, ..8],
}
pub struct in_addr {
s_addr: in_addr_t,
}
pub struct sockaddr_in6 {
sin6_len: u8,
sin6_family: sa_family_t,
sin6_port: in_port_t,
sin6_flowinfo: u32,
sin6_addr: in6_addr,
sin6_scope_id: u32,
}
pub struct in6_addr {
s6_addr: [u16, ..8]
}
pub struct ip_mreq {
imr_multiaddr: in_addr,
imr_interface: in_addr,
}
pub struct ip6_mreq {
ipv6mr_multiaddr: in6_addr,
ipv6mr_interface: c_uint,
}
pub struct addrinfo {
ai_flags: c_int,
ai_family: c_int,
ai_socktype: c_int,
ai_protocol: c_int,
ai_addrlen: socklen_t,
ai_canonname: *c_char,
ai_addr: *sockaddr,
ai_next: *addrinfo
}
}
}
#[cfg(target_arch = "x86_64")]
pub mod arch {
pub mod c95 {
pub type c_char = i8;
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
pub type c_ushort = u16;
pub type c_int = i32;
pub type c_uint = u32;
pub type c_long = i64;
pub type c_ulong = u64;
pub type c_float = f32;
pub type c_double = f64;
pub type size_t = u64;
pub type ptrdiff_t = i64;
pub type clock_t = i32;
pub type time_t = i64;
pub type suseconds_t = i64;
pub type wchar_t = i32;
}
pub mod c99 {
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type intptr_t = int;
pub type uintptr_t = uint;
}
pub mod posix88 {
pub type off_t = i64;
pub type dev_t = u32;
pub type ino_t = u32;
pub type pid_t = i32;
pub type uid_t = u32;
pub type gid_t = u32;
pub type useconds_t = u32;
pub type mode_t = u16;
pub type ssize_t = i64;
}
pub mod posix01 {
use libc::types::common::c95::{c_void};
use libc::types::common::c99::{uint8_t, uint32_t, int32_t};
use libc::types::os::arch::c95::{c_long, time_t};
use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
use libc::types::os::arch::posix88::{mode_t, off_t};
use libc::types::os::arch::posix88::{uid_t};
pub type nlink_t = u16;
pub type blksize_t = i64;
pub type blkcnt_t = i64;
pub type fflags_t = u32;
pub struct stat {
st_dev: dev_t,
st_ino: ino_t,
st_mode: mode_t,
st_nlink: nlink_t,
st_uid: uid_t,
st_gid: gid_t,
st_rdev: dev_t,
st_atime: time_t,
st_atime_nsec: c_long,
st_mtime: time_t,
st_mtime_nsec: c_long,
st_ctime: time_t,
st_ctime_nsec: c_long,
st_size: off_t,
st_blocks: blkcnt_t,
st_blksize: blksize_t,
st_flags: fflags_t,
st_gen: uint32_t,
st_lspare: int32_t,
st_birthtime: time_t,
st_birthtime_nsec: c_long,
__unused: [uint8_t, ..2],
}
pub struct utimbuf {
actime: time_t,
modtime: time_t,
}
pub type pthread_attr_t = *c_void;
}
pub mod posix08 {
}
pub mod bsd44 {
}
pub mod extra {
}
}
}
#[cfg(target_os = "win32")]
pub mod os {
pub mod common {
pub mod posix01 {
use libc::types::os::arch::c95::{c_short, time_t, suseconds_t,
c_long};
use libc::types::os::arch::extra::{int64, time64_t};
use libc::types::os::arch::posix88::{dev_t, ino_t};
use libc::types::os::arch::posix88::mode_t;
// Note: this is the struct called stat64 in win32. Not stat,
// nor stati64.
pub struct stat {
st_dev: dev_t,
st_ino: ino_t,
st_mode: mode_t,
st_nlink: c_short,
st_uid: c_short,
st_gid: c_short,
st_rdev: dev_t,
st_size: int64,
st_atime: time64_t,
st_mtime: time64_t,
st_ctime: time64_t,
}
// note that this is called utimbuf64 in win32
pub struct utimbuf {
actime: time64_t,
modtime: time64_t,
}
pub struct timeval {
tv_sec: time_t,
tv_usec: suseconds_t,
}
pub struct timespec {
tv_sec: time_t,
tv_nsec: c_long,
}
pub enum timezone {}
}
pub mod bsd44 {
use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
pub type SOCKET = c_uint;
pub type socklen_t = c_int;
pub type sa_family_t = u16;
pub type in_port_t = u16;
pub type in_addr_t = u32;
pub struct sockaddr {
sa_family: sa_family_t,
sa_data: [u8, ..14],
}
pub struct sockaddr_storage {
ss_family: sa_family_t,
__ss_align: i64,
__ss_pad2: [u8, ..112],
}
pub struct sockaddr_in {
sin_family: sa_family_t,
sin_port: in_port_t,
sin_addr: in_addr,
sin_zero: [u8, ..8],
}
pub struct in_addr {
s_addr: in_addr_t,
}
pub struct sockaddr_in6 {
sin6_family: sa_family_t,
sin6_port: in_port_t,
sin6_flowinfo: u32,
sin6_addr: in6_addr,
sin6_scope_id: u32,
}
pub struct in6_addr {
s6_addr: [u16, ..8]
}
pub struct ip_mreq {
imr_multiaddr: in_addr,
imr_interface: in_addr,
}
pub struct ip6_mreq {
ipv6mr_multiaddr: in6_addr,
ipv6mr_interface: c_uint,
}
pub struct addrinfo {
ai_flags: c_int,
ai_family: c_int,
ai_socktype: c_int,
ai_protocol: c_int,
ai_addrlen: size_t,
ai_canonname: *c_char,
ai_addr: *sockaddr,
ai_next: *addrinfo
}
}
}
pub mod arch {
pub mod c95 {
pub type c_char = i8;
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
pub type c_ushort = u16;
pub type c_int = i32;
pub type c_uint = u32;
pub type c_long = i32;
pub type c_ulong = u32;
pub type c_float = f32;
pub type c_double = f64;
#[cfg(target_arch = "x86")]
pub type size_t = u32;
#[cfg(target_arch = "x86_64")]
pub type size_t = u64;
#[cfg(target_arch = "x86")]
pub type ptrdiff_t = i32;
#[cfg(target_arch = "x86_64")]
pub type ptrdiff_t = i64;
pub type clock_t = i32;
#[cfg(target_arch = "x86")]
pub type time_t = i32;
#[cfg(target_arch = "x86_64")]
pub type time_t = i64;
#[cfg(target_arch = "x86")]
pub type suseconds_t = i32;
#[cfg(target_arch = "x86_64")]
pub type suseconds_t = i64;
pub type wchar_t = u16;
}
pub mod c99 {
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type intptr_t = int;
pub type uintptr_t = uint;
}
pub mod posix88 {
pub type off_t = i32;
pub type dev_t = u32;
pub type ino_t = i16;
#[cfg(target_arch = "x86")]
pub type pid_t = i32;
#[cfg(target_arch = "x86_64")]
pub type pid_t = i64;
pub type useconds_t = u32;
pub type mode_t = u16;
#[cfg(target_arch = "x86")]
pub type ssize_t = i32;
#[cfg(target_arch = "x86_64")]
pub type ssize_t = i64;
}
pub mod posix01 {
}
pub mod posix08 {
}
pub mod bsd44 {
}
pub mod extra {
use ptr;
use libc::consts::os::extra::{MAX_PROTOCOL_CHAIN,
WSAPROTOCOL_LEN};
use libc::types::common::c95::c_void;
use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
use libc::types::os::arch::c95::{c_long, c_ulong};
use libc::types::os::arch::c95::{wchar_t};
use libc::types::os::arch::c99::{c_ulonglong, c_longlong};
pub type BOOL = c_int;
pub type BYTE = u8;
pub type CCHAR = c_char;
pub type CHAR = c_char;
pub type DWORD = c_ulong;
pub type DWORDLONG = c_ulonglong;
pub type HANDLE = LPVOID;
pub type HMODULE = c_uint;
pub type LONG = c_long;
pub type PLONG = *mut c_long;
#[cfg(target_arch = "x86")]
pub type LONG_PTR = c_long;
#[cfg(target_arch = "x86_64")]
pub type LONG_PTR = i64;
pub type LARGE_INTEGER = c_longlong;
pub type PLARGE_INTEGER = *mut c_longlong;
pub type LPCWSTR = *WCHAR;
pub type LPCSTR = *CHAR;
pub type LPWSTR = *mut WCHAR;
pub type LPSTR = *mut CHAR;
pub type LPWCH = *mut WCHAR;
pub type LPCH = *mut CHAR;