]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_misc.c
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 #include <sys/errno.h>
31 #include <sys/types.h>
32 #include <sys/param.h>
33 #include <machine/spl.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
37 #include <sys/filedesc.h>
38 #include <sys/fcntl.h>
40 #include <sys/socket.h>
42 #include <netat/sysglue.h>
43 #include <netat/appletalk.h>
44 #include <netat/at_pcb.h>
45 #include <netat/debug.h>
46 #include <netat/adsp.h>
47 #include <netat/adsp_internal.h>
50 * These function replace the Mk68 assembly routines found in qAddToEnd.s and
52 * Modified for MP, 1996 by Tuyen Nguyen
53 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
55 extern atlock_t adspgen_lock
;
62 /* ----------------------------------------------------------------------
63 * void qAddToEnd(void *qhead, void *qelem)
66 * Ptr to ptr to 1st item in queue
67 * Ptr to item to add to end of queue
71 * Assumptions: The link field is the FIRST field of the qelem structure.
72 * ----------------------------------------------------------------------
74 int qAddToEnd(qhead
, qelem
)
78 /* define our own type to access the next field. NOTE THAT THE "NEXT"
79 * FIELD IS ASSUMED TO BE THE FIRST FIELD OF THE STRUCTURE
82 register struct qlink
*q
;
84 /* Scan the linked list to the end and update the previous
85 * element next field. (do that protocted).
91 /* are we about to link to ourself */
101 qelem
->qlinkp
= (struct qlink
*) 0;
104 DPRINTF("%s: qhead=%x added elem=%x\n","qAddToEnd", qhead
, qelem
);
111 /* ----------------------------------------------------------------------
113 * void* qfind_m(void *qhead, void NPTR match, ProcPtr compare_fnx)
115 * Hunt down a linked list of queue elements calling the compare
116 * function on each item. When the compare function returns true,
117 * return ptr to the queue element.
121 * qhead Address of ptr to first item in queue
125 * D0 & A0 Ptr to queue element or NIL
128 * ----------------------------------------------------------------------
130 void* qfind_m(qhead
, match
, compare_fnx
)
136 CCBPtr queue_item
= qhead
;
138 ATDISABLE(s
, adspgen_lock
);
140 if ((*compare_fnx
)(queue_item
,match
))
143 queue_item
= queue_item
->ccbLink
;
145 ATENABLE(s
, adspgen_lock
);