C++ compatibility for some kernel headers

This commit is contained in:
Sebastian Huber
2014-08-29 11:05:19 +02:00
parent b7ea2dd81c
commit 62bdb6ae50
4 changed files with 25 additions and 19 deletions

View File

@@ -612,7 +612,7 @@ drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m)
} }
static __inline void static __inline void
drbr_putback(struct ifnet *ifp, struct buf_ring *br, struct mbuf *new) drbr_putback(struct ifnet *ifp, struct buf_ring *br, struct mbuf *new_mbuf)
{ {
/* /*
* The top of the list needs to be swapped * The top of the list needs to be swapped
@@ -624,11 +624,11 @@ drbr_putback(struct ifnet *ifp, struct buf_ring *br, struct mbuf *new)
* Peek in altq case dequeued it * Peek in altq case dequeued it
* so put it back. * so put it back.
*/ */
IFQ_DRV_PREPEND(&ifp->if_snd, new); IFQ_DRV_PREPEND(&ifp->if_snd, new_mbuf);
return; return;
} }
#endif #endif
buf_ring_putback_sc(br, new); buf_ring_putback_sc(br, new_mbuf);
} }
static __inline struct mbuf * static __inline struct mbuf *
@@ -647,7 +647,7 @@ drbr_peek(struct ifnet *ifp, struct buf_ring *br)
return (m); return (m);
} }
#endif #endif
return(buf_ring_peek(br)); return ((struct mbuf *)buf_ring_peek(br));
} }
static __inline void static __inline void
@@ -659,7 +659,7 @@ drbr_flush(struct ifnet *ifp, struct buf_ring *br)
if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd)) if (ifp != NULL && ALTQ_IS_ENABLED(&ifp->if_snd))
IFQ_PURGE(&ifp->if_snd); IFQ_PURGE(&ifp->if_snd);
#endif #endif
while ((m = buf_ring_dequeue_sc(br)) != NULL) while ((m = (struct mbuf *)buf_ring_dequeue_sc(br)) != NULL)
m_freem(m); m_freem(m);
} }
@@ -682,7 +682,7 @@ drbr_dequeue(struct ifnet *ifp, struct buf_ring *br)
return (m); return (m);
} }
#endif #endif
return (buf_ring_dequeue_sc(br)); return ((struct mbuf *)buf_ring_dequeue_sc(br));
} }
static __inline void static __inline void
@@ -715,11 +715,11 @@ drbr_dequeue_cond(struct ifnet *ifp, struct buf_ring *br,
return (m); return (m);
} }
#endif #endif
m = buf_ring_peek(br); m = (struct mbuf *)buf_ring_peek(br);
if (m == NULL || func(m, arg) == 0) if (m == NULL || func(m, arg) == 0)
return (NULL); return (NULL);
return (buf_ring_dequeue_sc(br)); return ((struct mbuf *)buf_ring_dequeue_sc(br));
} }
static __inline int static __inline int

View File

