Commit Graph

83 Commits

Author SHA1 Message Date
Nick Cameron 1f1a1e6595 rustfmt: liballoc, liballoc_*, libarena 2015-11-24 11:23:17 +13:00
Nick Cameron 459f7720b9 Better function calls 2015-09-24 11:32:01 +12:00
Nick Cameron 8f51c8d687 rustfmt liballoc 2015-09-24 10:00:54 +12:00
Alex Crichton 6734c933b5 alloc: Add issues for all unstable features 2015-08-15 18:09:16 -07:00
Alex Crichton 45bf1ed1a1 rustc: Allow changing the default allocator
This commit is an implementation of [RFC 1183][rfc] which allows swapping out
the default allocator on nightly Rust. No new stable surface area should be
added as a part of this commit.

[rfc]: https://github.com/rust-lang/rfcs/pull/1183

Two new attributes have been added to the compiler:

* `#![needs_allocator]` - this is used by liballoc (and likely only liballoc) to
  indicate that it requires an allocator crate to be in scope.
* `#![allocator]` - this is a indicator that the crate is an allocator which can
  satisfy the `needs_allocator` attribute above.

The ABI of the allocator crate is defined to be a set of symbols that implement
the standard Rust allocation/deallocation functions. The symbols are not
currently checked for exhaustiveness or typechecked. There are also a number of
restrictions on these crates:

