Deleted Added
full compact
linux_compat.c (299930) linux_compat.c (300496)
1/*-
2 * Copyright (c) 2010 Isilon Systems, Inc.
3 * Copyright (c) 2010 iX Systems, Inc.
4 * Copyright (c) 2010 Panasas, Inc.
5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2010 Isilon Systems, Inc.
3 * Copyright (c) 2010 iX Systems, Inc.
4 * Copyright (c) 2010 Panasas, Inc.
5 * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/compat/linuxkpi/common/src/linux_compat.c 299930 2016-05-16 09:16:15Z hselasky $");
31__FBSDID("$FreeBSD: head/sys/compat/linuxkpi/common/src/linux_compat.c 300496 2016-05-23 12:03:40Z hselasky $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/malloc.h>
36#include <sys/kernel.h>
37#include <sys/sysctl.h>
38#include <sys/proc.h>
39#include <sys/sglist.h>

--- 27 unchanged lines hidden (view full) ---

67#include <linux/vmalloc.h>
68#include <linux/netdevice.h>
69#include <linux/timer.h>
70#include <linux/workqueue.h>
71#include <linux/rcupdate.h>
72#include <linux/interrupt.h>
73#include <linux/uaccess.h>
74#include <linux/kernel.h>
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/malloc.h>
36#include <sys/kernel.h>
37#include <sys/sysctl.h>
38#include <sys/proc.h>
39#include <sys/sglist.h>

--- 27 unchanged lines hidden (view full) ---

67#include <linux/vmalloc.h>
68#include <linux/netdevice.h>
69#include <linux/timer.h>
70#include <linux/workqueue.h>
71#include <linux/rcupdate.h>
72#include <linux/interrupt.h>
73#include <linux/uaccess.h>
74#include <linux/kernel.h>
75#include <linux/list.h>
75
76#include <vm/vm_pager.h>
77
78MALLOC_DEFINE(M_KMALLOC, "linux", "Linux kmalloc compat");
79
80#include <linux/rbtree.h>
81/* Undo Linux compat changes. */
82#undef RB_ROOT

--- 1270 unchanged lines hidden (view full) ---

1353{
1354
1355 EVENTHANDLER_DEREGISTER(ifaddr_event,
1356 nb->tags[NETDEV_CHANGEIFADDR]);
1357
1358 return (0);
1359}
1360
76
77#include <vm/vm_pager.h>
78
79MALLOC_DEFINE(M_KMALLOC, "linux", "Linux kmalloc compat");
80
81#include <linux/rbtree.h>
82/* Undo Linux compat changes. */
83#undef RB_ROOT

--- 1270 unchanged lines hidden (view full) ---

1354{
1355
1356 EVENTHANDLER_DEREGISTER(ifaddr_event,
1357 nb->tags[NETDEV_CHANGEIFADDR]);
1358
1359 return (0);
1360}
1361
1362struct list_sort_thunk {
1363 int (*cmp)(void *, struct list_head *, struct list_head *);
1364 void *priv;
1365};
1366
1367static inline int
1368linux_le_cmp(void *priv, const void *d1, const void *d2)
1369{
1370 struct list_head *le1, *le2;
1371 struct list_sort_thunk *thunk;
1372
1373 thunk = priv;
1374 le1 = *(__DECONST(struct list_head **, d1));
1375 le2 = *(__DECONST(struct list_head **, d2));
1376 return ((thunk->cmp)(thunk->priv, le1, le2));
1377}
1378
1361void
1379void
1380list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv,
1381 struct list_head *a, struct list_head *b))
1382{
1383 struct list_sort_thunk thunk;
1384 struct list_head **ar, *le;
1385 size_t count, i;
1386
1387 count = 0;
1388 list_for_each(le, head)
1389 count++;
1390 ar = malloc(sizeof(struct list_head *) * count, M_KMALLOC, M_WAITOK);
1391 i = 0;
1392 list_for_each(le, head)
1393 ar[i++] = le;
1394 thunk.cmp = cmp;
1395 thunk.priv = priv;
1396 qsort_r(ar, count, sizeof(struct list_head *), &thunk, linux_le_cmp);
1397 INIT_LIST_HEAD(head);
1398 for (i = 0; i < count; i++)
1399 list_add_tail(ar[i], head);
1400 free(ar, M_KMALLOC);
1401}
1402
1403void
1362linux_irq_handler(void *ent)
1363{
1364 struct irq_ent *irqe;
1365
1366 irqe = ent;
1367 irqe->handler(irqe->irq, irqe->arg);
1368}
1369

--- 57 unchanged lines hidden ---
1404linux_irq_handler(void *ent)
1405{
1406 struct irq_ent *irqe;
1407
1408 irqe = ent;
1409 irqe->handler(irqe->irq, irqe->arg);
1410}
1411

--- 57 unchanged lines hidden ---