forked from qbit/rust-cross-openbsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-rust
1915 lines (1751 loc) · 64.7 KB
/
patch-rust
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
diff --git a/configure b/configure
index 7790025..fa3f9ac 100755
--- a/configure
+++ b/configure
@@ -368,16 +368,19 @@ case $CFG_OSTYPE in
FreeBSD)
CFG_OSTYPE=unknown-freebsd
;;
DragonFly)
CFG_OSTYPE=unknown-dragonfly
;;
+ OpenBSD)
+ CFG_OSTYPE=unknown-openbsd
+ ;;
Darwin)
CFG_OSTYPE=apple-darwin
;;
MINGW*)
# msys' `uname` does not print gcc configuration, but prints msys
# configuration. so we cannot believe `uname -m`:
# msys1 is always i686 and msys2 is always x86_64.
@@ -703,20 +706,20 @@ then
putvar CFG_LOCAL_RUST_ROOT
else
if [ ! -z "$CFG_LOCAL_RUST_ROOT" ]
then
warn "Use of --local-rust-root without --enable-local-rust"
fi
fi
-# Force freebsd to build with clang; gcc doesn't like us there
-if [ $CFG_OSTYPE = unknown-freebsd ]
+# Force freebsd/openbsd to build with clang; gcc doesn't like us there
+if [ $CFG_OSTYPE = unknown-freebsd -o $CFG_OSTYPE = unknown-openbsd ]
then
- step_msg "on FreeBSD, forcing use of clang"
+ step_msg "on FreeBSD/OpenBSD, forcing use of clang"
CFG_ENABLE_CLANG=1
fi
if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
then
err "either clang or gcc is required"
fi
diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs
index a116cc3..934d94f 100644
--- a/src/compiletest/util.rs
+++ b/src/compiletest/util.rs
@@ -18,16 +18,17 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[
("mingw32", "windows"),
("win32", "windows"),
("windows", "windows"),
("darwin", "macos"),
("android", "android"),
("linux", "linux"),
("freebsd", "freebsd"),
("dragonfly", "dragonfly"),
+ ("openbsd", "openbsd"),
];
pub fn get_os(triple: &str) -> &'static str {
for &(triple_os, os) in OS_TABLE.iter() {
if triple.contains(triple_os) {
return os
}
}
diff --git a/src/doc/reference.md b/src/doc/reference.md
index f31f28d..15cb159 100644
--- a/src/doc/reference.md
+++ b/src/doc/reference.md
@@ -2067,17 +2067,18 @@ The following configurations must be defined by the implementation:
* `target_arch = "..."`. Target CPU architecture, such as `"x86"`, `"x86_64"`
`"mips"`, or `"arm"`.
* `target_endian = "..."`. Endianness of the target CPU, either `"little"` or
`"big"`.
* `target_family = "..."`. Operating system family of the target, e. g.
`"unix"` or `"windows"`. The value of this configuration option is defined
as a configuration itself, like `unix` or `windows`.
* `target_os = "..."`. Operating system of the target, examples include
- `"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"` or `"dragonfly"`.
+ `"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"`, `"openbsd"`, or
+ `"dragonfly"`.
* `target_word_size = "..."`. Target word size in bits. This is set to `"32"`
for targets with 32-bit pointers, and likewise set to `"64"` for 64-bit
pointers.
* `unix`. See `target_family`.
* `windows`. See `target_family`.
### Lint check attributes
diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py
index 0003de1..2fe04e7 100644
--- a/src/etc/mklldeps.py
+++ b/src/etc/mklldeps.py
@@ -53,16 +53,18 @@ for llconfig in sys.argv[4:]:
if 'darwin' in os:
os = 'macos'
elif 'linux' in os:
os = 'linux'
elif 'freebsd' in os:
os = 'freebsd'
elif 'dragonfly' in os:
os = 'dragonfly'
+ elif 'openbsd' in os:
+ os = 'openbsd'
elif 'android' in os:
os = 'android'
elif 'win' in os or 'mingw' in os:
os = 'windows'
cfg = [
"target_arch = \"" + arch + "\"",
"target_os = \"" + os + "\"",
]
diff --git a/src/libgreen/stack.rs b/src/libgreen/stack.rs
index 5d8c174..36a12ad 100644
--- a/src/libgreen/stack.rs
+++ b/src/libgreen/stack.rs
@@ -23,20 +23,20 @@ pub struct Stack {
// Try to use MAP_STACK on platforms that support it (it's what we're doing
// anyway), but some platforms don't support it at all. For example, it appears
// that there's a bug in freebsd that MAP_STACK implies MAP_FIXED (so it always
// panics): http://lists.freebsd.org/pipermail/freebsd-bugs/2011-July/044840.html
//
// DragonFly BSD also seems to suffer from the same problem. When MAP_STACK is
// used, it returns the same `ptr` multiple times.
-#[cfg(not(any(windows, target_os = "freebsd", target_os = "dragonfly")))]
+#[cfg(not(any(windows, target_os = "freebsd", target_os = "openbsd", target_os = "dragonfly")))]
static STACK_FLAGS: libc::c_int = libc::MAP_STACK | libc::MAP_PRIVATE |
libc::MAP_ANON;
-#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+#[cfg(any(target_os = "freebsd", target_os = "openbsd", target_os = "dragonfly"))]
static STACK_FLAGS: libc::c_int = libc::MAP_PRIVATE | libc::MAP_ANON;
#[cfg(windows)]
static STACK_FLAGS: libc::c_int = 0;
impl Stack {
/// Allocate a new stack of `size`. If size = 0, this will panic. Use
/// `dummy_stack` if you want a zero-sized stack.
pub fn new(size: uint) -> Stack {
diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs
index 1a86ef2..017ee09 100644
--- a/src/liblibc/lib.rs
+++ b/src/liblibc/lib.rs
@@ -279,30 +279,31 @@ pub use funcs::bsd43::{shutdown};
#[cfg(windows)] pub use funcs::extra::kernel32::{DisconnectNamedPipe, OpenProcess};
#[cfg(windows)] pub use funcs::extra::kernel32::{MoveFileExW, VirtualProtect};
#[cfg(windows)] pub use funcs::extra::msvcrt::{get_osfhandle, open_osfhandle};
#[cfg(windows)] pub use funcs::extra::winsock::{ioctlsocket};
#[cfg(any(target_os = "linux",
target_os = "android",
target_os = "freebsd",
- target_os = "dragonfly"))]
+ target_os = "dragonfly",
+ target_os = "openbsd"))]
pub use consts::os::posix01::{CLOCK_REALTIME, CLOCK_MONOTONIC};
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use funcs::posix01::unistd::{fdatasync};
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use types::os::arch::extra::{sockaddr_ll};
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use consts::os::extra::{AF_PACKET};
#[cfg(all(unix, not(target_os = "freebsd")))]
pub use consts::os::extra::{MAP_STACK};
-#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+#[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
pub use consts::os::bsd44::{TCP_KEEPIDLE};
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub use consts::os::bsd44::{TCP_KEEPALIVE};
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub use consts::os::extra::{F_FULLFSYNC};
#[cfg(any(target_os = "macos", target_os = "ios"))]
@@ -1260,16 +1261,324 @@ pub mod types {
}
pub mod bsd44 {
}
pub mod extra {
}
}
}
+ #[cfg(target_os = "openbsd")]
+ pub mod os {
+ pub mod common {
+ pub mod posix01 {
+ use types::common::c95::{c_void};
+ use types::os::arch::c95::{c_char, c_int, size_t,
+ time_t, suseconds_t, c_long};
+ use types::os::arch::c99::{uintptr_t};
+
+ pub type pthread_t = uintptr_t;
+
+ #[repr(C)]
+ pub struct glob_t {
+ pub gl_pathc: size_t,
+ pub __unused1: size_t,
+ pub gl_offs: size_t,
+ pub __unused2: c_int,
+ pub gl_pathv: *mut *mut c_char,
+
+ pub __unused3: *mut c_void,
+
+ pub __unused4: *mut c_void,
+ pub __unused5: *mut c_void,
+ pub __unused6: *mut c_void,
+ pub __unused7: *mut c_void,
+ pub __unused8: *mut c_void,
+ }
+
+ #[repr(C)]
+ pub struct timeval {
+ pub tv_sec: time_t,
+ pub tv_usec: suseconds_t,
+ }
+
+ #[repr(C)]
+ pub struct timespec {
+ pub tv_sec: time_t,
+ pub tv_nsec: c_long,
+ }
+
+ pub enum timezone {}
+
+ pub type sighandler_t = size_t;
+ }
+ pub mod bsd44 {
+ use types::common::c95::{c_void};
+ use 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;
+ #[repr(C)]
+ pub struct sockaddr {
+ pub sa_len: u8,
+ pub sa_family: sa_family_t,
+ pub sa_data: [u8, ..14],
+ }
+ #[repr(C)]
+ pub struct sockaddr_storage {
+ pub ss_len: u8,
+ pub ss_family: sa_family_t,
+ pub __ss_pad1: [u8, ..6],
+ pub __ss_align: i64,
+ pub __ss_pad2: [u8, ..112],
+ }
+ #[repr(C)]
+ pub struct sockaddr_in {
+ pub sin_len: u8,
+ pub sin_family: sa_family_t,
+ pub sin_port: in_port_t,
+ pub sin_addr: in_addr,
+ pub sin_zero: [u8, ..8],
+ }
+ #[repr(C)]
+ pub struct in_addr {
+ pub s_addr: in_addr_t,
+ }
+ #[repr(C)]
+ pub struct sockaddr_in6 {
+ pub sin6_len: u8,
+ pub sin6_family: sa_family_t,
+ pub sin6_port: in_port_t,
+ pub sin6_flowinfo: u32,
+ pub sin6_addr: in6_addr,
+ pub sin6_scope_id: u32,
+ }
+ #[repr(C)]
+ pub struct in6_addr {
+ pub s6_addr: [u16, ..8]
+ }
+ #[repr(C)]
+ pub struct ip_mreq {
+ pub imr_multiaddr: in_addr,
+ pub imr_interface: in_addr,
+ }
+ #[repr(C)]
+ pub struct ip6_mreq {
+ pub ipv6mr_multiaddr: in6_addr,
+ pub ipv6mr_interface: c_uint,
+ }
+ #[repr(C)]
+ pub struct addrinfo {
+ pub ai_flags: c_int,
+ pub ai_family: c_int,
+ pub ai_socktype: c_int,
+ pub ai_protocol: c_int,
+ pub ai_addrlen: socklen_t,
+ pub ai_canonname: *mut c_char,
+ pub ai_addr: *mut sockaddr,
+ pub ai_next: *mut addrinfo,
+ }
+ #[repr(C)]
+ pub struct sockaddr_un {
+ pub sun_len: u8,
+ pub sun_family: sa_family_t,
+ pub sun_path: [c_char, ..104]
+ }
+ #[repr(C)]
+ pub struct ifaddrs {
+ pub ifa_next: *mut ifaddrs,
+ pub ifa_name: *mut c_char,
+ pub ifa_flags: c_uint,
+ pub ifa_addr: *mut sockaddr,
+ pub ifa_netmask: *mut sockaddr,
+ pub ifa_dstaddr: *mut sockaddr,
+ pub ifa_data: *mut c_void
+ }
+ }
+ }
+
+ #[cfg(target_arch = "x86")]
+ 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 = i32;
+ pub type uintptr_t = u32;
+ pub type intmax_t = i64;
+ pub type uintmax_t = u64;
+ }
+ pub mod posix88 {
+ pub type off_t = i64;
+ pub type dev_t = i32;
+ 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 = i32;
+ }
+ pub mod posix01 {
+ use types::common::c95::{c_void};
+ use types::os::arch::c95::{c_uint, c_long, time_t};
+ use types::os::arch::posix88::{dev_t, gid_t, ino_t};
+ use types::os::arch::posix88::{mode_t, off_t};
+ use types::os::arch::posix88::{uid_t};
+
+ pub type nlink_t = u32;
+ pub type blkcnt_t = i64;
+
+ #[repr(C)]
+ pub struct stat {
+ pub st_mode: mode_t,
+ pub st_dev: dev_t,
+ pub st_ino: ino_t,
+ pub st_nlink: nlink_t,
+ pub st_uid: uid_t,
+ pub st_gid: gid_t,
+ pub st_rdev: dev_t,
+ pub st_atime: time_t,
+ pub st_atime_nsec: c_long,
+ pub st_mtime: time_t,
+ pub st_mtime_nsec: c_long,
+ pub st_ctime: time_t,
+ pub st_ctime_nsec: c_long,
+ pub st_size: off_t,
+ pub st_blocks: blkcnt_t,
+ pub st_blksize: c_uint,
+ pub st_flags: c_uint,
+ pub st_gen: c_uint,
+ }
+
+ #[repr(C)]
+ pub struct utimbuf {
+ pub actime: time_t,
+ pub modtime: time_t,
+ }
+
+ pub type pthread_attr_t = *mut c_void;
+ }
+ 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 = 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 = i64;
+ pub type uintptr_t = u64;
+ pub type intmax_t = i64;
+ pub type uintmax_t = u64;
+ }
+ 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 types::common::c95::{c_void};
+ use types::os::arch::c95::{c_uint, c_long, time_t};
+ use types::os::arch::posix88::{dev_t, gid_t, ino_t};
+ use types::os::arch::posix88::{mode_t, off_t};
+ use types::os::arch::posix88::{uid_t};
+
+ pub type nlink_t = u16;
+ pub type blkcnt_t = i64;
+
+ #[repr(C)]
+ pub struct stat {
+ pub st_mode: mode_t,
+ pub st_dev: dev_t,
+ pub st_ino: ino_t,
+ pub st_nlink: nlink_t,
+ pub st_uid: uid_t,
+ pub st_gid: gid_t,
+ pub st_rdev: dev_t,
+ pub st_atime: time_t,
+ pub st_atime_nsec: c_long,
+ pub st_mtime: time_t,
+ pub st_mtime_nsec: c_long,
+ pub st_ctime: time_t,
+ pub st_ctime_nsec: c_long,
+ pub st_size: off_t,
+ pub st_blocks: blkcnt_t,
+ pub st_blksize: c_uint,
+ pub st_flags: c_uint,
+ pub st_gen: c_uint,
+ }
+
+ #[repr(C)]
+ pub struct utimbuf {
+ pub actime: time_t,
+ pub modtime: time_t,
+ }
+
+ pub type pthread_attr_t = *mut c_void;
+ }
+ pub mod posix08 {
+ }
+ pub mod bsd44 {
+ }
+ pub mod extra {
+ }
+ }
+ }
+
#[cfg(target_os = "windows")]
pub mod os {
pub mod common {
pub mod posix01 {
use types::os::arch::c95::{c_short, time_t, c_long};
use types::os::arch::extra::{int64, time64_t};
use types::os::arch::posix88::{dev_t, ino_t};
@@ -3165,17 +3474,17 @@ pub mod consts {
pub const _SC_VERSION : c_int = 25;
pub const _SC_RE_DUP_MAX : c_int = 26;
pub const _SC_STREAM_MAX : c_int = 27;
pub const _SC_TZNAME_MAX : c_int = 28;
pub const _SC_PAGESIZE : c_int = 39;
}
}
- #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
pub mod os {
pub mod c95 {
use types::os::arch::c95::{c_int, c_uint};
pub const EXIT_FAILURE : c_int = 1;
pub const EXIT_SUCCESS : c_int = 0;
pub const RAND_MAX : c_int = 2147483647;
pub const EOF : c_int = -1;
@@ -3435,16 +3744,19 @@ pub mod consts {
target_arch = "mipsel",
target_arch = "x86",
target_arch = "x86_64")))]
pub const PTHREAD_STACK_MIN: size_t = 2048;
#[cfg(target_os = "dragonfly")]
pub const PTHREAD_STACK_MIN: size_t = 1024;
+ #[cfg(target_os = "openbsd")]
+ pub const PTHREAD_STACK_MIN: size_t = 2048;
+
pub const CLOCK_REALTIME: c_int = 0;
pub const CLOCK_MONOTONIC: c_int = 4;
}
pub mod posix08 {
}
pub mod bsd44 {
use types::os::arch::c95::c_int;
@@ -4270,44 +4582,47 @@ pub mod funcs {
}
}
#[cfg(any(target_os = "linux",
target_os = "android",
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
- target_os = "dragonfly"))]
+ target_os = "dragonfly",
+ target_os = "openbsd"))]
pub mod posix88 {
pub mod stat_ {
use types::os::arch::c95::{c_char, c_int};
use types::os::arch::posix01::stat;
use types::os::arch::posix88::mode_t;
extern {
pub fn chmod(path: *const c_char, mode: mode_t) -> c_int;
pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
#[cfg(any(target_os = "linux",
target_os = "freebsd",
target_os = "dragonfly",
+ target_os = "openbsd",
target_os = "android",
target_os = "ios"))]
pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
#[cfg(target_os = "macos")]
#[link_name = "fstat64"]
pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int;
pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int;
#[cfg(any(target_os = "linux",
target_os = "freebsd",
target_os = "dragonfly",
+ target_os = "openbsd",
target_os = "android",
target_os = "ios"))]
pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
#[cfg(target_os = "macos")]
#[link_name = "stat64"]
pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
}
@@ -4489,26 +4804,28 @@ pub mod funcs {
}
#[cfg(any(target_os = "linux",
target_os = "android",
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
- target_os = "dragonfly"))]
+ target_os = "dragonfly",
+ target_os = "openbsd"))]
pub mod posix01 {
pub mod stat_ {
use types::os::arch::c95::{c_char, c_int};
use types::os::arch::posix01::stat;
extern {
#[cfg(any(target_os = "linux",
target_os = "freebsd",
target_os = "dragonfly",
+ target_os = "openbsd",
target_os = "android",
target_os = "ios"))]
pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
#[cfg(target_os = "macos")]
#[link_name = "lstat64"]
pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
}
@@ -4606,17 +4923,18 @@ pub mod funcs {
#[cfg(any(target_os = "windows",
target_os = "linux",
target_os = "android",
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
- target_os = "dragonfly"))]
+ target_os = "dragonfly",
+ target_os = "openbsd"))]
pub mod posix08 {
pub mod unistd {
}
}
#[cfg(not(windows))]
pub mod bsd43 {
use types::common::c95::{c_void};
@@ -4692,17 +5010,18 @@ pub mod funcs {
addrlen: c_int) -> c_int;
pub fn shutdown(socket: SOCKET, how: c_int) -> c_int;
}
}
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
- target_os = "dragonfly"))]
+ target_os = "dragonfly",
+ target_os = "openbsd"))]
pub mod bsd44 {
use types::common::c95::{c_void};
use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, c_ulong, size_t};
extern {
pub fn ioctl(d: c_int, request: c_ulong, ...) -> c_int;
pub fn sysctl(name: *mut c_int,
namelen: c_uint,
@@ -4755,17 +5074,17 @@ pub mod funcs {
use types::os::arch::c95::{c_char, c_int};
extern {
pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32)
-> c_int;
}
}
- #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))]
pub mod extra {
}
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod extra {
}
diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs
index 30c916f..dc6e3b5 100644
--- a/src/libnative/io/process.rs
+++ b/src/libnative/io/process.rs
@@ -845,17 +845,18 @@ fn translate_status(status: c_int) -> rtio::ProcessExit {
pub fn WIFEXITED(status: i32) -> bool { (status & 0xff) == 0 }
pub fn WEXITSTATUS(status: i32) -> i32 { (status >> 8) & 0xff }
pub fn WTERMSIG(status: i32) -> i32 { status & 0x7f }
}
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
- target_os = "dragonfly"))]
+ target_os = "dragonfly",
+ target_os = "openbsd"))]
mod imp {
pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 }
pub fn WEXITSTATUS(status: i32) -> i32 { status >> 8 }
pub fn WTERMSIG(status: i32) -> i32 { status & 0o177 }
}
if imp::WIFEXITED(status) {
rtio::ExitStatus(imp::WEXITSTATUS(status) as int)
diff --git a/src/librustc_back/arm.rs b/src/librustc_back/arm.rs
index 134f710..55904a0 100644
--- a/src/librustc_back/arm.rs
+++ b/src/librustc_back/arm.rs
@@ -56,17 +56,17 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
abi::OsAndroid => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}
- abi::OsFreebsd | abi::OsDragonfly => {
+ abi::OsFreebsd | abi::OsDragonfly | abi::OsOpenbsd => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}
},
diff --git a/src/librustc_back/mips.rs b/src/librustc_back/mips.rs
index 322f001..7e6b7f6 100644
--- a/src/librustc_back/mips.rs
+++ b/src/librustc_back/mips.rs
@@ -51,17 +51,17 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
abi::OsAndroid => {
"E-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}
- abi::OsFreebsd | abi::OsDragonfly => {
+ abi::OsFreebsd | abi::OsDragonfly | abi::OsOpenbsd => {
"E-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}
},
diff --git a/src/librustc_back/mipsel.rs b/src/librustc_back/mipsel.rs
index e7ce5b0..6b7df49 100644
--- a/src/librustc_back/mipsel.rs
+++ b/src/librustc_back/mipsel.rs
@@ -51,17 +51,17 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
abi::OsAndroid => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}
- abi::OsFreebsd | abi::OsDragonfly => {
+ abi::OsFreebsd | abi::OsDragonfly | abi::OsOpenbsd => {
"e-p:32:32:32\
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
-f32:32:32-f64:64:64\
-v64:64:64-v128:64:128\
-a0:0:64-n32".to_string()
}
},
diff --git a/src/librustc_back/rpath.rs b/src/librustc_back/rpath.rs
index 974d8f8..4a45eb4 100644
--- a/src/librustc_back/rpath.rs
+++ b/src/librustc_back/rpath.rs
@@ -225,16 +225,31 @@ mod test {
get_install_prefix_lib_path: || panic!(),
realpath: |p| Ok(p.clone())
};
let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so"));
assert_eq!(res.as_slice(), "$ORIGIN/../lib");
}
#[test]
+ #[cfg(target_os = "openbsd")]
+ fn test_rpath_relative() {
+ let config = &mut RPathConfig {
+ used_crates: Vec::new(),
+ has_rpath: true,
+ is_like_osx: false,
+ out_filename: Path::new("bin/rustc"),
+ get_install_prefix_lib_path: || panic!(),
+ realpath: |p| Ok(p.clone())
+ };
+ let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so"));
+ assert_eq!(res.as_slice(), "$ORIGIN/../lib");
+ }
+
+ #[test]
#[cfg(target_os = "macos")]
fn test_rpath_relative() {
let config = &mut RPathConfig {
used_crates: Vec::new(),
has_rpath: true,
is_like_osx: true,
out_filename: Path::new("bin/rustc"),
get_install_prefix_lib_path: || panic!(),
diff --git a/src/librustc_back/target/i386_unknown_openbsd.rs b/src/librustc_back/target/i386_unknown_openbsd.rs
new file mode 100644
index 0000000..936fbaf
--- /dev/null
+++ b/src/librustc_back/target/i386_unknown_openbsd.rs
@@ -0,0 +1,26 @@
+// Copyright 2014 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.
+
+use target::Target;
+
+pub fn target() -> Target {
+ let mut base = super::openbsd_base::opts();
+ base.pre_link_args.push("-m32".to_string());
+
+ Target {
+ data_layout: "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
+ llvm_target: "i386-unknown-openbsd".to_string(),
+ target_endian: "little".to_string(),
+ target_word_size: "32".to_string(),
+ arch: "x86".to_string(),
+ target_os: "openbsd".to_string(),
+ options: base,
+ }
+}
diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs
index d7b4285..e2c3e85 100644
--- a/src/librustc_back/target/mod.rs
+++ b/src/librustc_back/target/mod.rs
@@ -50,33 +50,36 @@ use syntax::{diagnostic, abi};
use std::default::Default;
use std::io::fs::PathExtensions;
mod windows_base;
mod linux_base;
mod apple_base;
mod freebsd_base;
mod dragonfly_base;
+mod openbsd_base;
mod arm_apple_ios;
mod arm_linux_androideabi;
mod arm_unknown_linux_gnueabi;
mod arm_unknown_linux_gnueabihf;
mod i686_apple_darwin;
mod i386_apple_ios;
mod i686_pc_windows_gnu;
mod i686_unknown_dragonfly;
mod i686_unknown_linux_gnu;
+mod i386_unknown_openbsd;
mod mips_unknown_linux_gnu;
mod mipsel_unknown_linux_gnu;
mod x86_64_apple_darwin;
mod x86_64_pc_windows_gnu;
mod x86_64_unknown_freebsd;
mod x86_64_unknown_dragonfly;
mod x86_64_unknown_linux_gnu;
+mod x86_64_unknown_openbsd;
/// Everything `rustc` knows about how to compile for a specific target.
///
/// Every field here must be specified, and has no default value.
#[deriving(Clone, Show)]
pub struct Target {
/// [Data layout](http://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM.
pub data_layout: String,
@@ -337,16 +340,19 @@ impl Target {
arm_unknown_linux_gnueabi,
arm_unknown_linux_gnueabihf,
x86_64_unknown_freebsd,
i686_unknown_dragonfly,
x86_64_unknown_dragonfly,
+ i386_unknown_openbsd,
+ x86_64_unknown_openbsd,
+
x86_64_apple_darwin,
i686_apple_darwin,
i386_apple_ios,
arm_apple_ios,
x86_64_pc_windows_gnu,
i686_pc_windows_gnu
)
diff --git a/src/librustc_back/target/openbsd_base.rs b/src/librustc_back/target/openbsd_base.rs
new file mode 100644
index 0000000..500c636
--- /dev/null
+++ b/src/librustc_back/target/openbsd_base.rs
@@ -0,0 +1,30 @@
+// Copyright 2014 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.
+
+use target::TargetOptions;
+use std::default::Default;
+
+pub fn opts() -> TargetOptions {
+ TargetOptions {
+ linker: "cc".to_string(),
+ dynamic_linking: true,
+ executables: true,
+ morestack: true,
+ has_rpath: true,
+ pre_link_args: vec!(
+ "-L/usr/lib".to_string(),
+ "-L/usr/lib/gcc".to_string(),
+ "-L/usr/local/lib".to_string(),
+ ),
+
+ .. Default::default()
+ }
+}
+
diff --git a/src/librustc_back/target/x86_64_unknown_openbsd.rs b/src/librustc_back/target/x86_64_unknown_openbsd.rs
new file mode 100644
index 0000000..f985b71
--- /dev/null
+++ b/src/librustc_back/target/x86_64_unknown_openbsd.rs
@@ -0,0 +1,28 @@
+// Copyright 2014 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.
+
+use target::Target;
+
+pub fn target() -> Target {
+ let mut base = super::openbsd_base::opts();
+ base.pre_link_args.push("-m64".to_string());
+
+ Target {
+ data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
+ f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-\
+ s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
+ llvm_target: "x86_64-unknown-openbsd".to_string(),
+ target_endian: "little".to_string(),
+ target_word_size: "64".to_string(),
+ arch: "x86_64".to_string(),
+ target_os: "openbsd".to_string(),
+ options: base,
+ }
+}
diff --git a/src/librustc_back/x86.rs b/src/librustc_back/x86.rs
index 21c4fd4..87d7efa 100644
--- a/src/librustc_back/x86.rs
+++ b/src/librustc_back/x86.rs
@@ -40,20 +40,17 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os)
abi::OsLinux => {
"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
}
abi::OsAndroid => {
"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
}
- abi::OsFreebsd => {
- "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
- }
- abi::OsDragonfly => {
+ abi::OsFreebsd | abi::OsDragonfly | abi::OsOpenbsd => {
"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
}
},
target_triple: target_triple,