Skip to content

Fix Rust enum repr qualification #177

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

Merged
merged 3 commits into from
Sep 27, 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
10 changes: 5 additions & 5 deletions src/algorithm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extern crate libc;
use array::Array;
use defines::{AfError, BinaryOp};
use error::HANDLE_ERROR;
use self::libc::{c_int, uint8_t, c_uint, c_double};
use self::libc::{c_int, c_uint, c_double};
use util::{AfArray, MutAfArray, MutDouble, MutUint};
use util::{HasAfEnum, Scanable, RealNumber};

Expand Down Expand Up @@ -44,9 +44,9 @@ extern {
fn af_sort_by_key(out_keys: MutAfArray, out_vals: MutAfArray,
in_keys: AfArray, in_vals: AfArray, dim: c_uint, ascend: c_int) -> c_int;

fn af_scan(out: MutAfArray, inp: AfArray, dim: c_int, op: uint8_t, inclusive: c_int) -> c_int;
fn af_scan(out: MutAfArray, inp: AfArray, dim: c_int, op: c_uint, inclusive: c_int) -> c_int;
fn af_scan_by_key(out: MutAfArray, key: AfArray, inp: AfArray,
dim: c_int, op: uint8_t, inclusive: c_int) -> c_int;
dim: c_int, op: c_uint, inclusive: c_int) -> c_int;
}

