|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
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.
11: *
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
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /*
23: * @OSF_COPYRIGHT@
24: *
25: */
26:
27: #include <kern/ipc_kobject.h>
28: #include <kern/ipc_sync.h>
29: #include <ipc/port.h>
30: #include <ipc/ipc_space.h>
31: #include <ipc/ipc_port.h>
32: #include <mach/semaphore_server.h>
33: #include <mach/lock_set_server.h>
34: #include <mach/mach_port_server.h>
35: #include <mach/port.h>
36:
37:
38: semaphore_t
39: convert_port_to_semaphore (ipc_port_t port)
40: {
41: semaphore_t semaphore = SEMAPHORE_NULL;
42:
43: if (IP_VALID (port)) {
44: ip_lock(port);
45: if (ip_active(port) && (ip_kotype(port) == IKOT_SEMAPHORE)) {
46: semaphore = (semaphore_t) port->ip_kobject;
47: semaphore_reference(semaphore);
48: }
49: ip_unlock(port);
50: }
51:
52: return (semaphore);
53: }
54:
55: ipc_port_t
56: convert_semaphore_to_port (semaphore_t semaphore)
57: {
58: ipc_port_t port;
59:
60: if (semaphore != SEMAPHORE_NULL)
61: port = ipc_port_make_send(semaphore->port);
62: else
63: port = IP_NULL;
64:
65: return (port);
66: }
67:
68: lock_set_t
69: convert_port_to_lock_set (ipc_port_t port)
70: {
71: lock_set_t lock_set = LOCK_SET_NULL;
72:
73: if (IP_VALID (port)) {
74: ip_lock(port);
75: if (ip_active(port) && (ip_kotype(port) == IKOT_LOCK_SET)) {
76: lock_set = (lock_set_t) port->ip_kobject;
77: lock_set_reference(lock_set);
78: }
79: ip_unlock(port);
80: }
81:
82: return (lock_set);
83: }
84:
85: ipc_port_t
86: convert_lock_set_to_port (lock_set_t lock_set)
87: {
88: ipc_port_t port;
89:
90: if (lock_set != LOCK_SET_NULL)
91: port = ipc_port_make_send(lock_set->port);
92: else
93: port = IP_NULL;
94:
95: return (port);
96: }
97:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.