Ticket #12617: bsd.patch

File bsd.patch, 350.4 KB (added by TwoFx, 8 years ago)
  • new file headers/compatibility/bsd/sys/queue.h

    From a6de2d502c7cb53bed7b9940f9bce1be3caa64d5 Mon Sep 17 00:00:00 2001
    From: Markus Himmel <markus@himmel-villmar.de>
    Date: Mon, 25 Jan 2016 08:21:01 +0100
    Subject: [PATCH 1/3] headers: Move BSD <sys/queue.h> to BSD compatibility
     folder
    
    ---
     headers/compatibility/bsd/sys/queue.h              | 618 +++++++++++++++++++++
     headers/private/firewire/queue.h                   | 618 ---------------------
     src/libs/compat/freebsd_network/compat/sys/queue.h | 552 ------------------
     3 files changed, 618 insertions(+), 1170 deletions(-)
     create mode 100644 headers/compatibility/bsd/sys/queue.h
     delete mode 100644 headers/private/firewire/queue.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/queue.h
    
    diff --git a/headers/compatibility/bsd/sys/queue.h b/headers/compatibility/bsd/sys/queue.h
    new file mode 100644
    index 0000000..d62afcc
    - +  
     1/*-
     2 * Copyright (c) 1991, 1993
     3 *  The Regents of the University of California.  All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 * 4. Neither the name of the University nor the names of its contributors
     14 *    may be used to endorse or promote products derived from this software
     15 *    without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27 * SUCH DAMAGE.
     28 *
     29 *  @(#)queue.h 8.5 (Berkeley) 8/20/94
     30 * $FreeBSD: src/sys/sys/queue.h,v 1.68 2006/10/24 11:20:29 ru Exp $
     31 */
     32
     33#ifndef _SYS_QUEUE_H_
     34#define _SYS_QUEUE_H_
     35
     36#include <sys/cdefs.h>
     37
     38/*
     39 * This file defines four types of data structures: singly-linked lists,
     40 * singly-linked tail queues, lists and tail queues.
     41 *
     42 * A singly-linked list is headed by a single forward pointer. The elements
     43 * are singly linked for minimum space and pointer manipulation overhead at
     44 * the expense of O(n) removal for arbitrary elements. New elements can be
     45 * added to the list after an existing element or at the head of the list.
     46 * Elements being removed from the head of the list should use the explicit
     47 * macro for this purpose for optimum efficiency. A singly-linked list may
     48 * only be traversed in the forward direction.  Singly-linked lists are ideal
     49 * for applications with large datasets and few or no removals or for
     50 * implementing a LIFO queue.
     51 *
     52 * A singly-linked tail queue is headed by a pair of pointers, one to the
     53 * head of the list and the other to the tail of the list. The elements are
     54 * singly linked for minimum space and pointer manipulation overhead at the
     55 * expense of O(n) removal for arbitrary elements. New elements can be added
     56 * to the list after an existing element, at the head of the list, or at the
     57 * end of the list. Elements being removed from the head of the tail queue
     58 * should use the explicit macro for this purpose for optimum efficiency.
     59 * A singly-linked tail queue may only be traversed in the forward direction.
     60 * Singly-linked tail queues are ideal for applications with large datasets
     61 * and few or no removals or for implementing a FIFO queue.
     62 *
     63 * A list is headed by a single forward pointer (or an array of forward
     64 * pointers for a hash table header). The elements are doubly linked
     65 * so that an arbitrary element can be removed without a need to
     66 * traverse the list. New elements can be added to the list before
     67 * or after an existing element or at the head of the list. A list
     68 * may only be traversed in the forward direction.
     69 *
     70 * A tail queue is headed by a pair of pointers, one to the head of the
     71 * list and the other to the tail of the list. The elements are doubly
     72 * linked so that an arbitrary element can be removed without a need to
     73 * traverse the list. New elements can be added to the list before or
     74 * after an existing element, at the head of the list, or at the end of
     75 * the list. A tail queue may be traversed in either direction.
     76 *
     77 * For details on the use of these macros, see the queue(3) manual page.
     78 *
     79 *
     80 *              SLIST   LIST    STAILQ  TAILQ
     81 * _HEAD            +   +   +   +
     82 * _HEAD_INITIALIZER        +   +   +   +
     83 * _ENTRY           +   +   +   +
     84 * _INIT            +   +   +   +
     85 * _EMPTY           +   +   +   +
     86 * _FIRST           +   +   +   +
     87 * _NEXT            +   +   +   +
     88 * _PREV            -   -   -   +
     89 * _LAST            -   -   +   +
     90 * _FOREACH         +   +   +   +
     91 * _FOREACH_SAFE        +   +   +   +
     92 * _FOREACH_REVERSE     -   -   -   +
     93 * _FOREACH_REVERSE_SAFE    -   -   -   +
     94 * _INSERT_HEAD         +   +   +   +
     95 * _INSERT_BEFORE       -   +   -   +
     96 * _INSERT_AFTER        +   +   +   +
     97 * _INSERT_TAIL         -   -   +   +
     98 * _CONCAT          -   -   +   +
     99 * _REMOVE_HEAD         +   -   +   -
     100 * _REMOVE          +   +   +   +
     101 *
     102 */
     103#ifdef QUEUE_MACRO_DEBUG
     104/* Store the last 2 places the queue element or head was altered */
     105struct qm_trace {
     106    char * lastfile;
     107    int lastline;
     108    char * prevfile;
     109    int prevline;
     110};
     111
     112#define TRACEBUF    struct qm_trace trace;
     113#define TRASHIT(x)  do {(x) = (void *)-1;} while (0)
     114
     115#define QMD_TRACE_HEAD(head) do {                   \
     116    (head)->trace.prevline = (head)->trace.lastline;        \
     117    (head)->trace.prevfile = (head)->trace.lastfile;        \
     118    (head)->trace.lastline = __LINE__;              \
     119    (head)->trace.lastfile = __FILE__;              \
     120} while (0)
     121
     122#define QMD_TRACE_ELEM(elem) do {                   \
     123    (elem)->trace.prevline = (elem)->trace.lastline;        \
     124    (elem)->trace.prevfile = (elem)->trace.lastfile;        \
     125    (elem)->trace.lastline = __LINE__;              \
     126    (elem)->trace.lastfile = __FILE__;              \
     127} while (0)
     128
     129#else
     130#define QMD_TRACE_ELEM(elem)
     131#define QMD_TRACE_HEAD(head)
     132#define TRACEBUF
     133#define TRASHIT(x)
     134#endif  /* QUEUE_MACRO_DEBUG */
     135
     136/*
     137 * Singly-linked List declarations.
     138 */
     139#define SLIST_HEAD(name, type)                      \
     140struct name {                               \
     141    struct type *slh_first; /* first element */         \
     142}
     143
     144#define SLIST_HEAD_INITIALIZER(head)                    \
     145    { NULL }
     146
     147#define SLIST_ENTRY(type)                       \
     148struct {                                \
     149    struct type *sle_next;  /* next element */          \
     150}
     151
     152/*
     153 * Singly-linked List functions.
     154 */
     155#define SLIST_EMPTY(head)   ((head)->slh_first == NULL)
     156
     157#define SLIST_FIRST(head)   ((head)->slh_first)
     158
     159#define SLIST_FOREACH(var, head, field)                 \
     160    for ((var) = SLIST_FIRST((head));               \
     161        (var);                          \
     162        (var) = SLIST_NEXT((var), field))
     163
     164#define SLIST_FOREACH_SAFE(var, head, field, tvar)          \
     165    for ((var) = SLIST_FIRST((head));               \
     166        (var) && ((tvar) = SLIST_NEXT((var), field), 1);        \
     167        (var) = (tvar))
     168
     169#define SLIST_FOREACH_PREVPTR(var, varp, head, field)           \
     170    for ((varp) = &SLIST_FIRST((head));             \
     171        ((var) = *(varp)) != NULL;                  \
     172        (varp) = &SLIST_NEXT((var), field))
     173
     174#define SLIST_INIT(head) do {                       \
     175    SLIST_FIRST((head)) = NULL;                 \
     176} while (0)
     177
     178#define SLIST_INSERT_AFTER(slistelm, elm, field) do {           \
     179    SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);   \
     180    SLIST_NEXT((slistelm), field) = (elm);              \
     181} while (0)
     182
     183#define SLIST_INSERT_HEAD(head, elm, field) do {            \
     184    SLIST_NEXT((elm), field) = SLIST_FIRST((head));         \
     185    SLIST_FIRST((head)) = (elm);                    \
     186} while (0)
     187
     188#define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
     189
     190#define SLIST_REMOVE(head, elm, type, field) do {           \
     191    if (SLIST_FIRST((head)) == (elm)) {             \
     192        SLIST_REMOVE_HEAD((head), field);           \
     193    }                               \
     194    else {                              \
     195        struct type *curelm = SLIST_FIRST((head));      \
     196        while (SLIST_NEXT(curelm, field) != (elm))      \
     197            curelm = SLIST_NEXT(curelm, field);     \
     198        SLIST_NEXT(curelm, field) =             \
     199            SLIST_NEXT(SLIST_NEXT(curelm, field), field);   \
     200    }                               \
     201    TRASHIT((elm)->field.sle_next);                 \
     202} while (0)
     203
     204#define SLIST_REMOVE_HEAD(head, field) do {             \
     205    SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);   \
     206} while (0)
     207
     208/*
     209 * Singly-linked Tail queue declarations.
     210 */
     211#define STAILQ_HEAD(name, type)                     \
     212struct name {                               \
     213    struct type *stqh_first;/* first element */         \
     214    struct type **stqh_last;/* addr of last next element */     \
     215}
     216
     217#define STAILQ_HEAD_INITIALIZER(head)                   \
     218    { NULL, &(head).stqh_first }
     219
     220#define STAILQ_ENTRY(type)                      \
     221struct {                                \
     222    struct type *stqe_next; /* next element */          \
     223}
     224
     225/*
     226 * Singly-linked Tail queue functions.
     227 */
     228#define STAILQ_CONCAT(head1, head2) do {                \
     229    if (!STAILQ_EMPTY((head2))) {                   \
     230        *(head1)->stqh_last = (head2)->stqh_first;      \
     231        (head1)->stqh_last = (head2)->stqh_last;        \
     232        STAILQ_INIT((head2));                   \
     233    }                               \
     234} while (0)
     235
     236#define STAILQ_EMPTY(head)  ((head)->stqh_first == NULL)
     237
     238#define STAILQ_FIRST(head)  ((head)->stqh_first)
     239
     240#define STAILQ_FOREACH(var, head, field)                \
     241    for((var) = STAILQ_FIRST((head));               \
     242       (var);                           \
     243       (var) = STAILQ_NEXT((var), field))
     244
     245
     246#define STAILQ_FOREACH_SAFE(var, head, field, tvar)         \
     247    for ((var) = STAILQ_FIRST((head));              \
     248        (var) && ((tvar) = STAILQ_NEXT((var), field), 1);       \
     249        (var) = (tvar))
     250
     251#define STAILQ_INIT(head) do {                      \
     252    STAILQ_FIRST((head)) = NULL;                    \
     253    (head)->stqh_last = &STAILQ_FIRST((head));          \
     254} while (0)
     255
     256#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {       \
     257    if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
     258        (head)->stqh_last = &STAILQ_NEXT((elm), field);     \
     259    STAILQ_NEXT((tqelm), field) = (elm);                \
     260} while (0)
     261
     262#define STAILQ_INSERT_HEAD(head, elm, field) do {           \
     263    if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
     264        (head)->stqh_last = &STAILQ_NEXT((elm), field);     \
     265    STAILQ_FIRST((head)) = (elm);                   \
     266} while (0)
     267
     268#define STAILQ_INSERT_TAIL(head, elm, field) do {           \
     269    STAILQ_NEXT((elm), field) = NULL;               \
     270    *(head)->stqh_last = (elm);                 \
     271    (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
     272} while (0)
     273
     274#define STAILQ_LAST(head, type, field)                  \
     275    (STAILQ_EMPTY((head)) ?                     \
     276        NULL :                          \
     277            ((struct type *)(void *)                \
     278        ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
     279
     280#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
     281
     282#define STAILQ_REMOVE(head, elm, type, field) do {          \
     283    if (STAILQ_FIRST((head)) == (elm)) {                \
     284        STAILQ_REMOVE_HEAD((head), field);          \
     285    }                               \
     286    else {                              \
     287        struct type *curelm = STAILQ_FIRST((head));     \
     288        while (STAILQ_NEXT(curelm, field) != (elm))     \
     289            curelm = STAILQ_NEXT(curelm, field);        \
     290        if ((STAILQ_NEXT(curelm, field) =           \
     291             STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
     292            (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
     293    }                               \
     294    TRASHIT((elm)->field.stqe_next);                \
     295} while (0)
     296
     297#define STAILQ_REMOVE_HEAD(head, field) do {                \
     298    if ((STAILQ_FIRST((head)) =                 \
     299         STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)     \
     300        (head)->stqh_last = &STAILQ_FIRST((head));      \
     301} while (0)
     302
     303/*
     304 * List declarations.
     305 */
     306#define LIST_HEAD(name, type)                       \
     307struct name {                               \
     308    struct type *lh_first;  /* first element */         \
     309}
     310
     311#define LIST_HEAD_INITIALIZER(head)                 \
     312    { NULL }
     313
     314#define LIST_ENTRY(type)                        \
     315struct {                                \
     316    struct type *le_next;   /* next element */          \
     317    struct type **le_prev;  /* address of previous next element */  \
     318}
     319
     320/*
     321 * List functions.
     322 */
     323
     324#if (defined(_KERNEL) && defined(INVARIANTS))
     325#define QMD_LIST_CHECK_HEAD(head, field) do {               \
     326    if (LIST_FIRST((head)) != NULL &&               \
     327        LIST_FIRST((head))->field.le_prev !=            \
     328         &LIST_FIRST((head)))                   \
     329        panic("Bad list head %p first->prev != head", (head));  \
     330} while (0)
     331
     332#define QMD_LIST_CHECK_NEXT(elm, field) do {                \
     333    if (LIST_NEXT((elm), field) != NULL &&              \
     334        LIST_NEXT((elm), field)->field.le_prev !=           \
     335         &((elm)->field.le_next))                   \
     336            panic("Bad link elm %p next->prev != elm", (elm));  \
     337} while (0)
     338
     339#define QMD_LIST_CHECK_PREV(elm, field) do {                \
     340    if (*(elm)->field.le_prev != (elm))             \
     341        panic("Bad link elm %p prev->next != elm", (elm));  \
     342} while (0)
     343#else
     344#define QMD_LIST_CHECK_HEAD(head, field)
     345#define QMD_LIST_CHECK_NEXT(elm, field)
     346#define QMD_LIST_CHECK_PREV(elm, field)
     347#endif /* (_KERNEL && INVARIANTS) */
     348
     349#define LIST_EMPTY(head)    ((head)->lh_first == NULL)
     350
     351#define LIST_FIRST(head)    ((head)->lh_first)
     352
     353#define LIST_FOREACH(var, head, field)                  \
     354    for ((var) = LIST_FIRST((head));                \
     355        (var);                          \
     356        (var) = LIST_NEXT((var), field))
     357
     358#define LIST_FOREACH_SAFE(var, head, field, tvar)           \
     359    for ((var) = LIST_FIRST((head));                \
     360        (var) && ((tvar) = LIST_NEXT((var), field), 1);     \
     361        (var) = (tvar))
     362
     363#define LIST_INIT(head) do {                        \
     364    LIST_FIRST((head)) = NULL;                  \
     365} while (0)
     366
     367#define LIST_INSERT_AFTER(listelm, elm, field) do {         \
     368    QMD_LIST_CHECK_NEXT(listelm, field);                \
     369    if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
     370        LIST_NEXT((listelm), field)->field.le_prev =        \
     371            &LIST_NEXT((elm), field);               \
     372    LIST_NEXT((listelm), field) = (elm);                \
     373    (elm)->field.le_prev = &LIST_NEXT((listelm), field);        \
     374} while (0)
     375
     376#define LIST_INSERT_BEFORE(listelm, elm, field) do {            \
     377    QMD_LIST_CHECK_PREV(listelm, field);                \
     378    (elm)->field.le_prev = (listelm)->field.le_prev;        \
     379    LIST_NEXT((elm), field) = (listelm);                \
     380    *(listelm)->field.le_prev = (elm);              \
     381    (listelm)->field.le_prev = &LIST_NEXT((elm), field);        \
     382} while (0)
     383
     384#define LIST_INSERT_HEAD(head, elm, field) do {             \
     385    QMD_LIST_CHECK_HEAD((head), field);             \
     386    if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
     387        LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
     388    LIST_FIRST((head)) = (elm);                 \
     389    (elm)->field.le_prev = &LIST_FIRST((head));         \
     390} while (0)
     391
     392#define LIST_NEXT(elm, field)   ((elm)->field.le_next)
     393
     394#define LIST_REMOVE(elm, field) do {                    \
     395    QMD_LIST_CHECK_NEXT(elm, field);                \
     396    QMD_LIST_CHECK_PREV(elm, field);                \
     397    if (LIST_NEXT((elm), field) != NULL)                \
     398        LIST_NEXT((elm), field)->field.le_prev =        \
     399            (elm)->field.le_prev;               \
     400    *(elm)->field.le_prev = LIST_NEXT((elm), field);        \
     401    TRASHIT((elm)->field.le_next);                  \
     402    TRASHIT((elm)->field.le_prev);                  \
     403} while (0)
     404
     405/*
     406 * Tail queue declarations.
     407 */
     408#define TAILQ_HEAD(name, type)                      \
     409struct name {                               \
     410    struct type *tqh_first; /* first element */         \
     411    struct type **tqh_last; /* addr of last next element */     \
     412    TRACEBUF                            \
     413}
     414
     415#define TAILQ_HEAD_INITIALIZER(head)                    \
     416    { NULL, &(head).tqh_first }
     417
     418#define TAILQ_ENTRY(type)                       \
     419struct {                                \
     420    struct type *tqe_next;  /* next element */          \
     421    struct type **tqe_prev; /* address of previous next element */  \
     422    TRACEBUF                            \
     423}
     424
     425/*
     426 * Tail queue functions.
     427 */
     428#if (defined(_KERNEL) && defined(INVARIANTS))
     429#define QMD_TAILQ_CHECK_HEAD(head, field) do {              \
     430    if (!TAILQ_EMPTY(head) &&                   \
     431        TAILQ_FIRST((head))->field.tqe_prev !=          \
     432         &TAILQ_FIRST((head)))                  \
     433        panic("Bad tailq head %p first->prev != head", (head)); \
     434} while (0)
     435
     436#define QMD_TAILQ_CHECK_TAIL(head, field) do {              \
     437    if (*(head)->tqh_last != NULL)                  \
     438            panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head));  \
     439} while (0)
     440
     441#define QMD_TAILQ_CHECK_NEXT(elm, field) do {               \
     442    if (TAILQ_NEXT((elm), field) != NULL &&             \
     443        TAILQ_NEXT((elm), field)->field.tqe_prev !=         \
     444         &((elm)->field.tqe_next))                  \
     445        panic("Bad link elm %p next->prev != elm", (elm));  \
     446} while (0)
     447
     448#define QMD_TAILQ_CHECK_PREV(elm, field) do {               \
     449    if (*(elm)->field.tqe_prev != (elm))                \
     450        panic("Bad link elm %p prev->next != elm", (elm));  \
     451} while (0)
     452#else
     453#define QMD_TAILQ_CHECK_HEAD(head, field)
     454#define QMD_TAILQ_CHECK_TAIL(head, headname)
     455#define QMD_TAILQ_CHECK_NEXT(elm, field)
     456#define QMD_TAILQ_CHECK_PREV(elm, field)
     457#endif /* (_KERNEL && INVARIANTS) */
     458
     459#define TAILQ_CONCAT(head1, head2, field) do {              \
     460    if (!TAILQ_EMPTY(head2)) {                  \
     461        *(head1)->tqh_last = (head2)->tqh_first;        \
     462        (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
     463        (head1)->tqh_last = (head2)->tqh_last;          \
     464        TAILQ_INIT((head2));                    \
     465        QMD_TRACE_HEAD(head1);                  \
     466        QMD_TRACE_HEAD(head2);                  \
     467    }                               \
     468} while (0)
     469
     470#define TAILQ_EMPTY(head)   ((head)->tqh_first == NULL)
     471
     472#define TAILQ_FIRST(head)   ((head)->tqh_first)
     473
     474#define TAILQ_FOREACH(var, head, field)                 \
     475    for ((var) = TAILQ_FIRST((head));               \
     476        (var);                          \
     477        (var) = TAILQ_NEXT((var), field))
     478
     479#define TAILQ_FOREACH_SAFE(var, head, field, tvar)          \
     480    for ((var) = TAILQ_FIRST((head));               \
     481        (var) && ((tvar) = TAILQ_NEXT((var), field), 1);        \
     482        (var) = (tvar))
     483
     484#define TAILQ_FOREACH_REVERSE(var, head, headname, field)       \
     485    for ((var) = TAILQ_LAST((head), headname);          \
     486        (var);                          \
     487        (var) = TAILQ_PREV((var), headname, field))
     488
     489#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar)    \
     490    for ((var) = TAILQ_LAST((head), headname);          \
     491        (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1);  \
     492        (var) = (tvar))
     493
     494#define TAILQ_INIT(head) do {                       \
     495    TAILQ_FIRST((head)) = NULL;                 \
     496    (head)->tqh_last = &TAILQ_FIRST((head));            \
     497    QMD_TRACE_HEAD(head);                       \
     498} while (0)
     499
     500#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {      \
     501    QMD_TAILQ_CHECK_NEXT(listelm, field);               \
     502    if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
     503        TAILQ_NEXT((elm), field)->field.tqe_prev =      \
     504            &TAILQ_NEXT((elm), field);              \
     505    else {                              \
     506        (head)->tqh_last = &TAILQ_NEXT((elm), field);       \
     507        QMD_TRACE_HEAD(head);                   \
     508    }                               \
     509    TAILQ_NEXT((listelm), field) = (elm);               \
     510    (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);      \
     511    QMD_TRACE_ELEM(&(elm)->field);                  \
     512    QMD_TRACE_ELEM(&listelm->field);                \
     513} while (0)
     514
     515#define TAILQ_INSERT_BEFORE(listelm, elm, field) do {           \
     516    QMD_TAILQ_CHECK_PREV(listelm, field);               \
     517    (elm)->field.tqe_prev = (listelm)->field.tqe_prev;      \
     518    TAILQ_NEXT((elm), field) = (listelm);               \
     519    *(listelm)->field.tqe_prev = (elm);             \
     520    (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);      \
     521    QMD_TRACE_ELEM(&(elm)->field);                  \
     522    QMD_TRACE_ELEM(&listelm->field);                \
     523} while (0)
     524
     525#define TAILQ_INSERT_HEAD(head, elm, field) do {            \
     526    QMD_TAILQ_CHECK_HEAD(head, field);              \
     527    if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)   \
     528        TAILQ_FIRST((head))->field.tqe_prev =           \
     529            &TAILQ_NEXT((elm), field);              \
     530    else                                \
     531        (head)->tqh_last = &TAILQ_NEXT((elm), field);       \
     532    TAILQ_FIRST((head)) = (elm);                    \
     533    (elm)->field.tqe_prev = &TAILQ_FIRST((head));           \
     534    QMD_TRACE_HEAD(head);                       \
     535    QMD_TRACE_ELEM(&(elm)->field);                  \
     536} while (0)
     537
     538#define TAILQ_INSERT_TAIL(head, elm, field) do {            \
     539    QMD_TAILQ_CHECK_TAIL(head, field);              \
     540    TAILQ_NEXT((elm), field) = NULL;                \
     541    (elm)->field.tqe_prev = (head)->tqh_last;           \
     542    *(head)->tqh_last = (elm);                  \
     543    (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
     544    QMD_TRACE_HEAD(head);                       \
     545    QMD_TRACE_ELEM(&(elm)->field);                  \
     546} while (0)
     547
     548#define TAILQ_LAST(head, headname)                  \
     549    (*(((struct headname *)((head)->tqh_last))->tqh_last))
     550
     551#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
     552
     553#define TAILQ_PREV(elm, headname, field)                \
     554    (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
     555
     556#define TAILQ_REMOVE(head, elm, field) do {             \
     557    QMD_TAILQ_CHECK_NEXT(elm, field);               \
     558    QMD_TAILQ_CHECK_PREV(elm, field);               \
     559    if ((TAILQ_NEXT((elm), field)) != NULL)             \
     560        TAILQ_NEXT((elm), field)->field.tqe_prev =      \
     561            (elm)->field.tqe_prev;              \
     562    else {                              \
     563        (head)->tqh_last = (elm)->field.tqe_prev;       \
     564        QMD_TRACE_HEAD(head);                   \
     565    }                               \
     566    *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);      \
     567    TRASHIT((elm)->field.tqe_next);                 \
     568    TRASHIT((elm)->field.tqe_prev);                 \
     569    QMD_TRACE_ELEM(&(elm)->field);                  \
     570} while (0)
     571
     572
     573#ifdef _KERNEL
     574
     575/*
     576 * XXX insque() and remque() are an old way of handling certain queues.
     577 * They bogusly assumes that all queue heads look alike.
     578 */
     579
     580struct quehead {
     581    struct quehead *qh_link;
     582    struct quehead *qh_rlink;
     583};
     584
     585#ifdef __CC_SUPPORTS___INLINE
     586
     587static __inline void
     588insque(void *a, void *b)
     589{
     590    struct quehead *element = (struct quehead *)a,
     591         *head = (struct quehead *)b;
     592
     593    element->qh_link = head->qh_link;
     594    element->qh_rlink = head;
     595    head->qh_link = element;
     596    element->qh_link->qh_rlink = element;
     597}
     598
     599static __inline void
     600remque(void *a)
     601{
     602    struct quehead *element = (struct quehead *)a;
     603
     604    element->qh_link->qh_rlink = element->qh_rlink;
     605    element->qh_rlink->qh_link = element->qh_link;
     606    element->qh_rlink = 0;
     607}
     608
     609#else /* !__CC_SUPPORTS___INLINE */
     610
     611void    insque(void *a, void *b);
     612void    remque(void *a);
     613
     614#endif /* __CC_SUPPORTS___INLINE */
     615
     616#endif /* _KERNEL */
     617
     618#endif /* !_SYS_QUEUE_H_ */
  • deleted file headers/private/firewire/queue.h

    diff --git a/headers/private/firewire/queue.h b/headers/private/firewire/queue.h
    deleted file mode 100644
    index d62afcc..0000000
    + -  
    1 /*-
    2  * Copyright (c) 1991, 1993
    3  *  The Regents of the University of California.  All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
    10  * 2. Redistributions in binary form must reproduce the above copyright
    11  *    notice, this list of conditions and the following disclaimer in the
    12  *    documentation and/or other materials provided with the distribution.
    13  * 4. Neither the name of the University nor the names of its contributors
    14  *    may be used to endorse or promote products derived from this software
    15  *    without specific prior written permission.
    16  *
    17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    27  * SUCH DAMAGE.
    28  *
    29  *  @(#)queue.h 8.5 (Berkeley) 8/20/94
    30  * $FreeBSD: src/sys/sys/queue.h,v 1.68 2006/10/24 11:20:29 ru Exp $
    31  */
    32 
    33 #ifndef _SYS_QUEUE_H_
    34 #define _SYS_QUEUE_H_
    35 
    36 #include <sys/cdefs.h>
    37 
    38 /*
    39  * This file defines four types of data structures: singly-linked lists,
    40  * singly-linked tail queues, lists and tail queues.
    41  *
    42  * A singly-linked list is headed by a single forward pointer. The elements
    43  * are singly linked for minimum space and pointer manipulation overhead at
    44  * the expense of O(n) removal for arbitrary elements. New elements can be
    45  * added to the list after an existing element or at the head of the list.
    46  * Elements being removed from the head of the list should use the explicit
    47  * macro for this purpose for optimum efficiency. A singly-linked list may
    48  * only be traversed in the forward direction.  Singly-linked lists are ideal
    49  * for applications with large datasets and few or no removals or for
    50  * implementing a LIFO queue.
    51  *
    52  * A singly-linked tail queue is headed by a pair of pointers, one to the
    53  * head of the list and the other to the tail of the list. The elements are
    54  * singly linked for minimum space and pointer manipulation overhead at the
    55  * expense of O(n) removal for arbitrary elements. New elements can be added
    56  * to the list after an existing element, at the head of the list, or at the
    57  * end of the list. Elements being removed from the head of the tail queue
    58  * should use the explicit macro for this purpose for optimum efficiency.
    59  * A singly-linked tail queue may only be traversed in the forward direction.
    60  * Singly-linked tail queues are ideal for applications with large datasets
    61  * and few or no removals or for implementing a FIFO queue.
    62  *
    63  * A list is headed by a single forward pointer (or an array of forward
    64  * pointers for a hash table header). The elements are doubly linked
    65  * so that an arbitrary element can be removed without a need to
    66  * traverse the list. New elements can be added to the list before
    67  * or after an existing element or at the head of the list. A list
    68  * may only be traversed in the forward direction.
    69  *
    70  * A tail queue is headed by a pair of pointers, one to the head of the
    71  * list and the other to the tail of the list. The elements are doubly
    72  * linked so that an arbitrary element can be removed without a need to
    73  * traverse the list. New elements can be added to the list before or
    74  * after an existing element, at the head of the list, or at the end of
    75  * the list. A tail queue may be traversed in either direction.
    76  *
    77  * For details on the use of these macros, see the queue(3) manual page.
    78  *
    79  *
    80  *              SLIST   LIST    STAILQ  TAILQ
    81  * _HEAD            +   +   +   +
    82  * _HEAD_INITIALIZER        +   +   +   +
    83  * _ENTRY           +   +   +   +
    84  * _INIT            +   +   +   +
    85  * _EMPTY           +   +   +   +
    86  * _FIRST           +   +   +   +
    87  * _NEXT            +   +   +   +
    88  * _PREV            -   -   -   +
    89  * _LAST            -   -   +   +
    90  * _FOREACH         +   +   +   +
    91  * _FOREACH_SAFE        +   +   +   +
    92  * _FOREACH_REVERSE     -   -   -   +
    93  * _FOREACH_REVERSE_SAFE    -   -   -   +
    94  * _INSERT_HEAD         +   +   +   +
    95  * _INSERT_BEFORE       -   +   -   +
    96  * _INSERT_AFTER        +   +   +   +
    97  * _INSERT_TAIL         -   -   +   +
    98  * _CONCAT          -   -   +   +
    99  * _REMOVE_HEAD         +   -   +   -
    100  * _REMOVE          +   +   +   +
    101  *
    102  */
    103 #ifdef QUEUE_MACRO_DEBUG
    104 /* Store the last 2 places the queue element or head was altered */
    105 struct qm_trace {
    106     char * lastfile;
    107     int lastline;
    108     char * prevfile;
    109     int prevline;
    110 };
    111 
    112 #define TRACEBUF    struct qm_trace trace;
    113 #define TRASHIT(x)  do {(x) = (void *)-1;} while (0)
    114 
    115 #define QMD_TRACE_HEAD(head) do {                   \
    116     (head)->trace.prevline = (head)->trace.lastline;        \
    117     (head)->trace.prevfile = (head)->trace.lastfile;        \
    118     (head)->trace.lastline = __LINE__;              \
    119     (head)->trace.lastfile = __FILE__;              \
    120 } while (0)
    121 
    122 #define QMD_TRACE_ELEM(elem) do {                   \
    123     (elem)->trace.prevline = (elem)->trace.lastline;        \
    124     (elem)->trace.prevfile = (elem)->trace.lastfile;        \
    125     (elem)->trace.lastline = __LINE__;              \
    126     (elem)->trace.lastfile = __FILE__;              \
    127 } while (0)
    128 
    129 #else
    130 #define QMD_TRACE_ELEM(elem)
    131 #define QMD_TRACE_HEAD(head)
    132 #define TRACEBUF
    133 #define TRASHIT(x)
    134 #endif  /* QUEUE_MACRO_DEBUG */
    135 
    136 /*
    137  * Singly-linked List declarations.
    138  */
    139 #define SLIST_HEAD(name, type)                      \
    140 struct name {                               \
    141     struct type *slh_first; /* first element */         \
    142 }
    143 
    144 #define SLIST_HEAD_INITIALIZER(head)                    \
    145     { NULL }
    146 
    147 #define SLIST_ENTRY(type)                       \
    148 struct {                                \
    149     struct type *sle_next;  /* next element */          \
    150 }
    151 
    152 /*
    153  * Singly-linked List functions.
    154  */
    155 #define SLIST_EMPTY(head)   ((head)->slh_first == NULL)
    156 
    157 #define SLIST_FIRST(head)   ((head)->slh_first)
    158 
    159 #define SLIST_FOREACH(var, head, field)                 \
    160     for ((var) = SLIST_FIRST((head));               \
    161         (var);                          \
    162         (var) = SLIST_NEXT((var), field))
    163 
    164 #define SLIST_FOREACH_SAFE(var, head, field, tvar)          \
    165     for ((var) = SLIST_FIRST((head));               \
    166         (var) && ((tvar) = SLIST_NEXT((var), field), 1);        \
    167         (var) = (tvar))
    168 
    169 #define SLIST_FOREACH_PREVPTR(var, varp, head, field)           \
    170     for ((varp) = &SLIST_FIRST((head));             \
    171         ((var) = *(varp)) != NULL;                  \
    172         (varp) = &SLIST_NEXT((var), field))
    173 
    174 #define SLIST_INIT(head) do {                       \
    175     SLIST_FIRST((head)) = NULL;                 \
    176 } while (0)
    177 
    178 #define SLIST_INSERT_AFTER(slistelm, elm, field) do {           \
    179     SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);   \
    180     SLIST_NEXT((slistelm), field) = (elm);              \
    181 } while (0)
    182 
    183 #define SLIST_INSERT_HEAD(head, elm, field) do {            \
    184     SLIST_NEXT((elm), field) = SLIST_FIRST((head));         \
    185     SLIST_FIRST((head)) = (elm);                    \
    186 } while (0)
    187 
    188 #define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
    189 
    190 #define SLIST_REMOVE(head, elm, type, field) do {           \
    191     if (SLIST_FIRST((head)) == (elm)) {             \
    192         SLIST_REMOVE_HEAD((head), field);           \
    193     }                               \
    194     else {                              \
    195         struct type *curelm = SLIST_FIRST((head));      \
    196         while (SLIST_NEXT(curelm, field) != (elm))      \
    197             curelm = SLIST_NEXT(curelm, field);     \
    198         SLIST_NEXT(curelm, field) =             \
    199             SLIST_NEXT(SLIST_NEXT(curelm, field), field);   \
    200     }                               \
    201     TRASHIT((elm)->field.sle_next);                 \
    202 } while (0)
    203 
    204 #define SLIST_REMOVE_HEAD(head, field) do {             \
    205     SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);   \
    206 } while (0)
    207 
    208 /*
    209  * Singly-linked Tail queue declarations.
    210  */
    211 #define STAILQ_HEAD(name, type)                     \
    212 struct name {                               \
    213     struct type *stqh_first;/* first element */         \
    214     struct type **stqh_last;/* addr of last next element */     \
    215 }
    216 
    217 #define STAILQ_HEAD_INITIALIZER(head)                   \
    218     { NULL, &(head).stqh_first }
    219 
    220 #define STAILQ_ENTRY(type)                      \
    221 struct {                                \
    222     struct type *stqe_next; /* next element */          \
    223 }
    224 
    225 /*
    226  * Singly-linked Tail queue functions.
    227  */
    228 #define STAILQ_CONCAT(head1, head2) do {                \
    229     if (!STAILQ_EMPTY((head2))) {                   \
    230         *(head1)->stqh_last = (head2)->stqh_first;      \
    231         (head1)->stqh_last = (head2)->stqh_last;        \
    232         STAILQ_INIT((head2));                   \
    233     }                               \
    234 } while (0)
    235 
    236 #define STAILQ_EMPTY(head)  ((head)->stqh_first == NULL)
    237 
    238 #define STAILQ_FIRST(head)  ((head)->stqh_first)
    239 
    240 #define STAILQ_FOREACH(var, head, field)                \
    241     for((var) = STAILQ_FIRST((head));               \
    242        (var);                           \
    243        (var) = STAILQ_NEXT((var), field))
    244 
    245 
    246 #define STAILQ_FOREACH_SAFE(var, head, field, tvar)         \
    247     for ((var) = STAILQ_FIRST((head));              \
    248         (var) && ((tvar) = STAILQ_NEXT((var), field), 1);       \
    249         (var) = (tvar))
    250 
    251 #define STAILQ_INIT(head) do {                      \
    252     STAILQ_FIRST((head)) = NULL;                    \
    253     (head)->stqh_last = &STAILQ_FIRST((head));          \
    254 } while (0)
    255 
    256 #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {       \
    257     if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
    258         (head)->stqh_last = &STAILQ_NEXT((elm), field);     \
    259     STAILQ_NEXT((tqelm), field) = (elm);                \
    260 } while (0)
    261 
    262 #define STAILQ_INSERT_HEAD(head, elm, field) do {           \
    263     if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
    264         (head)->stqh_last = &STAILQ_NEXT((elm), field);     \
    265     STAILQ_FIRST((head)) = (elm);                   \
    266 } while (0)
    267 
    268 #define STAILQ_INSERT_TAIL(head, elm, field) do {           \
    269     STAILQ_NEXT((elm), field) = NULL;               \
    270     *(head)->stqh_last = (elm);                 \
    271     (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
    272 } while (0)
    273 
    274 #define STAILQ_LAST(head, type, field)                  \
    275     (STAILQ_EMPTY((head)) ?                     \
    276         NULL :                          \
    277             ((struct type *)(void *)                \
    278         ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
    279 
    280 #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
    281 
    282 #define STAILQ_REMOVE(head, elm, type, field) do {          \
    283     if (STAILQ_FIRST((head)) == (elm)) {                \
    284         STAILQ_REMOVE_HEAD((head), field);          \
    285     }                               \
    286     else {                              \
    287         struct type *curelm = STAILQ_FIRST((head));     \
    288         while (STAILQ_NEXT(curelm, field) != (elm))     \
    289             curelm = STAILQ_NEXT(curelm, field);        \
    290         if ((STAILQ_NEXT(curelm, field) =           \
    291              STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
    292             (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
    293     }                               \
    294     TRASHIT((elm)->field.stqe_next);                \
    295 } while (0)
    296 
    297 #define STAILQ_REMOVE_HEAD(head, field) do {                \
    298     if ((STAILQ_FIRST((head)) =                 \
    299          STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)     \
    300         (head)->stqh_last = &STAILQ_FIRST((head));      \
    301 } while (0)
    302 
    303 /*
    304  * List declarations.
    305  */
    306 #define LIST_HEAD(name, type)                       \
    307 struct name {                               \
    308     struct type *lh_first;  /* first element */         \
    309 }
    310 
    311 #define LIST_HEAD_INITIALIZER(head)                 \
    312     { NULL }
    313 
    314 #define LIST_ENTRY(type)                        \
    315 struct {                                \
    316     struct type *le_next;   /* next element */          \
    317     struct type **le_prev;  /* address of previous next element */  \
    318 }
    319 
    320 /*
    321  * List functions.
    322  */
    323 
    324 #if (defined(_KERNEL) && defined(INVARIANTS))
    325 #define QMD_LIST_CHECK_HEAD(head, field) do {               \
    326     if (LIST_FIRST((head)) != NULL &&               \
    327         LIST_FIRST((head))->field.le_prev !=            \
    328          &LIST_FIRST((head)))                   \
    329         panic("Bad list head %p first->prev != head", (head));  \
    330 } while (0)
    331 
    332 #define QMD_LIST_CHECK_NEXT(elm, field) do {                \
    333     if (LIST_NEXT((elm), field) != NULL &&              \
    334         LIST_NEXT((elm), field)->field.le_prev !=           \
    335          &((elm)->field.le_next))                   \
    336             panic("Bad link elm %p next->prev != elm", (elm));  \
    337 } while (0)
    338 
    339 #define QMD_LIST_CHECK_PREV(elm, field) do {                \
    340     if (*(elm)->field.le_prev != (elm))             \
    341         panic("Bad link elm %p prev->next != elm", (elm));  \
    342 } while (0)
    343 #else
    344 #define QMD_LIST_CHECK_HEAD(head, field)
    345 #define QMD_LIST_CHECK_NEXT(elm, field)
    346 #define QMD_LIST_CHECK_PREV(elm, field)
    347 #endif /* (_KERNEL && INVARIANTS) */
    348 
    349 #define LIST_EMPTY(head)    ((head)->lh_first == NULL)
    350 
    351 #define LIST_FIRST(head)    ((head)->lh_first)
    352 
    353 #define LIST_FOREACH(var, head, field)                  \
    354     for ((var) = LIST_FIRST((head));                \
    355         (var);                          \
    356         (var) = LIST_NEXT((var), field))
    357 
    358 #define LIST_FOREACH_SAFE(var, head, field, tvar)           \
    359     for ((var) = LIST_FIRST((head));                \
    360         (var) && ((tvar) = LIST_NEXT((var), field), 1);     \
    361         (var) = (tvar))
    362 
    363 #define LIST_INIT(head) do {                        \
    364     LIST_FIRST((head)) = NULL;                  \
    365 } while (0)
    366 
    367 #define LIST_INSERT_AFTER(listelm, elm, field) do {         \
    368     QMD_LIST_CHECK_NEXT(listelm, field);                \
    369     if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
    370         LIST_NEXT((listelm), field)->field.le_prev =        \
    371             &LIST_NEXT((elm), field);               \
    372     LIST_NEXT((listelm), field) = (elm);                \
    373     (elm)->field.le_prev = &LIST_NEXT((listelm), field);        \
    374 } while (0)
    375 
    376 #define LIST_INSERT_BEFORE(listelm, elm, field) do {            \
    377     QMD_LIST_CHECK_PREV(listelm, field);                \
    378     (elm)->field.le_prev = (listelm)->field.le_prev;        \
    379     LIST_NEXT((elm), field) = (listelm);                \
    380     *(listelm)->field.le_prev = (elm);              \
    381     (listelm)->field.le_prev = &LIST_NEXT((elm), field);        \
    382 } while (0)
    383 
    384 #define LIST_INSERT_HEAD(head, elm, field) do {             \
    385     QMD_LIST_CHECK_HEAD((head), field);             \
    386     if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
    387         LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
    388     LIST_FIRST((head)) = (elm);                 \
    389     (elm)->field.le_prev = &LIST_FIRST((head));         \
    390 } while (0)
    391 
    392 #define LIST_NEXT(elm, field)   ((elm)->field.le_next)
    393 
    394 #define LIST_REMOVE(elm, field) do {                    \
    395     QMD_LIST_CHECK_NEXT(elm, field);                \
    396     QMD_LIST_CHECK_PREV(elm, field);                \
    397     if (LIST_NEXT((elm), field) != NULL)                \
    398         LIST_NEXT((elm), field)->field.le_prev =        \
    399             (elm)->field.le_prev;               \
    400     *(elm)->field.le_prev = LIST_NEXT((elm), field);        \
    401     TRASHIT((elm)->field.le_next);                  \
    402     TRASHIT((elm)->field.le_prev);                  \
    403 } while (0)
    404 
    405 /*
    406  * Tail queue declarations.
    407  */
    408 #define TAILQ_HEAD(name, type)                      \
    409 struct name {                               \
    410     struct type *tqh_first; /* first element */         \
    411     struct type **tqh_last; /* addr of last next element */     \
    412     TRACEBUF                            \
    413 }
    414 
    415 #define TAILQ_HEAD_INITIALIZER(head)                    \
    416     { NULL, &(head).tqh_first }
    417 
    418 #define TAILQ_ENTRY(type)                       \
    419 struct {                                \
    420     struct type *tqe_next;  /* next element */          \
    421     struct type **tqe_prev; /* address of previous next element */  \
    422     TRACEBUF                            \
    423 }
    424 
    425 /*
    426  * Tail queue functions.
    427  */
    428 #if (defined(_KERNEL) && defined(INVARIANTS))
    429 #define QMD_TAILQ_CHECK_HEAD(head, field) do {              \
    430     if (!TAILQ_EMPTY(head) &&                   \
    431         TAILQ_FIRST((head))->field.tqe_prev !=          \
    432          &TAILQ_FIRST((head)))                  \
    433         panic("Bad tailq head %p first->prev != head", (head)); \
    434 } while (0)
    435 
    436 #define QMD_TAILQ_CHECK_TAIL(head, field) do {              \
    437     if (*(head)->tqh_last != NULL)                  \
    438             panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head));  \
    439 } while (0)
    440 
    441 #define QMD_TAILQ_CHECK_NEXT(elm, field) do {               \
    442     if (TAILQ_NEXT((elm), field) != NULL &&             \
    443         TAILQ_NEXT((elm), field)->field.tqe_prev !=         \
    444          &((elm)->field.tqe_next))                  \
    445         panic("Bad link elm %p next->prev != elm", (elm));  \
    446 } while (0)
    447 
    448 #define QMD_TAILQ_CHECK_PREV(elm, field) do {               \
    449     if (*(elm)->field.tqe_prev != (elm))                \
    450         panic("Bad link elm %p prev->next != elm", (elm));  \
    451 } while (0)
    452 #else
    453 #define QMD_TAILQ_CHECK_HEAD(head, field)
    454 #define QMD_TAILQ_CHECK_TAIL(head, headname)
    455 #define QMD_TAILQ_CHECK_NEXT(elm, field)
    456 #define QMD_TAILQ_CHECK_PREV(elm, field)
    457 #endif /* (_KERNEL && INVARIANTS) */
    458 
    459 #define TAILQ_CONCAT(head1, head2, field) do {              \
    460     if (!TAILQ_EMPTY(head2)) {                  \
    461         *(head1)->tqh_last = (head2)->tqh_first;        \
    462         (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
    463         (head1)->tqh_last = (head2)->tqh_last;          \
    464         TAILQ_INIT((head2));                    \
    465         QMD_TRACE_HEAD(head1);                  \
    466         QMD_TRACE_HEAD(head2);                  \
    467     }                               \
    468 } while (0)
    469 
    470 #define TAILQ_EMPTY(head)   ((head)->tqh_first == NULL)
    471 
    472 #define TAILQ_FIRST(head)   ((head)->tqh_first)
    473 
    474 #define TAILQ_FOREACH(var, head, field)                 \
    475     for ((var) = TAILQ_FIRST((head));               \
    476         (var);                          \
    477         (var) = TAILQ_NEXT((var), field))
    478 
    479 #define TAILQ_FOREACH_SAFE(var, head, field, tvar)          \
    480     for ((var) = TAILQ_FIRST((head));               \
    481         (var) && ((tvar) = TAILQ_NEXT((var), field), 1);        \
    482         (var) = (tvar))
    483 
    484 #define TAILQ_FOREACH_REVERSE(var, head, headname, field)       \
    485     for ((var) = TAILQ_LAST((head), headname);          \
    486         (var);                          \
    487         (var) = TAILQ_PREV((var), headname, field))
    488 
    489 #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar)    \
    490     for ((var) = TAILQ_LAST((head), headname);          \
    491         (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1);  \
    492         (var) = (tvar))
    493 
    494 #define TAILQ_INIT(head) do {                       \
    495     TAILQ_FIRST((head)) = NULL;                 \
    496     (head)->tqh_last = &TAILQ_FIRST((head));            \
    497     QMD_TRACE_HEAD(head);                       \
    498 } while (0)
    499 
    500 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {      \
    501     QMD_TAILQ_CHECK_NEXT(listelm, field);               \
    502     if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
    503         TAILQ_NEXT((elm), field)->field.tqe_prev =      \
    504             &TAILQ_NEXT((elm), field);              \
    505     else {                              \
    506         (head)->tqh_last = &TAILQ_NEXT((elm), field);       \
    507         QMD_TRACE_HEAD(head);                   \
    508     }                               \
    509     TAILQ_NEXT((listelm), field) = (elm);               \
    510     (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);      \
    511     QMD_TRACE_ELEM(&(elm)->field);                  \
    512     QMD_TRACE_ELEM(&listelm->field);                \
    513 } while (0)
    514 
    515 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do {           \
    516     QMD_TAILQ_CHECK_PREV(listelm, field);               \
    517     (elm)->field.tqe_prev = (listelm)->field.tqe_prev;      \
    518     TAILQ_NEXT((elm), field) = (listelm);               \
    519     *(listelm)->field.tqe_prev = (elm);             \
    520     (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);      \
    521     QMD_TRACE_ELEM(&(elm)->field);                  \
    522     QMD_TRACE_ELEM(&listelm->field);                \
    523 } while (0)
    524 
    525 #define TAILQ_INSERT_HEAD(head, elm, field) do {            \
    526     QMD_TAILQ_CHECK_HEAD(head, field);              \
    527     if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)   \
    528         TAILQ_FIRST((head))->field.tqe_prev =           \
    529             &TAILQ_NEXT((elm), field);              \
    530     else                                \
    531         (head)->tqh_last = &TAILQ_NEXT((elm), field);       \
    532     TAILQ_FIRST((head)) = (elm);                    \
    533     (elm)->field.tqe_prev = &TAILQ_FIRST((head));           \
    534     QMD_TRACE_HEAD(head);                       \
    535     QMD_TRACE_ELEM(&(elm)->field);                  \
    536 } while (0)
    537 
    538 #define TAILQ_INSERT_TAIL(head, elm, field) do {            \
    539     QMD_TAILQ_CHECK_TAIL(head, field);              \
    540     TAILQ_NEXT((elm), field) = NULL;                \
    541     (elm)->field.tqe_prev = (head)->tqh_last;           \
    542     *(head)->tqh_last = (elm);                  \
    543     (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
    544     QMD_TRACE_HEAD(head);                       \
    545     QMD_TRACE_ELEM(&(elm)->field);                  \
    546 } while (0)
    547 
    548 #define TAILQ_LAST(head, headname)                  \
    549     (*(((struct headname *)((head)->tqh_last))->tqh_last))
    550 
    551 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
    552 
    553 #define TAILQ_PREV(elm, headname, field)                \
    554     (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
    555 
    556 #define TAILQ_REMOVE(head, elm, field) do {             \
    557     QMD_TAILQ_CHECK_NEXT(elm, field);               \
    558     QMD_TAILQ_CHECK_PREV(elm, field);               \
    559     if ((TAILQ_NEXT((elm), field)) != NULL)             \
    560         TAILQ_NEXT((elm), field)->field.tqe_prev =      \
    561             (elm)->field.tqe_prev;              \
    562     else {                              \
    563         (head)->tqh_last = (elm)->field.tqe_prev;       \
    564         QMD_TRACE_HEAD(head);                   \
    565     }                               \
    566     *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);      \
    567     TRASHIT((elm)->field.tqe_next);                 \
    568     TRASHIT((elm)->field.tqe_prev);                 \
    569     QMD_TRACE_ELEM(&(elm)->field);                  \
    570 } while (0)
    571 
    572 
    573 #ifdef _KERNEL
    574 
    575 /*
    576  * XXX insque() and remque() are an old way of handling certain queues.
    577  * They bogusly assumes that all queue heads look alike.
    578  */
    579 
    580 struct quehead {
    581     struct quehead *qh_link;
    582     struct quehead *qh_rlink;
    583 };
    584 
    585 #ifdef __CC_SUPPORTS___INLINE
    586 
    587 static __inline void
    588 insque(void *a, void *b)
    589 {
    590     struct quehead *element = (struct quehead *)a,
    591          *head = (struct quehead *)b;
    592 
    593     element->qh_link = head->qh_link;
    594     element->qh_rlink = head;
    595     head->qh_link = element;
    596     element->qh_link->qh_rlink = element;
    597 }
    598 
    599 static __inline void
    600 remque(void *a)
    601 {
    602     struct quehead *element = (struct quehead *)a;
    603 
    604     element->qh_link->qh_rlink = element->qh_rlink;
    605     element->qh_rlink->qh_link = element->qh_link;
    606     element->qh_rlink = 0;
    607 }
    608 
    609 #else /* !__CC_SUPPORTS___INLINE */
    610 
    611 void    insque(void *a, void *b);
    612 void    remque(void *a);
    613 
    614 #endif /* __CC_SUPPORTS___INLINE */
    615 
    616 #endif /* _KERNEL */
    617 
    618 #endif /* !_SYS_QUEUE_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/queue.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/queue.h b/src/libs/compat/freebsd_network/compat/sys/queue.h
    deleted file mode 100644
    index 7f24287..0000000
    + -  
    1 /*-
    2  * Copyright (c) 1991, 1993
    3  *  The Regents of the University of California.  All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
    10  * 2. Redistributions in binary form must reproduce the above copyright
    11  *    notice, this list of conditions and the following disclaimer in the
    12  *    documentation and/or other materials provided with the distribution.
    13  * 4. Neither the name of the University nor the names of its contributors
    14  *    may be used to endorse or promote products derived from this software
    15  *    without specific prior written permission.
    16  *
    17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    27  * SUCH DAMAGE.
    28  *
    29  *  @(#)queue.h 8.5 (Berkeley) 8/20/94
    30  * $FreeBSD: src/sys/sys/queue.h,v 1.60.2.1 2005/08/16 22:41:39 phk Exp $
    31  */
    32 #ifndef _SYS_QUEUE_H_
    33 #define _SYS_QUEUE_H_
    34 
    35 #include <sys/cdefs.h>
    36 
    37 /*
    38  * This file defines four types of data structures: singly-linked lists,
    39  * singly-linked tail queues, lists and tail queues.
    40  *
    41  * A singly-linked list is headed by a single forward pointer. The elements
    42  * are singly linked for minimum space and pointer manipulation overhead at
    43  * the expense of O(n) removal for arbitrary elements. New elements can be
    44  * added to the list after an existing element or at the head of the list.
    45  * Elements being removed from the head of the list should use the explicit
    46  * macro for this purpose for optimum efficiency. A singly-linked list may
    47  * only be traversed in the forward direction.  Singly-linked lists are ideal
    48  * for applications with large datasets and few or no removals or for
    49  * implementing a LIFO queue.
    50  *
    51  * A singly-linked tail queue is headed by a pair of pointers, one to the
    52  * head of the list and the other to the tail of the list. The elements are
    53  * singly linked for minimum space and pointer manipulation overhead at the
    54  * expense of O(n) removal for arbitrary elements. New elements can be added
    55  * to the list after an existing element, at the head of the list, or at the
    56  * end of the list. Elements being removed from the head of the tail queue
    57  * should use the explicit macro for this purpose for optimum efficiency.
    58  * A singly-linked tail queue may only be traversed in the forward direction.
    59  * Singly-linked tail queues are ideal for applications with large datasets
    60  * and few or no removals or for implementing a FIFO queue.
    61  *
    62  * A list is headed by a single forward pointer (or an array of forward
    63  * pointers for a hash table header). The elements are doubly linked
    64  * so that an arbitrary element can be removed without a need to
    65  * traverse the list. New elements can be added to the list before
    66  * or after an existing element or at the head of the list. A list
    67  * may only be traversed in the forward direction.
    68  *
    69  * A tail queue is headed by a pair of pointers, one to the head of the
    70  * list and the other to the tail of the list. The elements are doubly
    71  * linked so that an arbitrary element can be removed without a need to
    72  * traverse the list. New elements can be added to the list before or
    73  * after an existing element, at the head of the list, or at the end of
    74  * the list. A tail queue may be traversed in either direction.
    75  *
    76  * For details on the use of these macros, see the queue(3) manual page.
    77  *
    78  *
    79  *              SLIST   LIST    STAILQ  TAILQ
    80  * _HEAD            +   +   +   +
    81  * _HEAD_INITIALIZER        +   +   +   +
    82  * _ENTRY           +   +   +   +
    83  * _INIT            +   +   +   +
    84  * _EMPTY           +   +   +   +
    85  * _FIRST           +   +   +   +
    86  * _NEXT            +   +   +   +
    87  * _PREV            -   -   -   +
    88  * _LAST            -   -   +   +
    89  * _FOREACH         +   +   +   +
    90  * _FOREACH_SAFE        +   +   +   +
    91  * _FOREACH_REVERSE     -   -   -   +
    92  * _FOREACH_REVERSE_SAFE    -   -   -   +
    93  * _INSERT_HEAD         +   +   +   +
    94  * _INSERT_BEFORE       -   +   -   +
    95  * _INSERT_AFTER        +   +   +   +
    96  * _INSERT_TAIL         -   -   +   +
    97  * _CONCAT          -   -   +   +
    98  * _REMOVE_HEAD         +   -   +   -
    99  * _REMOVE          +   +   +   +
    100  *
    101  */
    102 #define QUEUE_MACRO_DEBUG 0
    103 #if QUEUE_MACRO_DEBUG
    104 /* Store the last 2 places the queue element or head was altered */
    105 struct qm_trace {
    106     char * lastfile;
    107     int lastline;
    108     char * prevfile;
    109     int prevline;
    110 };
    111 
    112 #define TRACEBUF    struct qm_trace trace;
    113 #define TRASHIT(x)  do {(x) = (void *)-1;} while (0)
    114 
    115 #define QMD_TRACE_HEAD(head) do {                   \
    116     (head)->trace.prevline = (head)->trace.lastline;        \
    117     (head)->trace.prevfile = (head)->trace.lastfile;        \
    118     (head)->trace.lastline = __LINE__;              \
    119     (head)->trace.lastfile = __FILE__;              \
    120 } while (0)
    121 
    122 #define QMD_TRACE_ELEM(elem) do {                   \
    123     (elem)->trace.prevline = (elem)->trace.lastline;        \
    124     (elem)->trace.prevfile = (elem)->trace.lastfile;        \
    125     (elem)->trace.lastline = __LINE__;              \
    126     (elem)->trace.lastfile = __FILE__;              \
    127 } while (0)
    128 
    129 #else
    130 #define QMD_TRACE_ELEM(elem)
    131 #define QMD_TRACE_HEAD(head)
    132 #define TRACEBUF
    133 #define TRASHIT(x)
    134 #endif  /* QUEUE_MACRO_DEBUG */
    135 
    136 /*
    137  * Singly-linked List declarations.
    138  */
    139 #define SLIST_HEAD(name, type)                      \
    140 struct name {                               \
    141     struct type *slh_first; /* first element */         \
    142 }
    143 
    144 #define SLIST_HEAD_INITIALIZER(head)                    \
    145     { NULL }
    146 
    147 #define SLIST_ENTRY(type)                       \
    148 struct {                                \
    149     struct type *sle_next;  /* next element */          \
    150 }
    151 
    152 /*
    153  * Singly-linked List functions.
    154  */
    155 #define SLIST_EMPTY(head)   ((head)->slh_first == NULL)
    156 
    157 #define SLIST_FIRST(head)   ((head)->slh_first)
    158 
    159 #define SLIST_FOREACH(var, head, field)                 \
    160     for ((var) = SLIST_FIRST((head));               \
    161         (var);                          \
    162         (var) = SLIST_NEXT((var), field))
    163 
    164 #define SLIST_FOREACH_SAFE(var, head, field, tvar)          \
    165     for ((var) = SLIST_FIRST((head));               \
    166         (var) && ((tvar) = SLIST_NEXT((var), field), 1);        \
    167         (var) = (tvar))
    168 
    169 #define SLIST_FOREACH_PREVPTR(var, varp, head, field)           \
    170     for ((varp) = &SLIST_FIRST((head));             \
    171         ((var) = *(varp)) != NULL;                  \
    172         (varp) = &SLIST_NEXT((var), field))
    173 
    174 #define SLIST_INIT(head) do {                       \
    175     SLIST_FIRST((head)) = NULL;                 \
    176 } while (0)
    177 
    178 #define SLIST_INSERT_AFTER(slistelm, elm, field) do {           \
    179     SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field);   \
    180     SLIST_NEXT((slistelm), field) = (elm);              \
    181 } while (0)
    182 
    183 #define SLIST_INSERT_HEAD(head, elm, field) do {            \
    184     SLIST_NEXT((elm), field) = SLIST_FIRST((head));         \
    185     SLIST_FIRST((head)) = (elm);                    \
    186 } while (0)
    187 
    188 #define SLIST_NEXT(elm, field)  ((elm)->field.sle_next)
    189 
    190 #define SLIST_REMOVE(head, elm, type, field) do {           \
    191     if (SLIST_FIRST((head)) == (elm)) {             \
    192         SLIST_REMOVE_HEAD((head), field);           \
    193     }                               \
    194     else {                              \
    195         struct type *curelm = SLIST_FIRST((head));      \
    196         while (SLIST_NEXT(curelm, field) != (elm))      \
    197             curelm = SLIST_NEXT(curelm, field);     \
    198         SLIST_NEXT(curelm, field) =             \
    199             SLIST_NEXT(SLIST_NEXT(curelm, field), field);   \
    200     }                               \
    201 } while (0)
    202 
    203 #define SLIST_REMOVE_HEAD(head, field) do {             \
    204     SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field);   \
    205 } while (0)
    206 
    207 /*
    208  * Singly-linked Tail queue declarations.
    209  */
    210 #define STAILQ_HEAD(name, type)                     \
    211 struct name {                               \
    212     struct type *stqh_first;/* first element */         \
    213     struct type **stqh_last;/* addr of last next element */     \
    214 }
    215 
    216 #define STAILQ_HEAD_INITIALIZER(head)                   \
    217     { NULL, &(head).stqh_first }
    218 
    219 #define STAILQ_ENTRY(type)                      \
    220 struct {                                \
    221     struct type *stqe_next; /* next element */          \
    222 }
    223 
    224 /*
    225  * Singly-linked Tail queue functions.
    226  */
    227 #define STAILQ_CONCAT(head1, head2) do {                \
    228     if (!STAILQ_EMPTY((head2))) {                   \
    229         *(head1)->stqh_last = (head2)->stqh_first;      \
    230         (head1)->stqh_last = (head2)->stqh_last;        \
    231         STAILQ_INIT((head2));                   \
    232     }                               \
    233 } while (0)
    234 
    235 #define STAILQ_EMPTY(head)  ((head)->stqh_first == NULL)
    236 
    237 #define STAILQ_FIRST(head)  ((head)->stqh_first)
    238 
    239 #define STAILQ_FOREACH(var, head, field)                \
    240     for((var) = STAILQ_FIRST((head));               \
    241        (var);                           \
    242        (var) = STAILQ_NEXT((var), field))
    243 
    244 
    245 #define STAILQ_FOREACH_SAFE(var, head, field, tvar)         \
    246     for ((var) = STAILQ_FIRST((head));              \
    247         (var) && ((tvar) = STAILQ_NEXT((var), field), 1);       \
    248         (var) = (tvar))
    249 
    250 #define STAILQ_INIT(head) do {                      \
    251     STAILQ_FIRST((head)) = NULL;                    \
    252     (head)->stqh_last = &STAILQ_FIRST((head));          \
    253 } while (0)
    254 
    255 #define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do {       \
    256     if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
    257         (head)->stqh_last = &STAILQ_NEXT((elm), field);     \
    258     STAILQ_NEXT((tqelm), field) = (elm);                \
    259 } while (0)
    260 
    261 #define STAILQ_INSERT_HEAD(head, elm, field) do {           \
    262     if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
    263         (head)->stqh_last = &STAILQ_NEXT((elm), field);     \
    264     STAILQ_FIRST((head)) = (elm);                   \
    265 } while (0)
    266 
    267 #define STAILQ_INSERT_TAIL(head, elm, field) do {           \
    268     STAILQ_NEXT((elm), field) = NULL;               \
    269     *(head)->stqh_last = (elm);                 \
    270     (head)->stqh_last = &STAILQ_NEXT((elm), field);         \
    271 } while (0)
    272 
    273 #define STAILQ_LAST(head, type, field)                  \
    274     (STAILQ_EMPTY((head)) ?                     \
    275         NULL :                          \
    276             ((struct type *)                    \
    277         ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
    278 
    279 #define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
    280 
    281 #define STAILQ_REMOVE(head, elm, type, field) do {          \
    282     if (STAILQ_FIRST((head)) == (elm)) {                \
    283         STAILQ_REMOVE_HEAD((head), field);          \
    284     }                               \
    285     else {                              \
    286         struct type *curelm = STAILQ_FIRST((head));     \
    287         while (STAILQ_NEXT(curelm, field) != (elm))     \
    288             curelm = STAILQ_NEXT(curelm, field);        \
    289         if ((STAILQ_NEXT(curelm, field) =           \
    290              STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
    291             (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
    292     }                               \
    293 } while (0)
    294 
    295 #define STAILQ_REMOVE_HEAD(head, field) do {                \
    296     if ((STAILQ_FIRST((head)) =                 \
    297          STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL)     \
    298         (head)->stqh_last = &STAILQ_FIRST((head));      \
    299 } while (0)
    300 
    301 #define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do {         \
    302     if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \
    303         (head)->stqh_last = &STAILQ_FIRST((head));      \
    304 } while (0)
    305 
    306 /*
    307  * List declarations.
    308  */
    309 #define LIST_HEAD(name, type)                       \
    310 struct name {                               \
    311     struct type *lh_first;  /* first element */         \
    312 }
    313 
    314 #define LIST_HEAD_INITIALIZER(head)                 \
    315     { NULL }
    316 
    317 #define LIST_ENTRY(type)                        \
    318 struct {                                \
    319     struct type *le_next;   /* next element */          \
    320     struct type **le_prev;  /* address of previous next element */  \
    321 }
    322 
    323 /*
    324  * List functions.
    325  */
    326 
    327 #define LIST_EMPTY(head)    ((head)->lh_first == NULL)
    328 
    329 #define LIST_FIRST(head)    ((head)->lh_first)
    330 
    331 #define LIST_FOREACH(var, head, field)                  \
    332     for ((var) = LIST_FIRST((head));                \
    333         (var);                          \
    334         (var) = LIST_NEXT((var), field))
    335 
    336 #define LIST_FOREACH_SAFE(var, head, field, tvar)           \
    337     for ((var) = LIST_FIRST((head));                \
    338         (var) && ((tvar) = LIST_NEXT((var), field), 1);     \
    339         (var) = (tvar))
    340 
    341 #define LIST_INIT(head) do {                        \
    342     LIST_FIRST((head)) = NULL;                  \
    343 } while (0)
    344 
    345 #define LIST_INSERT_AFTER(listelm, elm, field) do {         \
    346     if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
    347         LIST_NEXT((listelm), field)->field.le_prev =        \
    348             &LIST_NEXT((elm), field);               \
    349     LIST_NEXT((listelm), field) = (elm);                \
    350     (elm)->field.le_prev = &LIST_NEXT((listelm), field);        \
    351 } while (0)
    352 
    353 #define LIST_INSERT_BEFORE(listelm, elm, field) do {            \
    354     (elm)->field.le_prev = (listelm)->field.le_prev;        \
    355     LIST_NEXT((elm), field) = (listelm);                \
    356     *(listelm)->field.le_prev = (elm);              \
    357     (listelm)->field.le_prev = &LIST_NEXT((elm), field);        \
    358 } while (0)
    359 
    360 #define LIST_INSERT_HEAD(head, elm, field) do {             \
    361     if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
    362         LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
    363     LIST_FIRST((head)) = (elm);                 \
    364     (elm)->field.le_prev = &LIST_FIRST((head));         \
    365 } while (0)
    366 
    367 #define LIST_NEXT(elm, field)   ((elm)->field.le_next)
    368 
    369 #define LIST_REMOVE(elm, field) do {                    \
    370     if (LIST_NEXT((elm), field) != NULL)                \
    371         LIST_NEXT((elm), field)->field.le_prev =        \
    372             (elm)->field.le_prev;               \
    373     *(elm)->field.le_prev = LIST_NEXT((elm), field);        \
    374 } while (0)
    375 
    376 /*
    377  * Tail queue declarations.
    378  */
    379 #define TAILQ_HEAD(name, type)                      \
    380 struct name {                               \
    381     struct type *tqh_first; /* first element */         \
    382     struct type **tqh_last; /* addr of last next element */     \
    383     TRACEBUF                            \
    384 }
    385 
    386 #define TAILQ_HEAD_INITIALIZER(head)                    \
    387     { NULL, &(head).tqh_first }
    388 
    389 #define TAILQ_ENTRY(type)                       \
    390 struct {                                \
    391     struct type *tqe_next;  /* next element */          \
    392     struct type **tqe_prev; /* address of previous next element */  \
    393     TRACEBUF                            \
    394 }
    395 
    396 /*
    397  * Tail queue functions.
    398  */
    399 #define TAILQ_CONCAT(head1, head2, field) do {              \
    400     if (!TAILQ_EMPTY(head2)) {                  \
    401         *(head1)->tqh_last = (head2)->tqh_first;        \
    402         (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
    403         (head1)->tqh_last = (head2)->tqh_last;          \
    404         TAILQ_INIT((head2));                    \
    405         QMD_TRACE_HEAD(head1);                  \
    406         QMD_TRACE_HEAD(head2);                  \
    407     }                               \
    408 } while (0)
    409 
    410 #define TAILQ_EMPTY(head)   ((head)->tqh_first == NULL)
    411 
    412 #define TAILQ_FIRST(head)   ((head)->tqh_first)
    413 
    414 #define TAILQ_FOREACH(var, head, field)                 \
    415     for ((var) = TAILQ_FIRST((head));               \
    416         (var);                          \
    417         (var) = TAILQ_NEXT((var), field))
    418 
    419 #define TAILQ_FOREACH_SAFE(var, head, field, tvar)          \
    420     for ((var) = TAILQ_FIRST((head));               \
    421         (var) && ((tvar) = TAILQ_NEXT((var), field), 1);        \
    422         (var) = (tvar))
    423 
    424 #define TAILQ_FOREACH_REVERSE(var, head, headname, field)       \
    425     for ((var) = TAILQ_LAST((head), headname);          \
    426         (var);                          \
    427         (var) = TAILQ_PREV((var), headname, field))
    428 
    429 #define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar)    \
    430     for ((var) = TAILQ_LAST((head), headname);          \
    431         (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1);  \
    432         (var) = (tvar))
    433 
    434 #define TAILQ_INIT(head) do {                       \
    435     TAILQ_FIRST((head)) = NULL;                 \
    436     (head)->tqh_last = &TAILQ_FIRST((head));            \
    437     QMD_TRACE_HEAD(head);                       \
    438 } while (0)
    439 
    440 #define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {      \
    441     if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
    442         TAILQ_NEXT((elm), field)->field.tqe_prev =      \
    443             &TAILQ_NEXT((elm), field);              \
    444     else {                              \
    445         (head)->tqh_last = &TAILQ_NEXT((elm), field);       \
    446         QMD_TRACE_HEAD(head);                   \
    447     }                               \
    448     TAILQ_NEXT((listelm), field) = (elm);               \
    449     (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field);      \
    450     QMD_TRACE_ELEM(&(elm)->field);                  \
    451     QMD_TRACE_ELEM(&listelm->field);                \
    452 } while (0)
    453 
    454 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do {           \
    455     (elm)->field.tqe_prev = (listelm)->field.tqe_prev;      \
    456     TAILQ_NEXT((elm), field) = (listelm);               \
    457     *(listelm)->field.tqe_prev = (elm);             \
    458     (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field);      \
    459     QMD_TRACE_ELEM(&(elm)->field);                  \
    460     QMD_TRACE_ELEM(&listelm->field);                \
    461 } while (0)
    462 
    463 #define TAILQ_INSERT_HEAD(head, elm, field) do {            \
    464     if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL)   \
    465         TAILQ_FIRST((head))->field.tqe_prev =           \
    466             &TAILQ_NEXT((elm), field);              \
    467     else                                \
    468         (head)->tqh_last = &TAILQ_NEXT((elm), field);       \
    469     TAILQ_FIRST((head)) = (elm);                    \
    470     (elm)->field.tqe_prev = &TAILQ_FIRST((head));           \
    471     QMD_TRACE_HEAD(head);                       \
    472     QMD_TRACE_ELEM(&(elm)->field);                  \
    473 } while (0)
    474 
    475 #define TAILQ_INSERT_TAIL(head, elm, field) do {            \
    476     TAILQ_NEXT((elm), field) = NULL;                \
    477     (elm)->field.tqe_prev = (head)->tqh_last;           \
    478     *(head)->tqh_last = (elm);                  \
    479     (head)->tqh_last = &TAILQ_NEXT((elm), field);           \
    480     QMD_TRACE_HEAD(head);                       \
    481     QMD_TRACE_ELEM(&(elm)->field);                  \
    482 } while (0)
    483 
    484 #define TAILQ_LAST(head, headname)                  \
    485     (*(((struct headname *)((head)->tqh_last))->tqh_last))
    486 
    487 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
    488 
    489 #define TAILQ_PREV(elm, headname, field)                \
    490     (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
    491 
    492 #define TAILQ_REMOVE(head, elm, field) do {             \
    493     if ((TAILQ_NEXT((elm), field)) != NULL)             \
    494         TAILQ_NEXT((elm), field)->field.tqe_prev =      \
    495             (elm)->field.tqe_prev;              \
    496     else {                              \
    497         (head)->tqh_last = (elm)->field.tqe_prev;       \
    498         QMD_TRACE_HEAD(head);                   \
    499     }                               \
    500     *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field);      \
    501     TRASHIT((elm)->field.tqe_next);                 \
    502     TRASHIT((elm)->field.tqe_prev);                 \
    503     QMD_TRACE_ELEM(&(elm)->field);                  \
    504 } while (0)
    505 
    506 
    507 #ifdef _KERNEL
    508 
    509 /*
    510  * XXX insque() and remque() are an old way of handling certain queues.
    511  * They bogusly assumes that all queue heads look alike.
    512  */
    513 
    514 struct quehead {
    515     struct quehead *qh_link;
    516     struct quehead *qh_rlink;
    517 };
    518 
    519 #ifdef __CC_SUPPORTS___INLINE
    520 
    521 static __inline void
    522 insque(void *a, void *b)
    523 {
    524     struct quehead *element = (struct quehead *)a,
    525          *head = (struct quehead *)b;
    526 
    527     element->qh_link = head->qh_link;
    528     element->qh_rlink = head;
    529     head->qh_link = element;
    530     element->qh_link->qh_rlink = element;
    531 }
    532 
    533 static __inline void
    534 remque(void *a)
    535 {
    536     struct quehead *element = (struct quehead *)a;
    537 
    538     element->qh_link->qh_rlink = element->qh_rlink;
    539     element->qh_rlink->qh_link = element->qh_link;
    540     element->qh_rlink = 0;
    541 }
    542 
    543 #else /* !__CC_SUPPORTS___INLINE */
    544 
    545 void    insque(void *a, void *b);
    546 void    remque(void *a);
    547 
    548 #endif /* __CC_SUPPORTS___INLINE */
    549 
    550 #endif /* _KERNEL */
    551 
    552 #endif /* !_SYS_QUEUE_H_ */
  • new file headers/compatibility/bsd/ar.h

    -- 
    2.1.4
    
    
    From 04a0e2bb7e2ba06089d32be5e7ac3f9ca5cafd35 Mon Sep 17 00:00:00 2001
    From: Markus Himmel <markus@himmel-villmar.de>
    Date: Mon, 25 Jan 2016 08:53:55 +0100
    Subject: [PATCH 2/3] Headers: Introduce FreeBSD ar.h
    
    ---
     headers/compatibility/bsd/ar.h | 67 ++++++++++++++++++++++++++++++++++++++++++
     1 file changed, 67 insertions(+)
     create mode 100644 headers/compatibility/bsd/ar.h
    
    diff --git a/headers/compatibility/bsd/ar.h b/headers/compatibility/bsd/ar.h
    new file mode 100644
    index 0000000..aa5fac2
    - +  
     1/*-
     2 * Copyright (c) 1991, 1993
     3 *  The Regents of the University of California.  All rights reserved.
     4 * (c) UNIX System Laboratories, Inc.
     5 * All or some portions of this file are derived from material licensed
     6 * to the University of California by American Telephone and Telegraph
     7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     8 * the permission of UNIX System Laboratories, Inc.
     9 *
     10 * This code is derived from software contributed to Berkeley by
     11 * Hugh Smith at The University of Guelph.
     12 *
     13 * Redistribution and use in source and binary forms, with or without
     14 * modification, are permitted provided that the following conditions
     15 * are met:
     16 * 1. Redistributions of source code must retain the above copyright
     17 *    notice, this list of conditions and the following disclaimer.
     18 * 2. Redistributions in binary form must reproduce the above copyright
     19 *    notice, this list of conditions and the following disclaimer in the
     20 *    documentation and/or other materials provided with the distribution.
     21 * 3. Neither the name of the University nor the names of its contributors
     22 *    may be used to endorse or promote products derived from this software
     23 *    without specific prior written permission.
     24 *
     25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     28 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     35 * SUCH DAMAGE.
     36 *
     37 *  @(#)ar.h    8.2 (Berkeley) 1/21/94
     38 *
     39 * $FreeBSD$
     40 */
     41
     42#ifndef _AR_H_
     43#define _AR_H_
     44
     45#include <sys/cdefs.h>
     46
     47/* Pre-4BSD archives had these magic numbers in them. */
     48#define OARMAG1 0177555
     49#define OARMAG2 0177545
     50
     51#define ARMAG       "!<arch>\n" /* ar "magic number" */
     52#define SARMAG      8       /* strlen(ARMAG); */
     53
     54#define AR_EFMT1    "#1/"       /* extended format #1 */
     55
     56struct ar_hdr {
     57    char ar_name[16];       /* name */
     58    char ar_date[12];       /* modification time */
     59    char ar_uid[6];         /* user id */
     60    char ar_gid[6];         /* group id */
     61    char ar_mode[8];        /* octal file permissions */
     62    char ar_size[10];       /* size in bytes */
     63#define ARFMAG  "`\n"
     64    char ar_fmag[2];        /* consistency check */
     65} __packed;
     66
     67#endif /* !_AR_H_ */
  • new file headers/compatibility/bsd/machine/_bus.h

    -- 
    2.1.4
    
    
    From c23da6927b8b83d912fe7774426499adaad88ecd Mon Sep 17 00:00:00 2001
    From: Markus Himmel <markus@himmel-villmar.de>
    Date: Mon, 25 Jan 2016 20:42:06 +0100
    Subject: [PATCH 3/3] WIP BSD Merge
    
    ---
     headers/compatibility/bsd/machine/_bus.h           |  32 +++
     headers/compatibility/bsd/machine/atomic.h         |  27 ++
     headers/compatibility/bsd/machine/bus.h            | 270 ++++++++++++++++++
     headers/compatibility/bsd/machine/bus_dma.h        |  11 +
     headers/compatibility/bsd/machine/clock.h          |   9 +
     headers/compatibility/bsd/machine/cpufunc.h        |  43 +++
     headers/compatibility/bsd/machine/endian.h         |  12 +
     headers/compatibility/bsd/machine/in_cksum.h       |  32 +++
     headers/compatibility/bsd/machine/md_var.h         |   0
     headers/compatibility/bsd/machine/ofw_machdep.h    |   0
     headers/compatibility/bsd/machine/resource.h       |  14 +
     headers/compatibility/bsd/machine/stdarg.h         |  12 +
     headers/compatibility/bsd/sys/_bus_dma.h           |  62 +++++
     headers/compatibility/bsd/sys/_mutex.h             |  26 ++
     headers/compatibility/bsd/sys/_task.h              |  24 ++
     headers/compatibility/bsd/sys/_timeval.h           |  11 +
     headers/compatibility/bsd/sys/_types.h             |  20 ++
     headers/compatibility/bsd/sys/bus.h                | 158 +++++++++++
     headers/compatibility/bsd/sys/bus_dma.h            | 271 ++++++++++++++++++
     headers/compatibility/bsd/sys/callout.h            |  45 +++
     headers/compatibility/bsd/sys/cdefs.h              | 295 +++++++++++++++++++-
     headers/compatibility/bsd/sys/condvar.h            |  31 +++
     headers/compatibility/bsd/sys/ctype.h              |  11 +
     headers/compatibility/bsd/sys/endian.h             | 197 +++++++++++++
     headers/compatibility/bsd/sys/errno.h              |  16 ++
     headers/compatibility/bsd/sys/event.h              |  13 +
     headers/compatibility/bsd/sys/eventhandler.h       | 176 ++++++++++++
     headers/compatibility/bsd/sys/firmware.h           |  23 ++
     headers/compatibility/bsd/sys/haiku-module.h       | 264 ++++++++++++++++++
     headers/compatibility/bsd/sys/ioccom.h             |   1 +
     headers/compatibility/bsd/sys/kernel.h             |  51 ++++
     headers/compatibility/bsd/sys/kthread.h            |   0
     headers/compatibility/bsd/sys/ktr.h                | 196 +++++++++++++
     headers/compatibility/bsd/sys/libkern.h            |  20 ++
     headers/compatibility/bsd/sys/limits.h             |   9 +
     headers/compatibility/bsd/sys/linker.h             |   9 +
     headers/compatibility/bsd/sys/linker_set.h         |  64 +++++
     headers/compatibility/bsd/sys/lock.h               |   0
     headers/compatibility/bsd/sys/malloc.h             |  67 +++++
     headers/compatibility/bsd/sys/mbuf-fbsd.h          | 117 ++++++++
     headers/compatibility/bsd/sys/mbuf.h               | 241 ++++++++++++++++
     headers/compatibility/bsd/sys/module.h             |  23 ++
     headers/compatibility/bsd/sys/mount.h              |   9 +
     headers/compatibility/bsd/sys/mutex.h              |  92 ++++++
     headers/compatibility/bsd/sys/namei.h              |   9 +
     headers/compatibility/bsd/sys/param.h              |  75 ++++-
     headers/compatibility/bsd/sys/pcpu.h               |  22 ++
     headers/compatibility/bsd/sys/priority.h           |  12 +
     headers/compatibility/bsd/sys/priv.h               |  38 +++
     headers/compatibility/bsd/sys/proc.h               |   9 +
     headers/compatibility/bsd/sys/protosw.h            |   0
     headers/compatibility/bsd/sys/random.h             |   0
     headers/compatibility/bsd/sys/rman.h               |  89 ++++++
     headers/compatibility/bsd/sys/socket.h             |  18 ++
     headers/compatibility/bsd/sys/sockio.h             |  16 ++
     headers/compatibility/bsd/sys/sysctl.h             | 165 +++++++++++
     headers/compatibility/bsd/sys/syslog.h             |  11 +
     headers/compatibility/bsd/sys/systm.h              | 103 +++++++
     headers/compatibility/bsd/sys/taskqueue.h          |  43 +++
     headers/compatibility/bsd/sys/time.h               |  20 ++
     headers/compatibility/bsd/sys/types.h              |  22 ++
     headers/private/firewire/fwglue.h                  |   4 -
     .../kernel/bus_managers/firewire/firewire.cpp      |   2 +-
     .../bus_managers/firewire/firewire_module.cpp      |   2 +-
     src/add-ons/kernel/bus_managers/firewire/fwdma.cpp |   2 +-
     src/add-ons/kernel/bus_managers/firewire/fwmem.cpp |   2 +-
     .../kernel/bus_managers/firewire/fwohci.cpp        |   2 +-
     .../kernel/bus_managers/firewire/fwohci_pci.cpp    |   2 +-
     src/add-ons/kernel/drivers/bus/firewire/fw_raw.c   |   2 +-
     .../kernel/drivers/network/3com/dev/xl/Jamfile     |   1 +
     src/bin/fwcontrol/fwcrom.c                         |   4 -
     src/kits/network/libnetapi/Jamfile                 |   2 +
     .../compat/freebsd_network/compat/machine/_bus.h   |  32 ---
     .../compat/freebsd_network/compat/machine/atomic.h |  27 --
     .../compat/freebsd_network/compat/machine/bus.h    | 270 ------------------
     .../freebsd_network/compat/machine/bus_dma.h       |  11 -
     .../compat/freebsd_network/compat/machine/clock.h  |   9 -
     .../freebsd_network/compat/machine/cpufunc.h       |  43 ---
     .../compat/freebsd_network/compat/machine/endian.h |  12 -
     .../freebsd_network/compat/machine/in_cksum.h      |  32 ---
     .../compat/freebsd_network/compat/machine/md_var.h |   0
     .../freebsd_network/compat/machine/ofw_machdep.h   |   0
     .../freebsd_network/compat/machine/resource.h      |  14 -
     .../compat/freebsd_network/compat/machine/stdarg.h |  12 -
     .../compat/freebsd_network/compat/sys/_bus_dma.h   |  62 -----
     .../compat/freebsd_network/compat/sys/_mutex.h     |  26 --
     src/libs/compat/freebsd_network/compat/sys/_task.h |  24 --
     .../compat/freebsd_network/compat/sys/_timeval.h   |  11 -
     .../compat/freebsd_network/compat/sys/_types.h     |  20 --
     src/libs/compat/freebsd_network/compat/sys/bus.h   | 158 -----------
     .../compat/freebsd_network/compat/sys/bus_dma.h    | 271 ------------------
     .../compat/freebsd_network/compat/sys/callout.h    |  45 ---
     src/libs/compat/freebsd_network/compat/sys/cdefs.h | 310 ---------------------
     .../compat/freebsd_network/compat/sys/condvar.h    |  31 ---
     src/libs/compat/freebsd_network/compat/sys/ctype.h |  11 -
     .../compat/freebsd_network/compat/sys/endian.h     | 197 -------------
     src/libs/compat/freebsd_network/compat/sys/errno.h |  16 --
     src/libs/compat/freebsd_network/compat/sys/event.h |  13 -
     .../freebsd_network/compat/sys/eventhandler.h      | 176 ------------
     .../compat/freebsd_network/compat/sys/firmware.h   |  23 --
     .../freebsd_network/compat/sys/haiku-module.h      | 264 ------------------
     .../compat/freebsd_network/compat/sys/ioccom.h     |  12 -
     .../compat/freebsd_network/compat/sys/kernel.h     |  51 ----
     .../compat/freebsd_network/compat/sys/kthread.h    |   0
     src/libs/compat/freebsd_network/compat/sys/ktr.h   | 196 -------------
     .../compat/freebsd_network/compat/sys/libkern.h    |  20 --
     .../compat/freebsd_network/compat/sys/limits.h     |   9 -
     .../compat/freebsd_network/compat/sys/linker.h     |   9 -
     .../compat/freebsd_network/compat/sys/linker_set.h |  64 -----
     src/libs/compat/freebsd_network/compat/sys/lock.h  |   0
     .../compat/freebsd_network/compat/sys/malloc.h     |  67 -----
     .../compat/freebsd_network/compat/sys/mbuf-fbsd.h  | 117 --------
     src/libs/compat/freebsd_network/compat/sys/mbuf.h  | 241 ----------------
     .../compat/freebsd_network/compat/sys/module.h     |  23 --
     src/libs/compat/freebsd_network/compat/sys/mount.h |   9 -
     src/libs/compat/freebsd_network/compat/sys/mutex.h |  92 ------
     src/libs/compat/freebsd_network/compat/sys/namei.h |   9 -
     src/libs/compat/freebsd_network/compat/sys/param.h |  75 -----
     src/libs/compat/freebsd_network/compat/sys/pcpu.h  |  22 --
     .../compat/freebsd_network/compat/sys/priority.h   |  12 -
     src/libs/compat/freebsd_network/compat/sys/priv.h  |  38 ---
     src/libs/compat/freebsd_network/compat/sys/proc.h  |   9 -
     .../compat/freebsd_network/compat/sys/protosw.h    |   0
     .../compat/freebsd_network/compat/sys/random.h     |   0
     src/libs/compat/freebsd_network/compat/sys/rman.h  |  89 ------
     .../compat/freebsd_network/compat/sys/socket.h     |  18 --
     .../compat/freebsd_network/compat/sys/sockio.h     |  16 --
     .../compat/freebsd_network/compat/sys/sysctl.h     | 165 -----------
     .../compat/freebsd_network/compat/sys/syslog.h     |  11 -
     src/libs/compat/freebsd_network/compat/sys/systm.h | 103 -------
     .../compat/freebsd_network/compat/sys/taskqueue.h  |  43 ---
     src/libs/compat/freebsd_network/compat/sys/time.h  |  20 --
     src/libs/compat/freebsd_network/compat/sys/types.h |  22 --
     src/servers/net/Jamfile                            |   3 +
     134 files changed, 3654 insertions(+), 3712 deletions(-)
     create mode 100644 headers/compatibility/bsd/machine/_bus.h
     create mode 100644 headers/compatibility/bsd/machine/atomic.h
     create mode 100644 headers/compatibility/bsd/machine/bus.h
     create mode 100644 headers/compatibility/bsd/machine/bus_dma.h
     create mode 100644 headers/compatibility/bsd/machine/clock.h
     create mode 100644 headers/compatibility/bsd/machine/cpufunc.h
     create mode 100644 headers/compatibility/bsd/machine/endian.h
     create mode 100644 headers/compatibility/bsd/machine/in_cksum.h
     create mode 100644 headers/compatibility/bsd/machine/md_var.h
     create mode 100644 headers/compatibility/bsd/machine/ofw_machdep.h
     create mode 100644 headers/compatibility/bsd/machine/resource.h
     create mode 100644 headers/compatibility/bsd/machine/stdarg.h
     create mode 100644 headers/compatibility/bsd/sys/_bus_dma.h
     create mode 100644 headers/compatibility/bsd/sys/_mutex.h
     create mode 100644 headers/compatibility/bsd/sys/_task.h
     create mode 100644 headers/compatibility/bsd/sys/_timeval.h
     create mode 100644 headers/compatibility/bsd/sys/_types.h
     create mode 100644 headers/compatibility/bsd/sys/bus.h
     create mode 100644 headers/compatibility/bsd/sys/bus_dma.h
     create mode 100644 headers/compatibility/bsd/sys/callout.h
     create mode 100644 headers/compatibility/bsd/sys/condvar.h
     create mode 100644 headers/compatibility/bsd/sys/ctype.h
     create mode 100644 headers/compatibility/bsd/sys/endian.h
     create mode 100644 headers/compatibility/bsd/sys/errno.h
     create mode 100644 headers/compatibility/bsd/sys/event.h
     create mode 100644 headers/compatibility/bsd/sys/eventhandler.h
     create mode 100644 headers/compatibility/bsd/sys/firmware.h
     create mode 100644 headers/compatibility/bsd/sys/haiku-module.h
     create mode 100644 headers/compatibility/bsd/sys/kernel.h
     create mode 100644 headers/compatibility/bsd/sys/kthread.h
     create mode 100644 headers/compatibility/bsd/sys/ktr.h
     create mode 100644 headers/compatibility/bsd/sys/libkern.h
     create mode 100644 headers/compatibility/bsd/sys/limits.h
     create mode 100644 headers/compatibility/bsd/sys/linker.h
     create mode 100644 headers/compatibility/bsd/sys/linker_set.h
     create mode 100644 headers/compatibility/bsd/sys/lock.h
     create mode 100644 headers/compatibility/bsd/sys/malloc.h
     create mode 100644 headers/compatibility/bsd/sys/mbuf-fbsd.h
     create mode 100644 headers/compatibility/bsd/sys/mbuf.h
     create mode 100644 headers/compatibility/bsd/sys/module.h
     create mode 100644 headers/compatibility/bsd/sys/mount.h
     create mode 100644 headers/compatibility/bsd/sys/mutex.h
     create mode 100644 headers/compatibility/bsd/sys/namei.h
     create mode 100644 headers/compatibility/bsd/sys/pcpu.h
     create mode 100644 headers/compatibility/bsd/sys/priority.h
     create mode 100644 headers/compatibility/bsd/sys/priv.h
     create mode 100644 headers/compatibility/bsd/sys/proc.h
     create mode 100644 headers/compatibility/bsd/sys/protosw.h
     create mode 100644 headers/compatibility/bsd/sys/random.h
     create mode 100644 headers/compatibility/bsd/sys/rman.h
     create mode 100644 headers/compatibility/bsd/sys/socket.h
     create mode 100644 headers/compatibility/bsd/sys/sockio.h
     create mode 100644 headers/compatibility/bsd/sys/sysctl.h
     create mode 100644 headers/compatibility/bsd/sys/syslog.h
     create mode 100644 headers/compatibility/bsd/sys/systm.h
     create mode 100644 headers/compatibility/bsd/sys/taskqueue.h
     create mode 100644 headers/compatibility/bsd/sys/time.h
     create mode 100644 headers/compatibility/bsd/sys/types.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/_bus.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/atomic.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/bus.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/bus_dma.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/clock.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/cpufunc.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/endian.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/in_cksum.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/md_var.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/ofw_machdep.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/resource.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/machine/stdarg.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/_bus_dma.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/_mutex.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/_task.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/_timeval.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/_types.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/bus.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/bus_dma.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/callout.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/cdefs.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/condvar.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/ctype.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/endian.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/errno.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/event.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/eventhandler.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/firmware.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/haiku-module.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/ioccom.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/kernel.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/kthread.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/ktr.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/libkern.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/limits.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/linker.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/linker_set.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/lock.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/malloc.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/mbuf-fbsd.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/mbuf.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/module.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/mount.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/mutex.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/namei.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/param.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/pcpu.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/priority.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/priv.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/proc.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/protosw.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/random.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/rman.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/socket.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/sockio.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/sysctl.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/syslog.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/systm.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/taskqueue.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/time.h
     delete mode 100644 src/libs/compat/freebsd_network/compat/sys/types.h
    
    diff --git a/headers/compatibility/bsd/machine/_bus.h b/headers/compatibility/bsd/machine/_bus.h
    new file mode 100644
    index 0000000..a4b9025
    - +  
     1/*
     2 * Copyright 2009, Colin Günther. All Rights Reserved.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_MACHINE__BUS_H_
     7#define _FBSD_COMPAT_MACHINE__BUS_H_
     8
     9
     10#ifdef B_HAIKU_64_BIT
     11
     12
     13typedef uint64_t bus_addr_t;
     14typedef uint64_t bus_size_t;
     15
     16typedef uint64_t bus_space_tag_t;
     17typedef uint64_t bus_space_handle_t;
     18
     19
     20#else
     21
     22
     23typedef uint32_t bus_addr_t;
     24typedef uint32_t bus_size_t;
     25
     26typedef int bus_space_tag_t;
     27typedef unsigned int bus_space_handle_t;
     28
     29
     30#endif
     31
     32#endif /* _FBSD_COMPAT_MACHINE__BUS_H_ */
  • new file headers/compatibility/bsd/machine/atomic.h

    diff --git a/headers/compatibility/bsd/machine/atomic.h b/headers/compatibility/bsd/machine/atomic.h
    new file mode 100644
    index 0000000..d02f8ff
    - +  
     1/*
     2 * Copyright 2007, Hugo Santos. All Rights Reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_MACHINE_ATOMIC_H_
     6#define _FBSD_COMPAT_MACHINE_ATOMIC_H_
     7
     8
     9#include <KernelExport.h>
     10
     11
     12#define atomic_add_int(ptr, value) \
     13    atomic_add((int32 *)(ptr), value)
     14
     15#define atomic_subtract_int(ptr, value) \
     16    atomic_add((int32 *)(ptr), -value)
     17
     18#define atomic_set_acq_32(ptr, value) \
     19    atomic_set_int(ptr, value)
     20
     21#define atomic_set_int(ptr, value) \
     22    atomic_or((int32 *)(ptr), value)
     23
     24#define atomic_readandclear_int(ptr) \
     25    atomic_set((int32 *)(ptr), 0)
     26
     27#endif  /* _FBSD_COMPAT_MACHINE_ATOMIC_H_ */
  • new file headers/compatibility/bsd/machine/bus.h

    diff --git a/headers/compatibility/bsd/machine/bus.h b/headers/compatibility/bsd/machine/bus.h
    new file mode 100644
    index 0000000..9e0a49d
    - +  
     1/*
     2 * Copyright 2009, Colin Günther. All Rights Reserved.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6
     7
     8/*-
     9 * Copyright (c) KATO Takenori, 1999.
     10 *
     11 * All rights reserved.  Unpublished rights reserved under the copyright
     12 * laws of Japan.
     13 *
     14 * Redistribution and use in source and binary forms, with or without
     15 * modification, are permitted provided that the following conditions
     16 * are met:
     17 *
     18 * 1. Redistributions of source code must retain the above copyright
     19 *    notice, this list of conditions and the following disclaimer as
     20 *    the first lines of this file unmodified.
     21 * 2. Redistributions in binary form must reproduce the above copyright
     22 *    notice, this list of conditions and the following disclaimer in the
     23 *    documentation and/or other materials provided with the distribution.
     24 * 3. The name of the author may not be used to endorse or promote products
     25 *    derived from this software without specific prior written permission.
     26 *
     27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     28 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     29 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     30 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     32 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     36 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     37 *
     38 * $FreeBSD$
     39 */
     40
     41/*  $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $    */
     42
     43/*-
     44 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
     45 * All rights reserved.
     46 *
     47 * This code is derived from software contributed to The NetBSD Foundation
     48 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
     49 * NASA Ames Research Center.
     50 *
     51 * Redistribution and use in source and binary forms, with or without
     52 * modification, are permitted provided that the following conditions
     53 * are met:
     54 * 1. Redistributions of source code must retain the above copyright
     55 *    notice, this list of conditions and the following disclaimer.
     56 * 2. Redistributions in binary form must reproduce the above copyright
     57 *    notice, this list of conditions and the following disclaimer in the
     58 *    documentation and/or other materials provided with the distribution.
     59 * 3. All advertising materials mentioning features or use of this software
     60 *    must display the following acknowledgement:
     61 *  This product includes software developed by the NetBSD
     62 *  Foundation, Inc. and its contributors.
     63 * 4. Neither the name of The NetBSD Foundation nor the names of its
     64 *    contributors may be used to endorse or promote products derived
     65 *    from this software without specific prior written permission.
     66 *
     67 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     68 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     69 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     70 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     71 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     72 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     73 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     74 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     75 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     76 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     77 * POSSIBILITY OF SUCH DAMAGE.
     78 */
     79
     80/*-
     81 * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
     82 * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
     83 *
     84 * Redistribution and use in source and binary forms, with or without
     85 * modification, are permitted provided that the following conditions
     86 * are met:
     87 * 1. Redistributions of source code must retain the above copyright
     88 *    notice, this list of conditions and the following disclaimer.
     89 * 2. Redistributions in binary form must reproduce the above copyright
     90 *    notice, this list of conditions and the following disclaimer in the
     91 *    documentation and/or other materials provided with the distribution.
     92 * 3. All advertising materials mentioning features or use of this software
     93 *    must display the following acknowledgement:
     94 *      This product includes software developed by Christopher G. Demetriou
     95 *  for the NetBSD Project.
     96 * 4. The name of the author may not be used to endorse or promote products
     97 *    derived from this software without specific prior written permission
     98 *
     99 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     100 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     101 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     102 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     103 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     104 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     105 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     106 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     107 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     108 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     109 */
     110#ifndef _FBSD_COMPAT_MACHINE_BUS_H_
     111#define _FBSD_COMPAT_MACHINE_BUS_H_
     112
     113
     114#include <machine/_bus.h>
     115#include <machine/cpufunc.h>
     116
     117
     118struct resource;
     119
     120
     121// TODO: x86 specific!
     122#define I386_BUS_SPACE_IO           0
     123#define I386_BUS_SPACE_MEM          1
     124
     125#define BUS_SPACE_MAXADDR_32BIT     0xffffffff
     126#ifdef __x86_64__
     127#   define BUS_SPACE_MAXADDR        0xffffffffffffffffull
     128#else
     129#   define BUS_SPACE_MAXADDR        0xffffffff
     130#endif
     131
     132#define BUS_SPACE_MAXSIZE_32BIT     0xffffffff
     133#define BUS_SPACE_MAXSIZE           0xffffffff
     134
     135#define BUS_SPACE_UNRESTRICTED  (~0)
     136
     137#define BUS_SPACE_BARRIER_READ      1
     138#define BUS_SPACE_BARRIER_WRITE     2
     139
     140
     141uint8_t bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
     142    bus_size_t offset);
     143uint16_t bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
     144    bus_size_t offset);
     145uint32_t bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
     146    bus_size_t offset);
     147void bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t handle,
     148    bus_size_t offset, uint8_t value);
     149void bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t handle,
     150    bus_size_t offset, uint16_t value);
     151void bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t handle,
     152    bus_size_t offset, uint32_t value);
     153
     154
     155static inline void
     156bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
     157            bus_size_t offset, u_int8_t *addr, size_t count)
     158{
     159    if (tag == I386_BUS_SPACE_IO) {
     160        int _port_ = bsh + offset;
     161        __asm __volatile("                          \n\
     162            cld                                     \n\
     163        1:  inb %w2,%%al                            \n\
     164            stosb                                   \n\
     165            incl %2                                 \n\
     166            loop 1b"                                :
     167            "=D" (addr), "=c" (count), "=d" (_port_):
     168            "0" (addr), "1" (count), "2" (_port_)   :
     169            "%eax", "memory", "cc");
     170    } else {
     171        void* _port_ = (void*) (bsh + offset);
     172        memcpy(addr, _port_, count);
     173    }
     174}
     175
     176
     177static inline void
     178bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
     179    bus_size_t offset, u_int32_t *addr, size_t count)
     180{
     181    if (tag == I386_BUS_SPACE_IO) {
     182        int _port_ = bsh + offset;
     183        __asm __volatile("                          \n\
     184            cld                                     \n\
     185        1:  inl %w2,%%eax                           \n\
     186            stosl                                   \n\
     187            addl $4,%2                              \n\
     188            loop 1b"                                :
     189            "=D" (addr), "=c" (count), "=d" (_port_):
     190            "0" (addr), "1" (count), "2" (_port_)   :
     191            "%eax", "memory", "cc");
     192    } else {
     193        void* _port_ = (void*) (bsh + offset);
     194        memcpy(addr, _port_, count);
     195    }
     196}
     197
     198
     199static inline void
     200bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
     201    bus_size_t offset, const u_int8_t *addr, size_t count)
     202{
     203    if (tag == I386_BUS_SPACE_IO) {
     204        int _port_ = bsh + offset;
     205        __asm __volatile("                          \n\
     206            cld                                     \n\
     207        1:  lodsb                                   \n\
     208            outb %%al,%w0                           \n\
     209            incl %0                                 \n\
     210            loop 1b"                                :
     211            "=d" (_port_), "=S" (addr), "=c" (count):
     212            "0" (_port_), "1" (addr), "2" (count)   :
     213            "%eax", "memory", "cc");
     214    } else {
     215        void* _port_ = (void*) (bsh + offset);
     216        memcpy(_port_, addr, count);
     217    }
     218}
     219
     220
     221static inline void
     222bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
     223               bus_size_t offset, u_int32_t value, size_t count)
     224{
     225    /* TODO implement */
     226}
     227
     228
     229static inline void
     230bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t handle,
     231    bus_size_t offset, bus_size_t len, int flags)
     232{
     233    if (flags & BUS_SPACE_BARRIER_READ)
     234#ifdef __x86_64__
     235        __asm__ __volatile__ ("lock; addl $0,0(%%rsp)" : : : "memory");
     236#else
     237        __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory");
     238#endif
     239    else
     240        __asm__ __volatile__ ("" : : : "memory");
     241}
     242
     243
     244static inline void
     245bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
     246    bus_size_t offset, const u_int8_t *addr, size_t count)
     247{
     248
     249    if (tag == I386_BUS_SPACE_IO)
     250        outsb(bsh + offset, addr, count);
     251    else {
     252        __asm __volatile("                              \n\
     253            cld                                         \n\
     254        1:  lodsb                                       \n\
     255            movb %%al,(%2)                              \n\
     256            loop 1b"                                    :
     257            "=S" (addr), "=c" (count)                   :
     258            "r" (bsh + offset), "0" (addr), "1" (count) :
     259            "%eax", "memory", "cc");
     260    }
     261}
     262
     263
     264#include <machine/bus_dma.h>
     265
     266
     267#define bus_space_write_stream_4(t, h, o, v) \
     268    bus_space_write_4((t), (h), (o), (v))
     269
     270#endif /* _FBSD_COMPAT_MACHINE_BUS_H_ */
  • new file headers/compatibility/bsd/machine/bus_dma.h

    diff --git a/headers/compatibility/bsd/machine/bus_dma.h b/headers/compatibility/bsd/machine/bus_dma.h
    new file mode 100644
    index 0000000..8520e43
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de
     3 * All Rights Reserved. Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_MACHINE_BUS_DMA_H_
     6#define _FBSD_COMPAT_MACHINE_BUS_DMA_H_
     7
     8
     9#include <sys/bus_dma.h>
     10
     11#endif /* _FBSD_COMPAT_MACHINE_BUS_DMA_H_ */
  • new file headers/compatibility/bsd/machine/clock.h

    diff --git a/headers/compatibility/bsd/machine/clock.h b/headers/compatibility/bsd/machine/clock.h
    new file mode 100644
    index 0000000..e458d01
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_CLOCK_H_
     6#define _FBSD_COMPAT_SYS_CLOCK_H_
     7
     8
     9#endif /* _FBSD_COMPAT_SYS_CLOCK_H_ */
  • new file headers/compatibility/bsd/machine/cpufunc.h

    diff --git a/headers/compatibility/bsd/machine/cpufunc.h b/headers/compatibility/bsd/machine/cpufunc.h
    new file mode 100644
    index 0000000..8e1575b
    - +  
     1/*-
     2 * Copyright (c) 1993 The Regents of the University of California.
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 * 4. Neither the name of the University nor the names of its contributors
     14 *    may be used to endorse or promote products derived from this software
     15 *    without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27 * SUCH DAMAGE.
     28 *
     29 * $FreeBSD$
     30 */
     31#ifndef _FBSD_COMPAT_MACHINE_CPUFUNC_H_
     32#define _FBSD_COMPAT_MACHINE_CPUFUNC_H_
     33
     34
     35static __inline void
     36outsb(u_int port, const void *addr, size_t cnt)
     37{
     38    __asm __volatile("cld; rep; outsb"
     39             : "+S" (addr), "+c" (cnt)
     40             : "d" (port));
     41}
     42
     43#endif /* _FBSD_COMPAT_MACHINE_CPUFUNC_H_ */
  • new file headers/compatibility/bsd/machine/endian.h

    diff --git a/headers/compatibility/bsd/machine/endian.h b/headers/compatibility/bsd/machine/endian.h
    new file mode 100644
    index 0000000..52861ac
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_MACHINE_ENDIAN_H_
     6#define _FBSD_COMPAT_MACHINE_ENDIAN_H_
     7
     8
     9#include <sys/cdefs.h>
     10#include <sys/_types.h>
     11
     12#endif
  • new file headers/compatibility/bsd/machine/in_cksum.h

    diff --git a/headers/compatibility/bsd/machine/in_cksum.h b/headers/compatibility/bsd/machine/in_cksum.h
    new file mode 100644
    index 0000000..f174d30
    - +  
     1/*
     2 * Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All Rights Reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_MACHINE_IN_CKSUM_H_
     6#define _FBSD_COMPAT_MACHINE_IN_CKSUM_H_
     7
     8
     9#include <stdint.h>
     10
     11
     12#define in_cksum(m, len)    in_cksum_skip(m, len, 0)
     13
     14
     15static inline u_short
     16in_pseudo(u_int sum, u_int b, u_int c)
     17{
     18    // should never be called
     19    panic("in_pseudo() called");
     20    return 0;
     21}
     22
     23
     24static inline u_short
     25in_cksum_skip(struct mbuf* m, int len, int skip)
     26{
     27    // should never be called
     28    panic("in_cksum_skip() called");
     29    return 0;
     30}
     31
     32#endif  /* _FBSD_COMPAT_MACHINE_IN_CKSUM_H_ */
  • new file headers/compatibility/bsd/machine/resource.h

    diff --git a/headers/compatibility/bsd/machine/md_var.h b/headers/compatibility/bsd/machine/md_var.h
    new file mode 100644
    index 0000000..e69de29
    diff --git a/headers/compatibility/bsd/machine/ofw_machdep.h b/headers/compatibility/bsd/machine/ofw_machdep.h
    new file mode 100644
    index 0000000..e69de29
    diff --git a/headers/compatibility/bsd/machine/resource.h b/headers/compatibility/bsd/machine/resource.h
    new file mode 100644
    index 0000000..f9d9d43
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_MACHINE_RESOURCE_H_
     6#define _FBSD_COMPAT_MACHINE_RESOURCE_H_
     7
     8
     9#define SYS_RES_IRQ     0x1
     10#define SYS_RES_DRQ     0x2
     11#define SYS_RES_MEMORY  0x3
     12#define SYS_RES_IOPORT  0x4
     13
     14#endif
  • new file headers/compatibility/bsd/machine/stdarg.h

    diff --git a/headers/compatibility/bsd/machine/stdarg.h b/headers/compatibility/bsd/machine/stdarg.h
    new file mode 100644
    index 0000000..7596167
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_MACHINE_STDARG_H_
     6#define _FBSD_COMPAT_MACHINE_STDARG_H_
     7
     8
     9#include <sys/cdefs.h>
     10#include <sys/_types.h>
     11
     12#endif /* _FBSD_COMPAT_MACHINE_STDARG_H_ */
  • new file headers/compatibility/bsd/sys/_bus_dma.h

    diff --git a/headers/compatibility/bsd/sys/_bus_dma.h b/headers/compatibility/bsd/sys/_bus_dma.h
    new file mode 100644
    index 0000000..5aa4482
    - +  
     1/*-
     2 * Copyright 2006 John-Mark Gurney.
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 *
     14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     24 * SUCH DAMAGE.
     25 *
     26 * $FreeBSD: src/sys/sys/_bus_dma.h,v 1.1 2006/09/03 00:26:17 jmg Exp $
     27 *
     28 */
     29#ifndef _SYS__BUS_DMA_H_
     30#define _SYS__BUS_DMA_H_
     31
     32typedef int bus_dmasync_op_t;
     33
     34/*
     35 *  bus_dma_tag_t
     36 *
     37 *  A machine-dependent opaque type describing the characteristics
     38 *  of how to perform DMA mappings.  This structure encapsultes
     39 *  information concerning address and alignment restrictions, number
     40 *  of S/G segments, amount of data per S/G segment, etc.
     41 */
     42typedef struct bus_dma_tag  *bus_dma_tag_t;
     43
     44/*
     45 *  bus_dmamap_t
     46 *
     47 *  DMA mapping instance information.
     48 */
     49typedef struct bus_dmamap   *bus_dmamap_t;
     50
     51/*
     52 * A function that performs driver-specific synchronization on behalf of
     53 * busdma.
     54 */
     55typedef enum {
     56    BUS_DMA_LOCK    = 0x01,
     57    BUS_DMA_UNLOCK  = 0x02,
     58} bus_dma_lock_op_t;
     59
     60typedef void bus_dma_lock_t(void *, bus_dma_lock_op_t);
     61
     62#endif /* !_SYS__BUS_DMA_H_ */
  • new file headers/compatibility/bsd/sys/_mutex.h

    diff --git a/headers/compatibility/bsd/sys/_mutex.h b/headers/compatibility/bsd/sys/_mutex.h
    new file mode 100644
    index 0000000..7d8e757
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_SYS__MUTEX_H_
     7#define _FBSD_COMPAT_SYS__MUTEX_H_
     8
     9
     10#include <lock.h>
     11
     12
     13struct mtx {
     14    int                     type;
     15    union {
     16        struct {
     17            mutex           lock;
     18            thread_id       owner;
     19        }                   mutex;
     20        int32               spinlock;
     21        recursive_lock      recursive;
     22    } u;
     23};
     24
     25
     26#endif /* _FBSD_COMPAT_SYS__MUTEX_H_ */
  • new file headers/compatibility/bsd/sys/_task.h

    diff --git a/headers/compatibility/bsd/sys/_task.h b/headers/compatibility/bsd/sys/_task.h
    new file mode 100644
    index 0000000..a94e6b8
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS__TASK_H_
     6#define _FBSD_COMPAT_SYS__TASK_H_
     7
     8
     9/* Haiku's list management */
     10#include <util/list.h>
     11
     12
     13typedef void (*task_handler_t)(void *context, int pending);
     14
     15struct task {
     16    int ta_priority;
     17    task_handler_t ta_handler;
     18    void *ta_argument;
     19    int ta_pending;
     20
     21    struct list_link ta_link;
     22};
     23
     24#endif
  • new file headers/compatibility/bsd/sys/_timeval.h

    diff --git a/headers/compatibility/bsd/sys/_timeval.h b/headers/compatibility/bsd/sys/_timeval.h
    new file mode 100644
    index 0000000..6ba7a53
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS__TIMEVAL_H_
     6#define _FBSD_COMPAT_SYS__TIMEVAL_H_
     7
     8
     9#include <sys/_types.h>
     10
     11#endif /* _FBSD_COMPAT_SYS__TIMEVAL_H_ */
  • new file headers/compatibility/bsd/sys/_types.h

    diff --git a/headers/compatibility/bsd/sys/_types.h b/headers/compatibility/bsd/sys/_types.h
    new file mode 100644
    index 0000000..790e013
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS__TYPES_H_
     6#define _FBSD_COMPAT_SYS__TYPES_H_
     7
     8
     9#ifdef __GNUCLIKE_BUILTIN_VARARGS
     10typedef __builtin_va_list   __va_list;  /* internally known to gcc */
     11#else
     12typedef char *          __va_list;
     13#endif /* __GNUCLIKE_BUILTIN_VARARGS */
     14#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
     15    && !defined(__NO_GNUC_VA_LIST)
     16#define __GNUC_VA_LIST
     17typedef __va_list       __gnuc_va_list; /* compatibility w/GNU headers*/
     18#endif
     19
     20#endif /* _FBSD_COMPAT_SYS__TYPES_H_ */
  • new file headers/compatibility/bsd/sys/bus.h

    diff --git a/headers/compatibility/bsd/sys/bus.h b/headers/compatibility/bsd/sys/bus.h
    new file mode 100644
    index 0000000..889cd99
    - +  
     1/*
     2 * Copyright 2009, Colin Günther. All Rights Reserved.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_SYS_BUS_H_
     7#define _FBSD_COMPAT_SYS_BUS_H_
     8
     9
     10#include <sys/haiku-module.h>
     11
     12#include <sys/_bus_dma.h>
     13
     14#include <sys/queue.h>
     15
     16
     17// TODO per platform, these are 32-bit
     18
     19// oh you glorious world of macros
     20#define bus_read_1(r, o) \
     21    bus_space_read_1((r)->r_bustag, (r)->r_bushandle, (o))
     22#define bus_read_2(r, o) \
     23    bus_space_read_2((r)->r_bustag, (r)->r_bushandle, (o))
     24#define bus_read_4(r, o) \
     25    bus_space_read_4((r)->r_bustag, (r)->r_bushandle, (o))
     26#define bus_write_1(r, o, v) \
     27    bus_space_write_1((r)->r_bustag, (r)->r_bushandle, (o), (v))
     28#define bus_write_2(r, o, v) \
     29    bus_space_write_2((r)->r_bustag, (r)->r_bushandle, (o), (v))
     30#define bus_write_4(r, o, v) \
     31    bus_space_write_4((r)->r_bustag, (r)->r_bushandle, (o), (v))
     32
     33#define bus_barrier(r, o, l, f) \
     34    bus_space_barrier((r)->r_bustag, (r)->r_bushandle, (o), (l), (f))
     35
     36#define bus_read_region_1(r, o, d, c) \
     37    bus_space_read_region_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
     38
     39#define FILTER_STRAY            B_UNHANDLED_INTERRUPT
     40#define FILTER_HANDLED          B_HANDLED_INTERRUPT
     41#define FILTER_SCHEDULE_THREAD  B_INVOKE_SCHEDULER
     42
     43/* Note that we reversed the original order, so whenever actual (negative)
     44   numbers are used in a driver, we have to change it. */
     45#define BUS_PROBE_SPECIFIC      0
     46#define BUS_PROBE_LOW_PRIORITY  10
     47#define BUS_PROBE_DEFAULT       20
     48#define BUS_PROBE_GENERIC       100
     49
     50#define __BUS_ACCESSOR(varp, var, ivarp, ivar, type)                        \
     51                                                                            \
     52static __inline type varp ## _get_ ## var(device_t dev)                 \
     53{                                                                       \
     54    return 0;                                                       \
     55}                                                                       \
     56                                                                            \
     57static __inline void varp ## _set_ ## var(device_t dev, type t)             \
     58{                                                                           \
     59}
     60
     61
     62struct resource;
     63
     64struct resource_spec {
     65    int type;
     66    int rid;
     67    int flags;
     68};
     69
     70enum intr_type {
     71    INTR_TYPE_NET   = 4,
     72    INTR_FAST       = 128,
     73    INTR_MPSAFE     = 512,
     74};
     75
     76
     77int bus_generic_detach(device_t dev);
     78int bus_generic_suspend(device_t dev);
     79int bus_generic_resume(device_t dev);
     80void bus_generic_shutdown(device_t dev);
     81
     82typedef int (*driver_filter_t)(void *);
     83typedef void driver_intr_t(void *);
     84
     85
     86int resource_int_value(const char *name, int unit, const char *resname,
     87    int *result);
     88
     89struct resource *bus_alloc_resource(device_t dev, int type, int *rid,
     90    unsigned long start, unsigned long end, unsigned long count, uint32 flags);
     91int bus_release_resource(device_t dev, int type, int rid, struct resource *r);
     92int bus_alloc_resources(device_t dev, struct resource_spec *resourceSpec,
     93    struct resource **resources);
     94void bus_release_resources(device_t dev,
     95    const struct resource_spec *resourceSpec, struct resource **resources);
     96
     97int bus_child_present(device_t child);
     98
     99static inline struct resource *
     100bus_alloc_resource_any(device_t dev, int type, int *rid, uint32 flags)
     101{
     102    return bus_alloc_resource(dev, type, rid, 0, ~0, 1, flags);
     103}
     104
     105bus_dma_tag_t bus_get_dma_tag(device_t dev);
     106
     107int bus_setup_intr(device_t dev, struct resource *r, int flags,
     108    driver_filter_t filter, driver_intr_t handler, void *arg, void **_cookie);
     109int bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
     110
     111const char *device_get_name(device_t dev);
     112const char *device_get_nameunit(device_t dev);
     113int device_get_unit(device_t dev);
     114void *device_get_softc(device_t dev);
     115int device_printf(device_t dev, const char *, ...) __printflike(2, 3);
     116void device_set_desc(device_t dev, const char *desc);
     117void device_set_desc_copy(device_t dev, const char *desc);
     118const char *device_get_desc(device_t dev);
     119device_t device_get_parent(device_t dev);
     120u_int32_t device_get_flags(device_t dev);
     121devclass_t device_get_devclass(device_t dev);
     122int device_get_children(device_t dev, device_t **devlistp, int *devcountp);
     123
     124void device_set_ivars(device_t dev, void *);
     125void *device_get_ivars(device_t dev);
     126
     127device_t device_add_child(device_t dev, const char *name, int unit);
     128int device_delete_child(device_t dev, device_t child);
     129int device_is_attached(device_t dev);
     130int device_attach(device_t dev);
     131int device_detach(device_t dev);
     132int bus_print_child_header(device_t dev, device_t child);
     133int bus_print_child_footer(device_t dev, device_t child);
     134int bus_generic_print_child(device_t dev, device_t child);
     135void bus_generic_driver_added(device_t dev, driver_t *driver);
     136int bus_generic_attach(device_t dev);
     137int device_set_driver(device_t dev, driver_t *driver);
     138int device_is_alive(device_t dev);
     139
     140
     141static inline struct sysctl_ctx_list *
     142device_get_sysctl_ctx(device_t dev)
     143{
     144    return NULL;
     145}
     146
     147
     148static inline void *
     149device_get_sysctl_tree(device_t dev)
     150{
     151    return NULL;
     152}
     153
     154devclass_t devclass_find(const char *classname);
     155device_t devclass_get_device(devclass_t dc, int unit);
     156int devclass_get_maxunit(devclass_t dc);
     157
     158#endif  /* _FBSD_COMPAT_SYS_BUS_H_ */
  • new file headers/compatibility/bsd/sys/bus_dma.h

    diff --git a/headers/compatibility/bsd/sys/bus_dma.h b/headers/compatibility/bsd/sys/bus_dma.h
    new file mode 100644
    index 0000000..362019f
    - +  
     1/*  $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $    */
     2
     3/*-
     4 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
     5 * All rights reserved.
     6 *
     7 * This code is derived from software contributed to The NetBSD Foundation
     8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
     9 * NASA Ames Research Center.
     10 *
     11 * Redistribution and use in source and binary forms, with or without
     12 * modification, are permitted provided that the following conditions
     13 * are met:
     14 * 1. Redistributions of source code must retain the above copyright
     15 *    notice, this list of conditions and the following disclaimer.
     16 * 2. Redistributions in binary form must reproduce the above copyright
     17 *    notice, this list of conditions and the following disclaimer in the
     18 *    documentation and/or other materials provided with the distribution.
     19 * 3. All advertising materials mentioning features or use of this software
     20 *    must display the following acknowledgement:
     21 *  This product includes software developed by the NetBSD
     22 *  Foundation, Inc. and its contributors.
     23 * 4. Neither the name of The NetBSD Foundation nor the names of its
     24 *    contributors may be used to endorse or promote products derived
     25 *    from this software without specific prior written permission.
     26 *
     27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37 * POSSIBILITY OF SUCH DAMAGE.
     38 */
     39
     40/*-
     41 * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
     42 * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
     43 *
     44 * Redistribution and use in source and binary forms, with or without
     45 * modification, are permitted provided that the following conditions
     46 * are met:
     47 * 1. Redistributions of source code must retain the above copyright
     48 *    notice, this list of conditions and the following disclaimer.
     49 * 2. Redistributions in binary form must reproduce the above copyright
     50 *    notice, this list of conditions and the following disclaimer in the
     51 *    documentation and/or other materials provided with the distribution.
     52 * 3. All advertising materials mentioning features or use of this software
     53 *    must display the following acknowledgement:
     54 *      This product includes software developed by Christopher G. Demetriou
     55 *  for the NetBSD Project.
     56 * 4. The name of the author may not be used to endorse or promote products
     57 *    derived from this software without specific prior written permission
     58 *
     59 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     60 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     61 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     62 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     63 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     64 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     65 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     66 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     67 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     68 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     69 */
     70/* $FreeBSD: src/sys/sys/bus_dma.h,v 1.30 2006/09/03 00:26:17 jmg Exp $ */
     71#ifndef _BUS_DMA_H_
     72#define _BUS_DMA_H_
     73
     74#include <sys/_bus_dma.h>
     75
     76
     77/*
     78 * Machine independent interface for mapping physical addresses to peripheral
     79 * bus 'physical' addresses, and assisting with DMA operations.
     80 *
     81 * XXX This file is always included from <machine/bus_dma.h> and should not
     82 *     (yet) be included directly.
     83 */
     84
     85/*
     86 * Flags used in various bus DMA methods.
     87 */
     88#define BUS_DMA_WAITOK      0x00    /* safe to sleep (pseudo-flag) */
     89#define BUS_DMA_NOWAIT      0x01    /* not safe to sleep */
     90#define BUS_DMA_ALLOCNOW    0x02    /* perform resource allocation now */
     91#define BUS_DMA_COHERENT    0x04    /* hint: map memory in a coherent way */
     92#define BUS_DMA_ZERO        0x08    /* allocate zero'ed memory */
     93#define BUS_DMA_BUS1        0x10    /* placeholders for bus functions... */
     94#define BUS_DMA_BUS2        0x20
     95#define BUS_DMA_BUS3        0x40
     96#define BUS_DMA_BUS4        0x80
     97
     98/*
     99 * The following two flags are non-standard or specific to only certain
     100 * architectures
     101 */
     102#define BUS_DMA_NOWRITE     0x100
     103#define BUS_DMA_NOCACHE     0x200
     104#define BUS_DMA_ISA     0x400   /* map memory for AXP ISA dma */
     105
     106/* Forwards needed by prototypes below. */
     107struct mbuf;
     108struct uio;
     109
     110/*
     111 * Operations performed by bus_dmamap_sync().
     112 */
     113#define BUS_DMASYNC_PREREAD 1
     114#define BUS_DMASYNC_POSTREAD    2
     115#define BUS_DMASYNC_PREWRITE    4
     116#define BUS_DMASYNC_POSTWRITE   8
     117
     118/*
     119 *  bus_dma_segment_t
     120 *
     121 *  Describes a single contiguous DMA transaction.  Values
     122 *  are suitable for programming into DMA registers.
     123 */
     124typedef struct bus_dma_segment {
     125    bus_addr_t  ds_addr;    /* DMA address */
     126    bus_size_t  ds_len;     /* length of transfer */
     127} bus_dma_segment_t;
     128
     129/*
     130 * A function that returns 1 if the address cannot be accessed by
     131 * a device and 0 if it can be.
     132 */
     133typedef int bus_dma_filter_t(void *, bus_addr_t);
     134
     135/*
     136 * Generic helper function for manipulating mutexes.
     137 */
     138void busdma_lock_mutex(void *arg, bus_dma_lock_op_t op);
     139
     140/*
     141 * Allocate a device specific dma_tag encapsulating the constraints of
     142 * the parent tag in addition to other restrictions specified:
     143 *
     144 *  alignment:  Alignment for segments.
     145 *  boundary:   Boundary that segments cannot cross.
     146 *  lowaddr:    Low restricted address that cannot appear in a mapping.
     147 *  highaddr:   High restricted address that cannot appear in a mapping.
     148 *  filtfunc:   An optional function to further test if an address
     149 *          within the range of lowaddr and highaddr cannot appear
     150 *          in a mapping.
     151 *  filtfuncarg:    An argument that will be passed to filtfunc in addition
     152 *          to the address to test.
     153 *  maxsize:    Maximum mapping size supported by this tag.
     154 *  nsegments:  Number of discontinuities allowed in maps.
     155 *  maxsegsz:   Maximum size of a segment in the map.
     156 *  flags:      Bus DMA flags.
     157 *  lockfunc:   An optional function to handle driver-defined lock
     158 *          operations.
     159 *  lockfuncarg:    An argument that will be passed to lockfunc in addition
     160 *          to the lock operation.
     161 *  dmat:       A pointer to set to a valid dma tag should the return
     162 *          value of this function indicate success.
     163 */
     164/* XXX Should probably allow specification of alignment */
     165int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
     166               bus_size_t boundary, bus_addr_t lowaddr,
     167               bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
     168               void *filtfuncarg, bus_size_t maxsize, int nsegments,
     169               bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
     170               void *lockfuncarg, bus_dma_tag_t *dmat);
     171
     172int bus_dma_tag_destroy(bus_dma_tag_t dmat);
     173
     174/*
     175 * A function that processes a successfully loaded dma map or an error
     176 * from a delayed load map.
     177 */
     178typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
     179
     180/*
     181 * Like bus_dmamap_callback but includes map size in bytes.  This is
     182 * defined as a separate interface to maintain compatibility for users
     183 * of bus_dmamap_callback_t--at some point these interfaces should be merged.
     184 */
     185typedef void bus_dmamap_callback2_t(void *, bus_dma_segment_t *, int, bus_size_t, int);
     186
     187/*
     188 * XXX sparc64 uses the same interface, but a much different implementation.
     189 *     <machine/bus_dma.h> for the sparc64 arch contains the equivalent
     190 *     declarations.
     191 */
     192#if !defined(__sparc64__)
     193
     194/*
     195 * Allocate a handle for mapping from kva/uva/physical
     196 * address space into bus device space.
     197 */
     198int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
     199
     200/*
     201 * Destroy a handle for mapping from kva/uva/physical
     202 * address space into bus device space.
     203 */
     204int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
     205
     206/*
     207 * Allocate a piece of memory that can be efficiently mapped into
     208 * bus device space based on the constraints listed in the dma tag.
     209 * A dmamap to for use with dmamap_load is also allocated.
     210 */
     211int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
     212             bus_dmamap_t *mapp);
     213
     214/*
     215 * Free a piece of memory and its allocated dmamap, that was allocated
     216 * via bus_dmamem_alloc.
     217 */
     218void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
     219
     220/*
     221 * Map the buffer buf into bus space using the dmamap map.
     222 */
     223int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
     224            bus_size_t buflen, bus_dmamap_callback_t *callback,
     225            void *callback_arg, int flags);
     226
     227/*
     228 * Like bus_dmamap_load but for mbufs.  Note the use of the
     229 * bus_dmamap_callback2_t interface.
     230 */
     231int bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map,
     232             struct mbuf *mbuf,
     233             bus_dmamap_callback2_t *callback, void *callback_arg,
     234             int flags);
     235
     236int bus_dmamap_load_mbuf_sg(bus_dma_tag_t dmat, bus_dmamap_t map,
     237                struct mbuf *mbuf, bus_dma_segment_t *segs,
     238                int *nsegs, int flags);
     239
     240/*
     241 * Like bus_dmamap_load but for uios.  Note the use of the
     242 * bus_dmamap_callback2_t interface.
     243 */
     244int bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map,
     245            struct uio *ui,
     246            bus_dmamap_callback2_t *callback, void *callback_arg,
     247            int flags);
     248
     249/*
     250 * Perform a synchronization operation on the given map.
     251 */
     252void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
     253#define bus_dmamap_sync(dmat, dmamap, op)           \
     254    do {                            \
     255        if ((dmamap) != NULL)               \
     256            _bus_dmamap_sync(dmat, dmamap, op); \
     257    } while (0)
     258
     259/*
     260 * Release the mapping held by map.
     261 */
     262void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
     263#define bus_dmamap_unload(dmat, dmamap)             \
     264    do {                            \
     265        if ((dmamap) != NULL)               \
     266            _bus_dmamap_unload(dmat, dmamap);   \
     267    } while (0)
     268
     269#endif /* __sparc64__ */
     270
     271#endif /* _BUS_DMA_H_ */
  • new file headers/compatibility/bsd/sys/callout.h

    diff --git a/headers/compatibility/bsd/sys/callout.h b/headers/compatibility/bsd/sys/callout.h
    new file mode 100644
    index 0000000..9d4da3b
    - +  
     1/*
     2 * Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
     3 * Copyright 2009, Colin Günther, coling@gmx.de.
     4 * Copyright 2007, Hugo Santos. All Rights Reserved.
     5 * Distributed under the terms of the MIT License.
     6 */
     7#ifndef _FBSD_COMPAT_SYS_CALLOUT_H_
     8#define _FBSD_COMPAT_SYS_CALLOUT_H_
     9
     10
     11#include <sys/haiku-module.h>
     12
     13#include <sys/queue.h>
     14
     15
     16struct callout {
     17    struct list_link    link;
     18    bigtime_t           due;
     19    uint32              flags;
     20
     21    void *              c_arg;
     22    void                (*c_func)(void *);
     23    struct mtx *        c_mtx;
     24    int                 c_flags;
     25};
     26
     27
     28#define CALLOUT_MPSAFE  0x0001
     29
     30
     31void callout_init(struct callout *c, int mpsafe);
     32void callout_init_mtx(struct callout *c, struct mtx *mutex, int flags);
     33/* Time values are in ticks, see compat/sys/kernel.h for its definition */
     34int callout_schedule(struct callout *c, int ticks);
     35int callout_reset(struct callout *c, int ticks, void (*func)(void *), void *arg);
     36int callout_pending(struct callout *c);
     37int callout_active(struct callout *c);
     38
     39#define callout_drain(c)    _callout_stop_safe(c, 1)
     40#define callout_stop(c)     _callout_stop_safe(c, 0)
     41int _callout_stop_safe(struct callout *c, int safe);
     42
     43
     44
     45#endif  /* _FBSD_COMPAT_SYS_CALLOUT_H_ */
  • headers/compatibility/bsd/sys/cdefs.h

    diff --git a/headers/compatibility/bsd/sys/cdefs.h b/headers/compatibility/bsd/sys/cdefs.h
    index 6647d2e..6ca418d 100644
    a b  
     1/*-
     2 * Copyright (c) 1991, 1993
     3 *  The Regents of the University of California.  All rights reserved.
     4 *
     5 * This code is derived from software contributed to Berkeley by
     6 * Berkeley Software Design, Inc.
     7 *
     8 * Redistribution and use in source and binary forms, with or without
     9 * modification, are permitted provided that the following conditions
     10 * are met:
     11 * 1. Redistributions of source code must retain the above copyright
     12 *    notice, this list of conditions and the following disclaimer.
     13 * 2. Redistributions in binary form must reproduce the above copyright
     14 *    notice, this list of conditions and the following disclaimer in the
     15 *    documentation and/or other materials provided with the distribution.
     16 * 4. Neither the name of the University nor the names of its contributors
     17 *    may be used to endorse or promote products derived from this software
     18 *    without specific prior written permission.
     19 *
     20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30 * SUCH DAMAGE.
     31 *
     32 *  @(#)cdefs.h 8.8 (Berkeley) 1/9/95
     33 * $FreeBSD$
     34 */
     35#ifndef _FBSD_COMPAT_SYS_CDEFS_H_
     36#define _FBSD_COMPAT_SYS_CDEFS_H_
     37
     38
     39#include <posix/sys/cdefs.h>
     40
     41
     42#define __FBSDID(str)   static const char __fbsdid[] = str
     43
    144/*
    2  * Copyright 2006-2012 Haiku Inc. All Rights Reserved.
    3  * Distributed under the terms of the MIT License.
     45 * This code has been put in place to help reduce the addition of
     46 * compiler specific defines in FreeBSD code.  It helps to aid in
     47 * having a compiler-agnostic source tree.
    448 */
    5 #ifndef _BSD_SYS_CDEFS_H_
    6 #define _BSD_SYS_CDEFS_H_
    749
     50#if defined(__GNUC__) || defined(__INTEL_COMPILER)
     51
     52#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
     53#define __GNUCLIKE_ASM 3
     54#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
     55#else
     56#define __GNUCLIKE_ASM 2
     57#endif
     58#define __GNUCLIKE___TYPEOF 1
     59#define __GNUCLIKE___OFFSETOF 1
     60#define __GNUCLIKE___SECTION 1
     61
     62#define __GNUCLIKE_ATTRIBUTE_MODE_DI 1
     63
     64#ifndef __INTEL_COMPILER
     65# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
     66#endif
     67
     68#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
     69# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
     70    && __INTEL_COMPILER < 800
     71#  undef __GNUCLIKE_BUILTIN_CONSTANT_P
     72# endif
    873
    9 #include_next <sys/cdefs.h>
     74#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
     75# define __GNUCLIKE_BUILTIN_VARARGS 1
     76# define __GNUCLIKE_BUILTIN_STDARG 1
     77# define __GNUCLIKE_BUILTIN_VAALIST 1
     78#endif
     79
     80#if defined(__GNUC__)
     81# define __GNUC_VA_LIST_COMPATIBILITY 1
     82#endif
    1083
     84#ifndef __INTEL_COMPILER
     85# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
     86# define __GNUCLIKE_MATH_BUILTIN_RELOPS
     87#endif
    1188
    12 #ifdef _BSD_SOURCE
     89#define __GNUCLIKE_BUILTIN_MEMCPY 1
    1390
     91/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
     92#define __CC_SUPPORTS_INLINE 1
     93#define __CC_SUPPORTS___INLINE 1
     94#define __CC_SUPPORTS___INLINE__ 1
    1495
    15 #define __FBSDID(x)
    16 #define __unused
     96#define __CC_SUPPORTS___FUNC__ 1
     97#define __CC_SUPPORTS_WARNING 1
     98
     99#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
     100
     101#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
     102
     103#endif /* __GNUC__ || __INTEL_COMPILER */
     104
     105
     106/*
     107 * Macro to test if we're using a specific version of gcc or later.
     108 */
     109#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
     110#define __GNUC_PREREQ__(ma, mi) \
     111    (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
     112#else
     113#define __GNUC_PREREQ__(ma, mi) 0
     114#endif
     115
     116/*
     117 * GNU C version 2.96 adds explicit branch prediction so that
     118 * the CPU back-end can hint the processor and also so that
     119 * code blocks can be reordered such that the predicted path
     120 * sees a more linear flow, thus improving cache behavior, etc.
     121 *
     122 * The following two macros provide us with a way to utilize this
     123 * compiler feature.  Use __predict_true() if you expect the expression
     124 * to evaluate to true, and __predict_false() if you expect the
     125 * expression to evaluate to false.
     126 *
     127 * A few notes about usage:
     128 *
     129 *  * Generally, __predict_false() error condition checks (unless
     130 *    you have some _strong_ reason to do otherwise, in which case
     131 *    document it), and/or __predict_true() `no-error' condition
     132 *    checks, assuming you want to optimize for the no-error case.
     133 *
     134 *  * Other than that, if you don't know the likelihood of a test
     135 *    succeeding from empirical or other `hard' evidence, don't
     136 *    make predictions.
     137 *
     138 *  * These are meant to be used in places that are run `a lot'.
     139 *    It is wasteful to make predictions in code that is run
     140 *    seldomly (e.g. at subsystem initialization time) as the
     141 *    basic block reordering that this affects can often generate
     142 *    larger code.
     143 */
     144#if __GNUC_PREREQ__(2, 96)
     145#define __predict_true(exp)     __builtin_expect((exp), 1)
     146#define __predict_false(exp)    __builtin_expect((exp), 0)
     147#else
     148#define __predict_true(exp)     (exp)
     149#define __predict_false(exp)    (exp)
     150#endif
     151
     152/*
     153 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
     154 * require it.
     155 */
     156#define __offsetof offsetof
    17157
    18 #define __printflike(a, b)  __attribute__ ((format (__printf__, (a), (b))))
     158/*
     159 * Compiler-dependent macros to help declare dead (non-returning) and
     160 * pure (no side effects) functions, and unused variables.  They are
     161 * null except for versions of gcc that are known to support the features
     162 * properly (old versions of gcc-2 supported the dead and pure features
     163 * in a different (wrong) way).  If we do not provide an implementation
     164 * for a given compiler, let the compile fail if it is told to use
     165 * a feature that we cannot live without.
     166 */
     167#ifdef lint
     168#define __pure2
     169#define __unused
     170#define __packed
     171#define __aligned(x)
     172#define __section(x)
     173#else
     174#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
     175#define __pure2
     176#define __unused
     177#endif
     178#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
     179#define __pure2     __attribute__((__const__))
     180#define __unused
     181/* XXX Find out what to do for __packed, __aligned and __section */
     182#endif
     183#if __GNUC_PREREQ__(2, 7)
     184#define __pure2     __attribute__((__const__))
     185#define __unused    __attribute__((__unused__))
     186#define __packed    __attribute__((__packed__))
     187#define __aligned(x)    __attribute__((__aligned__(x)))
     188#define __section(x)    __attribute__((__section__(x)))
     189#endif
     190
     191#if __GNUC_PREREQ__(3, 1)
     192#define __used      __attribute__((__used__))
     193#else
     194#if __GNUC_PREREQ__(2, 7)
     195#define __used
     196#endif
     197#endif
     198
     199#if defined(__INTEL_COMPILER)
     200#define __pure2     __attribute__((__const__))
     201#define __unused    __attribute__((__unused__))
     202#define __used      __attribute__((__used__))
     203#define __packed    __attribute__((__packed__))
     204#define __aligned(x)    __attribute__((__aligned__(x)))
     205#define __section(x)    __attribute__((__section__(x)))
     206#endif
     207#endif
     208
     209/*
     210 * Compiler-dependent macros to declare that functions take printf-like
     211 * or scanf-like arguments.  They are null except for versions of gcc
     212 * that are known to support the features properly (old versions of gcc-2
     213 * didn't permit keeping the keywords out of the application namespace).
     214 */
     215#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
     216#define __printflike(fmtarg, firstvararg)
     217#define __scanflike(fmtarg, firstvararg)
     218#define __format_arg(fmtarg)
     219#else
     220#define __printflike(fmtarg, firstvararg) \
     221        __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
     222#define __scanflike(fmtarg, firstvararg) \
     223        __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
     224#define __format_arg(fmtarg)    __attribute__((__format_arg__ (fmtarg)))
     225#endif
    19226#define __printf0like(a, b)
    20227
     228#if __GNUC_PREREQ__(3, 1)
     229#define __noinline  __attribute__ ((__noinline__))
     230#else
     231#define __noinline
     232#endif
    21233
     234#if __GNUC_PREREQ__(3, 3)
     235#define __nonnull(x)    __attribute__((__nonnull__(x)))
     236#else
     237#define __nonnull(x)
    22238#endif
    23239
     240/*
     241 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
     242 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
     243 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
     244 * mode -- there must be no spaces between its arguments, and for nested
     245 * __CONCAT's, all the __CONCAT's must be at the left.  __CONCAT can also
     246 * concatenate double-quoted strings produced by the __STRING macro, but
     247 * this only works with ANSI C.
     248 *
     249 * __XSTRING is like __STRING, but it expands any macros in its argument
     250 * first.  It is only available with ANSI C.
     251 */
     252#if defined(__STDC__) || defined(__cplusplus)
     253#define __XSTRING(x)    __STRING(x) /* expand x, then stringify */
     254
     255#define __const     const       /* define reserved names to standard */
     256#define __signed    signed
     257#define __volatile  volatile
     258#if defined(__cplusplus)
     259#define __inline    inline      /* convert to C++ keyword */
     260#else
     261#if !(defined(__CC_SUPPORTS___INLINE))
     262#define __inline            /* delete GCC keyword */
     263#endif /* ! __CC_SUPPORTS___INLINE */
     264#endif /* !__cplusplus */
     265
     266#else   /* !(__STDC__ || __cplusplus) */
     267
     268#if !defined(__CC_SUPPORTS___INLINE)
     269#define __const             /* delete pseudo-ANSI C keywords */
     270#define __inline
     271#define __signed
     272#define __volatile
     273/*
     274 * In non-ANSI C environments, new programs will want ANSI-only C keywords
     275 * deleted from the program and old programs will want them left alone.
     276 * When using a compiler other than gcc, programs using the ANSI C keywords
     277 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
     278 * When using "gcc -traditional", we assume that this is the intent; if
     279 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
     280 */
     281#ifndef NO_ANSI_KEYWORDS
     282#define const               /* delete ANSI C keywords */
     283#define inline
     284#define signed
     285#define volatile
     286#endif  /* !NO_ANSI_KEYWORDS */
     287#endif  /* !__CC_SUPPORTS___INLINE */
     288#endif  /* !(__STDC__ || __cplusplus) */
     289
     290#ifndef __DECONST
     291#define __DECONST(type, var)    ((type)(uintptr_t)(const void *)(var))
     292#endif
     293
     294#ifndef __UNCONST
     295#define __UNCONST(var)  ((void*)(uintptr_t)(const void *)(var))
     296#endif
     297
     298
     299#endif
    24300
    25 #endif  /* _BSD_SYS_CDEFS_H_ */
  • new file headers/compatibility/bsd/sys/condvar.h

    diff --git a/headers/compatibility/bsd/sys/condvar.h b/headers/compatibility/bsd/sys/condvar.h
    new file mode 100644
    index 0000000..55b96a8
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * All rights reserved. Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_CONDVAR_H_
     6#define _FBSD_COMPAT_SYS_CONDVAR_H_
     7
     8
     9#include <sys/queue.h>
     10
     11#ifdef __cplusplus
     12} /* extern "C" */
     13#include <kernel_c++_structs.h>
     14extern "C" {
     15#else
     16#include <kernel_c++_structs.h>
     17#endif
     18
     19
     20struct cv {
     21    struct ConditionVariable condition;
     22};
     23
     24
     25void cv_init(struct cv*, const char*);
     26void cv_destroy(struct cv*);
     27void cv_wait(struct cv*, struct mtx*);
     28int cv_timedwait(struct cv*, struct mtx*, int);
     29void cv_signal(struct cv*);
     30
     31#endif /* _FBSD_COMPAT_SYS_CONDVAR_H_ */
  • new file headers/compatibility/bsd/sys/ctype.h

    diff --git a/headers/compatibility/bsd/sys/ctype.h b/headers/compatibility/bsd/sys/ctype.h
    new file mode 100644
    index 0000000..60cc664
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_CTYPE_H_
     6#define _FBSD_COMPAT_SYS_CTYPE_H_
     7
     8
     9#define isprint(c) ((c) >= ' ' && (c) <= '~')
     10
     11#endif /* _FBSD_COMPAT_SYS_CTYPE_H_ */
  • new file headers/compatibility/bsd/sys/endian.h

    diff --git a/headers/compatibility/bsd/sys/endian.h b/headers/compatibility/bsd/sys/endian.h
    new file mode 100644
    index 0000000..6261634
    - +  
     1/*-
     2 * Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 *
     14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     24 * SUCH DAMAGE.
     25 *
     26 * $FreeBSD: src/sys/sys/endian.h,v 1.6 2003/10/15 20:05:57 obrien Exp $
     27 */
     28#ifndef _FBSD_COMPAT_SYS_ENDIAN_H_
     29#define _FBSD_COMPAT_SYS_ENDIAN_H_
     30
     31#include <stdint.h>
     32#include <posix/endian.h>
     33
     34#include <support/ByteOrder.h>
     35
     36#include <sys/cdefs.h>
     37#include <sys/_types.h>
     38#include <machine/endian.h>
     39
     40#define _BYTE_ORDER     BYTE_ORDER
     41#define _LITTLE_ENDIAN  LITTLE_ENDIAN
     42#define _BIG_ENDIAN     BIG_ENDIAN
     43
     44#define __bswap16(x)    __swap_int16(x)
     45#define __bswap32(x)    __swap_int32(x)
     46#define __bswap64(x)    __swap_int64(x)
     47
     48/*
     49 * General byte order swapping functions.
     50 */
     51#define bswap16(x)  __bswap16(x)
     52#define bswap32(x)  __bswap32(x)
     53#define bswap64(x)  __bswap64(x)
     54
     55/*
     56 * Host to big endian, host to little endian, big endian to host, and little
     57 * endian to host byte order functions as detailed in byteorder(9).
     58 */
     59#if _BYTE_ORDER == _LITTLE_ENDIAN
     60#define htobe16(x)  bswap16((x))
     61#define htobe32(x)  bswap32((x))
     62#define htobe64(x)  bswap64((x))
     63#define htole16(x)  ((uint16_t)(x))
     64#define htole32(x)  ((uint32_t)(x))
     65#define htole64(x)  ((uint64_t)(x))
     66
     67#define be16toh(x)  bswap16((x))
     68#define be32toh(x)  bswap32((x))
     69#define be64toh(x)  bswap64((x))
     70#define le16toh(x)  ((uint16_t)(x))
     71#define le32toh(x)  ((uint32_t)(x))
     72#define le64toh(x)  ((uint64_t)(x))
     73#else /* _BYTE_ORDER != _LITTLE_ENDIAN */
     74#define htobe16(x)  ((uint16_t)(x))
     75#define htobe32(x)  ((uint32_t)(x))
     76#define htobe64(x)  ((uint64_t)(x))
     77#define htole16(x)  bswap16((x))
     78#define htole32(x)  bswap32((x))
     79#define htole64(x)  bswap64((x))
     80
     81#define be16toh(x)  ((uint16_t)(x))
     82#define be32toh(x)  ((uint32_t)(x))
     83#define be64toh(x)  ((uint64_t)(x))
     84#define le16toh(x)  bswap16((x))
     85#define le32toh(x)  bswap32((x))
     86#define le64toh(x)  bswap64((x))
     87#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
     88
     89/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
     90
     91static __inline uint16_t
     92be16dec(const void *pp)
     93{
     94    unsigned char const *p = (unsigned char const *)pp;
     95
     96    return ((p[0] << 8) | p[1]);
     97}
     98
     99static __inline uint32_t
     100be32dec(const void *pp)
     101{
     102    unsigned char const *p = (unsigned char const *)pp;
     103
     104    return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
     105}
     106
     107static __inline uint64_t
     108be64dec(const void *pp)
     109{
     110    unsigned char const *p = (unsigned char const *)pp;
     111
     112    return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
     113}
     114
     115static __inline uint16_t
     116le16dec(const void *pp)
     117{
     118    unsigned char const *p = (unsigned char const *)pp;
     119
     120    return ((p[1] << 8) | p[0]);
     121}
     122
     123static __inline uint32_t
     124le32dec(const void *pp)
     125{
     126    unsigned char const *p = (unsigned char const *)pp;
     127
     128    return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
     129}
     130
     131static __inline uint64_t
     132le64dec(const void *pp)
     133{
     134    unsigned char const *p = (unsigned char const *)pp;
     135
     136    return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
     137}
     138
     139static __inline void
     140be16enc(void *pp, uint16_t u)
     141{
     142    unsigned char *p = (unsigned char *)pp;
     143
     144    p[0] = (u >> 8) & 0xff;
     145    p[1] = u & 0xff;
     146}
     147
     148static __inline void
     149be32enc(void *pp, uint32_t u)
     150{
     151    unsigned char *p = (unsigned char *)pp;
     152
     153    p[0] = (u >> 24) & 0xff;
     154    p[1] = (u >> 16) & 0xff;
     155    p[2] = (u >> 8) & 0xff;
     156    p[3] = u & 0xff;
     157}
     158
     159static __inline void
     160be64enc(void *pp, uint64_t u)
     161{
     162    unsigned char *p = (unsigned char *)pp;
     163
     164    be32enc(p, u >> 32);
     165    be32enc(p + 4, u & 0xffffffff);
     166}
     167
     168static __inline void
     169le16enc(void *pp, uint16_t u)
     170{
     171    unsigned char *p = (unsigned char *)pp;
     172
     173    p[0] = u & 0xff;
     174    p[1] = (u >> 8) & 0xff;
     175}
     176
     177static __inline void
     178le32enc(void *pp, uint32_t u)
     179{
     180    unsigned char *p = (unsigned char *)pp;
     181
     182    p[0] = u & 0xff;
     183    p[1] = (u >> 8) & 0xff;
     184    p[2] = (u >> 16) & 0xff;
     185    p[3] = (u >> 24) & 0xff;
     186}
     187
     188static __inline void
     189le64enc(void *pp, uint64_t u)
     190{
     191    unsigned char *p = (unsigned char *)pp;
     192
     193    le32enc(p, u & 0xffffffff);
     194    le32enc(p + 4, u >> 32);
     195}
     196
     197#endif  /* _SYS_ENDIAN_H_ */
  • new file headers/compatibility/bsd/sys/errno.h

    diff --git a/headers/compatibility/bsd/sys/errno.h b/headers/compatibility/bsd/sys/errno.h
    new file mode 100644
    index 0000000..fd307ce
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_ERRNO_H_
     6#define _FBSD_COMPAT_SYS_ERRNO_H_
     7
     8
     9#include <posix/errno.h>
     10
     11
     12/* pseudo-errors returned inside freebsd compat layer to modify return to process */
     13#define ERESTART        (B_ERRORS_END + 1)      /* restart syscall */
     14#define EJUSTRETURN     (B_ERRORS_END + 2)      /* don't modify regs, just return */
     15
     16#endif
  • new file headers/compatibility/bsd/sys/event.h

    diff --git a/headers/compatibility/bsd/sys/event.h b/headers/compatibility/bsd/sys/event.h
    new file mode 100644
    index 0000000..642f49c
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_EVENT_H_
     6#define _FBSD_COMPAT_SYS_EVENT_H_
     7
     8
     9struct knlist {
     10    int _dummy;
     11};
     12
     13#endif
  • new file headers/compatibility/bsd/sys/eventhandler.h

    diff --git a/headers/compatibility/bsd/sys/eventhandler.h b/headers/compatibility/bsd/sys/eventhandler.h
    new file mode 100644
    index 0000000..9a53c98
    - +  
     1/*-
     2 * Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 *
     14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     24 * SUCH DAMAGE.
     25 *
     26 * $FreeBSD: src/sys/sys/eventhandler.h,v 1.33.2.1 2006/05/16 07:27:49 ps Exp $
     27 */
     28#ifndef SYS_EVENTHANDLER_H
     29#define SYS_EVENTHANDLER_H
     30
     31#include <sys/lock.h>
     32#include <sys/ktr.h>
     33#include <sys/mutex.h>
     34#include <sys/queue.h>
     35
     36struct eventhandler_entry {
     37    TAILQ_ENTRY(eventhandler_entry) ee_link;
     38    int             ee_priority;
     39#define EHE_DEAD_PRIORITY   (-1)
     40    void                *ee_arg;
     41};
     42
     43struct eventhandler_list {
     44    char                *el_name;
     45    int             el_flags;
     46#define EHL_INITTED (1<<0)
     47    u_int               el_runcount;
     48    struct mtx          el_lock;
     49    TAILQ_ENTRY(eventhandler_list)  el_link;
     50    TAILQ_HEAD(,eventhandler_entry) el_entries;
     51};
     52
     53typedef struct eventhandler_entry   *eventhandler_tag;
     54
     55#define EHL_LOCK(p)     mtx_lock(&(p)->el_lock)
     56#define EHL_UNLOCK(p)       mtx_unlock(&(p)->el_lock)
     57#define EHL_LOCK_ASSERT(p, x)   mtx_assert(&(p)->el_lock, x)
     58
     59/*
     60 * Macro to invoke the handlers for a given event.
     61 */
     62#define _EVENTHANDLER_INVOKE(name, list, ...) do {          \
     63    struct eventhandler_entry *_ep;                 \
     64    struct eventhandler_entry_ ## name *_t;             \
     65                                    \
     66    KASSERT((list)->el_flags & EHL_INITTED,             \
     67       ("eventhandler_invoke: running non-inited list"));       \
     68    EHL_LOCK_ASSERT((list), MA_OWNED);              \
     69    (list)->el_runcount++;                      \
     70    KASSERT((list)->el_runcount > 0,                \
     71        ("eventhandler_invoke: runcount overflow"));        \
     72    CTR0(KTR_EVH, "eventhandler_invoke(\"" __STRING(name) "\")");   \
     73    TAILQ_FOREACH(_ep, &((list)->el_entries), ee_link) {        \
     74        if (_ep->ee_priority != EHE_DEAD_PRIORITY) {        \
     75            EHL_UNLOCK((list));             \
     76            _t = (struct eventhandler_entry_ ## name *)_ep; \
     77            CTR1(KTR_EVH, "eventhandler_invoke: executing %p", \
     78                (void *)_t->eh_func);           \
     79            _t->eh_func(_ep->ee_arg , ## __VA_ARGS__);  \
     80            EHL_LOCK((list));               \
     81        }                           \
     82    }                               \
     83    KASSERT((list)->el_runcount > 0,                \
     84        ("eventhandler_invoke: runcount underflow"));       \
     85    (list)->el_runcount--;                      \
     86    if ((list)->el_runcount == 0)                   \
     87        eventhandler_prune_list(list);              \
     88    EHL_UNLOCK((list));                     \
     89} while (0)
     90
     91/*
     92 * Slow handlers are entirely dynamic; lists are created
     93 * when entries are added to them, and thus have no concept of "owner",
     94 *
     95 * Slow handlers need to be declared, but do not need to be defined. The
     96 * declaration must be in scope wherever the handler is to be invoked.
     97 */
     98#define EVENTHANDLER_DECLARE(name, type)                \
     99struct eventhandler_entry_ ## name                  \
     100{                                   \
     101    struct eventhandler_entry   ee;             \
     102    type                eh_func;            \
     103};                                  \
     104struct __hack
     105
     106#define EVENTHANDLER_INVOKE(name, ...)                  \
     107do {                                    \
     108    struct eventhandler_list *_el;                  \
     109                                    \
     110    if ((_el = eventhandler_find_list(#name)) != NULL)      \
     111        _EVENTHANDLER_INVOKE(name, _el , ## __VA_ARGS__);   \
     112} while (0)
     113
     114#define EVENTHANDLER_REGISTER(name, func, arg, priority)        \
     115    eventhandler_register(NULL, #name, func, arg, priority)
     116
     117#define EVENTHANDLER_DEREGISTER(name, tag)              \
     118do {                                    \
     119    struct eventhandler_list *_el;                  \
     120                                    \
     121    if ((_el = eventhandler_find_list(#name)) != NULL)      \
     122        eventhandler_deregister(_el, tag);          \
     123} while(0)
     124   
     125
     126eventhandler_tag eventhandler_register(struct eventhandler_list *list,
     127        const char *name, void *func, void *arg, int priority);
     128void    eventhandler_deregister(struct eventhandler_list *list,
     129        eventhandler_tag tag);
     130struct eventhandler_list *eventhandler_find_list(const char *name);
     131void    eventhandler_prune_list(struct eventhandler_list *list);
     132
     133/*
     134 * Standard system event queues.
     135 */
     136
     137/* Generic priority levels */
     138#define EVENTHANDLER_PRI_FIRST  0
     139#define EVENTHANDLER_PRI_ANY    10000
     140#define EVENTHANDLER_PRI_LAST   20000
     141
     142/* Shutdown events */
     143typedef void (*shutdown_fn)(void *, int);
     144
     145#define SHUTDOWN_PRI_FIRST  EVENTHANDLER_PRI_FIRST
     146#define SHUTDOWN_PRI_DEFAULT    EVENTHANDLER_PRI_ANY
     147#define SHUTDOWN_PRI_LAST   EVENTHANDLER_PRI_LAST
     148
     149EVENTHANDLER_DECLARE(shutdown_pre_sync, shutdown_fn);   /* before fs sync */
     150EVENTHANDLER_DECLARE(shutdown_post_sync, shutdown_fn);  /* after fs sync */
     151EVENTHANDLER_DECLARE(shutdown_final, shutdown_fn);
     152
     153/* Low memory event */
     154typedef void (*vm_lowmem_handler_t)(void *, int);
     155#define LOWMEM_PRI_DEFAULT  EVENTHANDLER_PRI_FIRST
     156EVENTHANDLER_DECLARE(vm_lowmem, vm_lowmem_handler_t);
     157
     158/*
     159 * Process events
     160 * process_fork and exit handlers are called without Giant.
     161 * exec handlers are called with Giant, but that is by accident.
     162 */
     163struct proc;
     164
     165typedef void (*exitlist_fn)(void *, struct proc *);
     166typedef void (*forklist_fn)(void *, struct proc *, struct proc *, int);
     167typedef void (*execlist_fn)(void *, struct proc *);
     168
     169EVENTHANDLER_DECLARE(process_exit, exitlist_fn);
     170EVENTHANDLER_DECLARE(process_fork, forklist_fn);
     171EVENTHANDLER_DECLARE(process_exec, execlist_fn);
     172
     173typedef void (*uma_zone_chfn)(void *);
     174EVENTHANDLER_DECLARE(nmbclusters_change, uma_zone_chfn);
     175EVENTHANDLER_DECLARE(maxsockets_change, uma_zone_chfn);
     176#endif /* SYS_EVENTHANDLER_H */
  • new file headers/compatibility/bsd/sys/firmware.h

    diff --git a/headers/compatibility/bsd/sys/firmware.h b/headers/compatibility/bsd/sys/firmware.h
    new file mode 100644
    index 0000000..bfc52b2
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_FIRMWARE_H_
     6#define _FBSD_COMPAT_SYS_FIRMWARE_H_
     7
     8
     9#define FIRMWARE_UNLOAD 0x0001
     10
     11
     12struct firmware {
     13    const char*     name;       // system-wide name
     14    const void*     data;       // location of image
     15    size_t          datasize;   // size of image in bytes
     16    unsigned int    version;    // version of the image
     17};
     18
     19
     20const struct firmware* firmware_get(const char*);
     21void firmware_put(const struct firmware*, int);
     22
     23#endif /* _FBSD_COMPAT_SYS_FIRMWARE_H_ */
  • new file headers/compatibility/bsd/sys/haiku-module.h

    diff --git a/headers/compatibility/bsd/sys/haiku-module.h b/headers/compatibility/bsd/sys/haiku-module.h
    new file mode 100644
    index 0000000..26e07bb
    - +  
     1/*
     2 * Copyright 2009, Colin Günther. All Rights Reserved.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_SYS_HAIKU_MODULE_H_
     7#define _FBSD_COMPAT_SYS_HAIKU_MODULE_H_
     8
     9
     10#include <Drivers.h>
     11#include <KernelExport.h>
     12
     13#include <kernel/lock.h>
     14#include <net_stack.h>
     15
     16
     17#undef ASSERT
     18    /* private/kernel/debug.h sets it */
     19
     20typedef struct device *device_t;
     21typedef struct devclass *devclass_t;
     22
     23typedef int (*device_method_signature_t)(device_t dev);
     24
     25typedef int device_probe_t(device_t dev);
     26typedef int device_attach_t(device_t dev);
     27typedef int device_detach_t(device_t dev);
     28typedef int device_resume_t(device_t dev);
     29typedef int device_suspend_t(device_t dev);
     30
     31struct device_method {
     32    const char *name;
     33    device_method_signature_t method;
     34};
     35
     36typedef struct device_method device_method_t;
     37
     38#define DEVMETHOD(name, func)   { #name, (device_method_signature_t)&func }
     39#define DEVMETHOD_END   { 0, 0 }
     40
     41typedef struct {
     42    const char *name;
     43    device_method_t *methods;
     44    size_t softc_size;
     45} driver_t;
     46
     47#define DRIVER_MODULE_NAME(name, busname) \
     48    __fbsd_ ## name ## _ ## busname
     49
     50status_t _fbsd_init_hardware(driver_t *driver[]);
     51status_t _fbsd_init_drivers(driver_t *driver[]);
     52status_t _fbsd_uninit_drivers(driver_t *driver[]);
     53
     54extern const char *gDriverName;
     55driver_t *__haiku_select_miibus_driver(device_t dev);
     56driver_t *__haiku_probe_miibus(device_t dev, driver_t *drivers[]);
     57status_t __haiku_handle_fbsd_drivers_list(status_t (*handler)(driver_t *[]));
     58
     59status_t init_wlan_stack(void);
     60void uninit_wlan_stack(void);
     61status_t start_wlan(device_t);
     62status_t stop_wlan(device_t);
     63status_t wlan_control(void*, uint32, void*, size_t);
     64status_t wlan_close(void*);
     65status_t wlan_if_l2com_alloc(void*);
     66
     67/* we define the driver methods with HAIKU_FBSD_DRIVERS_GLUE to
     68 * force the rest of the stuff to be linked back with the driver.
     69 * While gcc 2.95 packs everything from the static library onto
     70 * the final binary, gcc 4.x rightfuly doesn't. */
     71
     72#define HAIKU_FBSD_DRIVERS_GLUE(publicname)                             \
     73    extern const char *gDeviceNameList[];                               \
     74    extern device_hooks gDeviceHooks;                                   \
     75    const char *gDriverName = #publicname;                              \
     76    int32 api_version = B_CUR_DRIVER_API_VERSION;                       \
     77    status_t init_hardware()                                            \
     78    {                                                                   \
     79        return __haiku_handle_fbsd_drivers_list(_fbsd_init_hardware);   \
     80    }                                                                   \
     81    status_t init_driver()                                              \
     82    {                                                                   \
     83        return __haiku_handle_fbsd_drivers_list(_fbsd_init_drivers);    \
     84    }                                                                   \
     85    void uninit_driver()                                                \
     86    {                                                                   \
     87        __haiku_handle_fbsd_drivers_list(_fbsd_uninit_drivers);         \
     88    }                                                                   \
     89    const char **publish_devices()                                      \
     90        { return gDeviceNameList; }                                     \
     91    device_hooks *find_device(const char *name)                         \
     92        { return &gDeviceHooks; }                                       \
     93    status_t init_wlan_stack(void)                                      \
     94        { return B_OK; }                                                \
     95    void uninit_wlan_stack(void) {}                                     \
     96    status_t start_wlan(device_t dev)                                   \
     97        { return B_OK; }                                                \
     98    status_t stop_wlan(device_t dev)                                    \
     99        { return B_OK; }                                                \
     100    status_t wlan_control(void *cookie, uint32 op, void *arg,           \
     101        size_t length)                                                  \
     102        { return B_BAD_VALUE; }                                         \
     103    status_t wlan_close(void* cookie)                                   \
     104        { return B_OK; }                                                \
     105    status_t wlan_if_l2com_alloc(void* ifp)                             \
     106        { return B_OK; }
     107
     108#define HAIKU_FBSD_DRIVER_GLUE(publicname, name, busname)               \
     109    extern driver_t *DRIVER_MODULE_NAME(name, busname);                 \
     110    status_t __haiku_handle_fbsd_drivers_list(status_t (*proc)(driver_t *[])) {\
     111        driver_t *drivers[] = {                                         \
     112            DRIVER_MODULE_NAME(name, busname),                          \
     113            NULL                                                        \
     114        };                                                              \
     115        return (*proc)(drivers);                                        \
     116    }                                                                   \
     117    HAIKU_FBSD_DRIVERS_GLUE(publicname);
     118
     119#define HAIKU_FBSD_WLAN_DRIVERS_GLUE(publicname)                        \
     120    extern const char *gDeviceNameList[];                               \
     121    extern device_hooks gDeviceHooks;                                   \
     122    const char *gDriverName = #publicname;                              \
     123    int32 api_version = B_CUR_DRIVER_API_VERSION;                       \
     124    status_t init_hardware()                                            \
     125    {                                                                   \
     126        return __haiku_handle_fbsd_drivers_list(_fbsd_init_hardware);   \
     127    }                                                                   \
     128    status_t init_driver()                                              \
     129    {                                                                   \
     130        return __haiku_handle_fbsd_drivers_list(_fbsd_init_drivers);    \
     131    }                                                                   \
     132    void uninit_driver()                                                \
     133    {                                                                   \
     134        __haiku_handle_fbsd_drivers_list(_fbsd_uninit_drivers);         \
     135    }                                                                   \
     136    const char **publish_devices()                                      \
     137        { return gDeviceNameList; }                                     \
     138    device_hooks *find_device(const char *name)                         \
     139        { return &gDeviceHooks; }
     140
     141#define HAIKU_FBSD_WLAN_DRIVER_GLUE(publicname, name, busname)          \
     142    extern driver_t *DRIVER_MODULE_NAME(name, busname);                 \
     143    status_t __haiku_handle_fbsd_drivers_list(status_t (*proc)(driver_t *[])) {\
     144        driver_t *drivers[] = {                                         \
     145            DRIVER_MODULE_NAME(name, busname),                          \
     146            NULL                                                        \
     147        };                                                              \
     148        return (*proc)(drivers);                                        \
     149    }                                                                   \
     150    HAIKU_FBSD_WLAN_DRIVERS_GLUE(publicname);
     151
     152#define HAIKU_FBSD_RETURN_MII_DRIVER(drivers)                   \
     153    driver_t *__haiku_select_miibus_driver(device_t dev)        \
     154    {                                                           \
     155        return __haiku_probe_miibus(dev, drivers);              \
     156    }
     157
     158#define HAIKU_FBSD_MII_DRIVER(name)                             \
     159    extern driver_t *DRIVER_MODULE_NAME(name, miibus);          \
     160    driver_t *__haiku_select_miibus_driver(device_t dev)        \
     161    {                                                           \
     162        driver_t *drivers[] = {                                 \
     163            DRIVER_MODULE_NAME(name, miibus),                   \
     164            NULL                                                \
     165        };                                                      \
     166        return __haiku_probe_miibus(dev, drivers);              \
     167    }
     168
     169#define NO_HAIKU_FBSD_MII_DRIVER()                              \
     170    HAIKU_FBSD_RETURN_MII_DRIVER(NULL)
     171
     172extern spinlock __haiku_intr_spinlock;
     173extern int __haiku_disable_interrupts(device_t dev);
     174extern void __haiku_reenable_interrupts(device_t dev);
     175
     176#define HAIKU_CHECK_DISABLE_INTERRUPTS      __haiku_disable_interrupts
     177#define HAIKU_REENABLE_INTERRUPTS           __haiku_reenable_interrupts
     178
     179#define NO_HAIKU_CHECK_DISABLE_INTERRUPTS()             \
     180    int HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev) {  \
     181        panic("should never be called.");               \
     182        return -1; \
     183    }
     184
     185#define NO_HAIKU_REENABLE_INTERRUPTS() \
     186    void HAIKU_REENABLE_INTERRUPTS(device_t dev) {}
     187
     188extern int __haiku_driver_requirements;
     189
     190enum {
     191    FBSD_TASKQUEUES     = 1 << 0,
     192    FBSD_FAST_TASKQUEUE = 1 << 1,
     193    FBSD_SWI_TASKQUEUE  = 1 << 2,
     194    FBSD_WLAN           = 1 << 3,
     195};
     196
     197#define HAIKU_DRIVER_REQUIREMENTS(flags) \
     198    int __haiku_driver_requirements = (flags)
     199
     200#define HAIKU_DRIVER_REQUIRES(flag) (__haiku_driver_requirements & (flag))
     201
     202
     203/* #pragma mark - firmware loading */
     204
     205
     206/*
     207 * Only needed to be specified in the glue code of drivers which actually need
     208 * to load firmware. See iprowifi2100 for an example.
     209 */
     210
     211extern const uint __haiku_firmware_version;
     212
     213/* Use 0 if driver doesn't care about firmware version. */
     214#define HAIKU_FIRMWARE_VERSION(version) \
     215    const uint __haiku_firmware_version = (version)
     216
     217extern const uint __haiku_firmware_parts_count;
     218extern const char* __haiku_firmware_name_map[][2];
     219
     220#define HAIKU_FIRMWARE_NAME_MAP(firmwarePartsCount) \
     221    const uint __haiku_firmware_parts_count = firmwarePartsCount; \
     222    const char* __haiku_firmware_name_map[firmwarePartsCount][2]
     223
     224#define NO_HAIKU_FIRMWARE_NAME_MAP() \
     225    const uint __haiku_firmware_parts_count = 0; \
     226    const char* __haiku_firmware_name_map[0][2] = {}
     227
     228
     229/* #pragma mark - synchronization */
     230
     231
     232#define HAIKU_INTR_REGISTER_STATE \
     233    cpu_status __haiku_cpu_state = 0
     234
     235#define HAIKU_INTR_REGISTER_ENTER() do {        \
     236    __haiku_cpu_state = disable_interrupts();   \
     237    acquire_spinlock(&__haiku_intr_spinlock);   \
     238} while (0)
     239
     240#define HAIKU_INTR_REGISTER_LEAVE() do {        \
     241    release_spinlock(&__haiku_intr_spinlock);   \
     242    restore_interrupts(__haiku_cpu_state);      \
     243} while (0)
     244
     245#define HAIKU_PROTECT_INTR_REGISTER(x) do {     \
     246    HAIKU_INTR_REGISTER_STATE;                  \
     247    HAIKU_INTR_REGISTER_ENTER();                \
     248    x;                                          \
     249    HAIKU_INTR_REGISTER_LEAVE();                \
     250} while (0)
     251
     252#define DEFINE_CLASS_0(name, driver, methods, size) \
     253    driver_t driver = { #name, methods, size }
     254
     255#define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \
     256    driver_t *DRIVER_MODULE_NAME(name, busname) = &(driver); \
     257    devclass_t *__class_ ## name ## _ ## busname ## _ ## devclass = &(devclass)
     258
     259#define DRIVER_MODULE_ORDERED(name, busname, driver, devclass, evh, arg, order) \
     260    DRIVER_MODULE(name, busname, driver, devclass, evh, arg)
     261
     262#define nitems(_a)     (sizeof((_a)) / sizeof((_a)[0]))
     263
     264#endif  /* _FBSD_COMPAT_SYS_HAIKU_MODULE_H_ */
  • headers/compatibility/bsd/sys/ioccom.h

    diff --git a/headers/compatibility/bsd/sys/ioccom.h b/headers/compatibility/bsd/sys/ioccom.h
    index ea9583c..9a790ad 100644
    a b  
    8686
    8787
    8888#endif /* _SYS_IOCCOM_H */
     89
  • new file headers/compatibility/bsd/sys/kernel.h

    diff --git a/headers/compatibility/bsd/sys/kernel.h b/headers/compatibility/bsd/sys/kernel.h
    new file mode 100644
    index 0000000..0124a68
    - +  
     1/*
     2 * Copyright 2007-2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_KERNEL_H_
     6#define _FBSD_COMPAT_SYS_KERNEL_H_
     7
     8
     9#include <stddef.h>
     10
     11#include <sys/haiku-module.h>
     12
     13#include <sys/linker_set.h>
     14#include <sys/queue.h>
     15
     16
     17/*
     18 *
     19 * The rate at which FreeBSD can generate callouts (kind of timeout mechanism).
     20 * For FreeBSD 8 this is typically 1000 times per second (100 for ARM).
     21 * This value is defined in a file called subr_param.c
     22 *
     23 * WHile Haiku can have a much higher granularity, it is not a good idea to have
     24 * this since FreeBSD tries to do certain tasks based on ticks, for instance
     25 * autonegotiation and wlan scanning.
     26 * Suffixing LL prevents integer overflows during calculations.
     27 * as it defines a long long constant.*/
     28#define hz  1000LL
     29
     30#define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz)
     31
     32typedef void (*system_init_func_t)(void *);
     33
     34
     35struct __system_init {
     36    system_init_func_t func;
     37};
     38
     39/* TODO implement SYSINIT/SYSUNINIT subsystem */
     40#define SYSINIT(uniquifier, subsystem, order, func, ident) \
     41    struct __system_init __init_##uniquifier = { (system_init_func_t) func }
     42
     43#define SYSUNINIT(uniquifier, subsystem, order, func, ident) \
     44    struct __system_init __uninit_##uniquifier = { (system_init_func_t) func }
     45
     46#define TUNABLE_INT(path, var)
     47#define TUNABLE_INT_FETCH(path, var)
     48
     49extern int ticks;
     50
     51#endif
  • new file headers/compatibility/bsd/sys/ktr.h

    diff --git a/headers/compatibility/bsd/sys/kthread.h b/headers/compatibility/bsd/sys/kthread.h
    new file mode 100644
    index 0000000..e69de29
    diff --git a/headers/compatibility/bsd/sys/ktr.h b/headers/compatibility/bsd/sys/ktr.h
    new file mode 100644
    index 0000000..2e817a7
    - +  
     1/*-
     2 * Copyright (c) 1996 Berkeley Software Design, Inc. All rights reserved.
     3 *
     4 * Redistribution and use in source and binary forms, with or without
     5 * modification, are permitted provided that the following conditions
     6 * are met:
     7 * 1. Redistributions of source code must retain the above copyright
     8 *    notice, this list of conditions and the following disclaimer.
     9 * 2. Redistributions in binary form must reproduce the above copyright
     10 *    notice, this list of conditions and the following disclaimer in the
     11 *    documentation and/or other materials provided with the distribution.
     12 * 3. Berkeley Software Design Inc's name may not be used to endorse or
     13 *    promote products derived from this software without specific prior
     14 *    written permission.
     15 *
     16 * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
     17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19 * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
     20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26 * SUCH DAMAGE.
     27 *
     28 *  from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $
     29 * $FreeBSD: src/sys/sys/ktr.h,v 1.32.2.2 2006/01/23 14:56:33 marius Exp $
     30 */
     31
     32/*
     33 *  Wraparound kernel trace buffer support.
     34 */
     35#ifndef _SYS_KTR_H_
     36#define _SYS_KTR_H_
     37
     38/*
     39 * Trace classes
     40 */
     41#define KTR_GEN     0x00000001      /* General (TR) */
     42#define KTR_NET     0x00000002      /* Network */
     43#define KTR_DEV     0x00000004      /* Device driver */
     44#define KTR_LOCK    0x00000008      /* MP locking */
     45#define KTR_SMP     0x00000010      /* MP general */
     46#define KTR_FS      0x00000020      /* Filesystem */
     47#define KTR_PMAP    0x00000040      /* Pmap tracing */
     48#define KTR_MALLOC  0x00000080      /* Malloc tracing */
     49#define KTR_TRAP    0x00000100      /* Trap processing */
     50#define KTR_INTR    0x00000200      /* Interrupt tracing */
     51#define KTR_SIG     0x00000400      /* Signal processing */
     52#define KTR_CLK     0x00000800      /* hardclock verbose */
     53#define KTR_PROC    0x00001000      /* Process scheduling */
     54#define KTR_SYSC    0x00002000      /* System call */
     55#define KTR_INIT    0x00004000      /* System initialization */
     56#define KTR_KGDB    0x00008000      /* Trace kgdb internals */
     57#define KTR_IO      0x00010000      /* Upper I/O  */
     58#define KTR_EVH     0x00020000      /* Eventhandler */
     59#define KTR_VFS     0x00040000      /* VFS events */
     60#define KTR_VOP     0x00080000      /* Auto-generated vop events */
     61#define KTR_VM      0x00100000      /* The virtual memory system */
     62#define KTR_WITNESS 0x00200000
     63#define KTR_RUNQ    0x00400000      /* Run queue */
     64#define KTR_CONTENTION  0x00800000      /* Lock contention */
     65#define KTR_UMA     0x01000000      /* UMA slab allocator */
     66#define KTR_CALLOUT 0x02000000      /* Callouts and timeouts */
     67#define KTR_GEOM    0x04000000      /* GEOM I/O events */
     68#define KTR_BUSDMA  0x08000000      /* busdma(9) events */
     69#define KTR_CRITICAL    0x10000000      /* Critical sections */
     70#define KTR_SCHED   0x20000000      /* Machine parsed sched info. */
     71#define KTR_BUF     0x40000000      /* Buffer cache */
     72#define KTR_ALL     0x7fffffff
     73
     74/*
     75 * Trace classes which can be assigned to particular use at compile time
     76 * These must remain in high 22 as some assembly code counts on it
     77 */
     78#define KTR_CT1     0x01000000
     79#define KTR_CT2     0x02000000
     80#define KTR_CT3     0x04000000
     81#define KTR_CT4     0x08000000
     82#define KTR_CT5     0x10000000
     83#define KTR_CT6     0x20000000
     84#define KTR_CT7     0x40000000
     85#define KTR_CT8     0x80000000
     86
     87/* Trace classes to compile in */
     88#ifdef KTR
     89#ifndef KTR_COMPILE
     90#define KTR_COMPILE (KTR_ALL)
     91#endif
     92#else   /* !KTR */
     93#undef KTR_COMPILE
     94#define KTR_COMPILE 0
     95#endif  /* KTR */
     96
     97/* Trace classes that can not be used with KTR_ALQ */
     98#define KTR_ALQ_MASK    (KTR_WITNESS)
     99
     100/*
     101 * Version number for ktr_entry struct.  Increment this when you break binary
     102 * compatibility.
     103 */
     104#define KTR_VERSION 2
     105
     106#define KTR_PARMS   6
     107
     108#ifndef LOCORE
     109
     110struct ktr_entry {
     111    u_int64_t ktr_timestamp;
     112    int ktr_cpu;
     113    int ktr_line;
     114    const   char *ktr_file;
     115    const   char *ktr_desc;
     116    struct  thread *ktr_thread;
     117    u_long  ktr_parms[KTR_PARMS];
     118};
     119
     120extern int ktr_cpumask;
     121extern int ktr_mask;
     122extern int ktr_entries;
     123extern int ktr_verbose;
     124
     125extern volatile int ktr_idx;
     126extern struct ktr_entry ktr_buf[];
     127
     128#ifdef KTR
     129
     130#if 0
     131void    ktr_tracepoint(u_int mask, const char *file, int line,
     132        const char *format, u_long arg1, u_long arg2, u_long arg3,
     133        u_long arg4, u_long arg5, u_long arg6);
     134#else
     135extern void driver_printf(const char *format, ...);
     136#define ktr_tracepoint(mask, file, line, format, arg1, arg2, arg3, arg4, arg5, arg6) \
     137    driver_printf("(%s:%i) " format "\n", file, line, arg1, arg2, arg3, arg4, arg5, arg6)
     138#endif
     139
     140#define CTR6(m, format, p1, p2, p3, p4, p5, p6) do {            \
     141    if (KTR_COMPILE & (m))                      \
     142        ktr_tracepoint((m), __FILE__, __LINE__, format,     \
     143            (u_long)(p1), (u_long)(p2), (u_long)(p3),       \
     144            (u_long)(p4), (u_long)(p5), (u_long)(p6));      \
     145    } while(0)
     146#define CTR0(m, format)         CTR6(m, format, 0, 0, 0, 0, 0, 0)
     147#define CTR1(m, format, p1)     CTR6(m, format, p1, 0, 0, 0, 0, 0)
     148#define CTR2(m, format, p1, p2)     CTR6(m, format, p1, p2, 0, 0, 0, 0)
     149#define CTR3(m, format, p1, p2, p3) CTR6(m, format, p1, p2, p3, 0, 0, 0)
     150#define CTR4(m, format, p1, p2, p3, p4) CTR6(m, format, p1, p2, p3, p4, 0, 0)
     151#define CTR5(m, format, p1, p2, p3, p4, p5) CTR6(m, format, p1, p2, p3, p4, p5, 0)
     152#else   /* KTR */
     153#define CTR0(m, d)
     154#define CTR1(m, d, p1)
     155#define CTR2(m, d, p1, p2)
     156#define CTR3(m, d, p1, p2, p3)
     157#define CTR4(m, d, p1, p2, p3, p4)
     158#define CTR5(m, d, p1, p2, p3, p4, p5)
     159#define CTR6(m, d, p1, p2, p3, p4, p5, p6)
     160#endif  /* KTR */
     161
     162#define TR0(d)              CTR0(KTR_GEN, d)
     163#define TR1(d, p1)          CTR1(KTR_GEN, d, p1)
     164#define TR2(d, p1, p2)          CTR2(KTR_GEN, d, p1, p2)
     165#define TR3(d, p1, p2, p3)      CTR3(KTR_GEN, d, p1, p2, p3)
     166#define TR4(d, p1, p2, p3, p4)      CTR4(KTR_GEN, d, p1, p2, p3, p4)
     167#define TR5(d, p1, p2, p3, p4, p5)  CTR5(KTR_GEN, d, p1, p2, p3, p4, p5)
     168#define TR6(d, p1, p2, p3, p4, p5, p6)  CTR6(KTR_GEN, d, p1, p2, p3, p4, p5, p6)
     169
     170/*
     171 * Trace initialization events, similar to CTR with KTR_INIT, but
     172 * completely ifdef'ed out if KTR_INIT isn't in KTR_COMPILE (to
     173 * save string space, the compiler doesn't optimize out strings
     174 * for the conditional ones above).
     175 */
     176#if (KTR_COMPILE & KTR_INIT) != 0
     177#define ITR0(d)             CTR0(KTR_INIT, d)
     178#define ITR1(d, p1)         CTR1(KTR_INIT, d, p1)
     179#define ITR2(d, p1, p2)         CTR2(KTR_INIT, d, p1, p2)
     180#define ITR3(d, p1, p2, p3)     CTR3(KTR_INIT, d, p1, p2, p3)
     181#define ITR4(d, p1, p2, p3, p4)     CTR4(KTR_INIT, d, p1, p2, p3, p4)
     182#define ITR5(d, p1, p2, p3, p4, p5) CTR5(KTR_INIT, d, p1, p2, p3, p4, p5)
     183#define ITR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_INIT, d, p1, p2, p3, p4, p5, p6)
     184#else
     185#define ITR0(d)
     186#define ITR1(d, p1)
     187#define ITR2(d, p1, p2)
     188#define ITR3(d, p1, p2, p3)
     189#define ITR4(d, p1, p2, p3, p4)
     190#define ITR5(d, p1, p2, p3, p4, p5)
     191#define ITR6(d, p1, p2, p3, p4, p5, p6)
     192#endif
     193
     194#endif /* !LOCORE */
     195
     196#endif /* !_SYS_KTR_H_ */
  • new file headers/compatibility/bsd/sys/libkern.h

    diff --git a/headers/compatibility/bsd/sys/libkern.h b/headers/compatibility/bsd/sys/libkern.h
    new file mode 100644
    index 0000000..98b870a
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * All rights reserved. Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_LIBKERN_H_
     6#define _FBSD_COMPAT_SYS_LIBKERN_H_
     7
     8
     9#include <sys/cdefs.h>
     10#include <sys/types.h>
     11
     12
     13extern int random(void);
     14uint32_t arc4random(void);
     15
     16static __inline int imax(int a, int b) { return (a > b ? a : b); }
     17
     18extern int abs(int a);
     19
     20#endif /* _FBSD_COMPAT_SYS_LIBKERN_H_ */
  • new file headers/compatibility/bsd/sys/limits.h

    diff --git a/headers/compatibility/bsd/sys/limits.h b/headers/compatibility/bsd/sys/limits.h
    new file mode 100644
    index 0000000..492074d
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_LIMITS_H_
     6#define _FBSD_COMPAT_SYS_LIMITS_H_
     7
     8
     9#endif /* _FBSD_COMPAT_SYS_LIMITS_H_ */
  • new file headers/compatibility/bsd/sys/linker.h

    diff --git a/headers/compatibility/bsd/sys/linker.h b/headers/compatibility/bsd/sys/linker.h
    new file mode 100644
    index 0000000..52cd150
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_LINKER_H_
     6#define _FBSD_COMPAT_SYS_LINKER_H_
     7
     8
     9#endif /* _FBSD_COMPAT_SYS_LINKER_H_ */
  • new file headers/compatibility/bsd/sys/linker_set.h

    diff --git a/headers/compatibility/bsd/sys/linker_set.h b/headers/compatibility/bsd/sys/linker_set.h
    new file mode 100644
    index 0000000..41c964d
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_LINKER_SET_H_
     6#define _FBSD_COMPAT_SYS_LINKER_SET_H_
     7
     8
     9#ifndef _FBSD_COMPAT_SYS_CDEFS_H_
     10#error this file needs sys/cdefs.h as a prerequisite
     11#endif
     12
     13/*
     14 * The following macros are used to declare global sets of objects, which
     15 * are collected by the linker into a `linker_set' as defined below.
     16 * For ELF, this is done by constructing a separate segment for each set.
     17 */
     18
     19/*
     20 * Private macros, not to be used outside this header file.
     21 */
     22#ifdef __GNUCLIKE___SECTION
     23#define __MAKE_SET(set, sym)                        \
     24    static void const * const __set_##set##_sym_##sym       \
     25    __section("set_" #set) __used = &sym
     26#else /* !__GNUCLIKE___SECTION */
     27#ifndef lint
     28#error this file needs to be ported to your compiler
     29#endif /* lint */
     30#define __MAKE_SET(set, sym)    extern void const * const (__set_##set##_sym_##sym)
     31#endif /* __GNUCLIKE___SECTION */
     32
     33/*
     34 * Public macros.
     35 */
     36#define TEXT_SET(set, sym)  __MAKE_SET(set, sym)
     37#define DATA_SET(set, sym)  __MAKE_SET(set, sym)
     38#define BSS_SET(set, sym)   __MAKE_SET(set, sym)
     39#define ABS_SET(set, sym)   __MAKE_SET(set, sym)
     40#define SET_ENTRY(set, sym) __MAKE_SET(set, sym)
     41
     42/*
     43 * Initialize before referring to a given linker set.
     44 */
     45#define SET_DECLARE(set, ptype)                     \
     46    extern ptype *__CONCAT(__start_set_,set);           \
     47    extern ptype *__CONCAT(__stop_set_,set)
     48
     49#define SET_BEGIN(set)                          \
     50    (&__CONCAT(__start_set_,set))
     51#define SET_LIMIT(set)                          \
     52    (&__CONCAT(__stop_set_,set))
     53
     54/*
     55 * Iterate over all the elements of a set.
     56 *
     57 * Sets always contain addresses of things, and "pvar" points to words
     58 * containing those addresses.  Thus is must be declared as "type **pvar",
     59 * and the address of each set item is obtained inside the loop by "*pvar".
     60 */
     61#define SET_FOREACH(pvar, set)                      \
     62    for (pvar = SET_BEGIN(set); pvar < SET_LIMIT(set); pvar++)
     63
     64#endif /* _FBSD_COMPAT_SYS_LINKER_SET_H_ */
  • new file headers/compatibility/bsd/sys/malloc.h

    diff --git a/headers/compatibility/bsd/sys/lock.h b/headers/compatibility/bsd/sys/lock.h
    new file mode 100644
    index 0000000..e69de29
    diff --git a/headers/compatibility/bsd/sys/malloc.h b/headers/compatibility/bsd/sys/malloc.h
    new file mode 100644
    index 0000000..7dc4018
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_SYS_MALLOC_H_
     7#define _FBSD_COMPAT_SYS_MALLOC_H_
     8
     9
     10#include <malloc.h>
     11
     12#include <vm/vm.h>
     13
     14#include <sys/param.h>
     15#include <sys/queue.h>
     16#include <sys/_mutex.h>
     17
     18
     19/*
     20 * flags to malloc.
     21 */
     22#define M_NOWAIT        0x0001
     23#define M_WAITOK        0x0002
     24#define M_ZERO          0x0100
     25
     26#define M_MAGIC         877983977   /* time when first defined :-) */
     27
     28#define M_DEVBUF
     29
     30
     31void *_kernel_malloc(size_t size, int flags);
     32void _kernel_free(void *ptr);
     33
     34void *_kernel_contigmalloc(const char *file, int line, size_t size, int flags,
     35    vm_paddr_t low, vm_paddr_t high, unsigned long alignment,
     36    unsigned long boundary);
     37void _kernel_contigfree(void *addr, unsigned long size);
     38
     39#define kernel_malloc(size, base, flags) \
     40    _kernel_malloc(size, flags)
     41
     42#define kernel_free(ptr, base) \
     43    _kernel_free(ptr)
     44
     45#define kernel_contigmalloc(size, type, flags, low, high, alignment, boundary) \
     46    _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \
     47        alignment, boundary)
     48
     49#define kernel_contigfree(addr, size, base) \
     50    _kernel_contigfree(addr, size)
     51
     52#ifdef FBSD_DRIVER
     53#   define malloc(size, tag, flags) kernel_malloc(size, tag, flags)
     54#   define free(pointer, tag)       kernel_free(pointer, tag)
     55#   define contigmalloc(size, type, flags, low, high, alignment, boundary) \
     56        _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \
     57            alignment, boundary)
     58#   define contigfree(addr, size, base) \
     59        _kernel_contigfree(addr, size)
     60#endif
     61
     62#define MALLOC_DEFINE(type, shortdesc, longdesc)    int type[1]
     63
     64#define MALLOC_DECLARE(type) \
     65        extern int type[1]
     66
     67#endif  /* _FBSD_COMPAT_SYS_MALLOC_H_ */
  • new file headers/compatibility/bsd/sys/mbuf-fbsd.h

    diff --git a/headers/compatibility/bsd/sys/mbuf-fbsd.h b/headers/compatibility/bsd/sys/mbuf-fbsd.h
    new file mode 100644
    index 0000000..2983efd
    - +  
     1/*-
     2 * Copyright (c) 1982, 1986, 1988, 1993
     3 *  The Regents of the University of California.  All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 * 3. Neither the name of the University nor the names of its contributors
     14 *    may be used to endorse or promote products derived from this software
     15 *    without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27 * SUCH DAMAGE.
     28 *
     29 *  @(#)mbuf.h  8.5 (Berkeley) 2/19/95
     30 * $FreeBSD: src/sys/sys/mbuf.h,v 1.170.2.6 2006/03/23 23:24:32 sam Exp $
     31 */
     32#ifndef _FBSD_COMPAT_SYS_MBUF_FBSD_H_
     33#define _FBSD_COMPAT_SYS_MBUF_FBSD_H_
     34
     35/*
     36 * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place
     37 * an object of the specified size at the end of the mbuf, longword aligned.
     38 */
     39#define M_ALIGN(m, len) do {                        \
     40    (m)->m_data += (MLEN - (len)) & ~(sizeof(long) - 1);        \
     41} while (0)
     42
     43/*
     44 * As above, for mbufs allocated with m_gethdr/MGETHDR
     45 * or initialized by M_COPY_PKTHDR.
     46 */
     47#define MH_ALIGN(m, len) do {                       \
     48    (m)->m_data += (MHLEN - (len)) & ~(sizeof(long) - 1);       \
     49} while (0)
     50
     51/*
     52#define MEXT_IS_REF(m)  (((m)->m_ext.ref_cnt != NULL)           \
     53    && (*((m)->m_ext.ref_cnt) > 1))
     54 */
     55#define MEXT_IS_REF(m)  0
     56
     57/*
     58 * Evaluate TRUE if it's safe to write to the mbuf m's data region (this
     59 * can be both the local data payload, or an external buffer area,
     60 * depending on whether M_EXT is set).
     61 */
     62
     63/*
     64#define M_WRITABLE(m)   (!((m)->m_flags & M_RDONLY) && (!((m)->m_flags  \
     65                & M_EXT) || !MEXT_IS_REF(m)))
     66 */
     67#define M_WRITABLE(m)   (!((m)->m_flags & M_EXT) || !MEXT_IS_REF(m))
     68
     69/*
     70 * Compute the amount of space available
     71 * before the current start of data in an mbuf.
     72 *
     73 * The M_WRITABLE() is a temporary, conservative safety measure: the burden
     74 * of checking writability of the mbuf data area rests solely with the caller.
     75 */
     76#define M_LEADINGSPACE(m)                       \
     77    ((m)->m_flags & M_EXT ?                     \
     78        (M_WRITABLE(m) ? (m)->m_data - (m)->m_ext.ext_buf : 0): \
     79        (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \
     80        (m)->m_data - (m)->m_dat)
     81
     82/*
     83 * Compute the amount of space available after the end of data in an mbuf.
     84 *
     85 * The M_WRITABLE() is a temporary, conservative safety measure: the burden
     86 * of checking writability of the mbuf data area rests solely with the caller.
     87 */
     88#define M_TRAILINGSPACE(m)                      \
     89    ((m)->m_flags & M_EXT ?                     \
     90        (M_WRITABLE(m) ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size   \
     91        - ((m)->m_data + (m)->m_len) : 0) :         \
     92        &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
     93
     94/*
     95 * Arrange to prepend space of size plen to mbuf m.
     96 * If a new mbuf must be allocated, how specifies whether to wait.
     97 * If the allocation fails, the original mbuf chain is freed and m is
     98 * set to NULL.
     99 */
     100#define M_PREPEND(m, plen, how) do {                    \
     101    struct mbuf **_mmp = &(m);                  \
     102    struct mbuf *_mm = *_mmp;                   \
     103    int _mplen = (plen);                        \
     104    int __mhow = (how);                     \
     105                                    \
     106    MBUF_CHECKSLEEP(how);                       \
     107    if (M_LEADINGSPACE(_mm) >= _mplen) {                \
     108        _mm->m_data -= _mplen;                  \
     109        _mm->m_len += _mplen;                   \
     110    } else                              \
     111        _mm = m_prepend(_mm, _mplen, __mhow);           \
     112    if (_mm != NULL && _mm->m_flags & M_PKTHDR)         \
     113        _mm->m_pkthdr.len += _mplen;                \
     114    *_mmp = _mm;                            \
     115} while (0)
     116
     117#endif
  • new file headers/compatibility/bsd/sys/mbuf.h

    diff --git a/headers/compatibility/bsd/sys/mbuf.h b/headers/compatibility/bsd/sys/mbuf.h
    new file mode 100644
    index 0000000..2b04340
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_SYS_MBUF_H_
     7#define _FBSD_COMPAT_SYS_MBUF_H_
     8
     9
     10#include <sys/queue.h>
     11#include <sys/systm.h>
     12#include <vm/uma.h>
     13
     14
     15#define MLEN        ((int)(MSIZE - sizeof(struct m_hdr)))
     16#define MHLEN       ((int)(MLEN - sizeof(struct pkthdr)))
     17
     18#define MINCLSIZE   (MHLEN + 1)
     19
     20#define MBTOM(how)  (how)
     21#define M_DONTWAIT  M_NOWAIT
     22#define M_TRYWAIT   M_WAITOK
     23#define M_WAIT      M_WAITOK
     24
     25#define MT_DATA     1
     26
     27#define M_EXT       0x00000001
     28#define M_PKTHDR    0x00000002
     29#define M_RDONLY    0x00000008
     30#define M_PROTO1    0x00000010
     31#define M_PROTO2    0x00000020
     32#define M_PROTO3    0x00000040
     33#define M_PROTO4    0x00000080
     34#define M_PROTO5    0x00000100
     35#define M_BCAST     0x00000200
     36#define M_MCAST     0x00000400
     37#define M_FRAG      0x00000800
     38#define M_FIRSTFRAG 0x00001000
     39#define M_LASTFRAG  0x00002000
     40#define M_VLANTAG   0x00010000
     41#define M_PROTO6    0x00080000
     42#define M_PROTO7    0x00100000
     43#define M_PROTO8    0x00200000
     44
     45#define M_COPYFLAGS (M_PKTHDR | M_RDONLY | M_BCAST | M_MCAST | M_FRAG \
     46    | M_FIRSTFRAG | M_LASTFRAG | M_VLANTAG)
     47    // Flags preserved when copying m_pkthdr
     48
     49#define M_MOVE_PKTHDR(to, from) m_move_pkthdr((to), (from))
     50#define MGET(m, how, type)      ((m) = m_get((how), (type)))
     51#define MGETHDR(m, how, type)   ((m) = m_gethdr((how), (type)))
     52#define MCLGET(m, how)          m_clget((m), (how))
     53
     54#define mtod(m, type)   ((type)((m)->m_data))
     55
     56// Check if the supplied mbuf has a packet header, or else panic.
     57#define M_ASSERTPKTHDR(m) KASSERT(m != NULL && m->m_flags & M_PKTHDR, \
     58    ("%s: no mbuf packet header!", __func__))
     59
     60#define MBUF_CHECKSLEEP(how) do { } while (0)
     61
     62#define MTAG_PERSISTENT 0x800
     63
     64#define EXT_CLUSTER     1       // 2048 bytes
     65#define EXT_JUMBOP      4       // Page size
     66#define EXT_JUMBO9      5       // 9 * 1024 bytes
     67#define EXT_NET_DRV     100     // custom ext_buf provided by net driver
     68
     69#define CSUM_IP         0x0001
     70#define CSUM_TCP        0x0002
     71#define CSUM_UDP        0x0004
     72#define CSUM_TSO        0x0020
     73#define CSUM_IP_CHECKED 0x0100
     74#define CSUM_IP_VALID   0x0200
     75#define CSUM_DATA_VALID 0x0400
     76#define CSUM_PSEUDO_HDR 0x0800
     77#define CSUM_DELAY_DATA (CSUM_TCP | CSUM_UDP)
     78
     79// TODO After all network driver are updated to the FreeBSD 8 version this can
     80// changed
     81#if __FreeBSD_version__ >= 8
     82#define MEXTADD(m, buf, size, free, arg1, arg2, flags, type) \
     83    m_extadd((m), (caddr_t)(buf), (size), (free),(arg1),(arg2),(flags), (type))
     84#else
     85#define MEXTADD(m, buf, size, free, args, flags, type) \
     86    m_extadd((m), (caddr_t)(buf), (size), (free),(args),(flags), (type))
     87#endif
     88
     89
     90extern int max_linkhdr;
     91extern int max_protohdr;
     92extern int max_hdr;
     93extern int max_datalen;     // MHLEN - max_hdr
     94
     95
     96struct m_hdr {
     97    struct mbuf*    mh_next;
     98    struct mbuf*    mh_nextpkt;
     99    caddr_t         mh_data;
     100    int             mh_len;
     101    int             mh_flags;
     102    short           mh_type;
     103};
     104
     105struct pkthdr {
     106    struct ifnet*                   rcvif;
     107    int                             len;
     108    int                             csum_flags;
     109    int                             csum_data;
     110    uint16_t                        tso_segsz;
     111    uint16_t                        ether_vtag;
     112    SLIST_HEAD(packet_tags, m_tag)  tags;
     113};
     114
     115struct m_tag {
     116    SLIST_ENTRY(m_tag)  m_tag_link;     // List of packet tags
     117    u_int16_t           m_tag_id;       // Tag ID
     118    u_int16_t           m_tag_len;      // Length of data
     119    u_int32_t           m_tag_cookie;   // ABI/Module ID
     120    void                (*m_tag_free)(struct m_tag*);
     121};
     122
     123struct m_ext {
     124    caddr_t         ext_buf;
     125    unsigned int    ext_size;
     126    int             ext_type;
     127};
     128
     129struct mbuf {
     130    struct m_hdr m_hdr;
     131    union {
     132        struct {
     133            struct pkthdr   MH_pkthdr;
     134            union {
     135                struct m_ext    MH_ext;
     136                char            MH_databuf[MHLEN];
     137            } MH_dat;
     138        } MH;
     139        char M_databuf[MLEN];
     140    } M_dat;
     141};
     142
     143
     144#define m_next      m_hdr.mh_next
     145#define m_len       m_hdr.mh_len
     146#define m_data      m_hdr.mh_data
     147#define m_type      m_hdr.mh_type
     148#define m_flags     m_hdr.mh_flags
     149#define m_nextpkt   m_hdr.mh_nextpkt
     150#define m_act       m_nextpkt
     151#define m_pkthdr    M_dat.MH.MH_pkthdr
     152#define m_ext       M_dat.MH.MH_dat.MH_ext
     153#define m_pktdat    M_dat.MH.MH_dat.MH_databuf
     154#define m_dat       M_dat.M_databuf
     155
     156
     157void            m_adj(struct mbuf*, int);
     158void            m_align(struct mbuf*, int);
     159int             m_append(struct mbuf*, int, c_caddr_t);
     160void            m_cat(struct mbuf*, struct mbuf*);
     161void            m_clget(struct mbuf*, int);
     162void*           m_cljget(struct mbuf*, int, int);
     163struct mbuf*    m_collapse(struct mbuf*, int, int);
     164void            m_copyback(struct mbuf*, int, int, caddr_t);
     165void            m_copydata(const struct mbuf*, int, int, caddr_t);
     166struct mbuf*    m_copypacket(struct mbuf*, int);
     167struct mbuf*    m_defrag(struct mbuf*, int);
     168struct mbuf*    m_devget(char*, int, int, struct ifnet*,
     169    void(*) (char*, caddr_t, u_int));
     170
     171struct mbuf*    m_dup(struct mbuf*, int);
     172int             m_dup_pkthdr(struct mbuf*, struct mbuf*, int);
     173
     174// TODO After all network driver are updated to the FreeBSD 8 version this can
     175// changed
     176#if __FreeBSD_version__ >= 8
     177void            m_extadd(struct mbuf*, caddr_t, u_int, void(*) (void*, void*),
     178    void*, void*, int, int);
     179#else
     180void            m_extadd(struct mbuf*, caddr_t, u_int, void(*) (void*, void*),
     181    void*, int, int);
     182#endif
     183
     184u_int           m_fixhdr(struct mbuf*);
     185struct mbuf*    m_free(struct mbuf*);
     186void            m_freem(struct mbuf*);
     187struct mbuf*    m_get(int, short);
     188struct mbuf*    m_gethdr(int, short);
     189struct mbuf*    m_getjcl(int, short, int, int);
     190u_int           m_length(struct mbuf*, struct mbuf**);
     191struct mbuf*    m_getcl(int, short, int);
     192void            m_move_pkthdr(struct mbuf*, struct mbuf*);
     193struct mbuf*    m_prepend(struct mbuf*, int, int);
     194struct mbuf*    m_pulldown(struct mbuf*, int, int, int*);
     195struct mbuf*    m_pullup(struct mbuf*, int);
     196struct mbuf*    m_split(struct mbuf*, int, int);
     197struct mbuf*    m_unshare(struct mbuf*, int);
     198
     199struct m_tag*   m_tag_alloc(u_int32_t, int, int, int);
     200void            m_tag_delete(struct mbuf*, struct m_tag*);
     201void            m_tag_delete_chain(struct mbuf*, struct m_tag*);
     202void            m_tag_free_default(struct m_tag*);
     203struct m_tag*   m_tag_locate(struct mbuf*, u_int32_t, int, struct m_tag*);
     204struct m_tag*   m_tag_copy(struct m_tag*, int);
     205int             m_tag_copy_chain(struct mbuf*, struct mbuf*, int);
     206void            m_tag_delete_nonpersistent(struct mbuf*);
     207
     208
     209static inline void
     210m_tag_setup(struct m_tag* tagPointer, u_int32_t cookie, int type, int length)
     211{
     212    tagPointer->m_tag_id = type;
     213    tagPointer->m_tag_len = length;
     214    tagPointer->m_tag_cookie = cookie;
     215}
     216
     217
     218static inline void
     219m_tag_free(struct m_tag* tag)
     220{
     221    (*tag->m_tag_free)(tag);
     222}
     223
     224
     225static inline void
     226m_tag_prepend(struct mbuf* memoryBuffer, struct m_tag* tag)
     227{
     228    SLIST_INSERT_HEAD(&memoryBuffer->m_pkthdr.tags, tag, m_tag_link);
     229}
     230
     231
     232static inline void
     233m_tag_unlink(struct mbuf* memoryBuffer, struct m_tag* tag)
     234{
     235    SLIST_REMOVE(&memoryBuffer->m_pkthdr.tags, tag, m_tag, m_tag_link);
     236}
     237
     238
     239#include <sys/mbuf-fbsd.h>
     240
     241#endif  /* _FBSD_COMPAT_SYS_MBUF_H_ */
  • new file headers/compatibility/bsd/sys/module.h

    diff --git a/headers/compatibility/bsd/sys/module.h b/headers/compatibility/bsd/sys/module.h
    new file mode 100644
    index 0000000..4315069
    - +  
     1#ifndef _FBSD_COMPAT_SYS_MODULE_H_
     2#define _FBSD_COMPAT_SYS_MODULE_H_
     3
     4
     5#include <sys/linker_set.h>
     6
     7
     8typedef struct module* module_t;
     9
     10typedef enum modeventtype {
     11    MOD_LOAD,
     12    MOD_UNLOAD,
     13    MOD_SHUTDOWN,
     14    MOD_QUIESCE
     15} modeventtype_t;
     16
     17
     18#define DECLARE_MODULE(name, data, sub, order)
     19
     20#define MODULE_VERSION(name, version)
     21#define MODULE_DEPEND(module, mdepend, vmin, vpref, vmax)
     22
     23#endif
  • new file headers/compatibility/bsd/sys/mount.h

    diff --git a/headers/compatibility/bsd/sys/mount.h b/headers/compatibility/bsd/sys/mount.h
    new file mode 100644
    index 0000000..4d44727
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_MOUNT_H_
     6#define _FBSD_COMPAT_SYS_MOUNT_H_
     7
     8
     9#endif /* _FBSD_COMPAT_SYS_MOUNT_H_ */
  • new file headers/compatibility/bsd/sys/mutex.h

    diff --git a/headers/compatibility/bsd/sys/mutex.h b/headers/compatibility/bsd/sys/mutex.h
    new file mode 100644
    index 0000000..18b2838
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_SYS_MUTEX_H_
     7#define _FBSD_COMPAT_SYS_MUTEX_H_
     8
     9
     10#include <sys/haiku-module.h>
     11
     12#include <sys/queue.h>
     13#include <sys/_mutex.h>
     14#include <sys/pcpu.h>
     15#include <machine/atomic.h>
     16#include <machine/cpufunc.h>
     17
     18
     19#define MA_OWNED        0x1
     20#define MA_NOTOWNED     0x2
     21#define MA_RECURSED     0x4
     22#define MA_NOTRECURSED  0x8
     23
     24#define mtx_assert(mtx, what)
     25
     26#define MTX_DEF             0x0000
     27#define MTX_RECURSE         0x0004
     28#define MTX_QUIET           0x40000
     29#define MTX_DUPOK           0x400000
     30
     31
     32#define MTX_NETWORK_LOCK    "network driver"
     33
     34#define NET_LOCK_GIANT()
     35#define NET_UNLOCK_GIANT()
     36
     37
     38extern struct mtx Giant;
     39
     40
     41void mtx_init(struct mtx*, const char*, const char*, int);
     42void mtx_destroy(struct mtx*);
     43
     44
     45static inline void
     46mtx_lock(struct mtx* mutex)
     47{
     48    if (mutex->type == MTX_DEF) {
     49        mutex_lock(&mutex->u.mutex.lock);
     50        mutex->u.mutex.owner = find_thread(NULL);
     51    } else if (mutex->type == MTX_RECURSE)
     52        recursive_lock_lock(&mutex->u.recursive);
     53}
     54
     55
     56static inline void
     57mtx_unlock(struct mtx* mutex)
     58{
     59    if (mutex->type == MTX_DEF) {
     60        mutex->u.mutex.owner = -1;
     61        mutex_unlock(&mutex->u.mutex.lock);
     62    } else if (mutex->type == MTX_RECURSE)
     63        recursive_lock_unlock(&mutex->u.recursive);
     64}
     65
     66
     67static inline int
     68mtx_initialized(struct mtx* mutex)
     69{
     70    /* TODO */
     71    return 1;
     72}
     73
     74
     75static inline int
     76mtx_owned(struct mtx* mutex)
     77{
     78    if (mutex->type == MTX_DEF)
     79        return mutex->u.mutex.owner == find_thread(NULL);
     80    if (mutex->type == MTX_RECURSE) {
     81#if KDEBUG
     82        return mutex->u.recursive.lock.holder == find_thread(NULL);
     83#else
     84        return mutex->u.recursive.holder == find_thread(NULL);
     85#endif
     86    }
     87
     88    return 0;
     89}
     90
     91
     92#endif  /* _FBSD_COMPAT_SYS_MUTEX_H_ */
  • new file headers/compatibility/bsd/sys/namei.h

    diff --git a/headers/compatibility/bsd/sys/namei.h b/headers/compatibility/bsd/sys/namei.h
    new file mode 100644
    index 0000000..3da8a0a
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_NAMEI_H_
     6#define _FBSD_COMPAT_SYS_NAMEI_H_
     7
     8
     9#endif /* _FBSD_COMPAT_SYS_NAMEI_H_ */
  • headers/compatibility/bsd/sys/param.h

    diff --git a/headers/compatibility/bsd/sys/param.h b/headers/compatibility/bsd/sys/param.h
    index d76da9b..5265c5d 100644
    a b  
    11/*
    2  * Copyright 2006-2010 Haiku Inc. All Rights Reserved.
     2<<<<<<< HEAD
     3 * Copyright 2009, Colin Günther, coling@gmx.de.
     4 * Copyright 2007, Hugo Santos. All Rights Reserved.
    35 * Distributed under the terms of the MIT License.
    46 */
    5 #ifndef _BSD_SYS_PARAM_H_
    6 #define _BSD_SYS_PARAM_H_
     7#ifndef _FBSD_COMPAT_SYS_PARAM_H_
     8#define _FBSD_COMPAT_SYS_PARAM_H_
    79
    810
    9 #include_next <sys/param.h>
     11#include <posix/sys/param.h>
    1012
     13#include <sys/types.h>
     14#include <sys/cdefs.h>
     15#include <sys/errno.h>
     16#include <sys/time.h>
     17#include <sys/priority.h>
     18
     19
     20/* The version this compatibility layer is based on */
     21#define __FreeBSD_version 800107
     22
     23#define MAXBSIZE    0x10000
     24
     25#define PAGE_SHIFT  12
     26#define PAGE_MASK   (PAGE_SIZE - 1)
     27
     28#define trunc_page(x)   ((x) & ~PAGE_MASK)
     29
     30#define ptoa(x)         ((unsigned long)((x) << PAGE_SHIFT))
     31#define atop(x)         ((unsigned long)((x) >> PAGE_SHIFT))
     32
     33/* MAJOR FIXME */
     34#define Maxmem          (32768)
     35
     36#ifndef MSIZE
     37#define MSIZE 256
     38#endif
     39
     40#ifndef MCLSHIFT
     41#define MCLSHIFT 11
     42#endif
     43
     44#define MCLBYTES        (1 << MCLSHIFT)
     45
     46#define MJUMPAGESIZE    PAGE_SIZE
     47#define MJUM9BYTES      (9 * 1024)
     48#define MJUM16BYTES     (16 * 1024)
     49
     50#define ALIGN_BYTES     (sizeof(unsigned long) - 1)
     51#define ALIGN(x)        ((((unsigned long)x) + ALIGN_BYTES) & ~ALIGN_BYTES)
     52
     53/* Macros for counting and rounding. */
     54#ifndef howmany
     55#define howmany(x, y)   (((x)+((y)-1))/(y))
     56#endif
     57#define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))  /* to any y */
     58#define roundup2(x, y)  (((x) + ((y) - 1)) & (~((y) - 1)))
     59#define rounddown(x, y)  (((x) / (y)) * (y))
     60
     61#define PRIMASK 0x0ff
     62#define PCATCH  0x100
     63#define PDROP   0x200
     64#define PBDRY   0x400
     65
     66#define NBBY    8       /* number of bits in a byte */
     67
     68/* Bit map related macros. */
     69#define setbit(a,i) (((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY))
     70#define clrbit(a,i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY)))
     71#define isset(a,i)                          \
     72    (((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY)))
     73#define isclr(a,i)                          \
     74    ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
    1175
    1276#ifdef _BSD_SOURCE
    1377
     
    38102#endif
    39103
    40104
    41 #endif  /* _BSD_SYS_PARAM_H_ */
     105#endif  /* _FBSD_COMPAT_SYS_PARAM_H_ */
     106
  • new file headers/compatibility/bsd/sys/pcpu.h

    diff --git a/headers/compatibility/bsd/sys/pcpu.h b/headers/compatibility/bsd/sys/pcpu.h
    new file mode 100644
    index 0000000..858d57b
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * All rights reserved. Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_PCPU_H_
     6#define _FBSD_COMPAT_SYS_PCPU_H_
     7
     8
     9#include <OS.h>
     10
     11
     12struct thread;
     13
     14#define curthread ((struct thread*)NULL)
     15    /* NOTE: Dereferencing curthread will crash, which is intentional. There is
     16       no FreeBSD compatible struct thread and Haiku's should not be used as it
     17       is only valid for the current thread or with proper locking. Currently
     18       only priv_check() expects a struct thread parameter and ignores it. Using
     19       NULL will show us when other uses appear. */
     20
     21
     22#endif /* _FBSD_COMPAT_SYS_PCPU_H_ */
  • new file headers/compatibility/bsd/sys/priority.h

    diff --git a/headers/compatibility/bsd/sys/priority.h b/headers/compatibility/bsd/sys/priority.h
    new file mode 100644
    index 0000000..61fd7f1
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_PRIORITY_H_
     6#define _FBSD_COMPAT_SYS_PRIORITY_H_
     7
     8
     9#define PRI_MIN_KERN    (64)
     10#define PZERO           (PRI_MIN_KERN + 20)
     11
     12#endif /* _FBSD_COMPAT_SYS_PRIORITY_H_ */
  • new file headers/compatibility/bsd/sys/priv.h

    diff --git a/headers/compatibility/bsd/sys/priv.h b/headers/compatibility/bsd/sys/priv.h
    new file mode 100644
    index 0000000..4ba76e3
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * All rights reserved. Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_PRIV_H_
     6#define _FBSD_COMPAT_SYS_PRIV_H_
     7
     8
     9#include <sys/cdefs.h>
     10
     11
     12/*
     13 * 802.11-related privileges.
     14 */
     15#define PRIV_NET80211_GETKEY    440 /* Query 802.11 keys. */
     16#define PRIV_NET80211_MANAGE    441 /* Administer 802.11. */
     17
     18#define PRIV_DRIVER     14  /* Low-level driver privilege. */
     19
     20
     21/*
     22 * Privilege check interfaces, modeled after historic suser() interfacs, but
     23 * with the addition of a specific privilege name.  No flags are currently
     24 * defined for the API.  Historically, flags specified using the real uid
     25 * instead of the effective uid, and whether or not the check should be
     26 * allowed in jail.
     27 */
     28struct thread;
     29
     30
     31__BEGIN_DECLS
     32
     33int priv_check(struct thread*, int);
     34
     35__END_DECLS
     36
     37
     38#endif /* _FBSD_COMPAT_SYS_PRIV_H_ */
  • new file headers/compatibility/bsd/sys/proc.h

    diff --git a/headers/compatibility/bsd/sys/proc.h b/headers/compatibility/bsd/sys/proc.h
    new file mode 100644
    index 0000000..1eb862a
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_PROC_H_
     6#define _FBSD_COMPAT_SYS_PROC_H_
     7
     8
     9#endif /* _FBSD_COMPAT_SYS_PROC_H_ */
  • new file headers/compatibility/bsd/sys/rman.h

    diff --git a/headers/compatibility/bsd/sys/protosw.h b/headers/compatibility/bsd/sys/protosw.h
    new file mode 100644
    index 0000000..e69de29
    diff --git a/headers/compatibility/bsd/sys/random.h b/headers/compatibility/bsd/sys/random.h
    new file mode 100644
    index 0000000..e69de29
    diff --git a/headers/compatibility/bsd/sys/rman.h b/headers/compatibility/bsd/sys/rman.h
    new file mode 100644
    index 0000000..c3911d9
    - +  
     1/*
     2 * Copyright 2007, Hugo Santos. All Rights Reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5
     6
     7/*-
     8 * Copyright 1998 Massachusetts Institute of Technology
     9 *
     10 * Permission to use, copy, modify, and distribute this software and
     11 * its documentation for any purpose and without fee is hereby
     12 * granted, provided that both the above copyright notice and this
     13 * permission notice appear in all copies, that both the above
     14 * copyright notice and this permission notice appear in all
     15 * supporting documentation, and that the name of M.I.T. not be used
     16 * in advertising or publicity pertaining to distribution of the
     17 * software without specific, written prior permission.  M.I.T. makes
     18 * no representations about the suitability of this software for any
     19 * purpose.  It is provided "as is" without express or implied
     20 * warranty.
     21 *
     22 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
     23 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
     24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
     26 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
     29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33 * SUCH DAMAGE.
     34 *
     35 * $FreeBSD$
     36 */
     37#ifndef _FBSD_COMPAT_SYS_RMAN_H_
     38#define _FBSD_COMPAT_SYS_RMAN_H_
     39
     40
     41#include <machine/_bus.h>
     42#include <machine/resource.h>
     43
     44
     45#define RF_ACTIVE       0x0002
     46#define RF_SHAREABLE    0x0004
     47#define RF_OPTIONAL     0x0080
     48
     49#define RF_ALIGNMENT_SHIFT      10 /* alignment size bit starts bit 10 */
     50#define RF_ALIGNMENT_LOG2(x)    ((x) << RF_ALIGNMENT_SHIFT)
     51
     52struct resource {
     53    int                 r_type;
     54    bus_space_tag_t     r_bustag;       /* bus_space tag */
     55    bus_space_handle_t  r_bushandle;    /* bus_space handle */
     56    area_id             r_mapped_area;
     57};
     58
     59
     60bus_space_handle_t rman_get_bushandle(struct resource *);
     61bus_space_tag_t rman_get_bustag(struct resource *);
     62int rman_get_rid(struct resource *);
     63
     64
     65static inline u_long
     66rman_get_start(struct resource *resourcePointer)
     67{
     68    return resourcePointer->r_bushandle;
     69}
     70
     71
     72static inline uint32_t
     73rman_make_alignment_flags(uint32_t size)
     74{
     75    int i;
     76
     77    /*
     78     * Find the hightest bit set, and add one if more than one bit
     79     * set.  We're effectively computing the ceil(log2(size)) here.
     80     */
     81    for (i = 31; i > 0; i--)
     82        if ((1 << i) & size)
     83            break;
     84    if (~(1 << i) & size)
     85        i++;
     86
     87    return RF_ALIGNMENT_LOG2(i);
     88}
     89#endif /* _FBSD_COMPAT_SYS_RMAN_H_ */
  • new file headers/compatibility/bsd/sys/socket.h

    diff --git a/headers/compatibility/bsd/sys/socket.h b/headers/compatibility/bsd/sys/socket.h
    new file mode 100644
    index 0000000..dc83ed2
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * All rights reserved. Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_SOCKET_H_
     6#define _FBSD_COMPAT_SYS_SOCKET_H_
     7
     8
     9#include <posix/sys/socket.h>
     10
     11#include <sys/cdefs.h>
     12#include <sys/_types.h>
     13
     14
     15// TODO Should be incorporated into Haikus socket.h with a number below AF_MAX
     16#define AF_IEEE80211    AF_MAX + 1  /* IEEE 802.11 protocol */
     17
     18#endif /* _FBSD_COMPAT_SYS_SOCKET_H_ */
  • new file headers/compatibility/bsd/sys/sockio.h

    diff --git a/headers/compatibility/bsd/sys/sockio.h b/headers/compatibility/bsd/sys/sockio.h
    new file mode 100644
    index 0000000..7d469d7
    - +  
     1/*
     2 * Copyright 2007-2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_SOCKIO_H_
     6#define _FBSD_COMPAT_SYS_SOCKIO_H_
     7
     8
     9#include <posix/sys/sockio.h>
     10
     11#include <sys/ioccom.h>
     12
     13
     14#define SIOCSIFCAP  SIOCSPACKETCAP
     15
     16#endif
  • new file headers/compatibility/bsd/sys/sysctl.h

    diff --git a/headers/compatibility/bsd/sys/sysctl.h b/headers/compatibility/bsd/sys/sysctl.h
    new file mode 100644
    index 0000000..0f324a2
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_SYSCTL_H_
     6#define _FBSD_COMPAT_SYS_SYSCTL_H_
     7
     8
     9#include <sys/queue.h>
     10
     11
     12#ifdef _KERNEL
     13
     14struct sysctl_req {
     15    void *newptr;
     16};
     17
     18struct sysctl_ctx_list {
     19};
     20
     21struct sysctl_oid_list {
     22};
     23
     24
     25#define SYSCTL_HANDLER_ARGS void *oidp, void *arg1, int arg2, \
     26    struct sysctl_req *req
     27
     28#define OID_AUTO    (-1)
     29
     30#define CTLTYPE     0xf /* Mask for the type */
     31#define CTLTYPE_NODE    1   /* name is a node */
     32#define CTLTYPE_INT 2   /* name describes an integer */
     33#define CTLTYPE_STRING  3   /* name describes a string */
     34#define CTLTYPE_QUAD    4   /* name describes a 64-bit number */
     35#define CTLTYPE_OPAQUE  5   /* name describes a structure */
     36#define CTLTYPE_STRUCT  CTLTYPE_OPAQUE  /* name describes a structure */
     37#define CTLTYPE_UINT    6   /* name describes an unsigned integer */
     38#define CTLTYPE_LONG    7   /* name describes a long */
     39#define CTLTYPE_ULONG   8   /* name describes an unsigned long */
     40#define CTLTYPE_U64     9   /* name describes an unsigned 64-bit number */
     41
     42#define CTLFLAG_RD  0x80000000  /* Allow reads of variable */
     43#define CTLFLAG_WR  0x40000000  /* Allow writes to the variable */
     44#define CTLFLAG_RW  (CTLFLAG_RD|CTLFLAG_WR)
     45#define CTLFLAG_NOLOCK  0x20000000  /* XXX Don't Lock */
     46#define CTLFLAG_ANYBODY 0x10000000  /* All users can set this var */
     47#define CTLFLAG_SECURE  0x08000000  /* Permit set only if securelevel<=0 */
     48#define CTLFLAG_PRISON  0x04000000  /* Prisoned roots can fiddle */
     49#define CTLFLAG_DYN 0x02000000  /* Dynamic oid - can be freed */
     50#define CTLFLAG_SKIP    0x01000000  /* Skip this sysctl when listing */
     51#define CTLMASK_SECURE  0x00F00000  /* Secure level */
     52#define CTLFLAG_TUN 0x00080000  /* Tunable variable */
     53#define CTLFLAG_MPSAFE  0x00040000  /* Handler is MP safe */
     54#define CTLFLAG_RDTUN   (CTLFLAG_RD|CTLFLAG_TUN)
     55
     56
     57static inline int
     58sysctl_ctx_init(struct sysctl_ctx_list *clist)
     59{
     60    return -1;
     61}
     62
     63
     64static inline int
     65sysctl_ctx_free(struct sysctl_ctx_list *clist)
     66{
     67    return -1;
     68}
     69
     70
     71static inline void *
     72sysctl_add_oid(struct sysctl_ctx_list *clist, void *parent, int nbr,
     73    const char *name, int kind, void *arg1, int arg2,
     74    int (*handler) (SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr)
     75{
     76    return NULL;
     77}
     78
     79
     80static inline int sysctl_handle_long(SYSCTL_HANDLER_ARGS) { return -1; }
     81static inline int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS) { return -1; }
     82static inline int sysctl_handle_quad(SYSCTL_HANDLER_ARGS) { return -1; }
     83static inline int sysctl_handle_int(SYSCTL_HANDLER_ARGS) { return -1; }
     84static inline int sysctl_handle_64(SYSCTL_HANDLER_ARGS) { return -1; }
     85static inline int sysctl_handle_string(SYSCTL_HANDLER_ARGS) { return -1; }
     86
     87
     88#define SYSCTL_OUT(r, p, l) -1
     89
     90#define __DESCR(x) ""
     91
     92#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
     93    sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, \
     94    __DESCR(descr))
     95
     96#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \
     97    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access),       \
     98    0, 0, handler, "N", __DESCR(descr))
     99
     100#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr)  \
     101    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access),         \
     102    arg, len, sysctl_handle_string, "A", __DESCR(descr))
     103
     104#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \
     105    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|(access),        \
     106    ptr, val, sysctl_handle_int, "I", __DESCR(descr))
     107
     108#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr)    \
     109    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access),           \
     110    ptr, val, sysctl_handle_int, "IU", __DESCR(descr))
     111
     112#define SYSCTL_ADD_XINT(ctx, parent, nbr, name, access, ptr, val, descr)    \
     113    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access),           \
     114    ptr, val, sysctl_handle_int, "IX", __DESCR(descr))
     115
     116#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \
     117    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|(access),   \
     118    ptr, 0, sysctl_handle_long, "L", __DESCR(descr))
     119
     120#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr)    \
     121    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access),      \
     122    ptr, 0, sysctl_handle_long, "LU", __DESCR(descr))
     123
     124#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \
     125    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_QUAD|(access),   \
     126    ptr, 0, sysctl_handle_quad, "Q", __DESCR(descr))
     127
     128#define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, descr)    \
     129    sysctl_add_oid(ctx, parent, nbr, name,                              \
     130    CTLTYPE_U64 | CTLFLAG_MPSAFE | (access),                            \
     131    ptr, 0, sysctl_handle_64, "QU", __DESCR(descr))
     132
     133#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \
     134    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
     135    ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr))
     136
     137#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \
     138    sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access),         \
     139    ptr, sizeof(struct type), sysctl_handle_opaque, "S," #type, __DESCR(descr))
     140
     141#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
     142    sysctl_add_oid(ctx, parent, nbr, name, (access), ptr, arg, handler, fmt, \
     143    __DESCR(descr))
     144
     145
     146static inline void *
     147SYSCTL_CHILDREN(void *ptr)
     148{
     149    return NULL;
     150}
     151
     152
     153#define SYSCTL_STATIC_CHILDREN(...) NULL
     154
     155#define SYSCTL_DECL(name) \
     156    extern struct sysctl_oid_list sysctl_##name##_children
     157
     158#define SYSCTL_NODE(...)
     159#define SYSCTL_INT(...)
     160#define SYSCTL_UINT(...)
     161#define SYSCTL_PROC(...)
     162
     163#endif
     164
     165#endif
  • new file headers/compatibility/bsd/sys/syslog.h

    diff --git a/headers/compatibility/bsd/sys/syslog.h b/headers/compatibility/bsd/sys/syslog.h
    new file mode 100644
    index 0000000..f785d64
    - +  
     1/*
     2 * Copyright 2009 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_SYSLOG_H_
     6#define _FBSD_COMPAT_SYS_SYSLOG_H_
     7
     8
     9#define LOG_ERR 3 /* error conditions */
     10
     11#endif /* _FBSD_COMPAT_SYS_SYSLOG_H_ */
  • new file headers/compatibility/bsd/sys/systm.h

    diff --git a/headers/compatibility/bsd/sys/systm.h b/headers/compatibility/bsd/sys/systm.h
    new file mode 100644
    index 0000000..42c2a79
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * Copyright 2007, Hugo Santos. All Rights Reserved.
     4 * Distributed under the terms of the MIT License.
     5 */
     6#ifndef _FBSD_COMPAT_SYS_SYSTM_H_
     7#define _FBSD_COMPAT_SYS_SYSTM_H_
     8
     9
     10#include <stdint.h>
     11#include <stdio.h>
     12#include <string.h>
     13#include <strings.h>
     14
     15#include <machine/atomic.h>
     16#include <machine/cpufunc.h>
     17
     18#include <sys/callout.h>
     19#include <sys/cdefs.h>
     20#include <sys/queue.h>
     21
     22#include <sys/libkern.h>
     23
     24
     25#define printf freebsd_printf
     26int printf(const char *format, ...) __printflike(1, 2);
     27
     28
     29#define ovbcopy(f, t, l) bcopy((f), (t), (l))
     30
     31#define bootverbose 1
     32
     33#ifdef INVARIANTS
     34#define KASSERT(cond,msg) do {  \
     35    if (!(cond))                \
     36        panic msg;              \
     37} while (0)
     38#else
     39#define KASSERT(exp,msg) do { \
     40} while (0)
     41#endif
     42
     43#define DELAY(n) \
     44    do {                \
     45        if (n < 1000)   \
     46            spin(n);    \
     47        else            \
     48            snooze(n);  \
     49    } while (0)
     50
     51void wakeup(void *);
     52
     53#ifndef CTASSERT /* Allow lint to override */
     54#define CTASSERT(x)         _CTASSERT(x, __LINE__)
     55#define _CTASSERT(x, y)     __CTASSERT(x, y)
     56#define __CTASSERT(x, y)    typedef char __assert ## y[(x) ? 1 : -1]
     57#endif
     58
     59
     60static inline int
     61copyin(const void * __restrict udaddr, void * __restrict kaddr,
     62    size_t len)
     63{
     64    return user_memcpy(kaddr, udaddr, len);
     65}
     66
     67
     68static inline int
     69copyout(const void * __restrict kaddr, void * __restrict udaddr,
     70    size_t len)
     71{
     72    return user_memcpy(udaddr, kaddr, len);
     73}
     74
     75
     76static inline void log(int level, const char *fmt, ...) { }
     77
     78
     79int snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
     80extern int sprintf(char *buf, const char *, ...);
     81
     82extern void driver_vprintf(const char *format, va_list vl);
     83#define vprintf(fmt, vl) driver_vprintf(fmt, vl)
     84
     85extern int vsnprintf(char *, size_t, const char *, __va_list)
     86    __printflike(3, 0);
     87
     88int msleep(void *, struct mtx *, int, const char *, int);
     89int _pause(const char *, int);
     90#define pause(waitMessage, timeout) _pause((waitMessage), (timeout))
     91#define tsleep(channel, priority, waitMessage, timeout) \
     92    msleep((channel), NULL, (priority), (waitMessage), (timeout))
     93
     94struct unrhdr;
     95struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
     96void delete_unrhdr(struct unrhdr *);
     97int alloc_unr(struct unrhdr *);
     98void free_unr(struct unrhdr *, u_int);
     99
     100extern char *getenv(const char *name);
     101extern void    freeenv(char *env);
     102
     103#endif  /* _FBSD_COMPAT_SYS_SYSTM_H_ */
  • new file headers/compatibility/bsd/sys/taskqueue.h

    diff --git a/headers/compatibility/bsd/sys/taskqueue.h b/headers/compatibility/bsd/sys/taskqueue.h
    new file mode 100644
    index 0000000..77fa6a0
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_TASKQUEUE_H_
     6#define _FBSD_COMPAT_SYS_TASKQUEUE_H_
     7
     8
     9#include <sys/queue.h>
     10#include <sys/_task.h>
     11
     12
     13#define PI_NET  (B_REAL_TIME_DISPLAY_PRIORITY - 1)
     14
     15#define TASK_INIT(taskp, prio, hand, arg) task_init(taskp, prio, hand, arg)
     16
     17
     18typedef void (*taskqueue_enqueue_fn)(void *context);
     19
     20
     21struct taskqueue;
     22struct taskqueue *taskqueue_create(const char *name, int mflags,
     23    taskqueue_enqueue_fn enqueue, void *context);
     24int taskqueue_start_threads(struct taskqueue **tq, int count, int pri,
     25    const char *name, ...) __printflike(4, 5);
     26void taskqueue_free(struct taskqueue *tq);
     27void taskqueue_drain(struct taskqueue *tq, struct task *task);
     28void taskqueue_block(struct taskqueue *queue);
     29void taskqueue_unblock(struct taskqueue *queue);
     30int taskqueue_enqueue(struct taskqueue *tq, struct task *task);
     31
     32void taskqueue_thread_enqueue(void *context);
     33
     34extern struct taskqueue *taskqueue_fast;
     35extern struct taskqueue *taskqueue_swi;
     36
     37int taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task);
     38struct taskqueue *taskqueue_create_fast(const char *name, int mflags,
     39    taskqueue_enqueue_fn enqueue, void *context);
     40
     41void task_init(struct task *, int prio, task_handler_t handler, void *arg);
     42
     43#endif
  • new file headers/compatibility/bsd/sys/time.h

    diff --git a/headers/compatibility/bsd/sys/time.h b/headers/compatibility/bsd/sys/time.h
    new file mode 100644
    index 0000000..4b061e3
    - +  
     1/*
     2 * Copyright 2009, Colin Günther, coling@gmx.de.
     3 * All rights reserved. Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_TIME_H_
     6#define _FBSD_COMPAT_SYS_TIME_H_
     7
     8
     9#include <posix/sys/time.h>
     10
     11#include <sys/_timeval.h>
     12#include <sys/types.h>
     13
     14
     15#define time_uptime (system_time() / 1000000)
     16
     17
     18int ppsratecheck(struct timeval*, int*, int);
     19
     20#endif /* _FBSD_COMPAT_SYS_TIME_H_ */
  • new file headers/compatibility/bsd/sys/types.h

    diff --git a/headers/compatibility/bsd/sys/types.h b/headers/compatibility/bsd/sys/types.h
    new file mode 100644
    index 0000000..babd91b
    - +  
     1/*
     2 * Copyright 2007 Haiku Inc. All rights reserved.
     3 * Distributed under the terms of the MIT License.
     4 */
     5#ifndef _FBSD_COMPAT_SYS_TYPES_H_
     6#define _FBSD_COMPAT_SYS_TYPES_H_
     7
     8
     9#include <posix/stdint.h>
     10#include <posix/sys/types.h>
     11
     12#include <sys/cdefs.h>
     13
     14#include <machine/endian.h>
     15#include <sys/_types.h>
     16
     17
     18typedef int boolean_t;
     19typedef __const char* c_caddr_t;
     20typedef uint64_t u_quad_t;
     21
     22#endif
  • headers/private/firewire/fwglue.h

    diff --git a/headers/private/firewire/fwglue.h b/headers/private/firewire/fwglue.h
    index 88cb374..eb5e42f 100644
    a b  
    2424#ifndef howmany
    2525#define howmany(x, y)   (((x)+((y)-1))/(y)) // x/y的上界
    2626#endif
    27 #define rounddown(x, y) (((x)/(y))*(y)) // 比x小,y的最大的倍数
    2827#define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))  /* to any y */ // 比x大,y的最小倍数
    29 #define roundup2(x, y)  (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
    3028#define powerof2(x)     ((((x)-1)&(x))==0) // 是否是2的次方
    3129
    3230typedef uint32_t bus_addr_t;
    typedef uint32_t bus_size_t;  
    5553#define MAX_CARDS 4
    5654extern dpc_module_info *gDpc;
    5755
    58 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
    59 
    6056#endif /*_FW_GLUE_H*/
  • src/add-ons/kernel/bus_managers/firewire/firewire.cpp

    diff --git a/src/add-ons/kernel/bus_managers/firewire/firewire.cpp b/src/add-ons/kernel/bus_managers/firewire/firewire.cpp
    index 3f2f458..4e14382 100644
    a b  
    4343#include <string.h>
    4444#include <stdio.h>
    4545#include <sys/param.h>
     46#include <sys/queue.h>
    4647#include <sys/types.h>
    4748#include <sys/uio.h>
    4849#include <dpc.h>
    4950
    5051#include "fwdebug.h"
    5152#include "fwglue.h"
    52 #include "queue.h"
    5353#include "firewire.h"
    5454#include "iec13213.h"
    5555#include "firewirereg.h"
  • src/add-ons/kernel/bus_managers/firewire/firewire_module.cpp

    diff --git a/src/add-ons/kernel/bus_managers/firewire/firewire_module.cpp b/src/add-ons/kernel/bus_managers/firewire/firewire_module.cpp
    index 6f6fbf3..f137bc5 100644
    a b  
    1515#include <string.h>
    1616#include <malloc.h>
    1717#include <dpc.h>
     18#include <sys/queue.h>
    1819
    1920#include "fwdebug.h"
    20 #include "queue.h"
    2121#include "fwglue.h"
    2222#include "firewire.h"
    2323#include "iec13213.h"
  • src/add-ons/kernel/bus_managers/firewire/fwdma.cpp

    diff --git a/src/add-ons/kernel/bus_managers/firewire/fwdma.cpp b/src/add-ons/kernel/bus_managers/firewire/fwdma.cpp
    index f5693e0..6ee853c 100644
    a b  
    3535
    3636#include <OS.h>
    3737#include <malloc.h>
     38#include <sys/queue.h>
    3839
    39 #include "queue.h"
    4040#include "fwglue.h"
    4141#include "firewire.h"
    4242#include "iec13213.h"
  • src/add-ons/kernel/bus_managers/firewire/fwmem.cpp

    diff --git a/src/add-ons/kernel/bus_managers/firewire/fwmem.cpp b/src/add-ons/kernel/bus_managers/firewire/fwmem.cpp
    index 89fa6c5..d4a8950 100644
    a b  
    3434 */
    3535
    3636#include <sys/param.h>
     37#include <sys/queue.h>
    3738#include <sys/types.h>
    3839#include <endian.h>
    3940
    4041#include <sys/ioccom.h>
    41 #include "queue.h"
    4242#include "fwglue.h"
    4343#include "firewire.h"
    4444#include "iec13213.h"
  • src/add-ons/kernel/bus_managers/firewire/fwohci.cpp

    diff --git a/src/add-ons/kernel/bus_managers/firewire/fwohci.cpp b/src/add-ons/kernel/bus_managers/firewire/fwohci.cpp
    index 8a69683..117bbdc 100644
    a b  
    5252#include <string.h>
    5353#include <dpc.h>
    5454#include <sys/param.h>
     55#include <sys/queue.h>
    5556
    5657#include "fwglue.h"
    57 #include "queue.h"
    5858#include "firewire.h"
    5959#include "iec13213.h"
    6060#include "firewirereg.h"
  • src/add-ons/kernel/bus_managers/firewire/fwohci_pci.cpp

    diff --git a/src/add-ons/kernel/bus_managers/firewire/fwohci_pci.cpp b/src/add-ons/kernel/bus_managers/firewire/fwohci_pci.cpp
    index 0814ba1..a0c505a 100644
    a b  
    4040#include <SupportDefs.h>
    4141#include <PCI.h>
    4242
     43#include <sys/queue.h>
    4344#include <stdlib.h>
    4445#include <stdio.h>
    4546#include <string.h>
     
    4849#include "util.h"
    4950#include "fwdebug.h"
    5051#include "fwglue.h"
    51 #include "queue.h"
    5252#include "firewire.h"
    5353#include "iec13213.h"
    5454#include "firewirereg.h"
  • src/add-ons/kernel/drivers/bus/firewire/fw_raw.c

    diff --git a/src/add-ons/kernel/drivers/bus/firewire/fw_raw.c b/src/add-ons/kernel/drivers/bus/firewire/fw_raw.c
    index cd5177e..9f1f1b1 100644
    a b  
    4444 */
    4545
    4646#include <sys/param.h>
     47#include <sys/queue.h>
    4748#include <sys/types.h>
    4849
    4950#include <Drivers.h>
     
    5657#include <string.h>
    5758#include <sys/ioccom.h>
    5859
    59 #include "queue.h"
    6060#include "firewire.h"
    6161#include "iec13213.h"
    6262#include "firewirereg.h"
  • src/add-ons/kernel/drivers/network/3com/dev/xl/Jamfile

    diff --git a/src/add-ons/kernel/drivers/network/3com/dev/xl/Jamfile b/src/add-ons/kernel/drivers/network/3com/dev/xl/Jamfile
    index ba110e7..b358bb1 100644
    a b  
    11SubDir HAIKU_TOP src add-ons kernel drivers network 3com dev xl ;
    22
    33UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ;
     4UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
    45UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ;
    56
    67UsePrivateHeaders net system ;
  • src/bin/fwcontrol/fwcrom.c

    diff --git a/src/bin/fwcontrol/fwcrom.c b/src/bin/fwcontrol/fwcrom.c
    index 70bac5c..cbf0124 100644
    a b __FBSDID("$FreeBSD: src/sys/dev/firewire/fwcrom.c,v 1.14 2006/02/04 21:37:39 imp  
    4444#include <bootstrap.h>
    4545#else
    4646#if defined(_KERNEL) || defined(TEST)
    47 #ifdef __HAIKU__
    48 #include "queue.h"
    49 #else
    5047#include <sys/queue.h>
    5148#endif
    52 #endif
    5349#ifdef _KERNEL
    5450#ifndef __HAIKU__
    5551#include <sys/systm.h>
  • src/kits/network/libnetapi/Jamfile

    diff --git a/src/kits/network/libnetapi/Jamfile b/src/kits/network/libnetapi/Jamfile
    index aef8869..741fb34 100644
    a b SubDir HAIKU_TOP src kits network libnetapi ;  
    33UsePrivateHeaders app net shared storage support ;
    44UsePrivateHeaders locale shared ;
    55
     6
     7UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
    68UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ]
    79    : true ;
    810UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;
  • deleted file src/libs/compat/freebsd_network/compat/machine/_bus.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/_bus.h b/src/libs/compat/freebsd_network/compat/machine/_bus.h
    deleted file mode 100644
    index a4b9025..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther. All Rights Reserved.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 #ifndef _FBSD_COMPAT_MACHINE__BUS_H_
    7 #define _FBSD_COMPAT_MACHINE__BUS_H_
    8 
    9 
    10 #ifdef B_HAIKU_64_BIT
    11 
    12 
    13 typedef uint64_t bus_addr_t;
    14 typedef uint64_t bus_size_t;
    15 
    16 typedef uint64_t bus_space_tag_t;
    17 typedef uint64_t bus_space_handle_t;
    18 
    19 
    20 #else
    21 
    22 
    23 typedef uint32_t bus_addr_t;
    24 typedef uint32_t bus_size_t;
    25 
    26 typedef int bus_space_tag_t;
    27 typedef unsigned int bus_space_handle_t;
    28 
    29 
    30 #endif
    31 
    32 #endif /* _FBSD_COMPAT_MACHINE__BUS_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/machine/atomic.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/atomic.h b/src/libs/compat/freebsd_network/compat/machine/atomic.h
    deleted file mode 100644
    index d02f8ff..0000000
    + -  
    1 /*
    2  * Copyright 2007, Hugo Santos. All Rights Reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_MACHINE_ATOMIC_H_
    6 #define _FBSD_COMPAT_MACHINE_ATOMIC_H_
    7 
    8 
    9 #include <KernelExport.h>
    10 
    11 
    12 #define atomic_add_int(ptr, value) \
    13     atomic_add((int32 *)(ptr), value)
    14 
    15 #define atomic_subtract_int(ptr, value) \
    16     atomic_add((int32 *)(ptr), -value)
    17 
    18 #define atomic_set_acq_32(ptr, value) \
    19     atomic_set_int(ptr, value)
    20 
    21 #define atomic_set_int(ptr, value) \
    22     atomic_or((int32 *)(ptr), value)
    23 
    24 #define atomic_readandclear_int(ptr) \
    25     atomic_set((int32 *)(ptr), 0)
    26 
    27 #endif  /* _FBSD_COMPAT_MACHINE_ATOMIC_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/machine/bus.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/bus.h b/src/libs/compat/freebsd_network/compat/machine/bus.h
    deleted file mode 100644
    index 9e0a49d..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther. All Rights Reserved.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 
    7 
    8 /*-
    9  * Copyright (c) KATO Takenori, 1999.
    10  *
    11  * All rights reserved.  Unpublished rights reserved under the copyright
    12  * laws of Japan.
    13  *
    14  * Redistribution and use in source and binary forms, with or without
    15  * modification, are permitted provided that the following conditions
    16  * are met:
    17  *
    18  * 1. Redistributions of source code must retain the above copyright
    19  *    notice, this list of conditions and the following disclaimer as
    20  *    the first lines of this file unmodified.
    21  * 2. Redistributions in binary form must reproduce the above copyright
    22  *    notice, this list of conditions and the following disclaimer in the
    23  *    documentation and/or other materials provided with the distribution.
    24  * 3. The name of the author may not be used to endorse or promote products
    25  *    derived from this software without specific prior written permission.
    26  *
    27  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    28  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    29  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    30  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    31  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    32  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    36  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    37  *
    38  * $FreeBSD$
    39  */
    40 
    41 /*  $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $    */
    42 
    43 /*-
    44  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
    45  * All rights reserved.
    46  *
    47  * This code is derived from software contributed to The NetBSD Foundation
    48  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
    49  * NASA Ames Research Center.
    50  *
    51  * Redistribution and use in source and binary forms, with or without
    52  * modification, are permitted provided that the following conditions
    53  * are met:
    54  * 1. Redistributions of source code must retain the above copyright
    55  *    notice, this list of conditions and the following disclaimer.
    56  * 2. Redistributions in binary form must reproduce the above copyright
    57  *    notice, this list of conditions and the following disclaimer in the
    58  *    documentation and/or other materials provided with the distribution.
    59  * 3. All advertising materials mentioning features or use of this software
    60  *    must display the following acknowledgement:
    61  *  This product includes software developed by the NetBSD
    62  *  Foundation, Inc. and its contributors.
    63  * 4. Neither the name of The NetBSD Foundation nor the names of its
    64  *    contributors may be used to endorse or promote products derived
    65  *    from this software without specific prior written permission.
    66  *
    67  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
    68  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
    69  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    70  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
    71  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    72  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    73  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    74  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    75  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    76  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    77  * POSSIBILITY OF SUCH DAMAGE.
    78  */
    79 
    80 /*-
    81  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
    82  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
    83  *
    84  * Redistribution and use in source and binary forms, with or without
    85  * modification, are permitted provided that the following conditions
    86  * are met:
    87  * 1. Redistributions of source code must retain the above copyright
    88  *    notice, this list of conditions and the following disclaimer.
    89  * 2. Redistributions in binary form must reproduce the above copyright
    90  *    notice, this list of conditions and the following disclaimer in the
    91  *    documentation and/or other materials provided with the distribution.
    92  * 3. All advertising materials mentioning features or use of this software
    93  *    must display the following acknowledgement:
    94  *      This product includes software developed by Christopher G. Demetriou
    95  *  for the NetBSD Project.
    96  * 4. The name of the author may not be used to endorse or promote products
    97  *    derived from this software without specific prior written permission
    98  *
    99  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    100  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    101  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    102  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    103  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    104  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    105  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    106  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    107  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    108  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    109  */
    110 #ifndef _FBSD_COMPAT_MACHINE_BUS_H_
    111 #define _FBSD_COMPAT_MACHINE_BUS_H_
    112 
    113 
    114 #include <machine/_bus.h>
    115 #include <machine/cpufunc.h>
    116 
    117 
    118 struct resource;
    119 
    120 
    121 // TODO: x86 specific!
    122 #define I386_BUS_SPACE_IO           0
    123 #define I386_BUS_SPACE_MEM          1
    124 
    125 #define BUS_SPACE_MAXADDR_32BIT     0xffffffff
    126 #ifdef __x86_64__
    127 #   define BUS_SPACE_MAXADDR        0xffffffffffffffffull
    128 #else
    129 #   define BUS_SPACE_MAXADDR        0xffffffff
    130 #endif
    131 
    132 #define BUS_SPACE_MAXSIZE_32BIT     0xffffffff
    133 #define BUS_SPACE_MAXSIZE           0xffffffff
    134 
    135 #define BUS_SPACE_UNRESTRICTED  (~0)
    136 
    137 #define BUS_SPACE_BARRIER_READ      1
    138 #define BUS_SPACE_BARRIER_WRITE     2
    139 
    140 
    141 uint8_t bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
    142     bus_size_t offset);
    143 uint16_t bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
    144     bus_size_t offset);
    145 uint32_t bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
    146     bus_size_t offset);
    147 void bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t handle,
    148     bus_size_t offset, uint8_t value);
    149 void bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t handle,
    150     bus_size_t offset, uint16_t value);
    151 void bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t handle,
    152     bus_size_t offset, uint32_t value);
    153 
    154 
    155 static inline void
    156 bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
    157             bus_size_t offset, u_int8_t *addr, size_t count)
    158 {
    159     if (tag == I386_BUS_SPACE_IO) {
    160         int _port_ = bsh + offset;
    161         __asm __volatile("                          \n\
    162             cld                                     \n\
    163         1:  inb %w2,%%al                            \n\
    164             stosb                                   \n\
    165             incl %2                                 \n\
    166             loop 1b"                                :
    167             "=D" (addr), "=c" (count), "=d" (_port_):
    168             "0" (addr), "1" (count), "2" (_port_)   :
    169             "%eax", "memory", "cc");
    170     } else {
    171         void* _port_ = (void*) (bsh + offset);
    172         memcpy(addr, _port_, count);
    173     }
    174 }
    175 
    176 
    177 static inline void
    178 bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
    179     bus_size_t offset, u_int32_t *addr, size_t count)
    180 {
    181     if (tag == I386_BUS_SPACE_IO) {
    182         int _port_ = bsh + offset;
    183         __asm __volatile("                          \n\
    184             cld                                     \n\
    185         1:  inl %w2,%%eax                           \n\
    186             stosl                                   \n\
    187             addl $4,%2                              \n\
    188             loop 1b"                                :
    189             "=D" (addr), "=c" (count), "=d" (_port_):
    190             "0" (addr), "1" (count), "2" (_port_)   :
    191             "%eax", "memory", "cc");
    192     } else {
    193         void* _port_ = (void*) (bsh + offset);
    194         memcpy(addr, _port_, count);
    195     }
    196 }
    197 
    198 
    199 static inline void
    200 bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
    201     bus_size_t offset, const u_int8_t *addr, size_t count)
    202 {
    203     if (tag == I386_BUS_SPACE_IO) {
    204         int _port_ = bsh + offset;
    205         __asm __volatile("                          \n\
    206             cld                                     \n\
    207         1:  lodsb                                   \n\
    208             outb %%al,%w0                           \n\
    209             incl %0                                 \n\
    210             loop 1b"                                :
    211             "=d" (_port_), "=S" (addr), "=c" (count):
    212             "0" (_port_), "1" (addr), "2" (count)   :
    213             "%eax", "memory", "cc");
    214     } else {
    215         void* _port_ = (void*) (bsh + offset);
    216         memcpy(_port_, addr, count);
    217     }
    218 }
    219 
    220 
    221 static inline void
    222 bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
    223                bus_size_t offset, u_int32_t value, size_t count)
    224 {
    225     /* TODO implement */
    226 }
    227 
    228 
    229 static inline void
    230 bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t handle,
    231     bus_size_t offset, bus_size_t len, int flags)
    232 {
    233     if (flags & BUS_SPACE_BARRIER_READ)
    234 #ifdef __x86_64__
    235         __asm__ __volatile__ ("lock; addl $0,0(%%rsp)" : : : "memory");
    236 #else
    237         __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory");
    238 #endif
    239     else
    240         __asm__ __volatile__ ("" : : : "memory");
    241 }
    242 
    243 
    244 static inline void
    245 bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
    246     bus_size_t offset, const u_int8_t *addr, size_t count)
    247 {
    248 
    249     if (tag == I386_BUS_SPACE_IO)
    250         outsb(bsh + offset, addr, count);
    251     else {
    252         __asm __volatile("                              \n\
    253             cld                                         \n\
    254         1:  lodsb                                       \n\
    255             movb %%al,(%2)                              \n\
    256             loop 1b"                                    :
    257             "=S" (addr), "=c" (count)                   :
    258             "r" (bsh + offset), "0" (addr), "1" (count) :
    259             "%eax", "memory", "cc");
    260     }
    261 }
    262 
    263 
    264 #include <machine/bus_dma.h>
    265 
    266 
    267 #define bus_space_write_stream_4(t, h, o, v) \
    268     bus_space_write_4((t), (h), (o), (v))
    269 
    270 #endif /* _FBSD_COMPAT_MACHINE_BUS_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/machine/bus_dma.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/bus_dma.h b/src/libs/compat/freebsd_network/compat/machine/bus_dma.h
    deleted file mode 100644
    index 8520e43..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de
    3  * All Rights Reserved. Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_MACHINE_BUS_DMA_H_
    6 #define _FBSD_COMPAT_MACHINE_BUS_DMA_H_
    7 
    8 
    9 #include <sys/bus_dma.h>
    10 
    11 #endif /* _FBSD_COMPAT_MACHINE_BUS_DMA_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/machine/clock.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/clock.h b/src/libs/compat/freebsd_network/compat/machine/clock.h
    deleted file mode 100644
    index e458d01..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_CLOCK_H_
    6 #define _FBSD_COMPAT_SYS_CLOCK_H_
    7 
    8 
    9 #endif /* _FBSD_COMPAT_SYS_CLOCK_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/machine/cpufunc.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/cpufunc.h b/src/libs/compat/freebsd_network/compat/machine/cpufunc.h
    deleted file mode 100644
    index 8e1575b..0000000
    + -  
    1 /*-
    2  * Copyright (c) 1993 The Regents of the University of California.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
    10  * 2. Redistributions in binary form must reproduce the above copyright
    11  *    notice, this list of conditions and the following disclaimer in the
    12  *    documentation and/or other materials provided with the distribution.
    13  * 4. Neither the name of the University nor the names of its contributors
    14  *    may be used to endorse or promote products derived from this software
    15  *    without specific prior written permission.
    16  *
    17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    27  * SUCH DAMAGE.
    28  *
    29  * $FreeBSD$
    30  */
    31 #ifndef _FBSD_COMPAT_MACHINE_CPUFUNC_H_
    32 #define _FBSD_COMPAT_MACHINE_CPUFUNC_H_
    33 
    34 
    35 static __inline void
    36 outsb(u_int port, const void *addr, size_t cnt)
    37 {
    38     __asm __volatile("cld; rep; outsb"
    39              : "+S" (addr), "+c" (cnt)
    40              : "d" (port));
    41 }
    42 
    43 #endif /* _FBSD_COMPAT_MACHINE_CPUFUNC_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/machine/endian.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/endian.h b/src/libs/compat/freebsd_network/compat/machine/endian.h
    deleted file mode 100644
    index 52861ac..0000000
    + -  
    1 /*
    2  * Copyright 2007 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_MACHINE_ENDIAN_H_
    6 #define _FBSD_COMPAT_MACHINE_ENDIAN_H_
    7 
    8 
    9 #include <sys/cdefs.h>
    10 #include <sys/_types.h>
    11 
    12 #endif
  • deleted file src/libs/compat/freebsd_network/compat/machine/in_cksum.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/in_cksum.h b/src/libs/compat/freebsd_network/compat/machine/in_cksum.h
    deleted file mode 100644
    index f174d30..0000000
    + -  
    1 /*
    2  * Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All Rights Reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_MACHINE_IN_CKSUM_H_
    6 #define _FBSD_COMPAT_MACHINE_IN_CKSUM_H_
    7 
    8 
    9 #include <stdint.h>
    10 
    11 
    12 #define in_cksum(m, len)    in_cksum_skip(m, len, 0)
    13 
    14 
    15 static inline u_short
    16 in_pseudo(u_int sum, u_int b, u_int c)
    17 {
    18     // should never be called
    19     panic("in_pseudo() called");
    20     return 0;
    21 }
    22 
    23 
    24 static inline u_short
    25 in_cksum_skip(struct mbuf* m, int len, int skip)
    26 {
    27     // should never be called
    28     panic("in_cksum_skip() called");
    29     return 0;
    30 }
    31 
    32 #endif  /* _FBSD_COMPAT_MACHINE_IN_CKSUM_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/machine/resource.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/md_var.h b/src/libs/compat/freebsd_network/compat/machine/md_var.h
    deleted file mode 100644
    index e69de29..0000000
    diff --git a/src/libs/compat/freebsd_network/compat/machine/ofw_machdep.h b/src/libs/compat/freebsd_network/compat/machine/ofw_machdep.h
    deleted file mode 100644
    index e69de29..0000000
    diff --git a/src/libs/compat/freebsd_network/compat/machine/resource.h b/src/libs/compat/freebsd_network/compat/machine/resource.h
    deleted file mode 100644
    index f9d9d43..0000000
    + -  
    1 /*
    2  * Copyright 2007 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_MACHINE_RESOURCE_H_
    6 #define _FBSD_COMPAT_MACHINE_RESOURCE_H_
    7 
    8 
    9 #define SYS_RES_IRQ     0x1
    10 #define SYS_RES_DRQ     0x2
    11 #define SYS_RES_MEMORY  0x3
    12 #define SYS_RES_IOPORT  0x4
    13 
    14 #endif
  • deleted file src/libs/compat/freebsd_network/compat/machine/stdarg.h

    diff --git a/src/libs/compat/freebsd_network/compat/machine/stdarg.h b/src/libs/compat/freebsd_network/compat/machine/stdarg.h
    deleted file mode 100644
    index 7596167..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_MACHINE_STDARG_H_
    6 #define _FBSD_COMPAT_MACHINE_STDARG_H_
    7 
    8 
    9 #include <sys/cdefs.h>
    10 #include <sys/_types.h>
    11 
    12 #endif /* _FBSD_COMPAT_MACHINE_STDARG_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/_bus_dma.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/_bus_dma.h b/src/libs/compat/freebsd_network/compat/sys/_bus_dma.h
    deleted file mode 100644
    index 5aa4482..0000000
    + -  
    1 /*-
    2  * Copyright 2006 John-Mark Gurney.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
    10  * 2. Redistributions in binary form must reproduce the above copyright
    11  *    notice, this list of conditions and the following disclaimer in the
    12  *    documentation and/or other materials provided with the distribution.
    13  *
    14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
    15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    24  * SUCH DAMAGE.
    25  *
    26  * $FreeBSD: src/sys/sys/_bus_dma.h,v 1.1 2006/09/03 00:26:17 jmg Exp $
    27  *
    28  */
    29 #ifndef _SYS__BUS_DMA_H_
    30 #define _SYS__BUS_DMA_H_
    31 
    32 typedef int bus_dmasync_op_t;
    33 
    34 /*
    35  *  bus_dma_tag_t
    36  *
    37  *  A machine-dependent opaque type describing the characteristics
    38  *  of how to perform DMA mappings.  This structure encapsultes
    39  *  information concerning address and alignment restrictions, number
    40  *  of S/G segments, amount of data per S/G segment, etc.
    41  */
    42 typedef struct bus_dma_tag  *bus_dma_tag_t;
    43 
    44 /*
    45  *  bus_dmamap_t
    46  *
    47  *  DMA mapping instance information.
    48  */
    49 typedef struct bus_dmamap   *bus_dmamap_t;
    50 
    51 /*
    52  * A function that performs driver-specific synchronization on behalf of
    53  * busdma.
    54  */
    55 typedef enum {
    56     BUS_DMA_LOCK    = 0x01,
    57     BUS_DMA_UNLOCK  = 0x02,
    58 } bus_dma_lock_op_t;
    59 
    60 typedef void bus_dma_lock_t(void *, bus_dma_lock_op_t);
    61 
    62 #endif /* !_SYS__BUS_DMA_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/_mutex.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/_mutex.h b/src/libs/compat/freebsd_network/compat/sys/_mutex.h
    deleted file mode 100644
    index 7d8e757..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 #ifndef _FBSD_COMPAT_SYS__MUTEX_H_
    7 #define _FBSD_COMPAT_SYS__MUTEX_H_
    8 
    9 
    10 #include <lock.h>
    11 
    12 
    13 struct mtx {
    14     int                     type;
    15     union {
    16         struct {
    17             mutex           lock;
    18             thread_id       owner;
    19         }                   mutex;
    20         int32               spinlock;
    21         recursive_lock      recursive;
    22     } u;
    23 };
    24 
    25 
    26 #endif /* _FBSD_COMPAT_SYS__MUTEX_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/_task.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/_task.h b/src/libs/compat/freebsd_network/compat/sys/_task.h
    deleted file mode 100644
    index a94e6b8..0000000
    + -  
    1 /*
    2  * Copyright 2007 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS__TASK_H_
    6 #define _FBSD_COMPAT_SYS__TASK_H_
    7 
    8 
    9 /* Haiku's list management */
    10 #include <util/list.h>
    11 
    12 
    13 typedef void (*task_handler_t)(void *context, int pending);
    14 
    15 struct task {
    16     int ta_priority;
    17     task_handler_t ta_handler;
    18     void *ta_argument;
    19     int ta_pending;
    20 
    21     struct list_link ta_link;
    22 };
    23 
    24 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/_timeval.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/_timeval.h b/src/libs/compat/freebsd_network/compat/sys/_timeval.h
    deleted file mode 100644
    index 6ba7a53..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS__TIMEVAL_H_
    6 #define _FBSD_COMPAT_SYS__TIMEVAL_H_
    7 
    8 
    9 #include <sys/_types.h>
    10 
    11 #endif /* _FBSD_COMPAT_SYS__TIMEVAL_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/_types.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/_types.h b/src/libs/compat/freebsd_network/compat/sys/_types.h
    deleted file mode 100644
    index 790e013..0000000
    + -  
    1 /*
    2  * Copyright 2007 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS__TYPES_H_
    6 #define _FBSD_COMPAT_SYS__TYPES_H_
    7 
    8 
    9 #ifdef __GNUCLIKE_BUILTIN_VARARGS
    10 typedef __builtin_va_list   __va_list;  /* internally known to gcc */
    11 #else
    12 typedef char *          __va_list;
    13 #endif /* __GNUCLIKE_BUILTIN_VARARGS */
    14 #if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
    15     && !defined(__NO_GNUC_VA_LIST)
    16 #define __GNUC_VA_LIST
    17 typedef __va_list       __gnuc_va_list; /* compatibility w/GNU headers*/
    18 #endif
    19 
    20 #endif /* _FBSD_COMPAT_SYS__TYPES_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/bus.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/bus.h b/src/libs/compat/freebsd_network/compat/sys/bus.h
    deleted file mode 100644
    index 889cd99..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther. All Rights Reserved.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 #ifndef _FBSD_COMPAT_SYS_BUS_H_
    7 #define _FBSD_COMPAT_SYS_BUS_H_
    8 
    9 
    10 #include <sys/haiku-module.h>
    11 
    12 #include <sys/_bus_dma.h>
    13 
    14 #include <sys/queue.h>
    15 
    16 
    17 // TODO per platform, these are 32-bit
    18 
    19 // oh you glorious world of macros
    20 #define bus_read_1(r, o) \
    21     bus_space_read_1((r)->r_bustag, (r)->r_bushandle, (o))
    22 #define bus_read_2(r, o) \
    23     bus_space_read_2((r)->r_bustag, (r)->r_bushandle, (o))
    24 #define bus_read_4(r, o) \
    25     bus_space_read_4((r)->r_bustag, (r)->r_bushandle, (o))
    26 #define bus_write_1(r, o, v) \
    27     bus_space_write_1((r)->r_bustag, (r)->r_bushandle, (o), (v))
    28 #define bus_write_2(r, o, v) \
    29     bus_space_write_2((r)->r_bustag, (r)->r_bushandle, (o), (v))
    30 #define bus_write_4(r, o, v) \
    31     bus_space_write_4((r)->r_bustag, (r)->r_bushandle, (o), (v))
    32 
    33 #define bus_barrier(r, o, l, f) \
    34     bus_space_barrier((r)->r_bustag, (r)->r_bushandle, (o), (l), (f))
    35 
    36 #define bus_read_region_1(r, o, d, c) \
    37     bus_space_read_region_1((r)->r_bustag, (r)->r_bushandle, (o), (d), (c))
    38 
    39 #define FILTER_STRAY            B_UNHANDLED_INTERRUPT
    40 #define FILTER_HANDLED          B_HANDLED_INTERRUPT
    41 #define FILTER_SCHEDULE_THREAD  B_INVOKE_SCHEDULER
    42 
    43 /* Note that we reversed the original order, so whenever actual (negative)
    44    numbers are used in a driver, we have to change it. */
    45 #define BUS_PROBE_SPECIFIC      0
    46 #define BUS_PROBE_LOW_PRIORITY  10
    47 #define BUS_PROBE_DEFAULT       20
    48 #define BUS_PROBE_GENERIC       100
    49 
    50 #define __BUS_ACCESSOR(varp, var, ivarp, ivar, type)                        \
    51                                                                             \
    52 static __inline type varp ## _get_ ## var(device_t dev)                 \
    53 {                                                                       \
    54     return 0;                                                       \
    55 }                                                                       \
    56                                                                             \
    57 static __inline void varp ## _set_ ## var(device_t dev, type t)             \
    58 {                                                                           \
    59 }
    60 
    61 
    62 struct resource;
    63 
    64 struct resource_spec {
    65     int type;
    66     int rid;
    67     int flags;
    68 };
    69 
    70 enum intr_type {
    71     INTR_TYPE_NET   = 4,
    72     INTR_FAST       = 128,
    73     INTR_MPSAFE     = 512,
    74 };
    75 
    76 
    77 int bus_generic_detach(device_t dev);
    78 int bus_generic_suspend(device_t dev);
    79 int bus_generic_resume(device_t dev);
    80 void bus_generic_shutdown(device_t dev);
    81 
    82 typedef int (*driver_filter_t)(void *);
    83 typedef void driver_intr_t(void *);
    84 
    85 
    86 int resource_int_value(const char *name, int unit, const char *resname,
    87     int *result);
    88 
    89 struct resource *bus_alloc_resource(device_t dev, int type, int *rid,
    90     unsigned long start, unsigned long end, unsigned long count, uint32 flags);
    91 int bus_release_resource(device_t dev, int type, int rid, struct resource *r);
    92 int bus_alloc_resources(device_t dev, struct resource_spec *resourceSpec,
    93     struct resource **resources);
    94 void bus_release_resources(device_t dev,
    95     const struct resource_spec *resourceSpec, struct resource **resources);
    96 
    97 int bus_child_present(device_t child);
    98 
    99 static inline struct resource *
    100 bus_alloc_resource_any(device_t dev, int type, int *rid, uint32 flags)
    101 {
    102     return bus_alloc_resource(dev, type, rid, 0, ~0, 1, flags);
    103 }
    104 
    105 bus_dma_tag_t bus_get_dma_tag(device_t dev);
    106 
    107 int bus_setup_intr(device_t dev, struct resource *r, int flags,
    108     driver_filter_t filter, driver_intr_t handler, void *arg, void **_cookie);
    109 int bus_teardown_intr(device_t dev, struct resource *r, void *cookie);
    110 
    111 const char *device_get_name(device_t dev);
    112 const char *device_get_nameunit(device_t dev);
    113 int device_get_unit(device_t dev);
    114 void *device_get_softc(device_t dev);
    115 int device_printf(device_t dev, const char *, ...) __printflike(2, 3);
    116 void device_set_desc(device_t dev, const char *desc);
    117 void device_set_desc_copy(device_t dev, const char *desc);
    118 const char *device_get_desc(device_t dev);
    119 device_t device_get_parent(device_t dev);
    120 u_int32_t device_get_flags(device_t dev);
    121 devclass_t device_get_devclass(device_t dev);
    122 int device_get_children(device_t dev, device_t **devlistp, int *devcountp);
    123 
    124 void device_set_ivars(device_t dev, void *);
    125 void *device_get_ivars(device_t dev);
    126 
    127 device_t device_add_child(device_t dev, const char *name, int unit);
    128 int device_delete_child(device_t dev, device_t child);
    129 int device_is_attached(device_t dev);
    130 int device_attach(device_t dev);
    131 int device_detach(device_t dev);
    132 int bus_print_child_header(device_t dev, device_t child);
    133 int bus_print_child_footer(device_t dev, device_t child);
    134 int bus_generic_print_child(device_t dev, device_t child);
    135 void bus_generic_driver_added(device_t dev, driver_t *driver);
    136 int bus_generic_attach(device_t dev);
    137 int device_set_driver(device_t dev, driver_t *driver);
    138 int device_is_alive(device_t dev);
    139 
    140 
    141 static inline struct sysctl_ctx_list *
    142 device_get_sysctl_ctx(device_t dev)
    143 {
    144     return NULL;
    145 }
    146 
    147 
    148 static inline void *
    149 device_get_sysctl_tree(device_t dev)
    150 {
    151     return NULL;
    152 }
    153 
    154 devclass_t devclass_find(const char *classname);
    155 device_t devclass_get_device(devclass_t dc, int unit);
    156 int devclass_get_maxunit(devclass_t dc);
    157 
    158 #endif  /* _FBSD_COMPAT_SYS_BUS_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/bus_dma.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/bus_dma.h b/src/libs/compat/freebsd_network/compat/sys/bus_dma.h
    deleted file mode 100644
    index 362019f..0000000
    + -  
    1 /*  $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $    */
    2 
    3 /*-
    4  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
    9  * NASA Ames Research Center.
    10  *
    11  * Redistribution and use in source and binary forms, with or without
    12  * modification, are permitted provided that the following conditions
    13  * are met:
    14  * 1. Redistributions of source code must retain the above copyright
    15  *    notice, this list of conditions and the following disclaimer.
    16  * 2. Redistributions in binary form must reproduce the above copyright
    17  *    notice, this list of conditions and the following disclaimer in the
    18  *    documentation and/or other materials provided with the distribution.
    19  * 3. All advertising materials mentioning features or use of this software
    20  *    must display the following acknowledgement:
    21  *  This product includes software developed by the NetBSD
    22  *  Foundation, Inc. and its contributors.
    23  * 4. Neither the name of The NetBSD Foundation nor the names of its
    24  *    contributors may be used to endorse or promote products derived
    25  *    from this software without specific prior written permission.
    26  *
    27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
    28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
    29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
    31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    37  * POSSIBILITY OF SUCH DAMAGE.
    38  */
    39 
    40 /*-
    41  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
    42  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
    43  *
    44  * Redistribution and use in source and binary forms, with or without
    45  * modification, are permitted provided that the following conditions
    46  * are met:
    47  * 1. Redistributions of source code must retain the above copyright
    48  *    notice, this list of conditions and the following disclaimer.
    49  * 2. Redistributions in binary form must reproduce the above copyright
    50  *    notice, this list of conditions and the following disclaimer in the
    51  *    documentation and/or other materials provided with the distribution.
    52  * 3. All advertising materials mentioning features or use of this software
    53  *    must display the following acknowledgement:
    54  *      This product includes software developed by Christopher G. Demetriou
    55  *  for the NetBSD Project.
    56  * 4. The name of the author may not be used to endorse or promote products
    57  *    derived from this software without specific prior written permission
    58  *
    59  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    60  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    61  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    62  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    63  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    64  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    65  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    66  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    67  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    68  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    69  */
    70 /* $FreeBSD: src/sys/sys/bus_dma.h,v 1.30 2006/09/03 00:26:17 jmg Exp $ */
    71 #ifndef _BUS_DMA_H_
    72 #define _BUS_DMA_H_
    73 
    74 #include <sys/_bus_dma.h>
    75 
    76 
    77 /*
    78  * Machine independent interface for mapping physical addresses to peripheral
    79  * bus 'physical' addresses, and assisting with DMA operations.
    80  *
    81  * XXX This file is always included from <machine/bus_dma.h> and should not
    82  *     (yet) be included directly.
    83  */
    84 
    85 /*
    86  * Flags used in various bus DMA methods.
    87  */
    88 #define BUS_DMA_WAITOK      0x00    /* safe to sleep (pseudo-flag) */
    89 #define BUS_DMA_NOWAIT      0x01    /* not safe to sleep */
    90 #define BUS_DMA_ALLOCNOW    0x02    /* perform resource allocation now */
    91 #define BUS_DMA_COHERENT    0x04    /* hint: map memory in a coherent way */
    92 #define BUS_DMA_ZERO        0x08    /* allocate zero'ed memory */
    93 #define BUS_DMA_BUS1        0x10    /* placeholders for bus functions... */
    94 #define BUS_DMA_BUS2        0x20
    95 #define BUS_DMA_BUS3        0x40
    96 #define BUS_DMA_BUS4        0x80
    97 
    98 /*
    99  * The following two flags are non-standard or specific to only certain
    100  * architectures
    101  */
    102 #define BUS_DMA_NOWRITE     0x100
    103 #define BUS_DMA_NOCACHE     0x200
    104 #define BUS_DMA_ISA     0x400   /* map memory for AXP ISA dma */
    105 
    106 /* Forwards needed by prototypes below. */
    107 struct mbuf;
    108 struct uio;
    109 
    110 /*
    111  * Operations performed by bus_dmamap_sync().
    112  */
    113 #define BUS_DMASYNC_PREREAD 1
    114 #define BUS_DMASYNC_POSTREAD    2
    115 #define BUS_DMASYNC_PREWRITE    4
    116 #define BUS_DMASYNC_POSTWRITE   8
    117 
    118 /*
    119  *  bus_dma_segment_t
    120  *
    121  *  Describes a single contiguous DMA transaction.  Values
    122  *  are suitable for programming into DMA registers.
    123  */
    124 typedef struct bus_dma_segment {
    125     bus_addr_t  ds_addr;    /* DMA address */
    126     bus_size_t  ds_len;     /* length of transfer */
    127 } bus_dma_segment_t;
    128 
    129 /*
    130  * A function that returns 1 if the address cannot be accessed by
    131  * a device and 0 if it can be.
    132  */
    133 typedef int bus_dma_filter_t(void *, bus_addr_t);
    134 
    135 /*
    136  * Generic helper function for manipulating mutexes.
    137  */
    138 void busdma_lock_mutex(void *arg, bus_dma_lock_op_t op);
    139 
    140 /*
    141  * Allocate a device specific dma_tag encapsulating the constraints of
    142  * the parent tag in addition to other restrictions specified:
    143  *
    144  *  alignment:  Alignment for segments.
    145  *  boundary:   Boundary that segments cannot cross.
    146  *  lowaddr:    Low restricted address that cannot appear in a mapping.
    147  *  highaddr:   High restricted address that cannot appear in a mapping.
    148  *  filtfunc:   An optional function to further test if an address
    149  *          within the range of lowaddr and highaddr cannot appear
    150  *          in a mapping.
    151  *  filtfuncarg:    An argument that will be passed to filtfunc in addition
    152  *          to the address to test.
    153  *  maxsize:    Maximum mapping size supported by this tag.
    154  *  nsegments:  Number of discontinuities allowed in maps.
    155  *  maxsegsz:   Maximum size of a segment in the map.
    156  *  flags:      Bus DMA flags.
    157  *  lockfunc:   An optional function to handle driver-defined lock
    158  *          operations.
    159  *  lockfuncarg:    An argument that will be passed to lockfunc in addition
    160  *          to the lock operation.
    161  *  dmat:       A pointer to set to a valid dma tag should the return
    162  *          value of this function indicate success.
    163  */
    164 /* XXX Should probably allow specification of alignment */
    165 int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
    166                bus_size_t boundary, bus_addr_t lowaddr,
    167                bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
    168                void *filtfuncarg, bus_size_t maxsize, int nsegments,
    169                bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
    170                void *lockfuncarg, bus_dma_tag_t *dmat);
    171 
    172 int bus_dma_tag_destroy(bus_dma_tag_t dmat);
    173 
    174 /*
    175  * A function that processes a successfully loaded dma map or an error
    176  * from a delayed load map.
    177  */
    178 typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
    179 
    180 /*
    181  * Like bus_dmamap_callback but includes map size in bytes.  This is
    182  * defined as a separate interface to maintain compatibility for users
    183  * of bus_dmamap_callback_t--at some point these interfaces should be merged.
    184  */
    185 typedef void bus_dmamap_callback2_t(void *, bus_dma_segment_t *, int, bus_size_t, int);
    186 
    187 /*
    188  * XXX sparc64 uses the same interface, but a much different implementation.
    189  *     <machine/bus_dma.h> for the sparc64 arch contains the equivalent
    190  *     declarations.
    191  */
    192 #if !defined(__sparc64__)
    193 
    194 /*
    195  * Allocate a handle for mapping from kva/uva/physical
    196  * address space into bus device space.
    197  */
    198 int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
    199 
    200 /*
    201  * Destroy a handle for mapping from kva/uva/physical
    202  * address space into bus device space.
    203  */
    204 int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
    205 
    206 /*
    207  * Allocate a piece of memory that can be efficiently mapped into
    208  * bus device space based on the constraints listed in the dma tag.
    209  * A dmamap to for use with dmamap_load is also allocated.
    210  */
    211 int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
    212              bus_dmamap_t *mapp);
    213 
    214 /*
    215  * Free a piece of memory and its allocated dmamap, that was allocated
    216  * via bus_dmamem_alloc.
    217  */
    218 void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
    219 
    220 /*
    221  * Map the buffer buf into bus space using the dmamap map.
    222  */
    223 int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
    224             bus_size_t buflen, bus_dmamap_callback_t *callback,
    225             void *callback_arg, int flags);
    226 
    227 /*
    228  * Like bus_dmamap_load but for mbufs.  Note the use of the
    229  * bus_dmamap_callback2_t interface.
    230  */
    231 int bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map,
    232              struct mbuf *mbuf,
    233              bus_dmamap_callback2_t *callback, void *callback_arg,
    234              int flags);
    235 
    236 int bus_dmamap_load_mbuf_sg(bus_dma_tag_t dmat, bus_dmamap_t map,
    237                 struct mbuf *mbuf, bus_dma_segment_t *segs,
    238                 int *nsegs, int flags);
    239 
    240 /*
    241  * Like bus_dmamap_load but for uios.  Note the use of the
    242  * bus_dmamap_callback2_t interface.
    243  */
    244 int bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map,
    245             struct uio *ui,
    246             bus_dmamap_callback2_t *callback, void *callback_arg,
    247             int flags);
    248 
    249 /*
    250  * Perform a synchronization operation on the given map.
    251  */
    252 void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
    253 #define bus_dmamap_sync(dmat, dmamap, op)           \
    254     do {                            \
    255         if ((dmamap) != NULL)               \
    256             _bus_dmamap_sync(dmat, dmamap, op); \
    257     } while (0)
    258 
    259 /*
    260  * Release the mapping held by map.
    261  */
    262 void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
    263 #define bus_dmamap_unload(dmat, dmamap)             \
    264     do {                            \
    265         if ((dmamap) != NULL)               \
    266             _bus_dmamap_unload(dmat, dmamap);   \
    267     } while (0)
    268 
    269 #endif /* __sparc64__ */
    270 
    271 #endif /* _BUS_DMA_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/callout.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/callout.h b/src/libs/compat/freebsd_network/compat/sys/callout.h
    deleted file mode 100644
    index 9d4da3b..0000000
    + -  
    1 /*
    2  * Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
    3  * Copyright 2009, Colin Günther, coling@gmx.de.
    4  * Copyright 2007, Hugo Santos. All Rights Reserved.
    5  * Distributed under the terms of the MIT License.
    6  */
    7 #ifndef _FBSD_COMPAT_SYS_CALLOUT_H_
    8 #define _FBSD_COMPAT_SYS_CALLOUT_H_
    9 
    10 
    11 #include <sys/haiku-module.h>
    12 
    13 #include <sys/queue.h>
    14 
    15 
    16 struct callout {
    17     struct list_link    link;
    18     bigtime_t           due;
    19     uint32              flags;
    20 
    21     void *              c_arg;
    22     void                (*c_func)(void *);
    23     struct mtx *        c_mtx;
    24     int                 c_flags;
    25 };
    26 
    27 
    28 #define CALLOUT_MPSAFE  0x0001
    29 
    30 
    31 void callout_init(struct callout *c, int mpsafe);
    32 void callout_init_mtx(struct callout *c, struct mtx *mutex, int flags);
    33 /* Time values are in ticks, see compat/sys/kernel.h for its definition */
    34 int callout_schedule(struct callout *c, int ticks);
    35 int callout_reset(struct callout *c, int ticks, void (*func)(void *), void *arg);
    36 int callout_pending(struct callout *c);
    37 int callout_active(struct callout *c);
    38 
    39 #define callout_drain(c)    _callout_stop_safe(c, 1)
    40 #define callout_stop(c)     _callout_stop_safe(c, 0)
    41 int _callout_stop_safe(struct callout *c, int safe);
    42 
    43 
    44 
    45 #endif  /* _FBSD_COMPAT_SYS_CALLOUT_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/cdefs.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/cdefs.h b/src/libs/compat/freebsd_network/compat/sys/cdefs.h
    deleted file mode 100644
    index f971269..0000000
    + -  
    1 /*-
    2  * Copyright (c) 1991, 1993
    3  *  The Regents of the University of California.  All rights reserved.
    4  *
    5  * This code is derived from software contributed to Berkeley by
    6  * Berkeley Software Design, Inc.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
    10  * are met:
    11  * 1. Redistributions of source code must retain the above copyright
    12  *    notice, this list of conditions and the following disclaimer.
    13  * 2. Redistributions in binary form must reproduce the above copyright
    14  *    notice, this list of conditions and the following disclaimer in the
    15  *    documentation and/or other materials provided with the distribution.
    16  * 4. Neither the name of the University nor the names of its contributors
    17  *    may be used to endorse or promote products derived from this software
    18  *    without specific prior written permission.
    19  *
    20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    30  * SUCH DAMAGE.
    31  *
    32  *  @(#)cdefs.h 8.8 (Berkeley) 1/9/95
    33  * $FreeBSD$
    34  */
    35 #ifndef _FBSD_COMPAT_SYS_CDEFS_H_
    36 #define _FBSD_COMPAT_SYS_CDEFS_H_
    37 
    38 
    39 #include <posix/sys/cdefs.h>
    40 
    41 
    42 #define __FBSDID(str)   static const char __fbsdid[] = str
    43 
    44 /*
    45  * This code has been put in place to help reduce the addition of
    46  * compiler specific defines in FreeBSD code.  It helps to aid in
    47  * having a compiler-agnostic source tree.
    48  */
    49 
    50 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
    51 
    52 #if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
    53 #define __GNUCLIKE_ASM 3
    54 #define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
    55 #else
    56 #define __GNUCLIKE_ASM 2
    57 #endif
    58 #define __GNUCLIKE___TYPEOF 1
    59 #define __GNUCLIKE___OFFSETOF 1
    60 #define __GNUCLIKE___SECTION 1
    61 
    62 #define __GNUCLIKE_ATTRIBUTE_MODE_DI 1
    63 
    64 #ifndef __INTEL_COMPILER
    65 # define __GNUCLIKE_CTOR_SECTION_HANDLING 1
    66 #endif
    67 
    68 #define __GNUCLIKE_BUILTIN_CONSTANT_P 1
    69 # if defined(__INTEL_COMPILER) && defined(__cplusplus) \
    70     && __INTEL_COMPILER < 800
    71 #  undef __GNUCLIKE_BUILTIN_CONSTANT_P
    72 # endif
    73 
    74 #if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
    75 # define __GNUCLIKE_BUILTIN_VARARGS 1
    76 # define __GNUCLIKE_BUILTIN_STDARG 1
    77 # define __GNUCLIKE_BUILTIN_VAALIST 1
    78 #endif
    79 
    80 #if defined(__GNUC__)
    81 # define __GNUC_VA_LIST_COMPATIBILITY 1
    82 #endif
    83 
    84 #ifndef __INTEL_COMPILER
    85 # define __GNUCLIKE_BUILTIN_NEXT_ARG 1
    86 # define __GNUCLIKE_MATH_BUILTIN_RELOPS
    87 #endif
    88 
    89 #define __GNUCLIKE_BUILTIN_MEMCPY 1
    90 
    91 /* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
    92 #define __CC_SUPPORTS_INLINE 1
    93 #define __CC_SUPPORTS___INLINE 1
    94 #define __CC_SUPPORTS___INLINE__ 1
    95 
    96 #define __CC_SUPPORTS___FUNC__ 1
    97 #define __CC_SUPPORTS_WARNING 1
    98 
    99 #define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
    100 
    101 #define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
    102 
    103 #endif /* __GNUC__ || __INTEL_COMPILER */
    104 
    105 
    106 /*
    107  * Macro to test if we're using a specific version of gcc or later.
    108  */
    109 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
    110 #define __GNUC_PREREQ__(ma, mi) \
    111     (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
    112 #else
    113 #define __GNUC_PREREQ__(ma, mi) 0
    114 #endif
    115 
    116 /*
    117  * GNU C version 2.96 adds explicit branch prediction so that
    118  * the CPU back-end can hint the processor and also so that
    119  * code blocks can be reordered such that the predicted path
    120  * sees a more linear flow, thus improving cache behavior, etc.
    121  *
    122  * The following two macros provide us with a way to utilize this
    123  * compiler feature.  Use __predict_true() if you expect the expression
    124  * to evaluate to true, and __predict_false() if you expect the
    125  * expression to evaluate to false.
    126  *
    127  * A few notes about usage:
    128  *
    129  *  * Generally, __predict_false() error condition checks (unless
    130  *    you have some _strong_ reason to do otherwise, in which case
    131  *    document it), and/or __predict_true() `no-error' condition
    132  *    checks, assuming you want to optimize for the no-error case.
    133  *
    134  *  * Other than that, if you don't know the likelihood of a test
    135  *    succeeding from empirical or other `hard' evidence, don't
    136  *    make predictions.
    137  *
    138  *  * These are meant to be used in places that are run `a lot'.
    139  *    It is wasteful to make predictions in code that is run
    140  *    seldomly (e.g. at subsystem initialization time) as the
    141  *    basic block reordering that this affects can often generate
    142  *    larger code.
    143  */
    144 #if __GNUC_PREREQ__(2, 96)
    145 #define __predict_true(exp)     __builtin_expect((exp), 1)
    146 #define __predict_false(exp)    __builtin_expect((exp), 0)
    147 #else
    148 #define __predict_true(exp)     (exp)
    149 #define __predict_false(exp)    (exp)
    150 #endif
    151 
    152 /*
    153  * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
    154  * require it.
    155  */
    156 #if __GNUC_PREREQ__(4, 1)
    157 #define __offsetof(type, field)  __builtin_offsetof(type, field)
    158 #else
    159 #ifndef __cplusplus
    160 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
    161 #else
    162 #define __offsetof(type, field)                 \
    163   (__offsetof__ (reinterpret_cast <size_t>          \
    164                  (&reinterpret_cast <const volatile char &> \
    165                   (static_cast<type *> (0)->field))))
    166 #endif
    167 #endif
    168 #define __rangeof(type, start, end) \
    169     (__offsetof(type, end) - __offsetof(type, start))
    170 
    171 /*
    172  * Compiler-dependent macros to help declare dead (non-returning) and
    173  * pure (no side effects) functions, and unused variables.  They are
    174  * null except for versions of gcc that are known to support the features
    175  * properly (old versions of gcc-2 supported the dead and pure features
    176  * in a different (wrong) way).  If we do not provide an implementation
    177  * for a given compiler, let the compile fail if it is told to use
    178  * a feature that we cannot live without.
    179  */
    180 #ifdef lint
    181 #define __pure2
    182 #define __unused
    183 #define __packed
    184 #define __aligned(x)
    185 #define __section(x)
    186 #else
    187 #if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
    188 #define __pure2
    189 #define __unused
    190 #endif
    191 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
    192 #define __pure2     __attribute__((__const__))
    193 #define __unused
    194 /* XXX Find out what to do for __packed, __aligned and __section */
    195 #endif
    196 #if __GNUC_PREREQ__(2, 7)
    197 #define __pure2     __attribute__((__const__))
    198 #define __unused    __attribute__((__unused__))
    199 #define __packed    __attribute__((__packed__))
    200 #define __aligned(x)    __attribute__((__aligned__(x)))
    201 #define __section(x)    __attribute__((__section__(x)))
    202 #endif
    203 
    204 #if __GNUC_PREREQ__(3, 1)
    205 #define __used      __attribute__((__used__))
    206 #else
    207 #if __GNUC_PREREQ__(2, 7)
    208 #define __used
    209 #endif
    210 #endif
    211 
    212 #if defined(__INTEL_COMPILER)
    213 #define __pure2     __attribute__((__const__))
    214 #define __unused    __attribute__((__unused__))
    215 #define __used      __attribute__((__used__))
    216 #define __packed    __attribute__((__packed__))
    217 #define __aligned(x)    __attribute__((__aligned__(x)))
    218 #define __section(x)    __attribute__((__section__(x)))
    219 #endif
    220 #endif
    221 
    222 /*
    223  * Compiler-dependent macros to declare that functions take printf-like
    224  * or scanf-like arguments.  They are null except for versions of gcc
    225  * that are known to support the features properly (old versions of gcc-2
    226  * didn't permit keeping the keywords out of the application namespace).
    227  */
    228 #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
    229 #define __printflike(fmtarg, firstvararg)
    230 #define __scanflike(fmtarg, firstvararg)
    231 #define __format_arg(fmtarg)
    232 #else
    233 #define __printflike(fmtarg, firstvararg) \
    234         __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
    235 #define __scanflike(fmtarg, firstvararg) \
    236         __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
    237 #define __format_arg(fmtarg)    __attribute__((__format_arg__ (fmtarg)))
    238 #endif
    239 
    240 #if __GNUC_PREREQ__(3, 1)
    241 #define __noinline  __attribute__ ((__noinline__))
    242 #else
    243 #define __noinline
    244 #endif
    245 
    246 #if __GNUC_PREREQ__(3, 3)
    247 #define __nonnull(x)    __attribute__((__nonnull__(x)))
    248 #else
    249 #define __nonnull(x)
    250 #endif
    251 
    252 /*
    253  * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
    254  * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
    255  * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
    256  * mode -- there must be no spaces between its arguments, and for nested
    257  * __CONCAT's, all the __CONCAT's must be at the left.  __CONCAT can also
    258  * concatenate double-quoted strings produced by the __STRING macro, but
    259  * this only works with ANSI C.
    260  *
    261  * __XSTRING is like __STRING, but it expands any macros in its argument
    262  * first.  It is only available with ANSI C.
    263  */
    264 #if defined(__STDC__) || defined(__cplusplus)
    265 #define __XSTRING(x)    __STRING(x) /* expand x, then stringify */
    266 
    267 #define __const     const       /* define reserved names to standard */
    268 #define __signed    signed
    269 #define __volatile  volatile
    270 #if defined(__cplusplus)
    271 #define __inline    inline      /* convert to C++ keyword */
    272 #else
    273 #if !(defined(__CC_SUPPORTS___INLINE))
    274 #define __inline            /* delete GCC keyword */
    275 #endif /* ! __CC_SUPPORTS___INLINE */
    276 #endif /* !__cplusplus */
    277 
    278 #else   /* !(__STDC__ || __cplusplus) */
    279 
    280 #if !defined(__CC_SUPPORTS___INLINE)
    281 #define __const             /* delete pseudo-ANSI C keywords */
    282 #define __inline
    283 #define __signed
    284 #define __volatile
    285 /*
    286  * In non-ANSI C environments, new programs will want ANSI-only C keywords
    287  * deleted from the program and old programs will want them left alone.
    288  * When using a compiler other than gcc, programs using the ANSI C keywords
    289  * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
    290  * When using "gcc -traditional", we assume that this is the intent; if
    291  * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
    292  */
    293 #ifndef NO_ANSI_KEYWORDS
    294 #define const               /* delete ANSI C keywords */
    295 #define inline
    296 #define signed
    297 #define volatile
    298 #endif  /* !NO_ANSI_KEYWORDS */
    299 #endif  /* !__CC_SUPPORTS___INLINE */
    300 #endif  /* !(__STDC__ || __cplusplus) */
    301 
    302 #ifndef __DECONST
    303 #define __DECONST(type, var)    ((type)(uintptr_t)(const void *)(var))
    304 #endif
    305 
    306 #ifndef __UNCONST
    307 #define __UNCONST(var)  ((void*)(uintptr_t)(const void *)(var))
    308 #endif
    309 
    310 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/condvar.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/condvar.h b/src/libs/compat/freebsd_network/compat/sys/condvar.h
    deleted file mode 100644
    index 55b96a8..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * All rights reserved. Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_CONDVAR_H_
    6 #define _FBSD_COMPAT_SYS_CONDVAR_H_
    7 
    8 
    9 #include <sys/queue.h>
    10 
    11 #ifdef __cplusplus
    12 } /* extern "C" */
    13 #include <kernel_c++_structs.h>
    14 extern "C" {
    15 #else
    16 #include <kernel_c++_structs.h>
    17 #endif
    18 
    19 
    20 struct cv {
    21     struct ConditionVariable condition;
    22 };
    23 
    24 
    25 void cv_init(struct cv*, const char*);
    26 void cv_destroy(struct cv*);
    27 void cv_wait(struct cv*, struct mtx*);
    28 int cv_timedwait(struct cv*, struct mtx*, int);
    29 void cv_signal(struct cv*);
    30 
    31 #endif /* _FBSD_COMPAT_SYS_CONDVAR_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/ctype.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/ctype.h b/src/libs/compat/freebsd_network/compat/sys/ctype.h
    deleted file mode 100644
    index 60cc664..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_CTYPE_H_
    6 #define _FBSD_COMPAT_SYS_CTYPE_H_
    7 
    8 
    9 #define isprint(c) ((c) >= ' ' && (c) <= '~')
    10 
    11 #endif /* _FBSD_COMPAT_SYS_CTYPE_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/endian.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/endian.h b/src/libs/compat/freebsd_network/compat/sys/endian.h
    deleted file mode 100644
    index 6261634..0000000
    + -  
    1 /*-
    2  * Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
    10  * 2. Redistributions in binary form must reproduce the above copyright
    11  *    notice, this list of conditions and the following disclaimer in the
    12  *    documentation and/or other materials provided with the distribution.
    13  *
    14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
    15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    24  * SUCH DAMAGE.
    25  *
    26  * $FreeBSD: src/sys/sys/endian.h,v 1.6 2003/10/15 20:05:57 obrien Exp $
    27  */
    28 #ifndef _FBSD_COMPAT_SYS_ENDIAN_H_
    29 #define _FBSD_COMPAT_SYS_ENDIAN_H_
    30 
    31 #include <stdint.h>
    32 #include <posix/endian.h>
    33 
    34 #include <support/ByteOrder.h>
    35 
    36 #include <sys/cdefs.h>
    37 #include <sys/_types.h>
    38 #include <machine/endian.h>
    39 
    40 #define _BYTE_ORDER     BYTE_ORDER
    41 #define _LITTLE_ENDIAN  LITTLE_ENDIAN
    42 #define _BIG_ENDIAN     BIG_ENDIAN
    43 
    44 #define __bswap16(x)    __swap_int16(x)
    45 #define __bswap32(x)    __swap_int32(x)
    46 #define __bswap64(x)    __swap_int64(x)
    47 
    48 /*
    49  * General byte order swapping functions.
    50  */
    51 #define bswap16(x)  __bswap16(x)
    52 #define bswap32(x)  __bswap32(x)
    53 #define bswap64(x)  __bswap64(x)
    54 
    55 /*
    56  * Host to big endian, host to little endian, big endian to host, and little
    57  * endian to host byte order functions as detailed in byteorder(9).
    58  */
    59 #if _BYTE_ORDER == _LITTLE_ENDIAN
    60 #define htobe16(x)  bswap16((x))
    61 #define htobe32(x)  bswap32((x))
    62 #define htobe64(x)  bswap64((x))
    63 #define htole16(x)  ((uint16_t)(x))
    64 #define htole32(x)  ((uint32_t)(x))
    65 #define htole64(x)  ((uint64_t)(x))
    66 
    67 #define be16toh(x)  bswap16((x))
    68 #define be32toh(x)  bswap32((x))
    69 #define be64toh(x)  bswap64((x))
    70 #define le16toh(x)  ((uint16_t)(x))
    71 #define le32toh(x)  ((uint32_t)(x))
    72 #define le64toh(x)  ((uint64_t)(x))
    73 #else /* _BYTE_ORDER != _LITTLE_ENDIAN */
    74 #define htobe16(x)  ((uint16_t)(x))
    75 #define htobe32(x)  ((uint32_t)(x))
    76 #define htobe64(x)  ((uint64_t)(x))
    77 #define htole16(x)  bswap16((x))
    78 #define htole32(x)  bswap32((x))
    79 #define htole64(x)  bswap64((x))
    80 
    81 #define be16toh(x)  ((uint16_t)(x))
    82 #define be32toh(x)  ((uint32_t)(x))
    83 #define be64toh(x)  ((uint64_t)(x))
    84 #define le16toh(x)  bswap16((x))
    85 #define le32toh(x)  bswap32((x))
    86 #define le64toh(x)  bswap64((x))
    87 #endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
    88 
    89 /* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
    90 
    91 static __inline uint16_t
    92 be16dec(const void *pp)
    93 {
    94     unsigned char const *p = (unsigned char const *)pp;
    95 
    96     return ((p[0] << 8) | p[1]);
    97 }
    98 
    99 static __inline uint32_t
    100 be32dec(const void *pp)
    101 {
    102     unsigned char const *p = (unsigned char const *)pp;
    103 
    104     return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
    105 }
    106 
    107 static __inline uint64_t
    108 be64dec(const void *pp)
    109 {
    110     unsigned char const *p = (unsigned char const *)pp;
    111 
    112     return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
    113 }
    114 
    115 static __inline uint16_t
    116 le16dec(const void *pp)
    117 {
    118     unsigned char const *p = (unsigned char const *)pp;
    119 
    120     return ((p[1] << 8) | p[0]);
    121 }
    122 
    123 static __inline uint32_t
    124 le32dec(const void *pp)
    125 {
    126     unsigned char const *p = (unsigned char const *)pp;
    127 
    128     return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
    129 }
    130 
    131 static __inline uint64_t
    132 le64dec(const void *pp)
    133 {
    134     unsigned char const *p = (unsigned char const *)pp;
    135 
    136     return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
    137 }
    138 
    139 static __inline void
    140 be16enc(void *pp, uint16_t u)
    141 {
    142     unsigned char *p = (unsigned char *)pp;
    143 
    144     p[0] = (u >> 8) & 0xff;
    145     p[1] = u & 0xff;
    146 }
    147 
    148 static __inline void
    149 be32enc(void *pp, uint32_t u)
    150 {
    151     unsigned char *p = (unsigned char *)pp;
    152 
    153     p[0] = (u >> 24) & 0xff;
    154     p[1] = (u >> 16) & 0xff;
    155     p[2] = (u >> 8) & 0xff;
    156     p[3] = u & 0xff;
    157 }
    158 
    159 static __inline void
    160 be64enc(void *pp, uint64_t u)
    161 {
    162     unsigned char *p = (unsigned char *)pp;
    163 
    164     be32enc(p, u >> 32);
    165     be32enc(p + 4, u & 0xffffffff);
    166 }
    167 
    168 static __inline void
    169 le16enc(void *pp, uint16_t u)
    170 {
    171     unsigned char *p = (unsigned char *)pp;
    172 
    173     p[0] = u & 0xff;
    174     p[1] = (u >> 8) & 0xff;
    175 }
    176 
    177 static __inline void
    178 le32enc(void *pp, uint32_t u)
    179 {
    180     unsigned char *p = (unsigned char *)pp;
    181 
    182     p[0] = u & 0xff;
    183     p[1] = (u >> 8) & 0xff;
    184     p[2] = (u >> 16) & 0xff;
    185     p[3] = (u >> 24) & 0xff;
    186 }
    187 
    188 static __inline void
    189 le64enc(void *pp, uint64_t u)
    190 {
    191     unsigned char *p = (unsigned char *)pp;
    192 
    193     le32enc(p, u & 0xffffffff);
    194     le32enc(p + 4, u >> 32);
    195 }
    196 
    197 #endif  /* _SYS_ENDIAN_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/errno.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/errno.h b/src/libs/compat/freebsd_network/compat/sys/errno.h
    deleted file mode 100644
    index fd307ce..0000000
    + -  
    1 /*
    2  * Copyright 2007 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_ERRNO_H_
    6 #define _FBSD_COMPAT_SYS_ERRNO_H_
    7 
    8 
    9 #include <posix/errno.h>
    10 
    11 
    12 /* pseudo-errors returned inside freebsd compat layer to modify return to process */
    13 #define ERESTART        (B_ERRORS_END + 1)      /* restart syscall */
    14 #define EJUSTRETURN     (B_ERRORS_END + 2)      /* don't modify regs, just return */
    15 
    16 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/event.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/event.h b/src/libs/compat/freebsd_network/compat/sys/event.h
    deleted file mode 100644
    index 642f49c..0000000
    + -  
    1 /*
    2  * Copyright 2007 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_EVENT_H_
    6 #define _FBSD_COMPAT_SYS_EVENT_H_
    7 
    8 
    9 struct knlist {
    10     int _dummy;
    11 };
    12 
    13 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/eventhandler.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/eventhandler.h b/src/libs/compat/freebsd_network/compat/sys/eventhandler.h
    deleted file mode 100644
    index 9a53c98..0000000
    + -  
    1 /*-
    2  * Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
    10  * 2. Redistributions in binary form must reproduce the above copyright
    11  *    notice, this list of conditions and the following disclaimer in the
    12  *    documentation and/or other materials provided with the distribution.
    13  *
    14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
    15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    24  * SUCH DAMAGE.
    25  *
    26  * $FreeBSD: src/sys/sys/eventhandler.h,v 1.33.2.1 2006/05/16 07:27:49 ps Exp $
    27  */
    28 #ifndef SYS_EVENTHANDLER_H
    29 #define SYS_EVENTHANDLER_H
    30 
    31 #include <sys/lock.h>
    32 #include <sys/ktr.h>
    33 #include <sys/mutex.h>
    34 #include <sys/queue.h>
    35 
    36 struct eventhandler_entry {
    37     TAILQ_ENTRY(eventhandler_entry) ee_link;
    38     int             ee_priority;
    39 #define EHE_DEAD_PRIORITY   (-1)
    40     void                *ee_arg;
    41 };
    42 
    43 struct eventhandler_list {
    44     char                *el_name;
    45     int             el_flags;
    46 #define EHL_INITTED (1<<0)
    47     u_int               el_runcount;
    48     struct mtx          el_lock;
    49     TAILQ_ENTRY(eventhandler_list)  el_link;
    50     TAILQ_HEAD(,eventhandler_entry) el_entries;
    51 };
    52 
    53 typedef struct eventhandler_entry   *eventhandler_tag;
    54 
    55 #define EHL_LOCK(p)     mtx_lock(&(p)->el_lock)
    56 #define EHL_UNLOCK(p)       mtx_unlock(&(p)->el_lock)
    57 #define EHL_LOCK_ASSERT(p, x)   mtx_assert(&(p)->el_lock, x)
    58 
    59 /*
    60  * Macro to invoke the handlers for a given event.
    61  */
    62 #define _EVENTHANDLER_INVOKE(name, list, ...) do {          \
    63     struct eventhandler_entry *_ep;                 \
    64     struct eventhandler_entry_ ## name *_t;             \
    65                                     \
    66     KASSERT((list)->el_flags & EHL_INITTED,             \
    67        ("eventhandler_invoke: running non-inited list"));       \
    68     EHL_LOCK_ASSERT((list), MA_OWNED);              \
    69     (list)->el_runcount++;                      \
    70     KASSERT((list)->el_runcount > 0,                \
    71         ("eventhandler_invoke: runcount overflow"));        \
    72     CTR0(KTR_EVH, "eventhandler_invoke(\"" __STRING(name) "\")");   \
    73     TAILQ_FOREACH(_ep, &((list)->el_entries), ee_link) {        \
    74         if (_ep->ee_priority != EHE_DEAD_PRIORITY) {        \
    75             EHL_UNLOCK((list));             \
    76             _t = (struct eventhandler_entry_ ## name *)_ep; \
    77             CTR1(KTR_EVH, "eventhandler_invoke: executing %p", \
    78                 (void *)_t->eh_func);           \
    79             _t->eh_func(_ep->ee_arg , ## __VA_ARGS__);  \
    80             EHL_LOCK((list));               \
    81         }                           \
    82     }                               \
    83     KASSERT((list)->el_runcount > 0,                \
    84         ("eventhandler_invoke: runcount underflow"));       \
    85     (list)->el_runcount--;                      \
    86     if ((list)->el_runcount == 0)                   \
    87         eventhandler_prune_list(list);              \
    88     EHL_UNLOCK((list));                     \
    89 } while (0)
    90 
    91 /*
    92  * Slow handlers are entirely dynamic; lists are created
    93  * when entries are added to them, and thus have no concept of "owner",
    94  *
    95  * Slow handlers need to be declared, but do not need to be defined. The
    96  * declaration must be in scope wherever the handler is to be invoked.
    97  */
    98 #define EVENTHANDLER_DECLARE(name, type)                \
    99 struct eventhandler_entry_ ## name                  \
    100 {                                   \
    101     struct eventhandler_entry   ee;             \
    102     type                eh_func;            \
    103 };                                  \
    104 struct __hack
    105 
    106 #define EVENTHANDLER_INVOKE(name, ...)                  \
    107 do {                                    \
    108     struct eventhandler_list *_el;                  \
    109                                     \
    110     if ((_el = eventhandler_find_list(#name)) != NULL)      \
    111         _EVENTHANDLER_INVOKE(name, _el , ## __VA_ARGS__);   \
    112 } while (0)
    113 
    114 #define EVENTHANDLER_REGISTER(name, func, arg, priority)        \
    115     eventhandler_register(NULL, #name, func, arg, priority)
    116 
    117 #define EVENTHANDLER_DEREGISTER(name, tag)              \
    118 do {                                    \
    119     struct eventhandler_list *_el;                  \
    120                                     \
    121     if ((_el = eventhandler_find_list(#name)) != NULL)      \
    122         eventhandler_deregister(_el, tag);          \
    123 } while(0)
    124    
    125 
    126 eventhandler_tag eventhandler_register(struct eventhandler_list *list,
    127         const char *name, void *func, void *arg, int priority);
    128 void    eventhandler_deregister(struct eventhandler_list *list,
    129         eventhandler_tag tag);
    130 struct eventhandler_list *eventhandler_find_list(const char *name);
    131 void    eventhandler_prune_list(struct eventhandler_list *list);
    132 
    133 /*
    134  * Standard system event queues.
    135  */
    136 
    137 /* Generic priority levels */
    138 #define EVENTHANDLER_PRI_FIRST  0
    139 #define EVENTHANDLER_PRI_ANY    10000
    140 #define EVENTHANDLER_PRI_LAST   20000
    141 
    142 /* Shutdown events */
    143 typedef void (*shutdown_fn)(void *, int);
    144 
    145 #define SHUTDOWN_PRI_FIRST  EVENTHANDLER_PRI_FIRST
    146 #define SHUTDOWN_PRI_DEFAULT    EVENTHANDLER_PRI_ANY
    147 #define SHUTDOWN_PRI_LAST   EVENTHANDLER_PRI_LAST
    148 
    149 EVENTHANDLER_DECLARE(shutdown_pre_sync, shutdown_fn);   /* before fs sync */
    150 EVENTHANDLER_DECLARE(shutdown_post_sync, shutdown_fn);  /* after fs sync */
    151 EVENTHANDLER_DECLARE(shutdown_final, shutdown_fn);
    152 
    153 /* Low memory event */
    154 typedef void (*vm_lowmem_handler_t)(void *, int);
    155 #define LOWMEM_PRI_DEFAULT  EVENTHANDLER_PRI_FIRST
    156 EVENTHANDLER_DECLARE(vm_lowmem, vm_lowmem_handler_t);
    157 
    158 /*
    159  * Process events
    160  * process_fork and exit handlers are called without Giant.
    161  * exec handlers are called with Giant, but that is by accident.
    162  */
    163 struct proc;
    164 
    165 typedef void (*exitlist_fn)(void *, struct proc *);
    166 typedef void (*forklist_fn)(void *, struct proc *, struct proc *, int);
    167 typedef void (*execlist_fn)(void *, struct proc *);
    168 
    169 EVENTHANDLER_DECLARE(process_exit, exitlist_fn);
    170 EVENTHANDLER_DECLARE(process_fork, forklist_fn);
    171 EVENTHANDLER_DECLARE(process_exec, execlist_fn);
    172 
    173 typedef void (*uma_zone_chfn)(void *);
    174 EVENTHANDLER_DECLARE(nmbclusters_change, uma_zone_chfn);
    175 EVENTHANDLER_DECLARE(maxsockets_change, uma_zone_chfn);
    176 #endif /* SYS_EVENTHANDLER_H */
  • deleted file src/libs/compat/freebsd_network/compat/sys/firmware.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/firmware.h b/src/libs/compat/freebsd_network/compat/sys/firmware.h
    deleted file mode 100644
    index bfc52b2..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_FIRMWARE_H_
    6 #define _FBSD_COMPAT_SYS_FIRMWARE_H_
    7 
    8 
    9 #define FIRMWARE_UNLOAD 0x0001
    10 
    11 
    12 struct firmware {
    13     const char*     name;       // system-wide name
    14     const void*     data;       // location of image
    15     size_t          datasize;   // size of image in bytes
    16     unsigned int    version;    // version of the image
    17 };
    18 
    19 
    20 const struct firmware* firmware_get(const char*);
    21 void firmware_put(const struct firmware*, int);
    22 
    23 #endif /* _FBSD_COMPAT_SYS_FIRMWARE_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/haiku-module.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/haiku-module.h b/src/libs/compat/freebsd_network/compat/sys/haiku-module.h
    deleted file mode 100644
    index 26e07bb..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther. All Rights Reserved.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 #ifndef _FBSD_COMPAT_SYS_HAIKU_MODULE_H_
    7 #define _FBSD_COMPAT_SYS_HAIKU_MODULE_H_
    8 
    9 
    10 #include <Drivers.h>
    11 #include <KernelExport.h>
    12 
    13 #include <kernel/lock.h>
    14 #include <net_stack.h>
    15 
    16 
    17 #undef ASSERT
    18     /* private/kernel/debug.h sets it */
    19 
    20 typedef struct device *device_t;
    21 typedef struct devclass *devclass_t;
    22 
    23 typedef int (*device_method_signature_t)(device_t dev);
    24 
    25 typedef int device_probe_t(device_t dev);
    26 typedef int device_attach_t(device_t dev);
    27 typedef int device_detach_t(device_t dev);
    28 typedef int device_resume_t(device_t dev);
    29 typedef int device_suspend_t(device_t dev);
    30 
    31 struct device_method {
    32     const char *name;
    33     device_method_signature_t method;
    34 };
    35 
    36 typedef struct device_method device_method_t;
    37 
    38 #define DEVMETHOD(name, func)   { #name, (device_method_signature_t)&func }
    39 #define DEVMETHOD_END   { 0, 0 }
    40 
    41 typedef struct {
    42     const char *name;
    43     device_method_t *methods;
    44     size_t softc_size;
    45 } driver_t;
    46 
    47 #define DRIVER_MODULE_NAME(name, busname) \
    48     __fbsd_ ## name ## _ ## busname
    49 
    50 status_t _fbsd_init_hardware(driver_t *driver[]);
    51 status_t _fbsd_init_drivers(driver_t *driver[]);
    52 status_t _fbsd_uninit_drivers(driver_t *driver[]);
    53 
    54 extern const char *gDriverName;
    55 driver_t *__haiku_select_miibus_driver(device_t dev);
    56 driver_t *__haiku_probe_miibus(device_t dev, driver_t *drivers[]);
    57 status_t __haiku_handle_fbsd_drivers_list(status_t (*handler)(driver_t *[]));
    58 
    59 status_t init_wlan_stack(void);
    60 void uninit_wlan_stack(void);
    61 status_t start_wlan(device_t);
    62 status_t stop_wlan(device_t);
    63 status_t wlan_control(void*, uint32, void*, size_t);
    64 status_t wlan_close(void*);
    65 status_t wlan_if_l2com_alloc(void*);
    66 
    67 /* we define the driver methods with HAIKU_FBSD_DRIVERS_GLUE to
    68  * force the rest of the stuff to be linked back with the driver.
    69  * While gcc 2.95 packs everything from the static library onto
    70  * the final binary, gcc 4.x rightfuly doesn't. */
    71 
    72 #define HAIKU_FBSD_DRIVERS_GLUE(publicname)                             \
    73     extern const char *gDeviceNameList[];                               \
    74     extern device_hooks gDeviceHooks;                                   \
    75     const char *gDriverName = #publicname;                              \
    76     int32 api_version = B_CUR_DRIVER_API_VERSION;                       \
    77     status_t init_hardware()                                            \
    78     {                                                                   \
    79         return __haiku_handle_fbsd_drivers_list(_fbsd_init_hardware);   \
    80     }                                                                   \
    81     status_t init_driver()                                              \
    82     {                                                                   \
    83         return __haiku_handle_fbsd_drivers_list(_fbsd_init_drivers);    \
    84     }                                                                   \
    85     void uninit_driver()                                                \
    86     {                                                                   \
    87         __haiku_handle_fbsd_drivers_list(_fbsd_uninit_drivers);         \
    88     }                                                                   \
    89     const char **publish_devices()                                      \
    90         { return gDeviceNameList; }                                     \
    91     device_hooks *find_device(const char *name)                         \
    92         { return &gDeviceHooks; }                                       \
    93     status_t init_wlan_stack(void)                                      \
    94         { return B_OK; }                                                \
    95     void uninit_wlan_stack(void) {}                                     \
    96     status_t start_wlan(device_t dev)                                   \
    97         { return B_OK; }                                                \
    98     status_t stop_wlan(device_t dev)                                    \
    99         { return B_OK; }                                                \
    100     status_t wlan_control(void *cookie, uint32 op, void *arg,           \
    101         size_t length)                                                  \
    102         { return B_BAD_VALUE; }                                         \
    103     status_t wlan_close(void* cookie)                                   \
    104         { return B_OK; }                                                \
    105     status_t wlan_if_l2com_alloc(void* ifp)                             \
    106         { return B_OK; }
    107 
    108 #define HAIKU_FBSD_DRIVER_GLUE(publicname, name, busname)               \
    109     extern driver_t *DRIVER_MODULE_NAME(name, busname);                 \
    110     status_t __haiku_handle_fbsd_drivers_list(status_t (*proc)(driver_t *[])) {\
    111         driver_t *drivers[] = {                                         \
    112             DRIVER_MODULE_NAME(name, busname),                          \
    113             NULL                                                        \
    114         };                                                              \
    115         return (*proc)(drivers);                                        \
    116     }                                                                   \
    117     HAIKU_FBSD_DRIVERS_GLUE(publicname);
    118 
    119 #define HAIKU_FBSD_WLAN_DRIVERS_GLUE(publicname)                        \
    120     extern const char *gDeviceNameList[];                               \
    121     extern device_hooks gDeviceHooks;                                   \
    122     const char *gDriverName = #publicname;                              \
    123     int32 api_version = B_CUR_DRIVER_API_VERSION;                       \
    124     status_t init_hardware()                                            \
    125     {                                                                   \
    126         return __haiku_handle_fbsd_drivers_list(_fbsd_init_hardware);   \
    127     }                                                                   \
    128     status_t init_driver()                                              \
    129     {                                                                   \
    130         return __haiku_handle_fbsd_drivers_list(_fbsd_init_drivers);    \
    131     }                                                                   \
    132     void uninit_driver()                                                \
    133     {                                                                   \
    134         __haiku_handle_fbsd_drivers_list(_fbsd_uninit_drivers);         \
    135     }                                                                   \
    136     const char **publish_devices()                                      \
    137         { return gDeviceNameList; }                                     \
    138     device_hooks *find_device(const char *name)                         \
    139         { return &gDeviceHooks; }
    140 
    141 #define HAIKU_FBSD_WLAN_DRIVER_GLUE(publicname, name, busname)          \
    142     extern driver_t *DRIVER_MODULE_NAME(name, busname);                 \
    143     status_t __haiku_handle_fbsd_drivers_list(status_t (*proc)(driver_t *[])) {\
    144         driver_t *drivers[] = {                                         \
    145             DRIVER_MODULE_NAME(name, busname),                          \
    146             NULL                                                        \
    147         };                                                              \
    148         return (*proc)(drivers);                                        \
    149     }                                                                   \
    150     HAIKU_FBSD_WLAN_DRIVERS_GLUE(publicname);
    151 
    152 #define HAIKU_FBSD_RETURN_MII_DRIVER(drivers)                   \
    153     driver_t *__haiku_select_miibus_driver(device_t dev)        \
    154     {                                                           \
    155         return __haiku_probe_miibus(dev, drivers);              \
    156     }
    157 
    158 #define HAIKU_FBSD_MII_DRIVER(name)                             \
    159     extern driver_t *DRIVER_MODULE_NAME(name, miibus);          \
    160     driver_t *__haiku_select_miibus_driver(device_t dev)        \
    161     {                                                           \
    162         driver_t *drivers[] = {                                 \
    163             DRIVER_MODULE_NAME(name, miibus),                   \
    164             NULL                                                \
    165         };                                                      \
    166         return __haiku_probe_miibus(dev, drivers);              \
    167     }
    168 
    169 #define NO_HAIKU_FBSD_MII_DRIVER()                              \
    170     HAIKU_FBSD_RETURN_MII_DRIVER(NULL)
    171 
    172 extern spinlock __haiku_intr_spinlock;
    173 extern int __haiku_disable_interrupts(device_t dev);
    174 extern void __haiku_reenable_interrupts(device_t dev);
    175 
    176 #define HAIKU_CHECK_DISABLE_INTERRUPTS      __haiku_disable_interrupts
    177 #define HAIKU_REENABLE_INTERRUPTS           __haiku_reenable_interrupts
    178 
    179 #define NO_HAIKU_CHECK_DISABLE_INTERRUPTS()             \
    180     int HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev) {  \
    181         panic("should never be called.");               \
    182         return -1; \
    183     }
    184 
    185 #define NO_HAIKU_REENABLE_INTERRUPTS() \
    186     void HAIKU_REENABLE_INTERRUPTS(device_t dev) {}
    187 
    188 extern int __haiku_driver_requirements;
    189 
    190 enum {
    191     FBSD_TASKQUEUES     = 1 << 0,
    192     FBSD_FAST_TASKQUEUE = 1 << 1,
    193     FBSD_SWI_TASKQUEUE  = 1 << 2,
    194     FBSD_WLAN           = 1 << 3,
    195 };
    196 
    197 #define HAIKU_DRIVER_REQUIREMENTS(flags) \
    198     int __haiku_driver_requirements = (flags)
    199 
    200 #define HAIKU_DRIVER_REQUIRES(flag) (__haiku_driver_requirements & (flag))
    201 
    202 
    203 /* #pragma mark - firmware loading */
    204 
    205 
    206 /*
    207  * Only needed to be specified in the glue code of drivers which actually need
    208  * to load firmware. See iprowifi2100 for an example.
    209  */
    210 
    211 extern const uint __haiku_firmware_version;
    212 
    213 /* Use 0 if driver doesn't care about firmware version. */
    214 #define HAIKU_FIRMWARE_VERSION(version) \
    215     const uint __haiku_firmware_version = (version)
    216 
    217 extern const uint __haiku_firmware_parts_count;
    218 extern const char* __haiku_firmware_name_map[][2];
    219 
    220 #define HAIKU_FIRMWARE_NAME_MAP(firmwarePartsCount) \
    221     const uint __haiku_firmware_parts_count = firmwarePartsCount; \
    222     const char* __haiku_firmware_name_map[firmwarePartsCount][2]
    223 
    224 #define NO_HAIKU_FIRMWARE_NAME_MAP() \
    225     const uint __haiku_firmware_parts_count = 0; \
    226     const char* __haiku_firmware_name_map[0][2] = {}
    227 
    228 
    229 /* #pragma mark - synchronization */
    230 
    231 
    232 #define HAIKU_INTR_REGISTER_STATE \
    233     cpu_status __haiku_cpu_state = 0
    234 
    235 #define HAIKU_INTR_REGISTER_ENTER() do {        \
    236     __haiku_cpu_state = disable_interrupts();   \
    237     acquire_spinlock(&__haiku_intr_spinlock);   \
    238 } while (0)
    239 
    240 #define HAIKU_INTR_REGISTER_LEAVE() do {        \
    241     release_spinlock(&__haiku_intr_spinlock);   \
    242     restore_interrupts(__haiku_cpu_state);      \
    243 } while (0)
    244 
    245 #define HAIKU_PROTECT_INTR_REGISTER(x) do {     \
    246     HAIKU_INTR_REGISTER_STATE;                  \
    247     HAIKU_INTR_REGISTER_ENTER();                \
    248     x;                                          \
    249     HAIKU_INTR_REGISTER_LEAVE();                \
    250 } while (0)
    251 
    252 #define DEFINE_CLASS_0(name, driver, methods, size) \
    253     driver_t driver = { #name, methods, size }
    254 
    255 #define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \
    256     driver_t *DRIVER_MODULE_NAME(name, busname) = &(driver); \
    257     devclass_t *__class_ ## name ## _ ## busname ## _ ## devclass = &(devclass)
    258 
    259 #define DRIVER_MODULE_ORDERED(name, busname, driver, devclass, evh, arg, order) \
    260     DRIVER_MODULE(name, busname, driver, devclass, evh, arg)
    261 
    262 #define nitems(_a)     (sizeof((_a)) / sizeof((_a)[0]))
    263 
    264 #endif  /* _FBSD_COMPAT_SYS_HAIKU_MODULE_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/ioccom.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/ioccom.h b/src/libs/compat/freebsd_network/compat/sys/ioccom.h
    deleted file mode 100644
    index f6ba2de..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * All rights reserved. Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_IOCCOM_H_
    6 #define _FBSD_COMPAT_SYS_IOCCOM_H_
    7 
    8 
    9 #define _IOW(g,n,t)     SIOCEND + n
    10 #define _IOWR(g,n,t)    SIOCEND + n
    11 
    12 #endif /* _FBSD_COMPAT_SYS_IOCCOM_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/kernel.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/kernel.h b/src/libs/compat/freebsd_network/compat/sys/kernel.h
    deleted file mode 100644
    index 0124a68..0000000
    + -  
    1 /*
    2  * Copyright 2007-2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_KERNEL_H_
    6 #define _FBSD_COMPAT_SYS_KERNEL_H_
    7 
    8 
    9 #include <stddef.h>
    10 
    11 #include <sys/haiku-module.h>
    12 
    13 #include <sys/linker_set.h>
    14 #include <sys/queue.h>
    15 
    16 
    17 /*
    18  *
    19  * The rate at which FreeBSD can generate callouts (kind of timeout mechanism).
    20  * For FreeBSD 8 this is typically 1000 times per second (100 for ARM).
    21  * This value is defined in a file called subr_param.c
    22  *
    23  * WHile Haiku can have a much higher granularity, it is not a good idea to have
    24  * this since FreeBSD tries to do certain tasks based on ticks, for instance
    25  * autonegotiation and wlan scanning.
    26  * Suffixing LL prevents integer overflows during calculations.
    27  * as it defines a long long constant.*/
    28 #define hz  1000LL
    29 
    30 #define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz)
    31 
    32 typedef void (*system_init_func_t)(void *);
    33 
    34 
    35 struct __system_init {
    36     system_init_func_t func;
    37 };
    38 
    39 /* TODO implement SYSINIT/SYSUNINIT subsystem */
    40 #define SYSINIT(uniquifier, subsystem, order, func, ident) \
    41     struct __system_init __init_##uniquifier = { (system_init_func_t) func }
    42 
    43 #define SYSUNINIT(uniquifier, subsystem, order, func, ident) \
    44     struct __system_init __uninit_##uniquifier = { (system_init_func_t) func }
    45 
    46 #define TUNABLE_INT(path, var)
    47 #define TUNABLE_INT_FETCH(path, var)
    48 
    49 extern int ticks;
    50 
    51 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/ktr.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/kthread.h b/src/libs/compat/freebsd_network/compat/sys/kthread.h
    deleted file mode 100644
    index e69de29..0000000
    diff --git a/src/libs/compat/freebsd_network/compat/sys/ktr.h b/src/libs/compat/freebsd_network/compat/sys/ktr.h
    deleted file mode 100644
    index 2e817a7..0000000
    + -  
    1 /*-
    2  * Copyright (c) 1996 Berkeley Software Design, Inc. All rights reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
    7  * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright
    10  *    notice, this list of conditions and the following disclaimer in the
    11  *    documentation and/or other materials provided with the distribution.
    12  * 3. Berkeley Software Design Inc's name may not be used to endorse or
    13  *    promote products derived from this software without specific prior
    14  *    written permission.
    15  *
    16  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
    17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    19  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
    20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    26  * SUCH DAMAGE.
    27  *
    28  *  from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $
    29  * $FreeBSD: src/sys/sys/ktr.h,v 1.32.2.2 2006/01/23 14:56:33 marius Exp $
    30  */
    31 
    32 /*
    33  *  Wraparound kernel trace buffer support.
    34  */
    35 #ifndef _SYS_KTR_H_
    36 #define _SYS_KTR_H_
    37 
    38 /*
    39  * Trace classes
    40  */
    41 #define KTR_GEN     0x00000001      /* General (TR) */
    42 #define KTR_NET     0x00000002      /* Network */
    43 #define KTR_DEV     0x00000004      /* Device driver */
    44 #define KTR_LOCK    0x00000008      /* MP locking */
    45 #define KTR_SMP     0x00000010      /* MP general */
    46 #define KTR_FS      0x00000020      /* Filesystem */
    47 #define KTR_PMAP    0x00000040      /* Pmap tracing */
    48 #define KTR_MALLOC  0x00000080      /* Malloc tracing */
    49 #define KTR_TRAP    0x00000100      /* Trap processing */
    50 #define KTR_INTR    0x00000200      /* Interrupt tracing */
    51 #define KTR_SIG     0x00000400      /* Signal processing */
    52 #define KTR_CLK     0x00000800      /* hardclock verbose */
    53 #define KTR_PROC    0x00001000      /* Process scheduling */
    54 #define KTR_SYSC    0x00002000      /* System call */
    55 #define KTR_INIT    0x00004000      /* System initialization */
    56 #define KTR_KGDB    0x00008000      /* Trace kgdb internals */
    57 #define KTR_IO      0x00010000      /* Upper I/O  */
    58 #define KTR_EVH     0x00020000      /* Eventhandler */
    59 #define KTR_VFS     0x00040000      /* VFS events */
    60 #define KTR_VOP     0x00080000      /* Auto-generated vop events */
    61 #define KTR_VM      0x00100000      /* The virtual memory system */
    62 #define KTR_WITNESS 0x00200000
    63 #define KTR_RUNQ    0x00400000      /* Run queue */
    64 #define KTR_CONTENTION  0x00800000      /* Lock contention */
    65 #define KTR_UMA     0x01000000      /* UMA slab allocator */
    66 #define KTR_CALLOUT 0x02000000      /* Callouts and timeouts */
    67 #define KTR_GEOM    0x04000000      /* GEOM I/O events */
    68 #define KTR_BUSDMA  0x08000000      /* busdma(9) events */
    69 #define KTR_CRITICAL    0x10000000      /* Critical sections */
    70 #define KTR_SCHED   0x20000000      /* Machine parsed sched info. */
    71 #define KTR_BUF     0x40000000      /* Buffer cache */
    72 #define KTR_ALL     0x7fffffff
    73 
    74 /*
    75  * Trace classes which can be assigned to particular use at compile time
    76  * These must remain in high 22 as some assembly code counts on it
    77  */
    78 #define KTR_CT1     0x01000000
    79 #define KTR_CT2     0x02000000
    80 #define KTR_CT3     0x04000000
    81 #define KTR_CT4     0x08000000
    82 #define KTR_CT5     0x10000000
    83 #define KTR_CT6     0x20000000
    84 #define KTR_CT7     0x40000000
    85 #define KTR_CT8     0x80000000
    86 
    87 /* Trace classes to compile in */
    88 #ifdef KTR
    89 #ifndef KTR_COMPILE
    90 #define KTR_COMPILE (KTR_ALL)
    91 #endif
    92 #else   /* !KTR */
    93 #undef KTR_COMPILE
    94 #define KTR_COMPILE 0
    95 #endif  /* KTR */
    96 
    97 /* Trace classes that can not be used with KTR_ALQ */
    98 #define KTR_ALQ_MASK    (KTR_WITNESS)
    99 
    100 /*
    101  * Version number for ktr_entry struct.  Increment this when you break binary
    102  * compatibility.
    103  */
    104 #define KTR_VERSION 2
    105 
    106 #define KTR_PARMS   6
    107 
    108 #ifndef LOCORE
    109 
    110 struct ktr_entry {
    111     u_int64_t ktr_timestamp;
    112     int ktr_cpu;
    113     int ktr_line;
    114     const   char *ktr_file;
    115     const   char *ktr_desc;
    116     struct  thread *ktr_thread;
    117     u_long  ktr_parms[KTR_PARMS];
    118 };
    119 
    120 extern int ktr_cpumask;
    121 extern int ktr_mask;
    122 extern int ktr_entries;
    123 extern int ktr_verbose;
    124 
    125 extern volatile int ktr_idx;
    126 extern struct ktr_entry ktr_buf[];
    127 
    128 #ifdef KTR
    129 
    130 #if 0
    131 void    ktr_tracepoint(u_int mask, const char *file, int line,
    132         const char *format, u_long arg1, u_long arg2, u_long arg3,
    133         u_long arg4, u_long arg5, u_long arg6);
    134 #else
    135 extern void driver_printf(const char *format, ...);
    136 #define ktr_tracepoint(mask, file, line, format, arg1, arg2, arg3, arg4, arg5, arg6) \
    137     driver_printf("(%s:%i) " format "\n", file, line, arg1, arg2, arg3, arg4, arg5, arg6)
    138 #endif
    139 
    140 #define CTR6(m, format, p1, p2, p3, p4, p5, p6) do {            \
    141     if (KTR_COMPILE & (m))                      \
    142         ktr_tracepoint((m), __FILE__, __LINE__, format,     \
    143             (u_long)(p1), (u_long)(p2), (u_long)(p3),       \
    144             (u_long)(p4), (u_long)(p5), (u_long)(p6));      \
    145     } while(0)
    146 #define CTR0(m, format)         CTR6(m, format, 0, 0, 0, 0, 0, 0)
    147 #define CTR1(m, format, p1)     CTR6(m, format, p1, 0, 0, 0, 0, 0)
    148 #define CTR2(m, format, p1, p2)     CTR6(m, format, p1, p2, 0, 0, 0, 0)
    149 #define CTR3(m, format, p1, p2, p3) CTR6(m, format, p1, p2, p3, 0, 0, 0)
    150 #define CTR4(m, format, p1, p2, p3, p4) CTR6(m, format, p1, p2, p3, p4, 0, 0)
    151 #define CTR5(m, format, p1, p2, p3, p4, p5) CTR6(m, format, p1, p2, p3, p4, p5, 0)
    152 #else   /* KTR */
    153 #define CTR0(m, d)
    154 #define CTR1(m, d, p1)
    155 #define CTR2(m, d, p1, p2)
    156 #define CTR3(m, d, p1, p2, p3)
    157 #define CTR4(m, d, p1, p2, p3, p4)
    158 #define CTR5(m, d, p1, p2, p3, p4, p5)
    159 #define CTR6(m, d, p1, p2, p3, p4, p5, p6)
    160 #endif  /* KTR */
    161 
    162 #define TR0(d)              CTR0(KTR_GEN, d)
    163 #define TR1(d, p1)          CTR1(KTR_GEN, d, p1)
    164 #define TR2(d, p1, p2)          CTR2(KTR_GEN, d, p1, p2)
    165 #define TR3(d, p1, p2, p3)      CTR3(KTR_GEN, d, p1, p2, p3)
    166 #define TR4(d, p1, p2, p3, p4)      CTR4(KTR_GEN, d, p1, p2, p3, p4)
    167 #define TR5(d, p1, p2, p3, p4, p5)  CTR5(KTR_GEN, d, p1, p2, p3, p4, p5)
    168 #define TR6(d, p1, p2, p3, p4, p5, p6)  CTR6(KTR_GEN, d, p1, p2, p3, p4, p5, p6)
    169 
    170 /*
    171  * Trace initialization events, similar to CTR with KTR_INIT, but
    172  * completely ifdef'ed out if KTR_INIT isn't in KTR_COMPILE (to
    173  * save string space, the compiler doesn't optimize out strings
    174  * for the conditional ones above).
    175  */
    176 #if (KTR_COMPILE & KTR_INIT) != 0
    177 #define ITR0(d)             CTR0(KTR_INIT, d)
    178 #define ITR1(d, p1)         CTR1(KTR_INIT, d, p1)
    179 #define ITR2(d, p1, p2)         CTR2(KTR_INIT, d, p1, p2)
    180 #define ITR3(d, p1, p2, p3)     CTR3(KTR_INIT, d, p1, p2, p3)
    181 #define ITR4(d, p1, p2, p3, p4)     CTR4(KTR_INIT, d, p1, p2, p3, p4)
    182 #define ITR5(d, p1, p2, p3, p4, p5) CTR5(KTR_INIT, d, p1, p2, p3, p4, p5)
    183 #define ITR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_INIT, d, p1, p2, p3, p4, p5, p6)
    184 #else
    185 #define ITR0(d)
    186 #define ITR1(d, p1)
    187 #define ITR2(d, p1, p2)
    188 #define ITR3(d, p1, p2, p3)
    189 #define ITR4(d, p1, p2, p3, p4)
    190 #define ITR5(d, p1, p2, p3, p4, p5)
    191 #define ITR6(d, p1, p2, p3, p4, p5, p6)
    192 #endif
    193 
    194 #endif /* !LOCORE */
    195 
    196 #endif /* !_SYS_KTR_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/libkern.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/libkern.h b/src/libs/compat/freebsd_network/compat/sys/libkern.h
    deleted file mode 100644
    index 98b870a..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * All rights reserved. Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_LIBKERN_H_
    6 #define _FBSD_COMPAT_SYS_LIBKERN_H_
    7 
    8 
    9 #include <sys/cdefs.h>
    10 #include <sys/types.h>
    11 
    12 
    13 extern int random(void);
    14 uint32_t arc4random(void);
    15 
    16 static __inline int imax(int a, int b) { return (a > b ? a : b); }
    17 
    18 extern int abs(int a);
    19 
    20 #endif /* _FBSD_COMPAT_SYS_LIBKERN_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/limits.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/limits.h b/src/libs/compat/freebsd_network/compat/sys/limits.h
    deleted file mode 100644
    index 492074d..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_LIMITS_H_
    6 #define _FBSD_COMPAT_SYS_LIMITS_H_
    7 
    8 
    9 #endif /* _FBSD_COMPAT_SYS_LIMITS_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/linker.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/linker.h b/src/libs/compat/freebsd_network/compat/sys/linker.h
    deleted file mode 100644
    index 52cd150..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_LINKER_H_
    6 #define _FBSD_COMPAT_SYS_LINKER_H_
    7 
    8 
    9 #endif /* _FBSD_COMPAT_SYS_LINKER_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/linker_set.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/linker_set.h b/src/libs/compat/freebsd_network/compat/sys/linker_set.h
    deleted file mode 100644
    index 41c964d..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_LINKER_SET_H_
    6 #define _FBSD_COMPAT_SYS_LINKER_SET_H_
    7 
    8 
    9 #ifndef _FBSD_COMPAT_SYS_CDEFS_H_
    10 #error this file needs sys/cdefs.h as a prerequisite
    11 #endif
    12 
    13 /*
    14  * The following macros are used to declare global sets of objects, which
    15  * are collected by the linker into a `linker_set' as defined below.
    16  * For ELF, this is done by constructing a separate segment for each set.
    17  */
    18 
    19 /*
    20  * Private macros, not to be used outside this header file.
    21  */
    22 #ifdef __GNUCLIKE___SECTION
    23 #define __MAKE_SET(set, sym)                        \
    24     static void const * const __set_##set##_sym_##sym       \
    25     __section("set_" #set) __used = &sym
    26 #else /* !__GNUCLIKE___SECTION */
    27 #ifndef lint
    28 #error this file needs to be ported to your compiler
    29 #endif /* lint */
    30 #define __MAKE_SET(set, sym)    extern void const * const (__set_##set##_sym_##sym)
    31 #endif /* __GNUCLIKE___SECTION */
    32 
    33 /*
    34  * Public macros.
    35  */
    36 #define TEXT_SET(set, sym)  __MAKE_SET(set, sym)
    37 #define DATA_SET(set, sym)  __MAKE_SET(set, sym)
    38 #define BSS_SET(set, sym)   __MAKE_SET(set, sym)
    39 #define ABS_SET(set, sym)   __MAKE_SET(set, sym)
    40 #define SET_ENTRY(set, sym) __MAKE_SET(set, sym)
    41 
    42 /*
    43  * Initialize before referring to a given linker set.
    44  */
    45 #define SET_DECLARE(set, ptype)                     \
    46     extern ptype *__CONCAT(__start_set_,set);           \
    47     extern ptype *__CONCAT(__stop_set_,set)
    48 
    49 #define SET_BEGIN(set)                          \
    50     (&__CONCAT(__start_set_,set))
    51 #define SET_LIMIT(set)                          \
    52     (&__CONCAT(__stop_set_,set))
    53 
    54 /*
    55  * Iterate over all the elements of a set.
    56  *
    57  * Sets always contain addresses of things, and "pvar" points to words
    58  * containing those addresses.  Thus is must be declared as "type **pvar",
    59  * and the address of each set item is obtained inside the loop by "*pvar".
    60  */
    61 #define SET_FOREACH(pvar, set)                      \
    62     for (pvar = SET_BEGIN(set); pvar < SET_LIMIT(set); pvar++)
    63 
    64 #endif /* _FBSD_COMPAT_SYS_LINKER_SET_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/malloc.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/lock.h b/src/libs/compat/freebsd_network/compat/sys/lock.h
    deleted file mode 100644
    index e69de29..0000000
    diff --git a/src/libs/compat/freebsd_network/compat/sys/malloc.h b/src/libs/compat/freebsd_network/compat/sys/malloc.h
    deleted file mode 100644
    index 7dc4018..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 #ifndef _FBSD_COMPAT_SYS_MALLOC_H_
    7 #define _FBSD_COMPAT_SYS_MALLOC_H_
    8 
    9 
    10 #include <malloc.h>
    11 
    12 #include <vm/vm.h>
    13 
    14 #include <sys/param.h>
    15 #include <sys/queue.h>
    16 #include <sys/_mutex.h>
    17 
    18 
    19 /*
    20  * flags to malloc.
    21  */
    22 #define M_NOWAIT        0x0001
    23 #define M_WAITOK        0x0002
    24 #define M_ZERO          0x0100
    25 
    26 #define M_MAGIC         877983977   /* time when first defined :-) */
    27 
    28 #define M_DEVBUF
    29 
    30 
    31 void *_kernel_malloc(size_t size, int flags);
    32 void _kernel_free(void *ptr);
    33 
    34 void *_kernel_contigmalloc(const char *file, int line, size_t size, int flags,
    35     vm_paddr_t low, vm_paddr_t high, unsigned long alignment,
    36     unsigned long boundary);
    37 void _kernel_contigfree(void *addr, unsigned long size);
    38 
    39 #define kernel_malloc(size, base, flags) \
    40     _kernel_malloc(size, flags)
    41 
    42 #define kernel_free(ptr, base) \
    43     _kernel_free(ptr)
    44 
    45 #define kernel_contigmalloc(size, type, flags, low, high, alignment, boundary) \
    46     _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \
    47         alignment, boundary)
    48 
    49 #define kernel_contigfree(addr, size, base) \
    50     _kernel_contigfree(addr, size)
    51 
    52 #ifdef FBSD_DRIVER
    53 #   define malloc(size, tag, flags) kernel_malloc(size, tag, flags)
    54 #   define free(pointer, tag)       kernel_free(pointer, tag)
    55 #   define contigmalloc(size, type, flags, low, high, alignment, boundary) \
    56         _kernel_contigmalloc(__FILE__, __LINE__, size, flags, low, high, \
    57             alignment, boundary)
    58 #   define contigfree(addr, size, base) \
    59         _kernel_contigfree(addr, size)
    60 #endif
    61 
    62 #define MALLOC_DEFINE(type, shortdesc, longdesc)    int type[1]
    63 
    64 #define MALLOC_DECLARE(type) \
    65         extern int type[1]
    66 
    67 #endif  /* _FBSD_COMPAT_SYS_MALLOC_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/mbuf-fbsd.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/mbuf-fbsd.h b/src/libs/compat/freebsd_network/compat/sys/mbuf-fbsd.h
    deleted file mode 100644
    index 2983efd..0000000
    + -  
    1 /*-
    2  * Copyright (c) 1982, 1986, 1988, 1993
    3  *  The Regents of the University of California.  All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
    10  * 2. Redistributions in binary form must reproduce the above copyright
    11  *    notice, this list of conditions and the following disclaimer in the
    12  *    documentation and/or other materials provided with the distribution.
    13  * 3. Neither the name of the University nor the names of its contributors
    14  *    may be used to endorse or promote products derived from this software
    15  *    without specific prior written permission.
    16  *
    17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    27  * SUCH DAMAGE.
    28  *
    29  *  @(#)mbuf.h  8.5 (Berkeley) 2/19/95
    30  * $FreeBSD: src/sys/sys/mbuf.h,v 1.170.2.6 2006/03/23 23:24:32 sam Exp $
    31  */
    32 #ifndef _FBSD_COMPAT_SYS_MBUF_FBSD_H_
    33 #define _FBSD_COMPAT_SYS_MBUF_FBSD_H_
    34 
    35 /*
    36  * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place
    37  * an object of the specified size at the end of the mbuf, longword aligned.
    38  */
    39 #define M_ALIGN(m, len) do {                        \
    40     (m)->m_data += (MLEN - (len)) & ~(sizeof(long) - 1);        \
    41 } while (0)
    42 
    43 /*
    44  * As above, for mbufs allocated with m_gethdr/MGETHDR
    45  * or initialized by M_COPY_PKTHDR.
    46  */
    47 #define MH_ALIGN(m, len) do {                       \
    48     (m)->m_data += (MHLEN - (len)) & ~(sizeof(long) - 1);       \
    49 } while (0)
    50 
    51 /*
    52 #define MEXT_IS_REF(m)  (((m)->m_ext.ref_cnt != NULL)           \
    53     && (*((m)->m_ext.ref_cnt) > 1))
    54  */
    55 #define MEXT_IS_REF(m)  0
    56 
    57 /*
    58  * Evaluate TRUE if it's safe to write to the mbuf m's data region (this
    59  * can be both the local data payload, or an external buffer area,
    60  * depending on whether M_EXT is set).
    61  */
    62 
    63 /*
    64 #define M_WRITABLE(m)   (!((m)->m_flags & M_RDONLY) && (!((m)->m_flags  \
    65                 & M_EXT) || !MEXT_IS_REF(m)))
    66  */
    67 #define M_WRITABLE(m)   (!((m)->m_flags & M_EXT) || !MEXT_IS_REF(m))
    68 
    69 /*
    70  * Compute the amount of space available
    71  * before the current start of data in an mbuf.
    72  *
    73  * The M_WRITABLE() is a temporary, conservative safety measure: the burden
    74  * of checking writability of the mbuf data area rests solely with the caller.
    75  */
    76 #define M_LEADINGSPACE(m)                       \
    77     ((m)->m_flags & M_EXT ?                     \
    78         (M_WRITABLE(m) ? (m)->m_data - (m)->m_ext.ext_buf : 0): \
    79         (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \
    80         (m)->m_data - (m)->m_dat)
    81 
    82 /*
    83  * Compute the amount of space available after the end of data in an mbuf.
    84  *
    85  * The M_WRITABLE() is a temporary, conservative safety measure: the burden
    86  * of checking writability of the mbuf data area rests solely with the caller.
    87  */
    88 #define M_TRAILINGSPACE(m)                      \
    89     ((m)->m_flags & M_EXT ?                     \
    90         (M_WRITABLE(m) ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size   \
    91         - ((m)->m_data + (m)->m_len) : 0) :         \
    92         &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
    93 
    94 /*
    95  * Arrange to prepend space of size plen to mbuf m.
    96  * If a new mbuf must be allocated, how specifies whether to wait.
    97  * If the allocation fails, the original mbuf chain is freed and m is
    98  * set to NULL.
    99  */
    100 #define M_PREPEND(m, plen, how) do {                    \
    101     struct mbuf **_mmp = &(m);                  \
    102     struct mbuf *_mm = *_mmp;                   \
    103     int _mplen = (plen);                        \
    104     int __mhow = (how);                     \
    105                                     \
    106     MBUF_CHECKSLEEP(how);                       \
    107     if (M_LEADINGSPACE(_mm) >= _mplen) {                \
    108         _mm->m_data -= _mplen;                  \
    109         _mm->m_len += _mplen;                   \
    110     } else                              \
    111         _mm = m_prepend(_mm, _mplen, __mhow);           \
    112     if (_mm != NULL && _mm->m_flags & M_PKTHDR)         \
    113         _mm->m_pkthdr.len += _mplen;                \
    114     *_mmp = _mm;                            \
    115 } while (0)
    116 
    117 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/mbuf.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/mbuf.h b/src/libs/compat/freebsd_network/compat/sys/mbuf.h
    deleted file mode 100644
    index 2b04340..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 #ifndef _FBSD_COMPAT_SYS_MBUF_H_
    7 #define _FBSD_COMPAT_SYS_MBUF_H_
    8 
    9 
    10 #include <sys/queue.h>
    11 #include <sys/systm.h>
    12 #include <vm/uma.h>
    13 
    14 
    15 #define MLEN        ((int)(MSIZE - sizeof(struct m_hdr)))
    16 #define MHLEN       ((int)(MLEN - sizeof(struct pkthdr)))
    17 
    18 #define MINCLSIZE   (MHLEN + 1)
    19 
    20 #define MBTOM(how)  (how)
    21 #define M_DONTWAIT  M_NOWAIT
    22 #define M_TRYWAIT   M_WAITOK
    23 #define M_WAIT      M_WAITOK
    24 
    25 #define MT_DATA     1
    26 
    27 #define M_EXT       0x00000001
    28 #define M_PKTHDR    0x00000002
    29 #define M_RDONLY    0x00000008
    30 #define M_PROTO1    0x00000010
    31 #define M_PROTO2    0x00000020
    32 #define M_PROTO3    0x00000040
    33 #define M_PROTO4    0x00000080
    34 #define M_PROTO5    0x00000100
    35 #define M_BCAST     0x00000200
    36 #define M_MCAST     0x00000400
    37 #define M_FRAG      0x00000800
    38 #define M_FIRSTFRAG 0x00001000
    39 #define M_LASTFRAG  0x00002000
    40 #define M_VLANTAG   0x00010000
    41 #define M_PROTO6    0x00080000
    42 #define M_PROTO7    0x00100000
    43 #define M_PROTO8    0x00200000
    44 
    45 #define M_COPYFLAGS (M_PKTHDR | M_RDONLY | M_BCAST | M_MCAST | M_FRAG \
    46     | M_FIRSTFRAG | M_LASTFRAG | M_VLANTAG)
    47     // Flags preserved when copying m_pkthdr
    48 
    49 #define M_MOVE_PKTHDR(to, from) m_move_pkthdr((to), (from))
    50 #define MGET(m, how, type)      ((m) = m_get((how), (type)))
    51 #define MGETHDR(m, how, type)   ((m) = m_gethdr((how), (type)))
    52 #define MCLGET(m, how)          m_clget((m), (how))
    53 
    54 #define mtod(m, type)   ((type)((m)->m_data))
    55 
    56 // Check if the supplied mbuf has a packet header, or else panic.
    57 #define M_ASSERTPKTHDR(m) KASSERT(m != NULL && m->m_flags & M_PKTHDR, \
    58     ("%s: no mbuf packet header!", __func__))
    59 
    60 #define MBUF_CHECKSLEEP(how) do { } while (0)
    61 
    62 #define MTAG_PERSISTENT 0x800
    63 
    64 #define EXT_CLUSTER     1       // 2048 bytes
    65 #define EXT_JUMBOP      4       // Page size
    66 #define EXT_JUMBO9      5       // 9 * 1024 bytes
    67 #define EXT_NET_DRV     100     // custom ext_buf provided by net driver
    68 
    69 #define CSUM_IP         0x0001
    70 #define CSUM_TCP        0x0002
    71 #define CSUM_UDP        0x0004
    72 #define CSUM_TSO        0x0020
    73 #define CSUM_IP_CHECKED 0x0100
    74 #define CSUM_IP_VALID   0x0200
    75 #define CSUM_DATA_VALID 0x0400
    76 #define CSUM_PSEUDO_HDR 0x0800
    77 #define CSUM_DELAY_DATA (CSUM_TCP | CSUM_UDP)
    78 
    79 // TODO After all network driver are updated to the FreeBSD 8 version this can
    80 // changed
    81 #if __FreeBSD_version__ >= 8
    82 #define MEXTADD(m, buf, size, free, arg1, arg2, flags, type) \
    83     m_extadd((m), (caddr_t)(buf), (size), (free),(arg1),(arg2),(flags), (type))
    84 #else
    85 #define MEXTADD(m, buf, size, free, args, flags, type) \
    86     m_extadd((m), (caddr_t)(buf), (size), (free),(args),(flags), (type))
    87 #endif
    88 
    89 
    90 extern int max_linkhdr;
    91 extern int max_protohdr;
    92 extern int max_hdr;
    93 extern int max_datalen;     // MHLEN - max_hdr
    94 
    95 
    96 struct m_hdr {
    97     struct mbuf*    mh_next;
    98     struct mbuf*    mh_nextpkt;
    99     caddr_t         mh_data;
    100     int             mh_len;
    101     int             mh_flags;
    102     short           mh_type;
    103 };
    104 
    105 struct pkthdr {
    106     struct ifnet*                   rcvif;
    107     int                             len;
    108     int                             csum_flags;
    109     int                             csum_data;
    110     uint16_t                        tso_segsz;
    111     uint16_t                        ether_vtag;
    112     SLIST_HEAD(packet_tags, m_tag)  tags;
    113 };
    114 
    115 struct m_tag {
    116     SLIST_ENTRY(m_tag)  m_tag_link;     // List of packet tags
    117     u_int16_t           m_tag_id;       // Tag ID
    118     u_int16_t           m_tag_len;      // Length of data
    119     u_int32_t           m_tag_cookie;   // ABI/Module ID
    120     void                (*m_tag_free)(struct m_tag*);
    121 };
    122 
    123 struct m_ext {
    124     caddr_t         ext_buf;
    125     unsigned int    ext_size;
    126     int             ext_type;
    127 };
    128 
    129 struct mbuf {
    130     struct m_hdr m_hdr;
    131     union {
    132         struct {
    133             struct pkthdr   MH_pkthdr;
    134             union {
    135                 struct m_ext    MH_ext;
    136                 char            MH_databuf[MHLEN];
    137             } MH_dat;
    138         } MH;
    139         char M_databuf[MLEN];
    140     } M_dat;
    141 };
    142 
    143 
    144 #define m_next      m_hdr.mh_next
    145 #define m_len       m_hdr.mh_len
    146 #define m_data      m_hdr.mh_data
    147 #define m_type      m_hdr.mh_type
    148 #define m_flags     m_hdr.mh_flags
    149 #define m_nextpkt   m_hdr.mh_nextpkt
    150 #define m_act       m_nextpkt
    151 #define m_pkthdr    M_dat.MH.MH_pkthdr
    152 #define m_ext       M_dat.MH.MH_dat.MH_ext
    153 #define m_pktdat    M_dat.MH.MH_dat.MH_databuf
    154 #define m_dat       M_dat.M_databuf
    155 
    156 
    157 void            m_adj(struct mbuf*, int);
    158 void            m_align(struct mbuf*, int);
    159 int             m_append(struct mbuf*, int, c_caddr_t);
    160 void            m_cat(struct mbuf*, struct mbuf*);
    161 void            m_clget(struct mbuf*, int);
    162 void*           m_cljget(struct mbuf*, int, int);
    163 struct mbuf*    m_collapse(struct mbuf*, int, int);
    164 void            m_copyback(struct mbuf*, int, int, caddr_t);
    165 void            m_copydata(const struct mbuf*, int, int, caddr_t);
    166 struct mbuf*    m_copypacket(struct mbuf*, int);
    167 struct mbuf*    m_defrag(struct mbuf*, int);
    168 struct mbuf*    m_devget(char*, int, int, struct ifnet*,
    169     void(*) (char*, caddr_t, u_int));
    170 
    171 struct mbuf*    m_dup(struct mbuf*, int);
    172 int             m_dup_pkthdr(struct mbuf*, struct mbuf*, int);
    173 
    174 // TODO After all network driver are updated to the FreeBSD 8 version this can
    175 // changed
    176 #if __FreeBSD_version__ >= 8
    177 void            m_extadd(struct mbuf*, caddr_t, u_int, void(*) (void*, void*),
    178     void*, void*, int, int);
    179 #else
    180 void            m_extadd(struct mbuf*, caddr_t, u_int, void(*) (void*, void*),
    181     void*, int, int);
    182 #endif
    183 
    184 u_int           m_fixhdr(struct mbuf*);
    185 struct mbuf*    m_free(struct mbuf*);
    186 void            m_freem(struct mbuf*);
    187 struct mbuf*    m_get(int, short);
    188 struct mbuf*    m_gethdr(int, short);
    189 struct mbuf*    m_getjcl(int, short, int, int);
    190 u_int           m_length(struct mbuf*, struct mbuf**);
    191 struct mbuf*    m_getcl(int, short, int);
    192 void            m_move_pkthdr(struct mbuf*, struct mbuf*);
    193 struct mbuf*    m_prepend(struct mbuf*, int, int);
    194 struct mbuf*    m_pulldown(struct mbuf*, int, int, int*);
    195 struct mbuf*    m_pullup(struct mbuf*, int);
    196 struct mbuf*    m_split(struct mbuf*, int, int);
    197 struct mbuf*    m_unshare(struct mbuf*, int);
    198 
    199 struct m_tag*   m_tag_alloc(u_int32_t, int, int, int);
    200 void            m_tag_delete(struct mbuf*, struct m_tag*);
    201 void            m_tag_delete_chain(struct mbuf*, struct m_tag*);
    202 void            m_tag_free_default(struct m_tag*);
    203 struct m_tag*   m_tag_locate(struct mbuf*, u_int32_t, int, struct m_tag*);
    204 struct m_tag*   m_tag_copy(struct m_tag*, int);
    205 int             m_tag_copy_chain(struct mbuf*, struct mbuf*, int);
    206 void            m_tag_delete_nonpersistent(struct mbuf*);
    207 
    208 
    209 static inline void
    210 m_tag_setup(struct m_tag* tagPointer, u_int32_t cookie, int type, int length)
    211 {
    212     tagPointer->m_tag_id = type;
    213     tagPointer->m_tag_len = length;
    214     tagPointer->m_tag_cookie = cookie;
    215 }
    216 
    217 
    218 static inline void
    219 m_tag_free(struct m_tag* tag)
    220 {
    221     (*tag->m_tag_free)(tag);
    222 }
    223 
    224 
    225 static inline void
    226 m_tag_prepend(struct mbuf* memoryBuffer, struct m_tag* tag)
    227 {
    228     SLIST_INSERT_HEAD(&memoryBuffer->m_pkthdr.tags, tag, m_tag_link);
    229 }
    230 
    231 
    232 static inline void
    233 m_tag_unlink(struct mbuf* memoryBuffer, struct m_tag* tag)
    234 {
    235     SLIST_REMOVE(&memoryBuffer->m_pkthdr.tags, tag, m_tag, m_tag_link);
    236 }
    237 
    238 
    239 #include <sys/mbuf-fbsd.h>
    240 
    241 #endif  /* _FBSD_COMPAT_SYS_MBUF_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/module.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/module.h b/src/libs/compat/freebsd_network/compat/sys/module.h
    deleted file mode 100644
    index 4315069..0000000
    + -  
    1 #ifndef _FBSD_COMPAT_SYS_MODULE_H_
    2 #define _FBSD_COMPAT_SYS_MODULE_H_
    3 
    4 
    5 #include <sys/linker_set.h>
    6 
    7 
    8 typedef struct module* module_t;
    9 
    10 typedef enum modeventtype {
    11     MOD_LOAD,
    12     MOD_UNLOAD,
    13     MOD_SHUTDOWN,
    14     MOD_QUIESCE
    15 } modeventtype_t;
    16 
    17 
    18 #define DECLARE_MODULE(name, data, sub, order)
    19 
    20 #define MODULE_VERSION(name, version)
    21 #define MODULE_DEPEND(module, mdepend, vmin, vpref, vmax)
    22 
    23 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/mount.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/mount.h b/src/libs/compat/freebsd_network/compat/sys/mount.h
    deleted file mode 100644
    index 4d44727..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_MOUNT_H_
    6 #define _FBSD_COMPAT_SYS_MOUNT_H_
    7 
    8 
    9 #endif /* _FBSD_COMPAT_SYS_MOUNT_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/mutex.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/mutex.h b/src/libs/compat/freebsd_network/compat/sys/mutex.h
    deleted file mode 100644
    index 18b2838..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 #ifndef _FBSD_COMPAT_SYS_MUTEX_H_
    7 #define _FBSD_COMPAT_SYS_MUTEX_H_
    8 
    9 
    10 #include <sys/haiku-module.h>
    11 
    12 #include <sys/queue.h>
    13 #include <sys/_mutex.h>
    14 #include <sys/pcpu.h>
    15 #include <machine/atomic.h>
    16 #include <machine/cpufunc.h>
    17 
    18 
    19 #define MA_OWNED        0x1
    20 #define MA_NOTOWNED     0x2
    21 #define MA_RECURSED     0x4
    22 #define MA_NOTRECURSED  0x8
    23 
    24 #define mtx_assert(mtx, what)
    25 
    26 #define MTX_DEF             0x0000
    27 #define MTX_RECURSE         0x0004
    28 #define MTX_QUIET           0x40000
    29 #define MTX_DUPOK           0x400000
    30 
    31 
    32 #define MTX_NETWORK_LOCK    "network driver"
    33 
    34 #define NET_LOCK_GIANT()
    35 #define NET_UNLOCK_GIANT()
    36 
    37 
    38 extern struct mtx Giant;
    39 
    40 
    41 void mtx_init(struct mtx*, const char*, const char*, int);
    42 void mtx_destroy(struct mtx*);
    43 
    44 
    45 static inline void
    46 mtx_lock(struct mtx* mutex)
    47 {
    48     if (mutex->type == MTX_DEF) {
    49         mutex_lock(&mutex->u.mutex.lock);
    50         mutex->u.mutex.owner = find_thread(NULL);
    51     } else if (mutex->type == MTX_RECURSE)
    52         recursive_lock_lock(&mutex->u.recursive);
    53 }
    54 
    55 
    56 static inline void
    57 mtx_unlock(struct mtx* mutex)
    58 {
    59     if (mutex->type == MTX_DEF) {
    60         mutex->u.mutex.owner = -1;
    61         mutex_unlock(&mutex->u.mutex.lock);
    62     } else if (mutex->type == MTX_RECURSE)
    63         recursive_lock_unlock(&mutex->u.recursive);
    64 }
    65 
    66 
    67 static inline int
    68 mtx_initialized(struct mtx* mutex)
    69 {
    70     /* TODO */
    71     return 1;
    72 }
    73 
    74 
    75 static inline int
    76 mtx_owned(struct mtx* mutex)
    77 {
    78     if (mutex->type == MTX_DEF)
    79         return mutex->u.mutex.owner == find_thread(NULL);
    80     if (mutex->type == MTX_RECURSE) {
    81 #if KDEBUG
    82         return mutex->u.recursive.lock.holder == find_thread(NULL);
    83 #else
    84         return mutex->u.recursive.holder == find_thread(NULL);
    85 #endif
    86     }
    87 
    88     return 0;
    89 }
    90 
    91 
    92 #endif  /* _FBSD_COMPAT_SYS_MUTEX_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/namei.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/namei.h b/src/libs/compat/freebsd_network/compat/sys/namei.h
    deleted file mode 100644
    index 3da8a0a..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_NAMEI_H_
    6 #define _FBSD_COMPAT_SYS_NAMEI_H_
    7 
    8 
    9 #endif /* _FBSD_COMPAT_SYS_NAMEI_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/param.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/param.h b/src/libs/compat/freebsd_network/compat/sys/param.h
    deleted file mode 100644
    index 51e09e4..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 #ifndef _FBSD_COMPAT_SYS_PARAM_H_
    7 #define _FBSD_COMPAT_SYS_PARAM_H_
    8 
    9 
    10 #include <posix/sys/param.h>
    11 
    12 #include <sys/types.h>
    13 #include <sys/cdefs.h>
    14 #include <sys/errno.h>
    15 #include <sys/time.h>
    16 #include <sys/priority.h>
    17 
    18 
    19 /* The version this compatibility layer is based on */
    20 #define __FreeBSD_version 800107
    21 
    22 #define MAXBSIZE    0x10000
    23 
    24 #define PAGE_SHIFT  12
    25 #define PAGE_MASK   (PAGE_SIZE - 1)
    26 
    27 #define trunc_page(x)   ((x) & ~PAGE_MASK)
    28 
    29 #define ptoa(x)         ((unsigned long)((x) << PAGE_SHIFT))
    30 #define atop(x)         ((unsigned long)((x) >> PAGE_SHIFT))
    31 
    32 /* MAJOR FIXME */
    33 #define Maxmem          (32768)
    34 
    35 #ifndef MSIZE
    36 #define MSIZE 256
    37 #endif
    38 
    39 #ifndef MCLSHIFT
    40 #define MCLSHIFT 11
    41 #endif
    42 
    43 #define MCLBYTES        (1 << MCLSHIFT)
    44 
    45 #define MJUMPAGESIZE    PAGE_SIZE
    46 #define MJUM9BYTES      (9 * 1024)
    47 #define MJUM16BYTES     (16 * 1024)
    48 
    49 #define ALIGN_BYTES     (sizeof(unsigned long) - 1)
    50 #define ALIGN(x)        ((((unsigned long)x) + ALIGN_BYTES) & ~ALIGN_BYTES)
    51 
    52 /* Macros for counting and rounding. */
    53 #ifndef howmany
    54 #define howmany(x, y)   (((x)+((y)-1))/(y))
    55 #endif
    56 #define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))  /* to any y */
    57 #define roundup2(x, y)  (((x) + ((y) - 1)) & (~((y) - 1)))
    58 #define rounddown(x, y)  (((x) / (y)) * (y))
    59 
    60 #define PRIMASK 0x0ff
    61 #define PCATCH  0x100
    62 #define PDROP   0x200
    63 #define PBDRY   0x400
    64 
    65 #define NBBY    8       /* number of bits in a byte */
    66 
    67 /* Bit map related macros. */
    68 #define setbit(a,i) (((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY))
    69 #define clrbit(a,i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY)))
    70 #define isset(a,i)                          \
    71     (((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY)))
    72 #define isclr(a,i)                          \
    73     ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
    74 
    75 #endif  /* _FBSD_COMPAT_SYS_PARAM_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/pcpu.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/pcpu.h b/src/libs/compat/freebsd_network/compat/sys/pcpu.h
    deleted file mode 100644
    index 858d57b..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * All rights reserved. Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_PCPU_H_
    6 #define _FBSD_COMPAT_SYS_PCPU_H_
    7 
    8 
    9 #include <OS.h>
    10 
    11 
    12 struct thread;
    13 
    14 #define curthread ((struct thread*)NULL)
    15     /* NOTE: Dereferencing curthread will crash, which is intentional. There is
    16        no FreeBSD compatible struct thread and Haiku's should not be used as it
    17        is only valid for the current thread or with proper locking. Currently
    18        only priv_check() expects a struct thread parameter and ignores it. Using
    19        NULL will show us when other uses appear. */
    20 
    21 
    22 #endif /* _FBSD_COMPAT_SYS_PCPU_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/priority.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/priority.h b/src/libs/compat/freebsd_network/compat/sys/priority.h
    deleted file mode 100644
    index 61fd7f1..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_PRIORITY_H_
    6 #define _FBSD_COMPAT_SYS_PRIORITY_H_
    7 
    8 
    9 #define PRI_MIN_KERN    (64)
    10 #define PZERO           (PRI_MIN_KERN + 20)
    11 
    12 #endif /* _FBSD_COMPAT_SYS_PRIORITY_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/priv.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/priv.h b/src/libs/compat/freebsd_network/compat/sys/priv.h
    deleted file mode 100644
    index 4ba76e3..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * All rights reserved. Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_PRIV_H_
    6 #define _FBSD_COMPAT_SYS_PRIV_H_
    7 
    8 
    9 #include <sys/cdefs.h>
    10 
    11 
    12 /*
    13  * 802.11-related privileges.
    14  */
    15 #define PRIV_NET80211_GETKEY    440 /* Query 802.11 keys. */
    16 #define PRIV_NET80211_MANAGE    441 /* Administer 802.11. */
    17 
    18 #define PRIV_DRIVER     14  /* Low-level driver privilege. */
    19 
    20 
    21 /*
    22  * Privilege check interfaces, modeled after historic suser() interfacs, but
    23  * with the addition of a specific privilege name.  No flags are currently
    24  * defined for the API.  Historically, flags specified using the real uid
    25  * instead of the effective uid, and whether or not the check should be
    26  * allowed in jail.
    27  */
    28 struct thread;
    29 
    30 
    31 __BEGIN_DECLS
    32 
    33 int priv_check(struct thread*, int);
    34 
    35 __END_DECLS
    36 
    37 
    38 #endif /* _FBSD_COMPAT_SYS_PRIV_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/proc.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/proc.h b/src/libs/compat/freebsd_network/compat/sys/proc.h
    deleted file mode 100644
    index 1eb862a..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_PROC_H_
    6 #define _FBSD_COMPAT_SYS_PROC_H_
    7 
    8 
    9 #endif /* _FBSD_COMPAT_SYS_PROC_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/rman.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/protosw.h b/src/libs/compat/freebsd_network/compat/sys/protosw.h
    deleted file mode 100644
    index e69de29..0000000
    diff --git a/src/libs/compat/freebsd_network/compat/sys/random.h b/src/libs/compat/freebsd_network/compat/sys/random.h
    deleted file mode 100644
    index e69de29..0000000
    diff --git a/src/libs/compat/freebsd_network/compat/sys/rman.h b/src/libs/compat/freebsd_network/compat/sys/rman.h
    deleted file mode 100644
    index c3911d9..0000000
    + -  
    1 /*
    2  * Copyright 2007, Hugo Santos. All Rights Reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 
    6 
    7 /*-
    8  * Copyright 1998 Massachusetts Institute of Technology
    9  *
    10  * Permission to use, copy, modify, and distribute this software and
    11  * its documentation for any purpose and without fee is hereby
    12  * granted, provided that both the above copyright notice and this
    13  * permission notice appear in all copies, that both the above
    14  * copyright notice and this permission notice appear in all
    15  * supporting documentation, and that the name of M.I.T. not be used
    16  * in advertising or publicity pertaining to distribution of the
    17  * software without specific, written prior permission.  M.I.T. makes
    18  * no representations about the suitability of this software for any
    19  * purpose.  It is provided "as is" without express or implied
    20  * warranty.
    21  *
    22  * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
    23  * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
    24  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
    26  * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    29  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    30  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    31  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    32  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    33  * SUCH DAMAGE.
    34  *
    35  * $FreeBSD$
    36  */
    37 #ifndef _FBSD_COMPAT_SYS_RMAN_H_
    38 #define _FBSD_COMPAT_SYS_RMAN_H_
    39 
    40 
    41 #include <machine/_bus.h>
    42 #include <machine/resource.h>
    43 
    44 
    45 #define RF_ACTIVE       0x0002
    46 #define RF_SHAREABLE    0x0004
    47 #define RF_OPTIONAL     0x0080
    48 
    49 #define RF_ALIGNMENT_SHIFT      10 /* alignment size bit starts bit 10 */
    50 #define RF_ALIGNMENT_LOG2(x)    ((x) << RF_ALIGNMENT_SHIFT)
    51 
    52 struct resource {
    53     int                 r_type;
    54     bus_space_tag_t     r_bustag;       /* bus_space tag */
    55     bus_space_handle_t  r_bushandle;    /* bus_space handle */
    56     area_id             r_mapped_area;
    57 };
    58 
    59 
    60 bus_space_handle_t rman_get_bushandle(struct resource *);
    61 bus_space_tag_t rman_get_bustag(struct resource *);
    62 int rman_get_rid(struct resource *);
    63 
    64 
    65 static inline u_long
    66 rman_get_start(struct resource *resourcePointer)
    67 {
    68     return resourcePointer->r_bushandle;
    69 }
    70 
    71 
    72 static inline uint32_t
    73 rman_make_alignment_flags(uint32_t size)
    74 {
    75     int i;
    76 
    77     /*
    78      * Find the hightest bit set, and add one if more than one bit
    79      * set.  We're effectively computing the ceil(log2(size)) here.
    80      */
    81     for (i = 31; i > 0; i--)
    82         if ((1 << i) & size)
    83             break;
    84     if (~(1 << i) & size)
    85         i++;
    86 
    87     return RF_ALIGNMENT_LOG2(i);
    88 }
    89 #endif /* _FBSD_COMPAT_SYS_RMAN_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/socket.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/socket.h b/src/libs/compat/freebsd_network/compat/sys/socket.h
    deleted file mode 100644
    index dc83ed2..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * All rights reserved. Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_SOCKET_H_
    6 #define _FBSD_COMPAT_SYS_SOCKET_H_
    7 
    8 
    9 #include <posix/sys/socket.h>
    10 
    11 #include <sys/cdefs.h>
    12 #include <sys/_types.h>
    13 
    14 
    15 // TODO Should be incorporated into Haikus socket.h with a number below AF_MAX
    16 #define AF_IEEE80211    AF_MAX + 1  /* IEEE 802.11 protocol */
    17 
    18 #endif /* _FBSD_COMPAT_SYS_SOCKET_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/sockio.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/sockio.h b/src/libs/compat/freebsd_network/compat/sys/sockio.h
    deleted file mode 100644
    index 7d469d7..0000000
    + -  
    1 /*
    2  * Copyright 2007-2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_SOCKIO_H_
    6 #define _FBSD_COMPAT_SYS_SOCKIO_H_
    7 
    8 
    9 #include <posix/sys/sockio.h>
    10 
    11 #include <sys/ioccom.h>
    12 
    13 
    14 #define SIOCSIFCAP  SIOCSPACKETCAP
    15 
    16 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/sysctl.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/sysctl.h b/src/libs/compat/freebsd_network/compat/sys/sysctl.h
    deleted file mode 100644
    index 0f324a2..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_SYSCTL_H_
    6 #define _FBSD_COMPAT_SYS_SYSCTL_H_
    7 
    8 
    9 #include <sys/queue.h>
    10 
    11 
    12 #ifdef _KERNEL
    13 
    14 struct sysctl_req {
    15     void *newptr;
    16 };
    17 
    18 struct sysctl_ctx_list {
    19 };
    20 
    21 struct sysctl_oid_list {
    22 };
    23 
    24 
    25 #define SYSCTL_HANDLER_ARGS void *oidp, void *arg1, int arg2, \
    26     struct sysctl_req *req
    27 
    28 #define OID_AUTO    (-1)
    29 
    30 #define CTLTYPE     0xf /* Mask for the type */
    31 #define CTLTYPE_NODE    1   /* name is a node */
    32 #define CTLTYPE_INT 2   /* name describes an integer */
    33 #define CTLTYPE_STRING  3   /* name describes a string */
    34 #define CTLTYPE_QUAD    4   /* name describes a 64-bit number */
    35 #define CTLTYPE_OPAQUE  5   /* name describes a structure */
    36 #define CTLTYPE_STRUCT  CTLTYPE_OPAQUE  /* name describes a structure */
    37 #define CTLTYPE_UINT    6   /* name describes an unsigned integer */
    38 #define CTLTYPE_LONG    7   /* name describes a long */
    39 #define CTLTYPE_ULONG   8   /* name describes an unsigned long */
    40 #define CTLTYPE_U64     9   /* name describes an unsigned 64-bit number */
    41 
    42 #define CTLFLAG_RD  0x80000000  /* Allow reads of variable */
    43 #define CTLFLAG_WR  0x40000000  /* Allow writes to the variable */
    44 #define CTLFLAG_RW  (CTLFLAG_RD|CTLFLAG_WR)
    45 #define CTLFLAG_NOLOCK  0x20000000  /* XXX Don't Lock */
    46 #define CTLFLAG_ANYBODY 0x10000000  /* All users can set this var */
    47 #define CTLFLAG_SECURE  0x08000000  /* Permit set only if securelevel<=0 */
    48 #define CTLFLAG_PRISON  0x04000000  /* Prisoned roots can fiddle */
    49 #define CTLFLAG_DYN 0x02000000  /* Dynamic oid - can be freed */
    50 #define CTLFLAG_SKIP    0x01000000  /* Skip this sysctl when listing */
    51 #define CTLMASK_SECURE  0x00F00000  /* Secure level */
    52 #define CTLFLAG_TUN 0x00080000  /* Tunable variable */
    53 #define CTLFLAG_MPSAFE  0x00040000  /* Handler is MP safe */
    54 #define CTLFLAG_RDTUN   (CTLFLAG_RD|CTLFLAG_TUN)
    55 
    56 
    57 static inline int
    58 sysctl_ctx_init(struct sysctl_ctx_list *clist)
    59 {
    60     return -1;
    61 }
    62 
    63 
    64 static inline int
    65 sysctl_ctx_free(struct sysctl_ctx_list *clist)
    66 {
    67     return -1;
    68 }
    69 
    70 
    71 static inline void *
    72 sysctl_add_oid(struct sysctl_ctx_list *clist, void *parent, int nbr,
    73     const char *name, int kind, void *arg1, int arg2,
    74     int (*handler) (SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr)
    75 {
    76     return NULL;
    77 }
    78 
    79 
    80 static inline int sysctl_handle_long(SYSCTL_HANDLER_ARGS) { return -1; }
    81 static inline int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS) { return -1; }
    82 static inline int sysctl_handle_quad(SYSCTL_HANDLER_ARGS) { return -1; }
    83 static inline int sysctl_handle_int(SYSCTL_HANDLER_ARGS) { return -1; }
    84 static inline int sysctl_handle_64(SYSCTL_HANDLER_ARGS) { return -1; }
    85 static inline int sysctl_handle_string(SYSCTL_HANDLER_ARGS) { return -1; }
    86 
    87 
    88 #define SYSCTL_OUT(r, p, l) -1
    89 
    90 #define __DESCR(x) ""
    91 
    92 #define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \
    93     sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, \
    94     __DESCR(descr))
    95 
    96 #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \
    97     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access),       \
    98     0, 0, handler, "N", __DESCR(descr))
    99 
    100 #define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr)  \
    101     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access),         \
    102     arg, len, sysctl_handle_string, "A", __DESCR(descr))
    103 
    104 #define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \
    105     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|(access),        \
    106     ptr, val, sysctl_handle_int, "I", __DESCR(descr))
    107 
    108 #define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr)    \
    109     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access),           \
    110     ptr, val, sysctl_handle_int, "IU", __DESCR(descr))
    111 
    112 #define SYSCTL_ADD_XINT(ctx, parent, nbr, name, access, ptr, val, descr)    \
    113     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access),           \
    114     ptr, val, sysctl_handle_int, "IX", __DESCR(descr))
    115 
    116 #define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \
    117     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|(access),   \
    118     ptr, 0, sysctl_handle_long, "L", __DESCR(descr))
    119 
    120 #define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr)    \
    121     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access),      \
    122     ptr, 0, sysctl_handle_long, "LU", __DESCR(descr))
    123 
    124 #define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \
    125     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_QUAD|(access),   \
    126     ptr, 0, sysctl_handle_quad, "Q", __DESCR(descr))
    127 
    128 #define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, descr)    \
    129     sysctl_add_oid(ctx, parent, nbr, name,                              \
    130     CTLTYPE_U64 | CTLFLAG_MPSAFE | (access),                            \
    131     ptr, 0, sysctl_handle_64, "QU", __DESCR(descr))
    132 
    133 #define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \
    134     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \
    135     ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr))
    136 
    137 #define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \
    138     sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access),         \
    139     ptr, sizeof(struct type), sysctl_handle_opaque, "S," #type, __DESCR(descr))
    140 
    141 #define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \
    142     sysctl_add_oid(ctx, parent, nbr, name, (access), ptr, arg, handler, fmt, \
    143     __DESCR(descr))
    144 
    145 
    146 static inline void *
    147 SYSCTL_CHILDREN(void *ptr)
    148 {
    149     return NULL;
    150 }
    151 
    152 
    153 #define SYSCTL_STATIC_CHILDREN(...) NULL
    154 
    155 #define SYSCTL_DECL(name) \
    156     extern struct sysctl_oid_list sysctl_##name##_children
    157 
    158 #define SYSCTL_NODE(...)
    159 #define SYSCTL_INT(...)
    160 #define SYSCTL_UINT(...)
    161 #define SYSCTL_PROC(...)
    162 
    163 #endif
    164 
    165 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/syslog.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/syslog.h b/src/libs/compat/freebsd_network/compat/sys/syslog.h
    deleted file mode 100644
    index f785d64..0000000
    + -  
    1 /*
    2  * Copyright 2009 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_SYSLOG_H_
    6 #define _FBSD_COMPAT_SYS_SYSLOG_H_
    7 
    8 
    9 #define LOG_ERR 3 /* error conditions */
    10 
    11 #endif /* _FBSD_COMPAT_SYS_SYSLOG_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/systm.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/systm.h b/src/libs/compat/freebsd_network/compat/sys/systm.h
    deleted file mode 100644
    index 42c2a79..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * Copyright 2007, Hugo Santos. All Rights Reserved.
    4  * Distributed under the terms of the MIT License.
    5  */
    6 #ifndef _FBSD_COMPAT_SYS_SYSTM_H_
    7 #define _FBSD_COMPAT_SYS_SYSTM_H_
    8 
    9 
    10 #include <stdint.h>
    11 #include <stdio.h>
    12 #include <string.h>
    13 #include <strings.h>
    14 
    15 #include <machine/atomic.h>
    16 #include <machine/cpufunc.h>
    17 
    18 #include <sys/callout.h>
    19 #include <sys/cdefs.h>
    20 #include <sys/queue.h>
    21 
    22 #include <sys/libkern.h>
    23 
    24 
    25 #define printf freebsd_printf
    26 int printf(const char *format, ...) __printflike(1, 2);
    27 
    28 
    29 #define ovbcopy(f, t, l) bcopy((f), (t), (l))
    30 
    31 #define bootverbose 1
    32 
    33 #ifdef INVARIANTS
    34 #define KASSERT(cond,msg) do {  \
    35     if (!(cond))                \
    36         panic msg;              \
    37 } while (0)
    38 #else
    39 #define KASSERT(exp,msg) do { \
    40 } while (0)
    41 #endif
    42 
    43 #define DELAY(n) \
    44     do {                \
    45         if (n < 1000)   \
    46             spin(n);    \
    47         else            \
    48             snooze(n);  \
    49     } while (0)
    50 
    51 void wakeup(void *);
    52 
    53 #ifndef CTASSERT /* Allow lint to override */
    54 #define CTASSERT(x)         _CTASSERT(x, __LINE__)
    55 #define _CTASSERT(x, y)     __CTASSERT(x, y)
    56 #define __CTASSERT(x, y)    typedef char __assert ## y[(x) ? 1 : -1]
    57 #endif
    58 
    59 
    60 static inline int
    61 copyin(const void * __restrict udaddr, void * __restrict kaddr,
    62     size_t len)
    63 {
    64     return user_memcpy(kaddr, udaddr, len);
    65 }
    66 
    67 
    68 static inline int
    69 copyout(const void * __restrict kaddr, void * __restrict udaddr,
    70     size_t len)
    71 {
    72     return user_memcpy(udaddr, kaddr, len);
    73 }
    74 
    75 
    76 static inline void log(int level, const char *fmt, ...) { }
    77 
    78 
    79 int snprintf(char *, size_t, const char *, ...) __printflike(3, 4);
    80 extern int sprintf(char *buf, const char *, ...);
    81 
    82 extern void driver_vprintf(const char *format, va_list vl);
    83 #define vprintf(fmt, vl) driver_vprintf(fmt, vl)
    84 
    85 extern int vsnprintf(char *, size_t, const char *, __va_list)
    86     __printflike(3, 0);
    87 
    88 int msleep(void *, struct mtx *, int, const char *, int);
    89 int _pause(const char *, int);
    90 #define pause(waitMessage, timeout) _pause((waitMessage), (timeout))
    91 #define tsleep(channel, priority, waitMessage, timeout) \
    92     msleep((channel), NULL, (priority), (waitMessage), (timeout))
    93 
    94 struct unrhdr;
    95 struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex);
    96 void delete_unrhdr(struct unrhdr *);
    97 int alloc_unr(struct unrhdr *);
    98 void free_unr(struct unrhdr *, u_int);
    99 
    100 extern char *getenv(const char *name);
    101 extern void    freeenv(char *env);
    102 
    103 #endif  /* _FBSD_COMPAT_SYS_SYSTM_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/taskqueue.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/taskqueue.h b/src/libs/compat/freebsd_network/compat/sys/taskqueue.h
    deleted file mode 100644
    index 77fa6a0..0000000
    + -  
    1 /*
    2  * Copyright 2007 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_TASKQUEUE_H_
    6 #define _FBSD_COMPAT_SYS_TASKQUEUE_H_
    7 
    8 
    9 #include <sys/queue.h>
    10 #include <sys/_task.h>
    11 
    12 
    13 #define PI_NET  (B_REAL_TIME_DISPLAY_PRIORITY - 1)
    14 
    15 #define TASK_INIT(taskp, prio, hand, arg) task_init(taskp, prio, hand, arg)
    16 
    17 
    18 typedef void (*taskqueue_enqueue_fn)(void *context);
    19 
    20 
    21 struct taskqueue;
    22 struct taskqueue *taskqueue_create(const char *name, int mflags,
    23     taskqueue_enqueue_fn enqueue, void *context);
    24 int taskqueue_start_threads(struct taskqueue **tq, int count, int pri,
    25     const char *name, ...) __printflike(4, 5);
    26 void taskqueue_free(struct taskqueue *tq);
    27 void taskqueue_drain(struct taskqueue *tq, struct task *task);
    28 void taskqueue_block(struct taskqueue *queue);
    29 void taskqueue_unblock(struct taskqueue *queue);
    30 int taskqueue_enqueue(struct taskqueue *tq, struct task *task);
    31 
    32 void taskqueue_thread_enqueue(void *context);
    33 
    34 extern struct taskqueue *taskqueue_fast;
    35 extern struct taskqueue *taskqueue_swi;
    36 
    37 int taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task);
    38 struct taskqueue *taskqueue_create_fast(const char *name, int mflags,
    39     taskqueue_enqueue_fn enqueue, void *context);
    40 
    41 void task_init(struct task *, int prio, task_handler_t handler, void *arg);
    42 
    43 #endif
  • deleted file src/libs/compat/freebsd_network/compat/sys/time.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/time.h b/src/libs/compat/freebsd_network/compat/sys/time.h
    deleted file mode 100644
    index 4b061e3..0000000
    + -  
    1 /*
    2  * Copyright 2009, Colin Günther, coling@gmx.de.
    3  * All rights reserved. Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_TIME_H_
    6 #define _FBSD_COMPAT_SYS_TIME_H_
    7 
    8 
    9 #include <posix/sys/time.h>
    10 
    11 #include <sys/_timeval.h>
    12 #include <sys/types.h>
    13 
    14 
    15 #define time_uptime (system_time() / 1000000)
    16 
    17 
    18 int ppsratecheck(struct timeval*, int*, int);
    19 
    20 #endif /* _FBSD_COMPAT_SYS_TIME_H_ */
  • deleted file src/libs/compat/freebsd_network/compat/sys/types.h

    diff --git a/src/libs/compat/freebsd_network/compat/sys/types.h b/src/libs/compat/freebsd_network/compat/sys/types.h
    deleted file mode 100644
    index babd91b..0000000
    + -  
    1 /*
    2  * Copyright 2007 Haiku Inc. All rights reserved.
    3  * Distributed under the terms of the MIT License.
    4  */
    5 #ifndef _FBSD_COMPAT_SYS_TYPES_H_
    6 #define _FBSD_COMPAT_SYS_TYPES_H_
    7 
    8 
    9 #include <posix/stdint.h>
    10 #include <posix/sys/types.h>
    11 
    12 #include <sys/cdefs.h>
    13 
    14 #include <machine/endian.h>
    15 #include <sys/_types.h>
    16 
    17 
    18 typedef int boolean_t;
    19 typedef __const char* c_caddr_t;
    20 typedef uint64_t u_quad_t;
    21 
    22 #endif
  • src/servers/net/Jamfile

    diff --git a/src/servers/net/Jamfile b/src/servers/net/Jamfile
    index 3d26909..7ce5c8d 100644
    a b SubDir HAIKU_TOP src servers net ;  
    22
    33UsePrivateHeaders app net shared storage ;
    44
     5UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
     6DEFINES += _BSD_SOURCE ;
     7
    58UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ]
    69    : true ;
    710UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;