]>
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_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #include <sys/errno.h>
23 #include <sys/types.h>
24 #include <sys/param.h>
25 #include <machine/spl.h>
26 #include <sys/systm.h>
27 #include <sys/kernel.h>
29 #include <sys/filedesc.h>
30 #include <sys/fcntl.h>
32 #include <sys/socket.h>
34 #include <netat/sysglue.h>
35 #include <netat/appletalk.h>
36 #include <netat/at_pcb.h>
37 #include <netat/debug.h>
38 #include <netat/adsp.h>
39 #include <netat/adsp_internal.h>
42 * These function replace the Mk68 assembly routines found in qAddToEnd.s and
44 * Modified for MP, 1996 by Tuyen Nguyen
45 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
47 extern atlock_t adspgen_lock
;
54 /* ----------------------------------------------------------------------
55 * void qAddToEnd(void *qhead, void *qelem)
58 * Ptr to ptr to 1st item in queue
59 * Ptr to item to add to end of queue
63 * Assumptions: The link field is the FIRST field of the qelem structure.
64 * ----------------------------------------------------------------------
66 int qAddToEnd(qhead
, qelem
)
70 /* define our own type to access the next field. NOTE THAT THE "NEXT"
71 * FIELD IS ASSUMED TO BE THE FIRST FIELD OF THE STRUCTURE
74 register struct qlink
*q
;
76 /* Scan the linked list to the end and update the previous
77 * element next field. (do that protocted).
83 /* are we about to link to ourself */
93 qelem
->qlinkp
= (struct qlink
*) 0;
96 DPRINTF("%s: qhead=%x added elem=%x\n","qAddToEnd", qhead
, qelem
);
103 /* ----------------------------------------------------------------------
105 * void* qfind_m(void *qhead, void NPTR match, ProcPtr compare_fnx)
107 * Hunt down a linked list of queue elements calling the compare
108 * function on each item. When the compare function returns true,
109 * return ptr to the queue element.
113 * qhead Address of ptr to first item in queue
117 * D0 & A0 Ptr to queue element or NIL
120 * ----------------------------------------------------------------------
122 void* qfind_m(qhead
, match
, compare_fnx
)
128 CCBPtr queue_item
= qhead
;
130 ATDISABLE(s
, adspgen_lock
);
132 if ((*compare_fnx
)(queue_item
,match
))
135 queue_item
= queue_item
->ccbLink
;
137 ATENABLE(s
, adspgen_lock
);