* An allocator crate cannot transitively depend on a crate that is flagged as
  needing an allocator (e.g. allocator crates can't depend on liballoc).
* There can only be one explicitly linked allocator in a final image.
* If no allocator is explicitly requested one will be injected on behalf of the
  compiler. Binaries and Rust dylibs will use jemalloc by default where
  available and staticlibs/other dylibs will use the system allocator by
  default.

Two allocators are provided by the distribution by default, `alloc_system` and
`alloc_jemalloc` which operate as advertised.

Closes #27389
2015-08-14 15:13:10 -07:00
Alex Crichton c44f5399e4 alloc: Split apart the global `alloc` feature 2015-06-17 09:06:59 -07:00
Peter Atashian ebbd90d28f Switch to direct HeapAlloc on Windows when not using jemalloc
Signed-off-by: Peter Atashian <retep998@gmail.com>
2015-06-13 15:13:16 -04:00
Steve Klabnik 30b527156b Rollup merge of #25254 - cgaebel:check-sizes-on-allocate, r=Gankro
They're only enabled in debug builds, but a panic is usually more
welcome than UB in debug builds.

Previous review at https://github.com/rust-lang/rust/pull/22069

r? @Gankro
cc @huon
2015-05-11 23:24:18 -04:00
Clark Gaebel 101b25c100
[liballoc] Adds checks for UB during allocation.
They're only enabled in debug builds, but a panic is usually more
welcome than UB in debug builds.
2015-05-09 20:49:59 -04:00
Nick Hamann a1898f890d Convert #[lang="..."] to #[lang = "..."]
In my opinion this looks nicer, but also it matches the whitespace generally
used for stability markers more closely.
2015-05-09 14:50:28 -05:00
Alex Crichton 6c048723f8 std: Prepare for linking to musl
This commit modifies the standard library and its dependencies to link correctly
when built against MUSL. This primarily ensures that the right libraries are
linked against and when they're linked against they're linked against
statically.
2015-04-27 10:11:15 -07:00
Johannes Oertel 07cc7d9960 Change name of unit test sub-module to "tests".
Changes the style guidelines regarding unit tests to recommend using a
sub-module named "tests" instead of "test" for unit tests as "test"
might clash with imports of libtest.
2015-04-24 23:06:41 +02:00
Krzysztof Drewniak f64510d72b Suppress improper_ctypes warnings when compiling liballoc with external_features 2015-04-16 21:34:12 -05:00
bors 80bf31dd51 Auto merge of #23549 - aturon:stab-num, r=alexcrichton
This commit stabilizes the `std::num` module:

* The `Int` and `Float` traits are deprecated in favor of (1) the
  newly-added inherent methods and (2) the generic traits available in
  rust-lang/num.

* The `Zero` and `One` traits are reintroduced in `std::num`, which
  together with various other traits allow you to recover the most
  common forms of generic programming.

* The `FromStrRadix` trait, and associated free function, is deprecated
  in favor of inherent implementations.

* A wide range of methods and constants for both integers and floating
  point numbers are now `#[stable]`, having been adjusted for integer
  guidelines.

* `is_positive` and `is_negative` are renamed to `is_sign_positive` and
  `is_sign_negative`, in order to address #22985

* The `Wrapping` type is moved to `std::num` and stabilized;
  `WrappingOps` is deprecated in favor of inherent methods on the
  integer types, and direct implementation of operations on
  `Wrapping<X>` for each concrete integer type `X`.

Closes #22985
Closes #21069

[breaking-change]

r? @alexcrichton
2015-03-31 14:50:46 +00:00
Aaron Turon 232424d995 Stabilize std::num
This commit stabilizes the `std::num` module:

* The `Int` and `Float` traits are deprecated in favor of (1) the
  newly-added inherent methods and (2) the generic traits available in
  rust-lang/num.

* The `Zero` and `One` traits are reintroduced in `std::num`, which
  together with various other traits allow you to recover the most
  common forms of generic programming.

* The `FromStrRadix` trait, and associated free function, is deprecated
  in favor of inherent implementations.

* A wide range of methods and constants for both integers and floating
  point numbers are now `#[stable]`, having been adjusted for integer
  guidelines.

* `is_positive` and `is_negative` are renamed to `is_sign_positive` and
  `is_sign_negative`, in order to address #22985

* The `Wrapping` type is moved to `std::num` and stabilized;
  `WrappingOps` is deprecated in favor of inherent methods on the
  integer types, and direct implementation of operations on
  `Wrapping<X>` for each concrete integer type `X`.

Closes #22985
Closes #21069

[breaking-change]
2015-03-31 07:50:25 -07:00
Alex Crichton acd48a2b3e std: Standardize (input, output) param orderings
This functions swaps the order of arguments to a few functions that previously
took (output, input) parameters, but now take (input, output) parameters (in
that order).

The affected functions are:

* ptr::copy
* ptr::copy_nonoverlapping
* slice::bytes::copy_memory
* intrinsics::copy
* intrinsics::copy_nonoverlapping

Closes #22890
[breaking-change]
2015-03-30 14:08:40 -07:00
Steve Klabnik 2750e3c83e Add note about pointer state after the call.
Fixes #23422
2015-03-23 12:21:53 -04:00
Alex Crichton fccf5a0005 Register new snapshots 2015-03-18 16:32:32 -07:00
Jorge Aparicio a079d5e4d2 remove imports 2015-03-16 21:57:42 -05:00
Jorge Aparicio 8afcaabee3 impl<T> *const T, impl<T> *mut T 2015-03-16 21:57:42 -05:00
Björn Steinbrink 0942803f50 Add an "allocator" attribute to mark functions as allocators
When this attribute is applied to a function, its return value gets the
noalias attribute, which is how you tell LLVM that the function returns
a "new" pointer that doesn't alias anything accessible to the caller,
i.e. it acts like a memory allocator.

Plain malloc doesn't need this attribute because LLVM already knows
about malloc and adds the attribute itself.
2015-03-13 03:19:30 +01:00
Felix S. Klock II 270f0eef73 Add `: Box<_>` or `::Box<_>` type annotations to various places.
This is the kind of change that one is expected to need to make to
accommodate overloaded-`box`.

----

Note that this is not *all* of the changes necessary to accommodate
Issue 22181.  It is merely the subset of those cases where there was
already a let-binding in place that made it easy to add the necesasry
type ascription.

(For unnamed intermediate `Box` values, one must go down a different
route; `Box::new` is the option that maximizes portability, but has
potential inefficiency depending on whether the call is inlined.)

----

There is one place worth note, `run-pass/coerce-match.rs`, where I
used an ugly form of `Box<_>` type ascription where I would have
preferred to use `Box::new` to accommodate overloaded-`box`.  I
deliberately did not use `Box::new` here, because that is already done
in coerce-match-calls.rs.

----

Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-03 20:29:01 +01:00
Valerii Hiora d0bb57cfc3 Fixed build with jemalloc disabled 2015-02-26 20:27:53 +02:00
we 6a2bad3257 int/uint => isize/usize in liblibc/liballoc/libarena 2015-02-09 10:00:46 +03:00
Tobias Bucher 7f64fe4e27 Remove all `i` suffixes 2015-01-30 04:38:54 +01:00
Manish Goregaokar f553f58b7f Rollup merge of 21681 - japaric:no-warn, r=alexcrichton 2015-01-29 03:14:35 +05:30
Jorge Aparicio 57dd4ea78d fix #[cfg(test)] warnings 2015-01-27 22:58:45 -05:00
Brian Anderson 63fcbcf3ce Merge remote-tracking branch 'rust-lang/master'
Conflicts:
	mk/tests.mk
	src/liballoc/arc.rs
	src/liballoc/boxed.rs
	src/liballoc/rc.rs
	src/libcollections/bit.rs
	src/libcollections/btree/map.rs
	src/libcollections/btree/set.rs
	src/libcollections/dlist.rs
	src/libcollections/ring_buf.rs
	src/libcollections/slice.rs
	src/libcollections/str.rs
	src/libcollections/string.rs
	src/libcollections/vec.rs
	src/libcollections/vec_map.rs
	src/libcore/any.rs
	src/libcore/array.rs
	src/libcore/borrow.rs
	src/libcore/error.rs
	src/libcore/fmt/mod.rs
	src/libcore/iter.rs
	src/libcore/marker.rs
	src/libcore/ops.rs
	src/libcore/result.rs
	src/libcore/slice.rs
	src/libcore/str/mod.rs
	src/libregex/lib.rs
	src/libregex/re.rs
	src/librustc/lint/builtin.rs
	src/libstd/collections/hash/map.rs
	src/libstd/collections/hash/set.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/mutex.rs
	src/libstd/sync/poison.rs
	src/libstd/sync/rwlock.rs
	src/libsyntax/feature_gate.rs
	src/libsyntax/test.rs
2015-01-25 01:20:55 -08:00
Brian Anderson cd6d9eab5d Set unstable feature names appropriately
* `core` - for the core crate
* `hash` - hashing
* `io` - io
* `path` - path
* `alloc` - alloc crate
* `rand` - rand crate
* `collections` - collections crate
* `std_misc` - other parts of std
* `test` - test crate
* `rustc_private` - everything else
2015-01-23 13:28:40 -08:00
Brian Anderson 41278c5441 Remove 'since' from unstable attributes 2015-01-21 19:25:55 -08:00
Brian Anderson 94ca8a3610 Add 'feature' and 'since' to stability attributes 2015-01-21 16:16:18 -08:00
Alex Crichton 4ffde0814f Test fixes and rebase conflicts 2015-01-21 10:32:56 -08:00
Alex Crichton 907db6c834 rollup merge of #21444: petrochenkov/null
Conflicts:
	src/libstd/sync/mpsc/select.rs
2015-01-21 09:18:07 -08:00
we 2c2480df5d Replace `0 as *const/mut T` with `ptr::null/null_mut()` 2015-01-19 08:27:09 +03:00
we 812ce6c190 Remove unnecessary explicit conversions to *const T 2015-01-17 07:34:10 +03:00
Richo Healey e5bbe8244b powerpc: Tell liballoc about power alignment 2015-01-11 21:14:30 -08:00
Alex Crichton 0dc48b47a8 Test fixes and rebase conflicts 2015-01-07 19:27:27 -08:00
John Ericson b1b4bc90b8 Fix warning in liballoc about unused constant MIN_ALIGN when cfg(feature = external_*) 2015-01-07 19:22:22 +00:00
John Ericson ea9d5c9653 liballoc's "extern_funcs" impl mod had a duplicate and missing item 2015-01-07 19:19:01 +00:00
John Ericson 2b84e44b07 Shorten cfg line lengths in liballoc 2015-01-07 19:19:01 +00:00
John Ericson efaa43ade5 liballoc's "external_funcs" and "external_crate" are now features
This allows the vanilla libary to built for kernel use with Cargo.
2015-01-07 19:19:00 +00:00
Akos Kiss 6e5fb8bd1b Initial version of AArch64 support.
Adds AArch64 knowledge to:
* configure,
* make files,
* sources,
* tests, and
* documentation.
2015-01-03 15:16:10 +00:00
Alex Crichton 54452cdd68 std: Second pass stabilization for `ptr`
This commit performs a second pass for stabilization over the `std::ptr` module.
The specific actions taken were:

* The `RawPtr` trait was renamed to `PtrExt`
* The `RawMutPtr` trait was renamed to `MutPtrExt`
* The module name `ptr` is now stable.
* These functions were all marked `#[stable]` with no modification:
  * `null`
  * `null_mut`
  * `swap`
  * `replace`
  * `read`
  * `write`
  * `PtrExt::is_null`
  * `PtrExt::offset`
* These functions remain unstable:
  * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive
                         as null isn't the only bad value, and it's unclear
                         whether we want to commit to these functions at this
                         time. The reference/lifetime semantics as written are
                         also problematic in how they encourage arbitrary
                         lifetimes.
  * `zero_memory` - This function is currently not used at all in the
                    distribution, and in general it plays a broader role in the
                    "working with unsafe pointers" story. This story is not yet
                    fully developed, so at this time the function remains
                    unstable for now.
  * `read_and_zero` - This function remains unstable for largely the same
                      reasons as `zero_memory`.
* These functions are now all deprecated:
  * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead.
  * `PtrExt::to_uint` - use an `as` expression instead.
  * `PtrExt::is_not_null` - use `!p.is_null()` instead.
2014-12-29 15:57:28 -08:00
Corey Farwell 4ef16741e3 Utilize fewer reexports
In regards to:

https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729

This commit:

* Changes the #deriving code so that it generates code that utilizes fewer
  reexports (in particur Option::* and Result::*), which is necessary to
  remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized
2014-12-05 18:13:04 -05:00
Alexander Light 87235687a1 Add ability to use custom alloc::heap::imp
Adds the ability to use a custom allocator heap by passing either --cfg
external_crate and --extern external=<allocator_crate_name> or --cfg
external_funcs and defining the allocator functions prefixed by 'rust_'
somewhere.

This is useful for many reasons including OS/embedded development, and
allocator development and testing.
2014-12-04 16:23:29 -05:00
Daniel Micay fea985a0b5 bubble up out-of-memory errors from liballoc
This makes the low-level allocation API suitable for use cases where
out-of-memory conditions need to be handled.

Closes #18292

[breaking-change]
2014-11-01 19:23:20 -04:00
Daniel Micay a9e85100cd fix sized deallocation documentation 2014-10-25 14:12:21 -04:00
Daniel Micay a6426cb43d return the new usable size from reallocate_inplace
The real size is also more useful than just a boolean, and the caller
can easily determine if the operation failed from the real size. In most
cases, the caller is only going to be growing the allocation so a branch
can be avoided.

[breaking-change]
2014-10-25 14:12:21 -04:00
Daniel Micay 2bc4d3ec23 get rid of libc_heap::{malloc_raw, realloc_raw}
The C standard library functions should be used directly. The quirky
NULL / zero-size allocation workaround is no longer necessary and was
adding an extra branch to the allocator code path in a build without
jemalloc. This is a small step towards liballoc being compatible with
handling OOM errors instead of aborting (#18292).

[breaking-change]
2014-10-25 14:12:19 -04:00
Björn Steinbrink 6c18e508f1 Make MIN_ALIGN a const to allow better optimization
With MIN_ALIGN as a static, other crates don't have access to its value
at compile time, because it is an extern global. That means that the
checks against it can't be optimized out, which is rather unfortunate.
So let's make it a constant instead.
2014-10-25 12:33:27 -04:00