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