Skip to content

Commit dfd557b

Browse files
committed
auto merge of #20606 : alexcrichton/rust/stabilize-libc, r=brson
This commit prepares the liblibc library to be moved to crates.io. Unlike the log, serialize, term, etc crates, the source for this crate will *not* be duplicated out-of-tree. Instead a new rust-lang/libc repository will be created with a submodule to this repository and it will use the source directly. In order to compile within the stable ecosystem of Rust, this crate cannot link to libcore, and it also needs some tweaks for the other attributes that it has. As a result this commit tweaks the source of the crate to link to libcore when built in tree but link to libstd when built via cargo. Note that the rust-lang/libc crate isn't quite prepared just yet, there's a Cargo bug or two that I'd like to iron out before publishing it. This is simply preparing the in-tree source.
2 parents a3a16e9 + 01ce6ef commit dfd557b

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

src/liblibc/lib.rs

+6-21
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
// except according to those terms.
1010

1111
#![crate_name = "libc"]
12-
#![experimental]
13-
#![no_std] // we don't need std, and we can't have std, since it doesn't exist
14-
// yet. std depends on us.
1512
#![crate_type = "rlib"]
13+
#![cfg_attr(not(feature = "cargo-build"), experimental)]
14+
#![no_std]
1615
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1716
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
1817
html_root_url = "http://doc.rust-lang.org/nightly/",
@@ -70,20 +69,14 @@
7069
//! in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the final
7170
//! one from Berkeley after the lawsuits died down and the CSRG dissolved.
7271
73-
#![allow(non_camel_case_types)]
74-
#![allow(non_snake_case)]
75-
#![allow(non_upper_case_globals)]
76-
#![allow(missing_docs)]
77-
#![allow(non_snake_case)]
78-
#![allow(raw_pointer_derive)]
72+
#![allow(bad_style, raw_pointer_derive)]
7973

80-
extern crate core;
74+
#[cfg(feature = "cargo-build")] extern crate "std" as core;
75+
#[cfg(not(feature = "cargo-build"))] extern crate core;
8176

8277
#[cfg(test)] extern crate std;
8378
#[cfg(test)] extern crate test;
8479

85-
pub use self::Nullable::*;
86-
8780
// Explicit export lists for the intersection (provided here) mean that
8881
// you can write more-platform-agnostic code if you stick to just these
8982
// symbols.
@@ -311,14 +304,6 @@ pub use types::os::arch::extra::{mach_timebase_info};
311304
#[link(name = "m")]
312305
extern {}
313306

314-
/// A wrapper for a nullable pointer. Don't use this except for interacting
315-
/// with libc. Basically Option, but without the dependence on libstd.
316-
// If/when libprim happens, this can be removed in favor of that
317-
pub enum Nullable<T> {
318-
Null,
319-
NotNull(T)
320-
}
321-
322307
pub mod types {
323308

324309
// Types tend to vary *per architecture* so we pull their definitions out
@@ -4648,7 +4633,7 @@ pub mod funcs {
46484633
extern {
46494634
pub fn glob(pattern: *const c_char,
46504635
flags: c_int,
4651-
errfunc: ::Nullable<extern "C" fn(epath: *const c_char,
4636+
errfunc: ::core::option::Option<extern "C" fn(epath: *const c_char,
46524637
errno: c_int) -> c_int>,
46534638
pglob: *mut glob_t);
46544639
pub fn globfree(pglob: *mut glob_t);

0 commit comments

Comments
 (0)