if align <= MIN_ALIGN {
libc::malloc(size as libc::size_t) as *mut u8
} else {
- let mut out = 0 as *mut libc::c_void;
+ let mut out = ptr::null();
let ret = posix_memalign(&mut out,
align as libc::size_t,
size as libc::size_t);
use std::io;
use std::mem;
use std::os;
+use std::ptr;
use std::rt;
use std::slice;
use std::sync::{Once, ONCE_INIT};
assert!(!DIRECTIVES.is_null());
let _directives: Box<Vec<directive::LogDirective>> =
mem::transmute(DIRECTIVES);
- DIRECTIVES = 0 as *const Vec<directive::LogDirective>;
+ DIRECTIVES = ptr::null();
if !FILTER.is_null() {
let _filter: Box<Regex> = mem::transmute(FILTER);
- FILTER = 0 as *const _;
+ FILTER = ptr::null();
}
});
}
pub use self::Diagnostic::*;
use libc::c_char;
+use std::ptr;
use {ValueRef, TwineRef, DebugLocRef, DiagnosticInfoRef};
let mut opt = OptimizationDiagnostic {
kind: kind,
- pass_name: 0 as *const c_char,
- function: 0 as ValueRef,
- debug_loc: 0 as DebugLocRef,
- message: 0 as TwineRef,
+ pass_name: ptr::null(),
+ function: ptr::null_mut(),
+ debug_loc: ptr::null_mut(),
+ message: ptr::null_mut(),
};
super::LLVMUnpackOptimizationDiagnostic(di,
use std::ffi::CString;
use std::cell::RefCell;
-use std::{raw, mem};
+use std::{raw, mem, ptr};
use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
use libc::{c_longlong, c_ulonglong, c_void};
use debuginfo::{DIBuilderRef, DIDescriptor,
LLVMInitializePowerPCAsmPrinter();
LLVMInitializePowerPCAsmParser();
- LLVMRustSetLLVMOptions(0 as c_int,
- 0 as *const _);
+ LLVMRustSetLLVMOptions(0 as c_int, ptr::null());
- LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
- LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
- LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
- LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
- LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
- LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
+ LLVMPassManagerBuilderPopulateModulePassManager(ptr::null_mut(), ptr::null_mut());
+ LLVMPassManagerBuilderPopulateLTOPassManager(ptr::null_mut(), ptr::null_mut(), False, False);
+ LLVMPassManagerBuilderPopulateFunctionPassManager(ptr::null_mut(), ptr::null_mut());
+ LLVMPassManagerBuilderSetOptLevel(ptr::null_mut(), 0 as c_uint);
+ LLVMPassManagerBuilderUseInlinerWithThreshold(ptr::null_mut(), 0 as c_uint);
+ LLVMWriteBitcodeToFile(ptr::null_mut(), ptr::null());
LLVMPassManagerBuilderCreate();
- LLVMPassManagerBuilderDispose(0 as *mut _);
+ LLVMPassManagerBuilderDispose(ptr::null_mut());
- LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
+ LLVMRustLinkInExternalBitcode(ptr::null_mut(), ptr::null(), 0 as size_t);
LLVMLinkInMCJIT();
LLVMLinkInInterpreter();
use std::ffi::CString;
use std::mem;
+use std::ptr;
use std::cell::RefCell;
use std::iter::repeat;
if n_elts == 0 {
return Vec::new();
}
- let mut elts: Vec<_> = repeat(Type { rf: 0 as TypeRef }).take(n_elts).collect();
+ let mut elts: Vec<_> = repeat(Type { rf: ptr::null_mut() }).take(n_elts).collect();
llvm::LLVMGetStructElementTypes(self.to_ref(),
elts.as_mut_ptr() as *mut TypeRef);
elts
pub fn func_params(&self) -> Vec<Type> {
unsafe {
let n_args = llvm::LLVMCountParamTypes(self.to_ref()) as uint;
- let mut args: Vec<_> = repeat(Type { rf: 0 as TypeRef }).take(n_args).collect();
+ let mut args: Vec<_> = repeat(Type { rf: ptr::null_mut() }).take(n_args).collect();
llvm::LLVMGetParamTypes(self.to_ref(),
args.as_mut_ptr() as *mut TypeRef);
args
use option::Option;
use option::Option::{Some, None};
use ops::{Deref, DerefMut, FnOnce};
+use ptr;
use result::Result::{Ok, Err};
use rt;
use slice::SliceExt;
// Make sure to free it at exit
rt::at_exit(|| {
mem::transmute::<_, Box<StdinReader>>(STDIN);
- STDIN = 0 as *const _;
+ STDIN = ptr::null();
});
});
use alloc::boxed::Box;
use core::mem;
+use core::ptr;
use core::cell::UnsafeCell;
use sync::atomic::{AtomicPtr, Ordering};
impl<T> Node<T> {
unsafe fn new(v: Option<T>) -> *mut Node<T> {
mem::transmute(box Node {
- next: AtomicPtr::new(0 as *mut Node<T>),
+ next: AtomicPtr::new(ptr::null_mut()),
value: v,
})
}
use core::cell::Cell;
use core::marker;
use core::mem;
+use core::ptr;
use core::uint;
use sync::mpsc::{Receiver, RecvError};
pub fn new() -> Select {
Select {
marker1: marker::NoSend,
- head: 0 as *mut Handle<'static, ()>,
- tail: 0 as *mut Handle<'static, ()>,
+ head: ptr::null_mut(),
+ tail: ptr::null_mut(),
next_id: Cell::new(1),
}
}
#[cfg(not(stage0))] // NOTE remove cfg after next snapshot
pub fn new() -> Select {
Select {
- head: 0 as *mut Handle<'static, ()>,
- tail: 0 as *mut Handle<'static, ()>,
+ head: ptr::null_mut(),
+ tail: ptr::null_mut(),
next_id: Cell::new(1),
}
}
Handle {
id: id,
selector: self,
- next: 0 as *mut Handle<'static, ()>,
- prev: 0 as *mut Handle<'static, ()>,
+ next: ptr::null_mut(),
+ prev: ptr::null_mut(),
added: false,
rx: rx,
packet: rx,
(*self.next).prev = self.prev;
}
- self.next = 0 as *mut Handle<'static, ()>;
- self.prev = 0 as *mut Handle<'static, ()>;
+ self.next = ptr::null_mut();
+ self.prev = ptr::null_mut();
self.added = false;
}
use alloc::boxed::Box;
use core::mem;
+use core::ptr;
use core::cell::UnsafeCell;
use sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
unsafe {
mem::transmute(box Node {
value: None,
- next: AtomicPtr::new(0 as *mut Node<T>),
+ next: AtomicPtr::new(ptr::null_mut::<Node<T>>()),
})
}
}
let n = self.alloc();
assert!((*n).value.is_none());
(*n).value = Some(t);
- (*n).next.store(0 as *mut Node<T>, Ordering::Relaxed);
+ (*n).next.store(ptr::null_mut(), Ordering::Relaxed);
(**self.head.get()).next.store(n, Ordering::Release);
*self.head.get() = n;
}
use vec::Vec;
use core::mem;
+use core::ptr;
use sync::atomic::{Ordering, AtomicUsize};
use sync::mpsc::blocking::{self, WaitToken, SignalToken};
cap: cap,
canceled: None,
queue: Queue {
- head: 0 as *mut Node,
- tail: 0 as *mut Node,
+ head: ptr::null_mut(),
+ tail: ptr::null_mut(),
},
buf: Buffer {
buf: range(0, cap + if cap == 0 {1} else {0}).map(|_| None).collect(),
// wait until a send slot is available, returning locked access to
// the channel state.
fn acquire_send_slot(&self) -> MutexGuard<State<T>> {
- let mut node = Node { token: None, next: 0 as *mut Node };
+ let mut node = Node { token: None, next: ptr::null_mut() };
loop {
let mut guard = self.lock.lock().unwrap();
// are we ready to go?
Vec::new()
};
let mut queue = mem::replace(&mut guard.queue, Queue {
- head: 0 as *mut Node,
- tail: 0 as *mut Node,
+ head: ptr::null_mut(),
+ tail: ptr::null_mut(),
});
let waiter = match mem::replace(&mut guard.blocker, NoneBlocked) {
fn enqueue(&mut self, node: &mut Node) -> WaitToken {
let (wait_token, signal_token) = blocking::tokens();
node.token = Some(signal_token);
- node.next = 0 as *mut Node;
+ node.next = ptr::null_mut();
if self.tail.is_null() {
self.head = node as *mut Node;
let node = self.head;
self.head = unsafe { (*node).next };
if self.head.is_null() {
- self.tail = 0 as *mut Node;
+ self.tail = ptr::null_mut();
}
unsafe {
- (*node).next = 0 as *mut Node;
+ (*node).next = ptr::null_mut();
Some((*node).token.take().unwrap())
}
}
use cell::UnsafeCell;
use mem;
+use ptr;
use rt;
use sync::{StaticMutex, StaticCondvar};
use sync::mpsc::{channel, Sender, Receiver};
// Close the channel by destroying it
let chan: Box<Sender<M>> = mem::transmute(*self.chan.get());
- *self.chan.get() = 0 as *mut Sender<M>;
+ *self.chan.get() = ptr::null_mut();
drop(chan);
helper_signal::signal(*self.signal.get() as helper_signal::signal);
if state.is_null() {
return output(w, idx, addr, None)
}
- let mut data = 0 as *const libc::c_char;
+ let mut data = ptr::null();
let data_addr = &mut data as *mut *const libc::c_char;
let ret = unsafe {
backtrace_syminfo(state, addr as libc::uintptr_t,
use cell::UnsafeCell;
use libc;
+use ptr;
use std::option::Option::{Some, None};
use sys::mutex::{self, Mutex};
use sys::time;
// time.
let mut sys_now = libc::timeval { tv_sec: 0, tv_usec: 0 };
let stable_now = time::SteadyTime::now();
- let r = ffi::gettimeofday(&mut sys_now, 0 as *mut _);
+ let r = ffi::gettimeofday(&mut sys_now, ptr::null_mut());
debug_assert_eq!(r, 0);
let seconds = NumCast::from(dur.num_seconds());
use io;
use libc::{self, c_int, c_void};
use mem;
+use ptr;
use sys::retry;
use sys_common::{keep_going, eof, mkerr_libc};
if dir_ptr as uint != 0 {
let mut paths = vec!();
- let mut entry_ptr = 0 as *mut dirent_t;
+ let mut entry_ptr = ptr::null_mut();
while unsafe { readdir_r(dir_ptr, ptr, &mut entry_ptr) == 0 } {
if entry_ptr.is_null() { break }
paths.push(unsafe {
os::last_os_error());
}
let mut result = Vec::new();
- while *environ != 0 as *const _ {
+ while *environ != ptr::null() {
let env_pair = ffi::c_str_to_bytes(&*environ).to_vec();
result.push(env_pair);
environ = environ.offset(1);
fn setgroups(ngroups: libc::c_int,
ptr: *const libc::c_void) -> libc::c_int;
}
- let _ = setgroups(0, 0 as *const libc::c_void);
+ let _ = setgroups(0, ptr::null());
if libc::setuid(u as libc::uid_t) != 0 {
fail(&mut output);
let image = arch::init_frame(&mut frame, &context);
// Initialize this process's symbols
- let ret = SymInitialize(process, 0 as *mut libc::c_void, libc::TRUE);
+ let ret = SymInitialize(process, ptr::null_mut(), libc::TRUE);
if ret != libc::TRUE { return Ok(()) }
let _c = Cleanup { handle: process, SymCleanup: SymCleanup };
let mut i = 0i;
try!(write!(w, "stack backtrace:\n"));
while StackWalk64(image, process, thread, &mut frame, &mut context,
- 0 as *mut libc::c_void,
- 0 as *mut libc::c_void,
- 0 as *mut libc::c_void,
- 0 as *mut libc::c_void) == libc::TRUE{
+ ptr::null_mut(),
+ ptr::null_mut(),
+ ptr::null_mut(),
+ ptr::null_mut()) == libc::TRUE{
let addr = frame.AddrPC.Offset;
if addr == frame.AddrReturn.Offset || addr == 0 ||
frame.AddrReturn.Offset == 0 { break }
rt::at_exit(move|| {
DTOR_LOCK.lock();
let dtors = DTORS;
- DTORS = 0 as *mut _;
+ DTORS = ptr::null_mut();
mem::transmute::<_, Box<Vec<(Key, Dtor)>>>(dtors);
assert!(DTORS.is_null()); // can't re-init after destructing
DTOR_LOCK.unlock();
for &(key, dtor) in dtors.iter() {
let ptr = TlsGetValue(key);
if !ptr.is_null() {
- TlsSetValue(key, 0 as *mut _);
+ TlsSetValue(key, ptr::null_mut());
dtor(ptr as *mut _);
any_run = true;
}
dtor(ptr);
}
ptr = DTORS.get();
- DTORS.set(0 as *mut _);
+ DTORS.set(ptr::null_mut());
}
}
}
let key = ptr.key;
key.os.set(1 as *mut u8);
drop(ptr);
- key.os.set(0 as *mut u8);
+ key.os.set(ptr::null_mut());
}
}