|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: ! 25: /* ! 26: * Copyright (c) 1995, 1994, 1993, 1992, 1991, 1990 ! 27: * Open Software Foundation, Inc. ! 28: * ! 29: * Permission to use, copy, modify, and distribute this software and ! 30: * its documentation for any purpose and without fee is hereby granted, ! 31: * provided that the above copyright notice appears in all copies and ! 32: * that both the copyright notice and this permission notice appear in ! 33: * supporting documentation, and that the name of ("OSF") or Open Software ! 34: * Foundation not be used in advertising or publicity pertaining to ! 35: * distribution of the software without specific, written prior permission. ! 36: * ! 37: * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE ! 38: * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ! 39: * FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL OSF BE LIABLE FOR ANY ! 40: * SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ! 41: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ! 42: * ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING ! 43: * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! 44: */ ! 45: /* ! 46: * OSF Research Institute MK6.1 (unencumbered) 1/31/1995 ! 47: */ ! 48: /* ! 49: * Mach Operating System ! 50: * Copyright (c) 1991,1990,1989 Carnegie Mellon University ! 51: * All Rights Reserved. ! 52: * ! 53: * Permission to use, copy, modify and distribute this software and its ! 54: * documentation is hereby granted, provided that both the copyright ! 55: * notice and this permission notice appear in all copies of the ! 56: * software, derivative works or modified versions, and any portions ! 57: * thereof, and that both notices appear in supporting documentation. ! 58: * ! 59: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" ! 60: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR ! 61: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ! 62: * ! 63: * Carnegie Mellon requests users of this software to return to ! 64: * ! 65: * Software Distribution Coordinator or [email protected] ! 66: * School of Computer Science ! 67: * Carnegie Mellon University ! 68: * Pittsburgh PA 15213-3890 ! 69: * ! 70: * any improvements or extensions that they make and grant Carnegie Mellon ! 71: * the rights to redistribute these changes. ! 72: */ ! 73: /* ! 74: * File: ipc/ipc_thread.h ! 75: * Author: Rich Draves ! 76: * Date: 1989 ! 77: * ! 78: * Definitions for the IPC component of threads. ! 79: */ ! 80: ! 81: #ifndef _IPC_IPC_THREAD_H_ ! 82: #define _IPC_IPC_THREAD_H_ ! 83: ! 84: #include <kern/thread.h> ! 85: ! 86: typedef thread_t ipc_thread_t; ! 87: ! 88: #define ITH_NULL THREAD_NULL ! 89: ! 90: #define ith_lock_init(thread) simple_lock_init(&(thread)->ith_lock_data) ! 91: #define ith_lock(thread) simple_lock(&(thread)->ith_lock_data) ! 92: #define ith_unlock(thread) simple_unlock(&(thread)->ith_lock_data) ! 93: ! 94: typedef struct ipc_thread_queue { ! 95: ipc_thread_t ithq_base; ! 96: } *ipc_thread_queue_t; ! 97: ! 98: #define ITHQ_NULL ((ipc_thread_queue_t) 0) ! 99: ! 100: ! 101: #define ipc_thread_links_init(thread) \ ! 102: MACRO_BEGIN \ ! 103: (thread)->ith_next = (thread); \ ! 104: (thread)->ith_prev = (thread); \ ! 105: MACRO_END ! 106: ! 107: #define ipc_thread_queue_init(queue) \ ! 108: MACRO_BEGIN \ ! 109: (queue)->ithq_base = ITH_NULL; \ ! 110: MACRO_END ! 111: ! 112: #define ipc_thread_queue_empty(queue) ((queue)->ithq_base == ITH_NULL) ! 113: ! 114: #define ipc_thread_queue_first(queue) ((queue)->ithq_base) ! 115: ! 116: #define ipc_thread_rmqueue_first_macro(queue, thread) \ ! 117: MACRO_BEGIN \ ! 118: register ipc_thread_t _next; \ ! 119: \ ! 120: assert((queue)->ithq_base == (thread)); \ ! 121: \ ! 122: _next = (thread)->ith_next; \ ! 123: if (_next == (thread)) { \ ! 124: assert((thread)->ith_prev == (thread)); \ ! 125: (queue)->ithq_base = ITH_NULL; \ ! 126: } else { \ ! 127: register ipc_thread_t _prev = (thread)->ith_prev; \ ! 128: \ ! 129: (queue)->ithq_base = _next; \ ! 130: _next->ith_prev = _prev; \ ! 131: _prev->ith_next = _next; \ ! 132: ipc_thread_links_init(thread); \ ! 133: } \ ! 134: MACRO_END ! 135: ! 136: #define ipc_thread_enqueue_macro(queue, thread) \ ! 137: MACRO_BEGIN \ ! 138: register ipc_thread_t _first = (queue)->ithq_base; \ ! 139: \ ! 140: if (_first == ITH_NULL) { \ ! 141: (queue)->ithq_base = (thread); \ ! 142: assert((thread)->ith_next == (thread)); \ ! 143: assert((thread)->ith_prev == (thread)); \ ! 144: } else { \ ! 145: register ipc_thread_t _last = _first->ith_prev; \ ! 146: \ ! 147: (thread)->ith_next = _first; \ ! 148: (thread)->ith_prev = _last; \ ! 149: _first->ith_prev = (thread); \ ! 150: _last->ith_next = (thread); \ ! 151: } \ ! 152: MACRO_END ! 153: ! 154: /* Enqueue a thread on a message queue */ ! 155: extern void ipc_thread_enqueue( ! 156: ipc_thread_queue_t queue, ! 157: ipc_thread_t thread); ! 158: ! 159: /* Dequeue a thread from a message queue */ ! 160: extern ipc_thread_t ipc_thread_dequeue( ! 161: ipc_thread_queue_t queue); ! 162: ! 163: /* Remove a thread from a message queue */ ! 164: extern void ipc_thread_rmqueue( ! 165: ipc_thread_queue_t queue, ! 166: ipc_thread_t thread); ! 167: ! 168: #endif /* _IPC_IPC_THREAD_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.