@@ -99,7 +99,7 @@ buf_ring_enqueue(struct buf_ring *br, void *buf)
return (ENOBUFS); return (ENOBUFS);
} }
success = atomic_cmpset_int(&br->br_prod_head, prod_head, success = atomic_cmpset_int((volatile int *)&br->br_prod_head, prod_head,
prod_next); prod_next);
} while (success == 0); } while (success == 0);
#ifdef DEBUG_BUFRING #ifdef DEBUG_BUFRING
@@ -146,7 +146,7 @@ buf_ring_dequeue_mc(struct buf_ring *br)
return (NULL); return (NULL);
} }
success = atomic_cmpset_int(&br->br_cons_head, cons_head, success = atomic_cmpset_int((volatile int *)&br->br_cons_head, cons_head,
cons_next); cons_next);
} while (success == 0); } while (success == 0);
@@ -178,7 +178,10 @@ buf_ring_dequeue_mc(struct buf_ring *br)
static __inline void * static __inline void *
buf_ring_dequeue_sc(struct buf_ring *br) buf_ring_dequeue_sc(struct buf_ring *br)
{ {
uint32_t cons_head, cons_next, cons_next_next; uint32_t cons_head, cons_next;
#ifdef PREFETCH_DEFINED
uint32_t cons_next_next;
#endif
uint32_t prod_tail; uint32_t prod_tail;
void *buf; void *buf;
@@ -186,7 +189,9 @@ buf_ring_dequeue_sc(struct buf_ring *br)
prod_tail = br->br_prod_tail; prod_tail = br->br_prod_tail;
cons_next = (cons_head + 1) & br->br_cons_mask; cons_next = (cons_head + 1) & br->br_cons_mask;
#ifdef PREFETCH_DEFINED
cons_next_next = (cons_head + 2) & br->br_cons_mask; cons_next_next = (cons_head + 2) & br->br_cons_mask;
#endif
if (cons_head == prod_tail) if (cons_head == prod_tail)
return (NULL); return (NULL);
@@ -254,11 +259,11 @@ buf_ring_advance_sc(struct buf_ring *br)
* the compare and an atomic. * the compare and an atomic.
*/ */
static __inline void static __inline void
buf_ring_putback_sc(struct buf_ring *br, void *new) buf_ring_putback_sc(struct buf_ring *br, void *new_item)
{ {
KASSERT(br->br_cons_head != br->br_prod_tail, KASSERT(br->br_cons_head != br->br_prod_tail,
("Buf-Ring has none in putback")) ; ("Buf-Ring has none in putback")) ;
br->br_ring[br->br_cons_head] = new; br->br_ring[br->br_cons_head] = new_item;
} }
/* /*

View File

@@ -529,7 +529,7 @@ m_getclr(int how, short type)
args.flags = 0; args.flags = 0;
args.type = type; args.type = type;
m = uma_zalloc_arg(zone_mbuf, &args, how); m = (struct mbuf *)uma_zalloc_arg(zone_mbuf, &args, how);
if (m != NULL) if (m != NULL)
bzero(m->m_data, MLEN); bzero(m->m_data, MLEN);
return (m); return (m);
@@ -574,12 +574,12 @@ m_getjcl(int how, short type, int flags, int size)
args.flags = flags; args.flags = flags;
args.type = type; args.type = type;
m = uma_zalloc_arg(zone_mbuf, &args, how); m = (struct mbuf *)uma_zalloc_arg(zone_mbuf, &args, how);
if (m == NULL) if (m == NULL)
return (NULL); return (NULL);
zone = m_getzone(size); zone = m_getzone(size);
n = uma_zalloc_arg(zone, m, how); n = (struct mbuf *)uma_zalloc_arg(zone, m, how);
if (n == NULL) { if (n == NULL) {
uma_zfree(zone_mbuf, m); uma_zfree(zone_mbuf, m);
return (NULL); return (NULL);
@@ -679,8 +679,9 @@ m_cljset(struct mbuf *m, void *cl, int type)
break; break;
} }
m->m_data = m->m_ext.ext_buf = cl; m->m_data = m->m_ext.ext_buf = (caddr_t)cl;
m->m_ext.ext_free = m->m_ext.ext_arg1 = m->m_ext.ext_arg2 = NULL; m->m_ext.ext_free = NULL;
m->m_ext.ext_arg1 = m->m_ext.ext_arg2 = NULL;
m->m_ext.ext_size = size; m->m_ext.ext_size = size;
m->m_ext.ext_type = type; m->m_ext.ext_type = type;
m->m_ext.ref_cnt = (volatile u_int *) uma_find_refcnt(zone, cl); m->m_ext.ref_cnt = (volatile u_int *) uma_find_refcnt(zone, cl);

View File

@@ -306,7 +306,7 @@ int fubyte(const void *base);
static inline int static inline int
fubyte(const void *base) fubyte(const void *base)
{ {
const unsigned char *byte_base = base; const unsigned char *byte_base = (const unsigned char *)base;
return byte_base[0]; return byte_base[0];
} }