]> git.saurik.com Git - apple/libdispatch.git/blob - src/firehose/firehose_server_internal.h
libdispatch-913.30.4.tar.gz
[apple/libdispatch.git] / src / firehose / firehose_server_internal.h
1 /*
2 * Copyright (c) 2015 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21 #ifndef __FIREHOSE_SERVER_INTERNAL__
22 #define __FIREHOSE_SERVER_INTERNAL__
23
24 OS_OBJECT_CLASS_DECL(firehose_client, object);
25 #define FIREHOSE_CLIENT_CLASS OS_OBJECT_VTABLE(firehose_client)
26
27 typedef struct firehose_snapshot_s *firehose_snapshot_t;
28 struct firehose_snapshot_s {
29 firehose_snapshot_handler_t handler;
30 dispatch_group_t fs_group;
31 };
32
33 struct firehose_client_s {
34 union {
35 _OS_OBJECT_HEADER(void *os_obj_isa, os_obj_ref_cnt, os_obj_xref_cnt);
36 struct _os_object_s fc_as_os_object;
37 };
38 TAILQ_ENTRY(firehose_client_s) fc_entry;
39 struct firehose_client_s *volatile fc_next[2];
40
41 firehose_buffer_t fc_buffer;
42 uint64_t volatile fc_mem_sent_flushed_pos;
43 uint64_t volatile fc_mem_flushed_pos;
44 uint64_t volatile fc_io_sent_flushed_pos;
45 uint64_t volatile fc_io_flushed_pos;
46
47 #define FC_STATE_ENQUEUED(for_io) (0x0001u << (for_io))
48 #define FC_STATE_MEM_ENQUEUED 0x0001
49 #define FC_STATE_IO_ENQUEUED 0x0002
50
51 #define FC_STATE_CANCELING(for_io) (0x0010u << (for_io))
52 #define FC_STATE_MEM_CANCELING 0x0010
53 #define FC_STATE_IO_CANCELING 0x0020
54
55 #define FC_STATE_CANCELED(for_io) (0x0100u << (for_io))
56 #define FC_STATE_MEM_CANCELED 0x0100
57 #define FC_STATE_IO_CANCELED 0x0200
58 #define FC_STATE_CANCELED_MASK 0x0300
59
60 uintptr_t volatile fc_state;
61
62 void *volatile fc_ctxt;
63
64 union {
65 dispatch_mach_t fc_mach_channel;
66 dispatch_source_t fc_kernel_source;
67 };
68 mach_port_t fc_recvp;
69 mach_port_t fc_sendp;
70 os_unfair_lock fc_lock;
71 pid_t fc_pid;
72 int fc_pidversion;
73 uid_t fc_euid;
74 bool fc_use_notifs;
75 bool fc_memory_corrupted;
76 bool fc_needs_io_snapshot;
77 bool fc_needs_mem_snapshot;
78 bool fc_quarantined;
79 };
80
81 void
82 _firehose_client_xref_dispose(struct firehose_client_s *fc);
83 void
84 _firehose_client_dispose(struct firehose_client_s *fc);
85
86 extern unsigned char __libfirehose_serverVersionString[];
87 extern double __libfirehose_serverVersionNumber;
88
89 #endif // __FIREHOSE_SERVER_INTERNAL__