macro_rules! dim_reduce_func_def {
Expand Down Expand Up @@ -922,7 +922,7 @@ pub fn scan<T>(input: &Array<T>, dim: i32,
let mut temp : i64 = 0;
unsafe {
let err_val = af_scan(&mut temp as MutAfArray, input.get() as AfArray,
dim as c_int, op as uint8_t, inclusive as c_int);
dim as c_int, op as c_uint, inclusive as c_int);
HANDLE_ERROR(AfError::from(err_val));
}
temp.into()
Expand Down Expand Up @@ -953,7 +953,7 @@ pub fn scan_by_key<K, V>(key: &Array<K>, input: &Array<V>,
unsafe {
let err_val = af_scan_by_key(&mut temp as MutAfArray, key.get() as AfArray,
input.get() as AfArray, dim as c_int,
op as uint8_t, inclusive as c_int);
op as c_uint, inclusive as c_int);
HANDLE_ERROR(AfError::from(err_val));
}
temp.into()
Expand Down
30 changes: 15 additions & 15 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use dim4::Dim4;
use defines::{AfError, DType, Backend};
use error::HANDLE_ERROR;
use util::{AfArray, DimT, HasAfEnum, MutAfArray, MutVoidPtr};
use self::libc::{uint8_t, c_void, c_int, c_uint, c_longlong, c_char};
use self::libc::{c_void, c_int, c_uint, c_longlong, c_char};
use std::marker::PhantomData;
use std::ffi::CString;

Expand All @@ -16,13 +16,13 @@ use std::ffi::CString;
#[allow(dead_code)]
extern {
fn af_create_array(out: MutAfArray, data: *const c_void,
ndims: c_uint, dims: *const DimT, aftype: uint8_t) -> c_int;
ndims: c_uint, dims: *const DimT, aftype: c_uint) -> c_int;

fn af_create_handle(out: MutAfArray, ndims: c_uint, dims: *const DimT, aftype: uint8_t) -> c_int;
fn af_create_handle(out: MutAfArray, ndims: c_uint, dims: *const DimT, aftype: c_uint) -> c_int;

fn af_get_elements(out: MutAfArray, arr: AfArray) -> c_int;

fn af_get_type(out: *mut c_int, arr: AfArray) -> c_int;
fn af_get_type(out: *mut c_uint, arr: AfArray) -> c_int;

fn af_get_dims(dim0: *mut c_longlong, dim1: *mut c_longlong, dim2: *mut c_longlong,
dim3: *mut c_longlong, arr: AfArray) -> c_int;
Expand Down Expand Up @@ -75,15 +75,15 @@ extern {

fn af_print_array_gen(exp: *const c_char, arr: AfArray, precision: c_int) -> c_int;

fn af_cast(out: MutAfArray, arr: AfArray, aftype: uint8_t) -> c_int;
fn af_cast(out: MutAfArray, arr: AfArray, aftype: c_uint) -> c_int;

fn af_get_backend_id(backend: *mut c_int, input: AfArray) -> c_int;
fn af_get_backend_id(backend: *mut c_uint, input: AfArray) -> c_int;

fn af_get_device_id(device: *mut c_int, input: AfArray) -> c_int;

fn af_create_strided_array(arr: MutAfArray, data: *const c_void, offset: DimT,
ndims: c_uint, dims: *const DimT, strides: *const DimT,
aftype: uint8_t, stype: uint8_t) -> c_int;
aftype: c_uint, stype: c_uint) -> c_int;

fn af_get_strides(s0: *mut DimT, s1: *mut DimT, s2: *mut DimT, s3: *mut DimT,
arr: AfArray) -> c_int;
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<T> Array<T> where T: HasAfEnum {
slice.as_ptr() as *const c_void,
dims.ndims() as c_uint,
dims.get().as_ptr() as * const c_longlong,
aftype as uint8_t);
aftype as c_uint);
HANDLE_ERROR(AfError::from(err_val));
}
temp.into()
Expand All @@ -176,7 +176,7 @@ impl<T> Array<T> where T: HasAfEnum {
dims.ndims() as c_uint,
dims.get().as_ptr() as * const c_longlong,
strides.get().as_ptr() as * const c_longlong,
aftype as uint8_t, 1);
aftype as c_uint, 1 as c_uint);
HANDLE_ERROR(AfError::from(err_val));
}
temp.into()
Expand All @@ -198,7 +198,7 @@ impl<T> Array<T> where T: HasAfEnum {
let err_val = af_create_handle(&mut temp as MutAfArray,
dims.ndims() as c_uint,
dims.get().as_ptr() as * const c_longlong,
aftype as uint8_t);
aftype as c_uint);
HANDLE_ERROR(AfError::from(err_val));
temp.into()
}
Expand All @@ -212,8 +212,8 @@ impl<T> Array<T> where T: HasAfEnum {
/// was active when Array was created.
pub fn get_backend(&self) -> Backend {
unsafe {
let mut ret_val: i32 = 0;
let err_val = af_get_backend_id(&mut ret_val as *mut c_int, self.handle as AfArray);
let mut ret_val: u32 = 0;
let err_val = af_get_backend_id(&mut ret_val as *mut c_uint, self.handle as AfArray);
HANDLE_ERROR(AfError::from(err_val));
match (err_val, ret_val) {
(0, 1) => Backend::CPU,
Expand Down Expand Up @@ -251,8 +251,8 @@ impl<T> Array<T> where T: HasAfEnum {
/// Returns the Array data type
pub fn get_type(&self) -> DType {
unsafe {
let mut ret_val: i32 = 0;
let err_val = af_get_type(&mut ret_val as *mut c_int, self.handle as AfArray);
let mut ret_val: u32 = 0;
let err_val = af_get_type(&mut ret_val as *mut c_uint, self.handle as AfArray);
HANDLE_ERROR(AfError::from(err_val));
DType::from(ret_val)
}
Expand Down Expand Up @@ -364,7 +364,7 @@ impl<T> Array<T> where T: HasAfEnum {
let trgt_type = O::get_af_dtype();
let mut temp: i64 = 0;
unsafe {
let err_val = af_cast(&mut temp as MutAfArray, self.handle as AfArray, trgt_type as uint8_t);
let err_val = af_cast(&mut temp as MutAfArray, self.handle as AfArray, trgt_type as c_uint);
HANDLE_ERROR(AfError::from(err_val));
}
temp.into()
Expand Down
14 changes: 7 additions & 7 deletions src/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use array::Array;
use dim4::Dim4;
use defines::{AfError};
use error::HANDLE_ERROR;
use self::libc::{uint8_t, c_int, c_uint, c_double};
use self::libc::{c_int, c_uint, c_double};
use self::num::Complex;
use util::{AfArray, DimT, HasAfEnum, Intl, MutAfArray, Uintl};
use std::vec::Vec;
Expand All @@ -25,12 +25,12 @@ extern {
ndims: c_uint, dims: *const DimT) -> c_int;

fn af_range(out: MutAfArray, ndims: c_uint, dims: *const DimT,
seq_dims: c_int, afdtype: uint8_t) -> c_int;
seq_dims: c_int, afdtype: c_uint) -> c_int;

fn af_iota(out: MutAfArray, ndims: c_uint, dims: *const DimT,
t_ndims: c_uint, tdims: *const DimT, afdtype: uint8_t) -> c_int;
t_ndims: c_uint, tdims: *const DimT, afdtype: c_uint) -> c_int;

fn af_identity(out: MutAfArray, ndims: c_uint, dims: *const DimT, afdtype: uint8_t) -> c_int;
fn af_identity(out: MutAfArray, ndims: c_uint, dims: *const DimT, afdtype: c_uint) -> c_int;
fn af_diag_create(out: MutAfArray, arr: AfArray, num: c_int) -> c_int;
fn af_diag_extract(out: MutAfArray, arr: AfArray, num: c_int) -> c_int;
fn af_join(out: MutAfArray, dim: c_int, first: AfArray, second: AfArray) -> c_int;
Expand Down Expand Up @@ -243,7 +243,7 @@ pub fn range<T: HasAfEnum>(dims: Dim4, seq_dim: i32) -> Array<T> {
unsafe {
let err_val = af_range(&mut temp as MutAfArray,
dims.ndims() as c_uint, dims.get().as_ptr() as *const DimT,
seq_dim as c_int, aftype as uint8_t);
seq_dim as c_int, aftype as c_uint);
HANDLE_ERROR(AfError::from(err_val));
}
temp.into()
Expand All @@ -269,7 +269,7 @@ pub fn iota<T: HasAfEnum>(dims: Dim4, tdims: Dim4) -> Array<T> {
let err_val =af_iota(&mut temp as MutAfArray,
dims.ndims() as c_uint, dims.get().as_ptr() as *const DimT,
tdims.ndims() as c_uint, tdims.get().as_ptr() as *const DimT,
aftype as uint8_t);
aftype as c_uint);
HANDLE_ERROR(AfError::from(err_val));
}
temp.into()
Expand All @@ -291,7 +291,7 @@ pub fn identity<T: HasAfEnum>(dims: Dim4) -> Array<T> {
unsafe {
let err_val = af_identity(&mut temp as MutAfArray,
dims.ndims() as c_uint, dims.get().as_ptr() as *const DimT,
aftype as uint8_t);
aftype as c_uint);
HANDLE_ERROR(AfError::from(err_val));
}
temp.into()
Expand Down
Loading