portability fixes

This commit is contained in:
Luigi Rizzo 2010-03-04 21:52:40 +00:00
parent ae8b199313
commit b05934e2cb
2 changed files with 17 additions and 2 deletions

View File

@ -12,11 +12,9 @@
#include <strings.h> /* bzero, ffs, ... */
#include <string.h> /* strcmp */
#include <errno.h>
#include <inttypes.h>
#include <sys/queue.h>
#include <sys/time.h>
extern int debug;
#define ND(fmt, args...) do {} while (0)
#define D1(fmt, args...) do {} while (0)
@ -141,6 +139,10 @@ struct dn_alg {
#endif
#ifndef __FreeBSD__
int fls(int);
#endif
static inline void
mq_append(struct mq *q, struct mbuf *m)
{

View File

@ -74,3 +74,16 @@ ipdn_bound_var(int *v, int dflt, int lo, int hi, const char *msg)
return *v;
}
#ifndef __FreeBSD__
int
fls(int mask)
{
int bit;
if (mask == 0)
return (0);
for (bit = 1; mask != 1; bit++)
mask = (unsigned int)mask >> 1;
return (bit);
}
#endif