Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove logic related to endianness after purging all the related occurrences from ccommon #204

Merged
merged 8 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ check_symbol_exists(sys_signame signal.h HAVE_SIGNAME)
include(CheckFunctionExists)
check_function_exists(backtrace HAVE_BACKTRACE)

include(TestBigEndian)
test_big_endian(HAVE_BIG_ENDIAN)

# how to use config.h.in to generate config.h
# this has to be set _after_ the above checks
configure_file(
Expand Down Expand Up @@ -172,7 +169,6 @@ message(STATUS "CFLAGS: " ${CMAKE_C_FLAGS})
message(STATUS "HAVE_SIGNAME: " ${HAVE_SIGNAME})

message(STATUS "HAVE_BACKTRACE: " ${HAVE_BACKTRACE})
message(STATUS "HAVE_BIG_ENDIAN: " ${HAVE_BIG_ENDIAN})

if(DUMP_ALL)
message(STATUS "<<++=====------------------\\/------------------=====++>>")
Expand Down
2 changes: 0 additions & 2 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#cmakedefine HAVE_BACKTRACE

#cmakedefine HAVE_BIG_ENDIAN

#cmakedefine HAVE_LOGGING

#cmakedefine HAVE_STATS
Expand Down
3 changes: 0 additions & 3 deletions deps/ccommon/ci/before-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ TEMP="$(mktemp -d -t TEMP.XXXXXXX)" || die "failed to make tmpdir"
cleanup() { [[ -n "${TEMP:-}" ]] && rm -rf "${TEMP}"; }
trap cleanup EXIT

realpath() { python -c "from __future__ import print_function; import os,sys; print(os.path.realpath(sys.argv[1]))" "$1"; }

TOPLEVEL="$(cd "$(dirname "$(realpath "$0" >/dev/null || exit 1)")" && git rev-parse --show-toplevel)" || die 'failed to find TOPLEVEL'


if [[ -n "${RUST_ENABLED:-}" ]]; then
curl https://sh.rustup.rs -sSf | sh -s -- -y
fi
26 changes: 7 additions & 19 deletions deps/ccommon/rust/ccommon_rs/src/bstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use cc_binding as bind;
use std::borrow::Borrow;
use std::boxed::Box;
use std::cell::UnsafeCell;
use std::fmt;
use std::fmt::Debug;
Expand Down Expand Up @@ -58,12 +59,6 @@ unsafe fn raw_ptr_to_bytes_mut<'a>(ptr: *mut CCbstring) -> &'a mut [u8] {


// this pattern lifted from https://docs.rs/foreign-types-shared/0.1.1/src/foreign_types_shared/lib.rs.html
//
// according to the author (Steven Fackler) who is a rust stdlib maintainer:
// > Opaque is just there to be some arbitrary non-constructable type.
// > the unsafecell inside is a hedge against something that I can't
// > quite remember but eddyb claims is important
//
struct Opaque(UnsafeCell<()>);

/// A reference to a BString. String is to &str as BString is to &BStr.
Expand All @@ -74,15 +69,14 @@ struct Opaque(UnsafeCell<()>);
/// data field and expects it to be filled (as opposed to in BString where
/// *we* own that memory).
///
#[repr(C)]
pub struct BStr(Opaque);

impl BStr {
/// Wraps a raw pointer to a cc_bstring struct with a BStr. This is a
/// reference only conversion, and is zero cost.
#[inline]
pub unsafe fn from_ptr<'a>(ptr: *mut CCbstring) -> &'a Self {
&*(ptr as *mut _) // This is more or less equivalent to a transmute
&*(ptr as *mut _)
}

/// Wraps a raw pointer to a cc_bstring struct with a BStr, and returns
Expand All @@ -93,13 +87,9 @@ impl BStr {
&mut *(ptr as *mut _)
}

// it's ok to ignore the cast_ptr_alignment lint because we're going
// *mut CCbstring -> &BStr -> *mut CCbstring
#[allow(unknown_lints)]
#[allow(cast_ptr_alignment)]
#[inline]
pub fn as_ptr(&self) -> *mut CCbstring {
(&*self) as *const _ as *mut _
self as *const _ as *mut _
}

pub fn from_ref<'a>(ccb: &'a CCbstring) -> &'a Self {
Expand Down Expand Up @@ -128,7 +118,7 @@ impl Deref for BStr {
impl DerefMut for BStr {
#[inline]
fn deref_mut(&mut self) -> &mut [u8] {
unsafe { raw_ptr_to_bytes_mut(self.as_ptr() as *mut _) }
unsafe { raw_ptr_to_bytes_mut(self.as_ptr()) }
}
}

Expand Down Expand Up @@ -161,7 +151,7 @@ impl ToOwned for BStr {

#[inline]
fn to_owned(&self) -> BString {
unsafe { BString::from_raw(self.as_ptr() as *mut _).clone() }
unsafe { BString::from_raw(self.as_ptr()).clone() }
}
}

Expand Down Expand Up @@ -257,8 +247,6 @@ impl BString {
}

#[inline]
#[allow(unknown_lints)]
#[allow(wrong_self_convention)] // nb(jsimms): what about Box.into_raw?
pub fn into_raw(bs: BString) -> *mut CCbstring {
let unique = bs.0;
mem::forget(bs);
Expand Down Expand Up @@ -403,9 +391,9 @@ impl From<BString> for Vec<u8> {
}
}

impl<'a> From<&'a [u8]> for BString {
impl From<Box<[u8]>> for BString {
#[inline]
fn from(b: &'a [u8]) -> Self {
fn from(b: Box<[u8]>) -> Self {
BString::from_bytes(&b[..])
}
}
Expand Down