1
0
Fork 0

use libvalgrind instead of valgrind.h

no more C!
This commit is contained in:
edef 2016-01-04 15:32:03 +01:00
parent cd4fe1ecc8
commit bc46941e89
8 changed files with 30 additions and 6708 deletions

View File

@ -2,10 +2,6 @@
name = "fringe" name = "fringe"
version = "0.0.1" version = "0.0.1"
authors = ["edef <edef@edef.eu>"] authors = ["edef <edef@edef.eu>"]
build = "build.rs"
[build-dependencies]
gcc = "0.3.3"
[dependencies] [dependencies]
void = "0.0.5" void = "0.0.5"
@ -13,8 +9,12 @@ void = "0.0.5"
[features] [features]
default = ["os", "valgrind"] default = ["os", "valgrind"]
os = ["libc"] os = ["libc"]
valgrind = []
[dependencies.libc] [dependencies.libc]
version = "0.1.6" version = "0.1.6"
optional = true optional = true
[dependencies.valgrind]
git = "https://github.com/edef1c/libvalgrind"
rev = "9ef793e9549aabfd2d969615180b69d29ce28d88"
optional = true

45
LICENSE
View File

@ -12,48 +12,3 @@ SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
This distribution includes packages written by third parties.
The following third party packages are included, and carry
their own copyright notices and license terms:
* A header file that is part of the Valgrind package. This file is found at
src/debug/valgrind/valgrind.h within this distribution. This file is
redistributed under the following terms, as noted in it:
This file is part of Valgrind, a dynamic binary instrumentation
framework.
Copyright (C) 2000-2013 Julian Seward. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,11 +0,0 @@
// This file is part of libfringe, a low-level green threading library.
// Copyright (c) 2015, edef <edef@edef.eu>
// See the LICENSE file included in this distribution.
extern crate gcc;
use std::env::var_os;
fn main() {
if var_os("CARGO_FEATURE_VALGRIND").is_some() {
gcc::compile_library("libvalgrind.a", &["src/debug/valgrind/native.c"]);
}
}

View File

@ -4,7 +4,7 @@
pub use self::imp::*; pub use self::imp::*;
#[cfg(feature = "valgrind")] #[cfg(feature = "valgrind")]
#[path = "valgrind/mod.rs"] #[path = "valgrind.rs"]
mod imp; mod imp;
#[cfg(not(feature = "valgrind"))] #[cfg(not(feature = "valgrind"))]

24
src/debug/valgrind.rs Normal file
View File

@ -0,0 +1,24 @@
// This file is part of libfringe, a low-level green threading library.
// Copyright (c) 2015, edef <edef@edef.eu>
// See the LICENSE file included in this distribution.
extern crate valgrind;
use stack;
use self::valgrind::{stack_register, stack_deregister};
#[derive(Debug)]
pub struct StackId(self::valgrind::Value);
impl StackId {
#[inline(always)]
pub fn register<Stack: stack::Stack>(stack: &mut Stack) -> StackId {
StackId(stack_register(stack.limit(), stack.top()))
}
}
impl Drop for StackId {
#[inline(always)]
fn drop(&mut self) {
stack_deregister(self.0)
}
}

View File

@ -1,44 +0,0 @@
// This file is part of libfringe, a low-level green threading library.
// Copyright (c) 2015, edef <edef@edef.eu>
// See the LICENSE file included in this distribution.
#![allow(non_camel_case_types)]
//! In order for Valgrind to keep track of stack overflows and such, it needs
//! a little help. That help unfortunately comes in the form of a set of C
//! macros. Calling out to un-inlineable C code for this is pointlessly slow,
//! but that's the way it is for now.
use stack;
pub type stack_id_t = u32;
extern "C" {
#[link_name = "valgrind_stack_register"]
/// Register a stack with Valgrind. Returns an integer ID that can
/// be used to deregister the stack when it's deallocated.
/// `start < end`.
pub fn stack_register(start: *const u8, end: *const u8) -> stack_id_t;
#[link_name = "valgrind_stack_deregister"]
/// Deregister a stack from Valgrind. Takes the integer ID that was returned
/// on registration.
pub fn stack_deregister(id: stack_id_t);
}
#[derive(Debug)]
pub struct StackId(stack_id_t);
impl StackId {
#[inline(always)]
pub fn register<Stack: stack::Stack>(stack: &mut Stack) -> StackId {
StackId(unsafe {
stack_register(stack.limit(), stack.top())
})
}
}
impl Drop for StackId {
#[inline(always)]
fn drop(&mut self) {
unsafe {
stack_deregister(self.0)
}
}
}

View File

@ -1,15 +0,0 @@
// This file is part of libfringe, a low-level green threading library.
// Copyright (c) 2015, edef <edef@edef.eu>
// See the LICENSE file included in this distribution.
#include <stdint.h>
#include "valgrind.h"
typedef uint32_t valgrind_stack_id_t;
valgrind_stack_id_t valgrind_stack_register(const void *start, const void *end) {
return VALGRIND_STACK_REGISTER(start, end);
}
void valgrind_stack_deregister(valgrind_stack_id_t id) {
VALGRIND_STACK_DEREGISTER(id);
}

File diff suppressed because it is too large Load Diff