Skip to content

Commit

Permalink
Merge pull request #9 from polachok/various-fixes
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
mrmonday committed Apr 13, 2016
2 parents 46d7f2b + b35d334 commit 73d06ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/netmap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use libc::{c_int, c_uint, c_ulong, c_char, timeval, ssize_t};
use libc::{c_int, c_uint, c_ulong, c_char, timeval, ssize_t, IF_NAMESIZE};

pub const IF_NAMESIZE: usize = 16;
pub const IFNAMSIZ: usize = IF_NAMESIZE;

pub const NETMAP_API: c_int = 11;
Expand Down Expand Up @@ -47,6 +46,7 @@ pub struct netmap_ring {

pub ts: timeval,

_padding: [u8; 72],
pub sem: [u8; 128], // FIXME __attribute__((__aligned__(NM_CACHE_ALIGN)))

pub slot: [netmap_slot; 0], // FIXME Check struct size/field alignment
Expand Down Expand Up @@ -79,8 +79,6 @@ pub struct netmap_if {

pub const NI_PRIV_MEM: c_int = 0x1;

pub const SIZEOF_NR_NAME: usize = IFNAMSIZ;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct nmreq {
Expand Down Expand Up @@ -142,9 +140,9 @@ pub const NIOCGINFO: c_ulong = 3225184657;
#[cfg(target_os = "linux")]
pub const NIOCREGIF: c_ulong = 3225184658;
#[cfg(target_os = "linux")]
pub const NIOTXSYNC: c_uint = 27028;
pub const NIOCTXSYNC: c_uint = 27028;
#[cfg(target_os = "linux")]
pub const NIORXSYNC: c_uint = 27029;
pub const NIOCRXSYNC: c_uint = 27029;
#[cfg(target_os = "linux")]
pub const NIOCCONFIG: c_ulong = 3239078294;

Expand Down
4 changes: 2 additions & 2 deletions src/netmap_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ pub unsafe fn NETMAP_IF<U>(_base: *mut U, _ofs: isize) -> *mut netmap_if {
// FIXME It's possible the pointer arithmetic here uses the wrong integer types.
#[inline(always)]
pub unsafe fn NETMAP_TXRING(nifp: *mut netmap_if, index: isize) -> *mut netmap_ring {
let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut c_void;
let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut isize;
_NETMAP_OFFSET(nifp, *(ptr.offset(index) as *mut isize))
}

#[inline(always)]
pub unsafe fn NETMAP_RXRING(nifp: *mut netmap_if, index: isize) -> *mut netmap_ring {
let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut c_void;
let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut isize;
_NETMAP_OFFSET(nifp, *(ptr.offset(index + (*nifp).ni_tx_rings as isize + 1) as *mut isize))
}

Expand Down

0 comments on commit 73d06ad

Please sign in to comment.