Skip to content

Commit da3b73d

Browse files
committed
WIP on stubbing out missing pieces to get code to compile
1 parent 4f9b58c commit da3b73d

File tree

4 files changed

+74
-7
lines changed

4 files changed

+74
-7
lines changed

os/linux_base.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,27 @@ typedef uint32_t mach_port_t;
1818

1919
typedef uint32_t mach_error_t;
2020

21+
typedef uint32_t mach_vm_size_t;
22+
23+
typedef uint32_t mach_msg_return_t;
24+
25+
typedef uintptr_t mach_vm_address_t;
26+
2127
typedef uint32_t dispatch_mach_msg_t;
2228

2329
typedef uint32_t dispatch_mach_t;
2430

2531
typedef uint32_t dispatch_mach_reason_t;
2632

27-
typedef uint32_t mach_vm_size_t;
28-
29-
typedef uintptr_t mach_vm_address_t;
3033

3134
typedef struct
3235
{
3336
} mach_msg_header_t;
3437

3538

36-
typedef void (*dispatch_mach_handler_function_t)(void*);
39+
typedef void (*dispatch_mach_handler_function_t)(void*, dispatch_mach_reason_t,
40+
dispatch_mach_msg_t, mach_error_t);
41+
3742
typedef void (*dispatch_mach_msg_destructor_t)(void*);
3843

3944
/*
@@ -42,8 +47,25 @@ typedef void (*dispatch_mach_msg_destructor_t)(void*);
4247

4348
struct kevent64_s
4449
{
50+
uint64_t ident;
51+
int16_t filter;
52+
uint16_t flags;
53+
uint32_t fflags;
54+
int64_t data;
55+
uint64_t udata;
56+
uint64_t ext[2];
4557
};
4658

59+
typedef uint32_t voucher_activity_mode_t;
60+
61+
struct voucher_offsets_s {
62+
uint32_t vo_version;
63+
};
64+
65+
66+
// bogus...
67+
#define PAGE_SIZE 4096
68+
4769
/*
4870
* Stub out misc linking and compilation attributes
4971
*/

os/stubs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mach_port_t mach_task_self();
1212

1313
void mach_vm_deallocate(mach_port_t, mach_vm_address_t, mach_vm_size_t);
1414

15+
char* mach_error_string(mach_msg_return_t);
1516
#endif
1617

1718

src/init.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ const struct dispatch_tsd_indexes_s dispatch_tsd_indexes = {
162162
.dti_qos_class_index = dispatch_priority_key,
163163
};
164164
#else // DISPATCH_USE_DIRECT_TSD
165+
#ifndef __LINUX_PORT_HDD__
165166
#error Not implemented on this platform
167+
#endif
166168
#endif // DISPATCH_USE_DIRECT_TSD
167169

168170
// 6618342 Contact the team that owns the Instrument DTrace probe before
@@ -1157,7 +1159,10 @@ const struct dispatch_source_type_s _dispatch_source_type_vnode = {
11571159
.flags = EV_CLEAR|EV_UDATA_SPECIFIC,
11581160
},
11591161
.mask = NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND|NOTE_ATTRIB|NOTE_LINK|
1160-
NOTE_RENAME|NOTE_REVOKE
1162+
NOTE_RENAME
1163+
#if HAVE_DECL_NOTE_REVOKE
1164+
|NOTE_REVOKE
1165+
#endif
11611166
#if HAVE_DECL_NOTE_NONE
11621167
|NOTE_NONE
11631168
#endif

