Skip to content

Commit 12e30b3

Browse files
committed
---
yaml --- r: 233854 b: refs/heads/beta c: ce40c48 h: refs/heads/master v: v3
1 parent 8191b78 commit 12e30b3

File tree

9 files changed

+138
-9
lines changed

9 files changed

+138
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: ef4853041a091f928a44aac28abf431965ce6fa2
26+
refs/heads/beta: ce40c48c4562fbc73a00d8023c221b54c7f2d466
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/libcollectionstest/str.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,37 @@ fn test_bytes_revator() {
833833
}
834834
}
835835

836+
#[test]
837+
fn test_bytesator_nth() {
838+
let s = "ศไทย中华Việt Nam";
839+
let v = [
840+
224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228,
841+
184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97,
842+
109
843+
];
844+
845+
let mut b = s.bytes();
846+
assert_eq!(b.nth(2).unwrap(), v[2]);
847+
assert_eq!(b.nth(10).unwrap(), v[10]);
848+
assert_eq!(b.nth(200), None);
849+
}
850+
851+
#[test]
852+
fn test_bytesator_count() {
853+
let s = "ศไทย中华Việt Nam";
854+
855+
let b = s.bytes();
856+
assert_eq!(b.count(), 28)
857+
}
858+
859+
#[test]
860+
fn test_bytesator_last() {
861+
let s = "ศไทย中华Việt Nam";
862+
863+
let b = s.bytes();
864+
assert_eq!(b.last().unwrap(), 109)
865+
}
866+
836867
#[test]
837868
fn test_char_indicesator() {
838869
let s = "ศไทย中华Việt Nam";

branches/beta/src/libcore/str/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,21 @@ impl<'a> Iterator for Bytes<'a> {
411411
fn size_hint(&self) -> (usize, Option<usize>) {
412412
self.0.size_hint()
413413
}
414+
415+
#[inline]
416+
fn count(self) -> usize {
417+
self.0.count()
418+
}
419+
420+
#[inline]
421+
fn last(self) -> Option<Self::Item> {
422+
self.0.last()
423+
}
424+
425+
#[inline]
426+
fn nth(&mut self, n: usize) -> Option<Self::Item> {
427+
self.0.nth(n)
428+
}
414429
}
415430

416431
#[stable(feature = "rust1", since = "1.0.0")]

branches/beta/src/liblibc/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3614,6 +3614,7 @@ pub mod consts {
36143614
pub mod posix08 {
36153615
use types::os::arch::c95::c_int;
36163616
pub const O_CLOEXEC: c_int = 0x80000;
3617+
pub const F_DUPFD_CLOEXEC: c_int = 1030;
36173618
}
36183619
#[cfg(any(target_arch = "arm",
36193620
target_arch = "aarch64",
@@ -4285,11 +4286,13 @@ pub mod consts {
42854286
pub mod posix08 {
42864287
use types::os::arch::c95::c_int;
42874288
pub const O_CLOEXEC: c_int = 0x100000;
4289+
pub const F_DUPFD_CLOEXEC: c_int = 17;
42884290
}
42894291
#[cfg(target_os = "dragonfly")]
42904292
pub mod posix08 {
42914293
use types::os::arch::c95::c_int;
42924294
pub const O_CLOEXEC: c_int = 0x20000;
4295+
pub const F_DUPFD_CLOEXEC: c_int = 17;
42934296
}
42944297
pub mod bsd44 {
42954298
use types::os::arch::c95::c_int;
@@ -4657,7 +4660,6 @@ pub mod consts {
46574660
pub const F_GETLK : c_int = 7;
46584661
pub const F_SETLK : c_int = 8;
46594662
pub const F_SETLKW : c_int = 9;
4660-
pub const F_DUPFD_CLOEXEC : c_int = 10;
46614663

46624664
pub const SIGTRAP : c_int = 5;
46634665
pub const SIG_IGN: size_t = 1;
@@ -4739,11 +4741,13 @@ pub mod consts {
47394741
pub mod posix08 {
47404742
use types::os::arch::c95::c_int;
47414743
pub const O_CLOEXEC: c_int = 0x10000;
4744+
pub const F_DUPFD_CLOEXEC: c_int = 10;
47424745
}
47434746
#[cfg(target_os = "netbsd")]
47444747
pub mod posix08 {
47454748
use types::os::arch::c95::c_int;
47464749
pub const O_CLOEXEC: c_int = 0x400000;
4750+
pub const F_DUPFD_CLOEXEC: c_int = 12;
47474751
}
47484752
pub mod bsd44 {
47494753
use types::os::arch::c95::c_int;
@@ -5186,6 +5190,7 @@ pub mod consts {
51865190
pub mod posix08 {
51875191
use types::os::arch::c95::c_int;
51885192
pub const O_CLOEXEC: c_int = 0x1000000;
5193+
pub const F_DUPFD_CLOEXEC: c_int = 67;
51895194
}
51905195
pub mod bsd44 {
51915196
use types::os::arch::c95::c_int;

branches/beta/src/librustc_back/target/dragonfly_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn opts() -> TargetOptions {
2828
"-Wl,--as-needed".to_string(),
2929
),
3030
position_independent_executables: true,
31-
archive_format: "bsd".to_string(),
31+
archive_format: "gnu".to_string(),
3232
exe_allocation_crate: super::best_allocator(),
3333
.. Default::default()
3434
}

branches/beta/src/librustc_typeck/check/intrinsic.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,13 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt,
408408
let mut structural_to_nomimal = HashMap::new();
409409

410410
let sig = tcx.no_late_bound_regions(i_ty.ty.fn_sig()).unwrap();
411+
if intr.inputs.len() != sig.inputs.len() {
412+
span_err!(tcx.sess, it.span, E0444,
413+
"platform-specific intrinsic has invalid number of \
414+
arguments: found {}, expected {}",
415+
intr.inputs.len(), sig.inputs.len());
416+
return
417+
}
411418
let input_pairs = intr.inputs.iter().zip(&sig.inputs);
412419
for (i, (expected_arg, arg)) in input_pairs.enumerate() {
413420
match_intrinsic_type_to_type(tcx, &format!("argument {}", i + 1), it.span,

branches/beta/src/librustc_typeck/diagnostics.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,34 @@ PhantomData can also be used to express information about unused type
30183018
parameters. You can read more about it in the API documentation:
30193019
30203020
https://doc.rust-lang.org/std/marker/struct.PhantomData.html
3021-
"##
3021+
"##,
3022+
3023+
E0444: r##"
3024+
A platform-specific intrinsic function has wrong number of arguments.
3025+
Erroneous code example:
3026+
3027+
```
3028+
#[repr(simd)]
3029+
struct f64x2(f64, f64);
3030+
3031+
extern "platform-intrinsic" {
3032+
fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32;
3033+
// error: platform-specific intrinsic has invalid number of arguments
3034+
}
3035+
```
3036+
3037+
Please refer to the function declaration to see if it corresponds
3038+
with yours. Example:
3039+
3040+
```
3041+
#[repr(simd)]
3042+
struct f64x2(f64, f64);
3043+
3044+
extern "platform-intrinsic" {
3045+
fn x86_mm_movemask_pd(x: f64x2) -> i32; // ok!
3046+
}
3047+
```
3048+
"##,
30223049

30233050
}
30243051

branches/beta/src/libstd/sys/unix/net.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ use prelude::v1::*;
1313
use ffi::CStr;
1414
use io;
1515
use libc::{self, c_int, size_t};
16+
use net::SocketAddr;
1617
use str;
18+
use sync::atomic::{self, AtomicBool};
1719
use sys::c;
18-
use net::SocketAddr;
1920
use sys::fd::FileDesc;
2021
use sys_common::{AsInner, FromInner, IntoInner};
2122
use sys_common::net::{getsockopt, setsockopt};
@@ -66,10 +67,29 @@ impl Socket {
6667
}
6768

6869
pub fn duplicate(&self) -> io::Result<Socket> {
69-
let fd = try!(cvt(unsafe { libc::dup(self.0.raw()) }));
70-
let fd = FileDesc::new(fd);
71-
fd.set_cloexec();
72-
Ok(Socket(fd))
70+
use libc::funcs::posix88::fcntl::fcntl;
71+
let make_socket = |fd| {
72+
let fd = FileDesc::new(fd);
73+
fd.set_cloexec();
74+
Socket(fd)
75+
};
76+
static EMULATE_F_DUPFD_CLOEXEC: AtomicBool = AtomicBool::new(false);
77+
if !EMULATE_F_DUPFD_CLOEXEC.load(atomic::Ordering::Relaxed) {
78+
match cvt(unsafe { fcntl(self.0.raw(), libc::F_DUPFD_CLOEXEC, 0) }) {
79+
// `EINVAL` can only be returned on two occasions: Invalid
80+
// command (second parameter) or invalid third parameter. 0 is
81+
// always a valid third parameter, so it must be the second
82+
// parameter.
83+
//
84+
// Store the result in a global variable so we don't try each
85+
// syscall twice.
86+
Err(ref e) if e.raw_os_error() == Some(libc::EINVAL) => {
87+
EMULATE_F_DUPFD_CLOEXEC.store(true, atomic::Ordering::Relaxed);
88+
}
89+
res => return res.map(make_socket),
90+
}
91+
}
92+
cvt(unsafe { fcntl(self.0.raw(), libc::F_DUPFD, 0) }).map(make_socket)
7393
}
7494

7595
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test number of arguments in platform-specific intrinsic function
12+
// This is the error E0444
13+
14+
#![feature(repr_simd, platform_intrinsics)]
15+
16+
#[repr(simd)]
17+
struct f64x2(f64, f64);
18+
19+
extern "platform-intrinsic" {
20+
fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ platform-specific intrinsic
21+
}
22+
23+
pub fn main() {
24+
}

0 commit comments

Comments
 (0)