Skip to content

Commit

Permalink
Remove logic related to endianness after purging all the related occu…
Browse files Browse the repository at this point in the history
…rrences from ccommon (#204)

* Squashed 'deps/ccommon/' changes from f5efe29..a6a54d9

a6a54d9 remove endian-specific logic from str*cmp (#177)
4c0668b epoll_create* ignores size hint in newer kernels, switch to new API (#179)
c9c5ee5 improve cc_bstring string literal and cstring names (#176)
0184d73 Add unit tests for buffer, fix buf/dbuf bugs and refactor (#174)
d7dab43 create a .cargo/config so intellij uses the same target dir as cmake (#173)
e710712 use accept4 for tcp_accept when available (#171)
21ba10e Remove cargo lock for shared lib, closes #169 (#172)
24660f1 update style guide (#170)
17baf1e Per thread logging (#168)

git-subtree-dir: deps/ccommon
git-subtree-split: a6a54d9

* remove endianness from pelikan cmake as well

* remove deps changes

* Squashed 'deps/ccommon/' changes from a6a54d9..2168fec

2168fec minimize osx build config (#185)
42b24de Simplify rust options, specify fewer output targets (#183)
c9fa905 update CMakeRust used to latest version, tweaks to make build work (#184)
2ef0163 Reorder dependency includes in cmake, don't parallel build (#182)

git-subtree-dir: deps/ccommon
git-subtree-split: 2168fec

* fix weird divergence of bstring.rs
  • Loading branch information
Yao Yue authored Dec 14, 2018
1 parent 8a9ecc2 commit 0d88599
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
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

0 comments on commit 0d88599

Please sign in to comment.