Add more functions to the LinuxKPI.

Define strnicmp as a function macro instead of a regular macro while
at it.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2016-03-03 09:56:04 +00:00
parent 24fe42dcdd
commit 510ebed7be
4 changed files with 16 additions and 3 deletions

View File

@ -93,6 +93,12 @@ ether_addr_equal_64bits(const u8 *pa, const u8 *pb)
return (memcmp(pa, pb, 6) == 0);
}
static inline void
eth_broadcast_addr(u8 *pa)
{
memset(pa, 0xff, 6);
}
static inline void
random_ether_addr(u8 * dst)
{

View File

@ -163,6 +163,7 @@
#define simple_strtol(...) strtol(__VA_ARGS__)
#define kstrtol(a,b,c) ({*(c) = strtol(a,0,b); 0;})
#define kstrtoint(a,b,c) ({*(c) = strtol(a,0,b); 0;})
#define kstrtouint(a,b,c) ({*(c) = strtol(a,0,b); 0;})
#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))

View File

@ -46,6 +46,7 @@ MALLOC_DECLARE(M_KMALLOC);
#define kzalloc(size, flags) kmalloc((size), (flags) | M_ZERO)
#define kzalloc_node(size, flags, node) kzalloc(size, flags)
#define kfree(ptr) free(__DECONST(void *, (ptr)), M_KMALLOC)
#define kfree_const(ptr) kfree(ptr)
#define krealloc(ptr, size, flags) realloc((ptr), (size), M_KMALLOC, (flags))
#define kcalloc(n, size, flags) kmalloc((n) * (size), flags | M_ZERO)
#define vzalloc(size) kzalloc(size, GFP_KERNEL | __GFP_NOWARN)

View File

@ -2,7 +2,7 @@
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
* Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
* Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -37,8 +37,7 @@
#include <sys/libkern.h>
#define strnicmp strncasecmp
#define strnicmp(...) strncasecmp(__VA_ARGS__)
static inline void *
kmemdup(const void *src, size_t len, gfp_t gfp)
@ -51,4 +50,10 @@ kmemdup(const void *src, size_t len, gfp_t gfp)
return (dst);
}
static inline const char *
kstrdup_const(const char *src, gfp_t gfp)
{
return (kmemdup(src, strlen(src) + 1, gfp));
}
#endif /* _LINUX_STRING_H_ */