1 // Copyright 2017 The Bazel Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 use libc::{c_int, size_t}; 16 17 #[repr(C)] 18 #[derive(Clone, Copy)] 19 pub struct Matrix { 20 pub rows: size_t, 21 pub cols: size_t, 22 pub data: *mut u64, 23 } 24 25 // #[link(name = "native_matrix")] // Don't need this, BUILD file manages linking already. 26 extern "C" { matrix_new(rows: size_t, cols: size_t, data: *const u64) -> *mut Matrix27 pub fn matrix_new(rows: size_t, cols: size_t, data: *const u64) -> *mut Matrix; matrix_at(matrix: *const Matrix, row: size_t, col: size_t, n: *mut u64) -> c_int28 pub fn matrix_at(matrix: *const Matrix, row: size_t, col: size_t, n: *mut u64) -> c_int; matrix_set(matrix: *const Matrix, row: size_t, col: size_t, n: u64) -> c_int29 pub fn matrix_set(matrix: *const Matrix, row: size_t, col: size_t, n: u64) -> c_int; matrix_transpose(matrix: *mut Matrix)30 pub fn matrix_transpose(matrix: *mut Matrix); matrix_equal(a: *const Matrix, b: *const Matrix) -> c_int31 pub fn matrix_equal(a: *const Matrix, b: *const Matrix) -> c_int; matrix_free(matrix: *mut Matrix)32 pub fn matrix_free(matrix: *mut Matrix); 33 } 34