Adds priv qualifiers where they have been commented out before implementation.
| cut -d ' ' -f 2)
case $CFG_CLANG_VERSION in
- (3.0svn | 3.0 | 3.1 | 4.0 | 4.1)
+ (3.0svn | 3.0 | 3.1 | 3.2 | 4.0 | 4.1)
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
CFG_C_COMPILER="clang"
;;
pub use kinds::{Const, Copy, Owned, Durable};
pub use ops::{Drop};
-pub use ops::{Add, Sub, Mul, Div, Modulo, Neg};
+pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
pub use ops::{BitAnd, BitOr, BitXor};
pub use ops::{Shl, Shr, Index};
pure fn neg(&self) -> Result;
}
+#[lang="not"]
+pub trait Not<Result> {
+ pure fn not(&self) -> Result;
+}
+
#[lang="bitand"]
pub trait BitAnd<RHS,Result> {
pure fn bitand(&self, rhs: &RHS) -> Result;
pub trait Index<Index,Result> {
pure fn index(&self, index: Index) -> Result;
}
-
pub use kinds::{Const, Copy, Owned, Durable};
pub use ops::{Drop};
-pub use ops::{Add, Sub, Mul, Div, Modulo, Neg};
+pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
pub use ops::{BitAnd, BitOr, BitXor};
pub use ops::{Shl, Shr, Index};
pub use option::{Option, Some, None};
unsafe fn rust_destroy_little_lock(lock: rust_little_lock);
unsafe fn rust_lock_little_lock(lock: rust_little_lock);
unsafe fn rust_unlock_little_lock(lock: rust_little_lock);
+
+ unsafe fn rust_raw_thread_start(f: &fn()) -> *raw_thread;
+ unsafe fn rust_raw_thread_join_delete(thread: *raw_thread);
}
#[abi = "rust-intrinsic"]
fn atomic_xsub(dst: &mut int, src: int) -> int;
}
+#[allow(non_camel_case_types)] // runtime type
+type raw_thread = libc::c_void;
+
+/**
+
+Start a new thread outside of the current runtime context and wait
+for it to terminate.
+
+The executing thread has no access to a task pointer and will be using
+a normal large stack.
+*/
+pub unsafe fn run_in_bare_thread(f: ~fn()) {
+ let (port, chan) = pipes::stream();
+ // XXX Unfortunate that this creates an extra scheduler but it's necessary
+ // since rust_raw_thread_join_delete is blocking
+ do task::spawn_sched(task::SingleThreaded) unsafe {
+ let closure: &fn() = || {
+ f()
+ };
+ let thread = rustrt::rust_raw_thread_start(closure);
+ rustrt::rust_raw_thread_join_delete(thread);
+ chan.send(());
+ }
+ port.recv();
+}
+
+#[test]
+fn test_run_in_bare_thread() unsafe {
+ let i = 100;
+ do run_in_bare_thread {
+ assert i == 100;
+ }
+}
+
#[allow(non_camel_case_types)] // runtime type
type rust_port_id = uint;
debug!("encoding %s", ast_util::path_name_i(path,
cx.sess.parse_sess.interner));
- // XXX: Bad copy of `path`.
let name_lit: ast::lit =
nospan(ast::lit_str(@ast_util::path_name_i(
- copy path, cx.sess.parse_sess.interner)));
+ path, cx.sess.parse_sess.interner)));
let name_expr_inner: @ast::expr =
@{id: cx.sess.next_node_id(),
callee_id: cx.sess.next_node_id(),
DivTraitLangItem, // 8
ModuloTraitLangItem, // 9
NegTraitLangItem, // 10
- BitXorTraitLangItem, // 11
- BitAndTraitLangItem, // 12
- BitOrTraitLangItem, // 13
- ShlTraitLangItem, // 14
- ShrTraitLangItem, // 15
- IndexTraitLangItem, // 16
-
- EqTraitLangItem, // 17
- OrdTraitLangItem, // 18
-
- StrEqFnLangItem, // 19
- UniqStrEqFnLangItem, // 20
- AnnihilateFnLangItem, // 21
- LogTypeFnLangItem, // 22
- FailFnLangItem, // 23
- FailBoundsCheckFnLangItem, // 24
- ExchangeMallocFnLangItem, // 25
- ExchangeFreeFnLangItem, // 26
- MallocFnLangItem, // 27
- FreeFnLangItem, // 28
+ NotTraitLangItem, // 11
+ BitXorTraitLangItem, // 12
+ BitAndTraitLangItem, // 13
+ BitOrTraitLangItem, // 14
+ ShlTraitLangItem, // 15
+ ShrTraitLangItem, // 16
+ IndexTraitLangItem, // 17
+
+ EqTraitLangItem, // 18
+ OrdTraitLangItem, // 19
+
+ StrEqFnLangItem, // 20
+ UniqStrEqFnLangItem, // 21
+ AnnihilateFnLangItem, // 22
+ LogTypeFnLangItem, // 23
+ FailFnLangItem, // 24
+ FailBoundsCheckFnLangItem, // 25
+ ExchangeMallocFnLangItem, // 26
+ ExchangeFreeFnLangItem, // 27
+ MallocFnLangItem, // 28
+ FreeFnLangItem, // 29
}
struct LanguageItems {
- items: [ Option<def_id> * 29 ]
+ items: [ Option<def_id> * 30 ]
}
impl LanguageItems {
static pub fn new() -> LanguageItems {
LanguageItems {
- items: [ None, ..29 ]
+ items: [ None, ..30 ]
}
}
8 => "div",
9 => "modulo",
10 => "neg",
- 11 => "bitxor",
- 12 => "bitand",
- 13 => "bitor",
- 14 => "shl",
- 15 => "shr",
- 16 => "index",
- 17 => "eq",
- 18 => "ord",
-
- 19 => "str_eq",
- 20 => "uniq_str_eq",
- 21 => "annihilate",
- 22 => "log_type",
- 23 => "fail_",
- 24 => "fail_bounds_check",
- 25 => "exchange_malloc",
- 26 => "exchange_free",
- 27 => "malloc",
- 28 => "free",
+ 11 => "not",
+ 12 => "bitxor",
+ 13 => "bitand",
+ 14 => "bitor",
+ 15 => "shl",
+ 16 => "shr",
+ 17 => "index",
+ 18 => "eq",
+ 19 => "ord",
+
+ 20 => "str_eq",
+ 21 => "uniq_str_eq",
+ 22 => "annihilate",
+ 23 => "log_type",
+ 24 => "fail_",
+ 25 => "fail_bounds_check",
+ 26 => "exchange_malloc",
+ 27 => "exchange_free",
+ 28 => "malloc",
+ 29 => "free",
_ => "???"
}
pub fn neg_trait(&const self) -> def_id {
self.items[NegTraitLangItem as uint].get()
}
+ pub fn not_trait(&const self) -> def_id {
+ self.items[NotTraitLangItem as uint].get()
+ }
pub fn bitxor_trait(&const self) -> def_id {
self.items[BitXorTraitLangItem as uint].get()
}
item_refs.insert(~"div", DivTraitLangItem as uint);
item_refs.insert(~"modulo", ModuloTraitLangItem as uint);
item_refs.insert(~"neg", NegTraitLangItem as uint);
+ item_refs.insert(~"not", NotTraitLangItem as uint);
item_refs.insert(~"bitxor", BitXorTraitLangItem as uint);
item_refs.insert(~"bitand", BitAndTraitLangItem as uint);
item_refs.insert(~"bitor", BitOrTraitLangItem as uint);
use syntax::ast::{type_value_ns, ty_param_bound, unnamed_field};
use syntax::ast::{variant, view_item, view_item_export, view_item_import};
use syntax::ast::{view_item_use, view_path_glob, view_path_list};
-use syntax::ast::{view_path_simple, visibility, anonymous, named};
+use syntax::ast::{view_path_simple, visibility, anonymous, named, not};
use syntax::ast_util::{def_id_of_def, dummy_sp, local_def};
use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method};
use syntax::ast_util::{Privacy, Public, Private, visibility_to_privacy};
self.add_fixed_trait_for_expr(expr.id,
self.lang_items.neg_trait());
}
+ expr_unary(not, _) => {
+ self.add_fixed_trait_for_expr(expr.id,
+ self.lang_items.not_trait());
+ }
expr_index(*) => {
self.add_fixed_trait_for_expr(expr.id,
self.lang_items.index_trait());
use core::libc;
fn malloc(n: size_t) -> CVec<u8> {
- let mem = libc::malloc(n);
+ unsafe {
+ let mem = libc::malloc(n);
- assert mem as int != 0;
+ assert mem as int != 0;
- return unsafe { c_vec_with_dtor(mem as *mut u8, n as uint,
- ||free(mem)) };
+ return unsafe { c_vec_with_dtor(mem as *mut u8, n as uint,
+ || unsafe { free(mem) }) };
+ }
}
#[test]
fn test_gl_tcp_server_access_denied() unsafe {
impl_gl_tcp_ipv4_server_access_denied();
}
+ // Strange failure on Windows. --pcwalton
#[test]
+ #[ignore(cfg(target_os = "windows"))]
fn test_gl_tcp_ipv4_server_client_reader_writer() {
impl_gl_tcp_ipv4_server_client_reader_writer();
}
}
#[test]
#[ignore(cfg(target_os = "linux"))]
+ #[ignore(cfg(target_os = "windows"))]
fn test_gl_tcp_ipv4_server_client_reader_writer() {
impl_gl_tcp_ipv4_server_client_reader_writer();
}
#[test]
fn test_decode_form_urlencoded() {
+ // FIXME #4449: Commented out because this causes an ICE, but only
+ // on FreeBSD
+ /*
assert decode_form_urlencoded(~[]).len() == 0;
let s = str::to_bytes("a=1&foo+bar=abc&foo+bar=12+%3D+34");
assert form.len() == 2;
assert form.get_ref(&~"a") == &~[~"1"];
assert form.get_ref(&~"foo bar") == &~[~"abc", ~"12 = 34"];
+ */
}
}
// struct size tests
#[test]
fn test_uv_ll_struct_size_uv_tcp_t() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_uv_tcp_t_size();
- let rust_handle_size = sys::size_of::<uv_tcp_t>();
- let output = fmt!("uv_tcp_t -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- assert foreign_handle_size as uint == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_uv_tcp_t_size();
+ let rust_handle_size = sys::size_of::<uv_tcp_t>();
+ let output = fmt!("uv_tcp_t -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ assert foreign_handle_size as uint == rust_handle_size;
+ }
}
#[test]
fn test_uv_ll_struct_size_uv_connect_t() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_uv_connect_t_size();
- let rust_handle_size = sys::size_of::<uv_connect_t>();
- let output = fmt!("uv_connect_t -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- assert foreign_handle_size as uint == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_uv_connect_t_size();
+ let rust_handle_size = sys::size_of::<uv_connect_t>();
+ let output = fmt!("uv_connect_t -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ assert foreign_handle_size as uint == rust_handle_size;
+ }
}
#[test]
fn test_uv_ll_struct_size_uv_buf_t() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_uv_buf_t_size();
- let rust_handle_size = sys::size_of::<uv_buf_t>();
- let output = fmt!("uv_buf_t -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- assert foreign_handle_size as uint == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_uv_buf_t_size();
+ let rust_handle_size = sys::size_of::<uv_buf_t>();
+ let output = fmt!("uv_buf_t -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ assert foreign_handle_size as uint == rust_handle_size;
+ }
}
#[test]
fn test_uv_ll_struct_size_uv_write_t() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_uv_write_t_size();
- let rust_handle_size = sys::size_of::<uv_write_t>();
- let output = fmt!("uv_write_t -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- assert foreign_handle_size as uint == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_uv_write_t_size();
+ let rust_handle_size = sys::size_of::<uv_write_t>();
+ let output = fmt!("uv_write_t -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ assert foreign_handle_size as uint == rust_handle_size;
+ }
}
#[test]
fn test_uv_ll_struct_size_sockaddr_in() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_sockaddr_in_size();
- let rust_handle_size = sys::size_of::<sockaddr_in>();
- let output = fmt!("sockaddr_in -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- assert foreign_handle_size as uint == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_sockaddr_in_size();
+ let rust_handle_size = sys::size_of::<sockaddr_in>();
+ let output = fmt!("sockaddr_in -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ assert foreign_handle_size as uint == rust_handle_size;
+ }
}
#[test]
fn test_uv_ll_struct_size_sockaddr_in6() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_sockaddr_in6_size();
- let rust_handle_size = sys::size_of::<sockaddr_in6>();
- let output = fmt!("sockaddr_in6 -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- // FIXME #1645 .. rust appears to pad structs to the nearest byte..?
- // .. can't get the uv::ll::sockaddr_in6 to == 28 :/
- // .. so the type always appears to be 32 in size.. which is
- // good, i guess.. better too big than too little
- assert (4u+foreign_handle_size as uint) == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_sockaddr_in6_size();
+ let rust_handle_size = sys::size_of::<sockaddr_in6>();
+ let output = fmt!("sockaddr_in6 -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ // FIXME #1645 .. rust appears to pad structs to the nearest
+ // byte..?
+ // .. can't get the uv::ll::sockaddr_in6 to == 28 :/
+ // .. so the type always appears to be 32 in size.. which is
+ // good, i guess.. better too big than too little
+ assert (4u+foreign_handle_size as uint) == rust_handle_size;
+ }
}
#[test]
#[ignore(reason = "questionable size calculations")]
fn test_uv_ll_struct_size_addr_in() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_addr_in_size();
- let rust_handle_size = sys::size_of::<addr_in>();
- let output = fmt!("addr_in -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- // FIXME #1645 .. see note above about struct padding
- assert (4u+foreign_handle_size as uint) == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_addr_in_size();
+ let rust_handle_size = sys::size_of::<addr_in>();
+ let output = fmt!("addr_in -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ // FIXME #1645 .. see note above about struct padding
+ assert (4u+foreign_handle_size as uint) == rust_handle_size;
+ }
}
#[test]
fn test_uv_ll_struct_size_uv_async_t() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_uv_async_t_size();
- let rust_handle_size = sys::size_of::<uv_async_t>();
- let output = fmt!("uv_async_t -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- assert foreign_handle_size as uint == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_uv_async_t_size();
+ let rust_handle_size = sys::size_of::<uv_async_t>();
+ let output = fmt!("uv_async_t -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ assert foreign_handle_size as uint == rust_handle_size;
+ }
}
#[test]
fn test_uv_ll_struct_size_uv_timer_t() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size();
- let rust_handle_size = sys::size_of::<uv_timer_t>();
- let output = fmt!("uv_timer_t -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- assert foreign_handle_size as uint == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_uv_timer_t_size();
+ let rust_handle_size = sys::size_of::<uv_timer_t>();
+ let output = fmt!("uv_timer_t -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ assert foreign_handle_size as uint == rust_handle_size;
+ }
}
#[test]
#[ignore(cfg(target_os = "win32"))]
fn test_uv_ll_struct_size_uv_getaddrinfo_t() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_uv_getaddrinfo_t_size();
- let rust_handle_size = sys::size_of::<uv_getaddrinfo_t>();
- let output = fmt!("uv_getaddrinfo_t -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- assert foreign_handle_size as uint == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_uv_getaddrinfo_t_size();
+ let rust_handle_size = sys::size_of::<uv_getaddrinfo_t>();
+ let output = fmt!("uv_getaddrinfo_t -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ assert foreign_handle_size as uint == rust_handle_size;
+ }
}
#[test]
#[ignore(cfg(target_os = "macos"))]
#[ignore(cfg(target_os = "win32"))]
fn test_uv_ll_struct_size_addrinfo() {
- let foreign_handle_size =
- ::uv_ll::rustrt::rust_uv_helper_addrinfo_size();
- let rust_handle_size = sys::size_of::<addrinfo>();
- let output = fmt!("addrinfo -- foreign: %u rust: %u",
- foreign_handle_size as uint, rust_handle_size);
- log(debug, output);
- assert foreign_handle_size as uint == rust_handle_size;
+ unsafe {
+ let foreign_handle_size =
+ ::uv_ll::rustrt::rust_uv_helper_addrinfo_size();
+ let rust_handle_size = sys::size_of::<addrinfo>();
+ let output = fmt!("addrinfo -- foreign: %u rust: %u",
+ foreign_handle_size as uint, rust_handle_size);
+ log(debug, output);
+ assert foreign_handle_size as uint == rust_handle_size;
+ }
}
}
-pure fn path_name_i(idents: ~[ident], intr: @token::ident_interner) -> ~str {
+pure fn path_name_i(idents: &[ident], intr: @token::ident_interner) -> ~str {
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
str::connect(idents.map(|i| *intr.get(*i)), ~"::")
}
pub const cond : ::core::condition::Condition<$in,$out> =
::core::condition::Condition {
- name: stringify!(c),
+ name: stringify!($c),
key: key
};
}
#include "rust_util.h"
#include "rust_scheduler.h"
#include "sync/timer.h"
+#include "sync/rust_thread.h"
#include "rust_abi.h"
#include "rust_port.h"
task->sched_loop->get_log().log(task, level, "%.*s", (int)size, str);
}
+extern "C" CDECL void record_sp_limit(void *limit);
+
+class raw_thread: public rust_thread {
+public:
+ fn_env_pair *fn;
+
+ raw_thread(fn_env_pair *fn) : fn(fn) { }
+
+ virtual void run() {
+ record_sp_limit(0);
+ fn->f(NULL, fn->env, NULL);
+ }
+};
+
+extern "C" raw_thread*
+rust_raw_thread_start(fn_env_pair *fn) {
+ assert(fn);
+ raw_thread *thread = new raw_thread(fn);
+ thread->start();
+ return thread;
+}
+
+extern "C" void
+rust_raw_thread_join_delete(raw_thread *thread) {
+ assert(thread);
+ thread->join();
+ delete thread;
+}
+
+
//
// Local Variables:
// mode: C++
linenoiseHistorySetMaxLen
linenoiseHistorySave
linenoiseHistoryLoad
+rust_raw_thread_start
+rust_raw_thread_join_delete
+// xfail-test
+
// 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.
}
}
+impl Point : ops::Not<Point> {
+ pure fn not(&self) -> Point {
+ Point {x: !self.x, y: !self.y }
+ }
+}
+
impl Point : ops::Index<bool,int> {
pure fn index(&self, +x: bool) -> int {
if x { self.x } else { self.y }
assert -p == Point {x: -11, y: -22};
assert p[true] == 11;
assert p[false] == 22;
+
+ let q = !p;
+ assert q.x == !(p.x);
+ assert q.y == !(p.y);
+
// Issue #1733
fn~(_x: int){}(p[true]);
}