]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_misc.c
c337a616b634e4761c54f747268b329e60a52ca7
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 #include <sys/errno.h>
24 #include <sys/types.h>
25 #include <sys/param.h>
26 #include <machine/spl.h>
27 #include <sys/systm.h>
28 #include <sys/kernel.h>
30 #include <sys/filedesc.h>
31 #include <sys/fcntl.h>
33 #include <sys/socket.h>
35 #include <netat/sysglue.h>
36 #include <netat/appletalk.h>
37 #include <netat/at_pcb.h>
38 #include <netat/debug.h>
39 #include <netat/adsp.h>
40 #include <netat/adsp_internal.h>
43 * These function replace the Mk68 assembly routines found in qAddToEnd.s and
45 * Modified for MP, 1996 by Tuyen Nguyen
46 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
48 extern atlock_t adspgen_lock
;
55 /* ----------------------------------------------------------------------
56 * void qAddToEnd(void *qhead, void *qelem)
59 * Ptr to ptr to 1st item in queue
60 * Ptr to item to add to end of queue
64 * Assumptions: The link field is the FIRST field of the qelem structure.
65 * ----------------------------------------------------------------------
67 int qAddToEnd(qhead
, qelem
)
71 /* define our own type to access the next field. NOTE THAT THE "NEXT"
72 * FIELD IS ASSUMED TO BE THE FIRST FIELD OF THE STRUCTURE
75 register struct qlink
*q
;
77 /* Scan the linked list to the end and update the previous
78 * element next field. (do that protocted).
84 /* are we about to link to ourself */
94 qelem
->qlinkp
= (struct qlink
*) 0;
97 DPRINTF("%s: qhead=%x added elem=%x\n","qAddToEnd", qhead
, qelem
);
104 /* ----------------------------------------------------------------------
106 * void* qfind_m(void *qhead, void NPTR match, ProcPtr compare_fnx)
108 * Hunt down a linked list of queue elements calling the compare
109 * function on each item. When the compare function returns true,
110 * return ptr to the queue element.
114 * qhead Address of ptr to first item in queue
118 * D0 & A0 Ptr to queue element or NIL
121 * ----------------------------------------------------------------------
123 void* qfind_m(qhead
, match
, compare_fnx
)
129 CCBPtr queue_item
= qhead
;
131 ATDISABLE(s
, adspgen_lock
);
133 if ((*compare_fnx
)(queue_item
,match
))
136 queue_item
= queue_item
->ccbLink
;
138 ATENABLE(s
, adspgen_lock
);