src/io.c

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,14 @@ dispatch_io_create_with_path(dispatch_io_type_t type, const char *path,
387387
int err = 0;
388388
struct stat st;
389389
_dispatch_io_syscall_switch_noerr(err,
390-
(path_data->oflag & O_NOFOLLOW) == O_NOFOLLOW ||
391-
(path_data->oflag & O_SYMLINK) == O_SYMLINK ?
390+
(path_data->oflag & O_NOFOLLOW) == O_NOFOLLOW
391+
#ifdef __LINUX_PORT_HDD__
392+
?
392393
lstat(path_data->path, &st) : stat(path_data->path, &st),
394+
#else
395+
|| (path_data->oflag & O_SYMLINK) == O_SYMLINK ?
396+
lstat(path_data->path, &st) : stat(path_data->path, &st),
397+
#endif
393398
case 0:
394399
err = _dispatch_io_validate_type(channel, st.st_mode);
395400
break;
@@ -1777,17 +1782,37 @@ _dispatch_stream_cleanup_operations(dispatch_stream_t stream,
17771782
dispatch_operation_t op, tmp;
17781783
typeof(*stream->operations) *operations;
17791784
operations = &stream->operations[DISPATCH_IO_RANDOM];
1785+
#ifdef __LINUX_PORT_HDD__
1786+
LINUX_PORT_ERROR();
1787+
// NOT CORRECT (doesn't support removal during iteration)
1788+
TAILQ_FOREACH(op, operations, operation_list) {
1789+
if (!channel || op->channel == channel) {
1790+
_dispatch_stream_complete_operation(stream, op);
1791+
}
1792+
}
1793+
#else
17801794
TAILQ_FOREACH_SAFE(op, operations, operation_list, tmp) {
17811795
if (!channel || op->channel == channel) {
17821796
_dispatch_stream_complete_operation(stream, op);
17831797
}
17841798
}
1799+
#endif
17851800
operations = &stream->operations[DISPATCH_IO_STREAM];
1801+
#ifdef __LINUX_PORT_HDD__
1802+
LINUX_PORT_ERROR();
1803+
// NOT CORRECT (doesn't support removal during iteration)
1804+
TAILQ_FOREACH(op, operations, operation_list) {
1805+
if (!channel || op->channel == channel) {
1806+
_dispatch_stream_complete_operation(stream, op);
1807+
}
1808+
}
1809+
#else
17861810
TAILQ_FOREACH_SAFE(op, operations, operation_list, tmp) {
17871811
if (!channel || op->channel == channel) {
17881812
_dispatch_stream_complete_operation(stream, op);
17891813
}
17901814
}
1815+
#endif
17911816
if (stream->source_running && !_dispatch_stream_operation_avail(stream)) {
17921817
dispatch_suspend(stream->source);
17931818
stream->source_running = false;
@@ -1799,11 +1824,21 @@ _dispatch_disk_cleanup_operations(dispatch_disk_t disk, dispatch_io_t channel)
17991824
{
18001825
// On pick queue
18011826
dispatch_operation_t op, tmp;
1827+
#ifdef __LINUX_PORT_HDD__
1828+
LINUX_PORT_ERROR();
1829+
// NOT CORRECT (doesn't support removal during iteration)
1830+
TAILQ_FOREACH(op, &disk->operations, operation_list) {
1831+
if (!channel || op->channel == channel) {
1832+
_dispatch_disk_complete_operation(disk, op);
1833+
}
1834+
}
1835+
#else
18021836
TAILQ_FOREACH_SAFE(op, &disk->operations, operation_list, tmp) {
18031837
if (!channel || op->channel == channel) {
18041838
_dispatch_disk_complete_operation(disk, op);
18051839
}
18061840
}
1841+
#endif
18071842
}
18081843

18091844
#pragma mark -
@@ -2064,6 +2099,9 @@ _dispatch_disk_perform(void *ctxt)
20642099
static void
20652100
_dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size)
20662101
{
2102+
#ifdef __LINUX_PORT_HDD__
2103+
LINUX_PORT_ERROR();
2104+
#else
20672105
int err;
20682106
struct radvisory advise;
20692107
// No point in issuing a read advise for the next chunk if we are already
@@ -2090,6 +2128,7 @@ _dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size)
20902128
// TODO: set disk status on error
20912129
default: (void)dispatch_assume_zero(err); break;
20922130
);
2131+
#endif
20932132
}
20942133

20952134
static int

0 commit comments

Comments
 (0)