Skip to content

Commit 16d8a2c

Browse files
committed
fix stubbed functions to have the right prototype and abort in their bodies when called
1 parent a6ede63 commit 16d8a2c

File tree

1 file changed

+68
-36
lines changed

1 file changed

+68
-36
lines changed

src/stubs.c

Lines changed: 68 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,73 @@
1+
#include <stdint.h>
2+
3+
#include <config/config.h>
4+
15
#include "pthread.h"
26

3-
// void _dispatch_source_type_timer() { }
4-
//void dispatch_source_create() { }
5-
//void dispatch_source_set_event_handler_f() { }
6-
//void dispatch_source_set_timer() { }
7-
//void dispatch_resume() { }
8-
//void dispatch_main() { }
9-
void pthread_workqueue_attr_destroy_np() { }
10-
void dispatch_timer__program_semaphore() { }
11-
void kqueue() { }
12-
void _dispatch_mach_msg_dispose() { }
13-
void dispatch_timer__wake_semaphore() { }
14-
void _dispatch_mach_probe() { }
15-
void _dispatch_block_create() { }
16-
void _dispatch_mach_invoke() { }
17-
void _dispatch_mach_msg_debug() { }
18-
void _dispatch_mach_dispose() { }
19-
void TRASHIT() { }
20-
void _dispatch_mach_msg_invoke() { }
21-
void pthread_workqueue_attr_setovercommit_np() { }
22-
void _dispatch_runloop_queue_probe() { }
23-
void _dispatch_runloop_queue_xref_dispose() { }
24-
void pthread_workqueue_attr_setqueuepriority_np() { }
25-
void dispatch_timer__configure_semaphore() { }
26-
void strlcpy() { }
27-
void _dispatch_runloop_queue_dispose() { }
28-
void kevent64() { }
29-
void mach_error_string() { }
30-
void pthread_workqueue_additem_np() { }
31-
void _dispatch_block_special_invoke() { }
32-
void dispatch_timer__fire_semaphore() { }
33-
void mach_vm_deallocate() { }
34-
void pthread_mach_thread_np() { }
35-
void pthread_workqueue_create_np() { }
36-
void mach_task_self() { }
37-
void pthread_workqueue_attr_init_np() { }
38-
void sysctlbyname() { }
7+
#define program_invocation_short_name "hi"
8+
9+
#include "os/base.h"
10+
#include "internal.h"
11+
12+
13+
#undef LINUX_PORT_ERROR
14+
#define LINUX_PORT_ERROR() do { printf("LINUX_PORT_ERROR_CALLED %s:%d: %s\n",__FILE__,__LINE__,__FUNCTION__); abort(); } while (0)
15+
16+
int kqueue() { LINUX_PORT_ERROR(); }
17+
18+
void _dispatch_mach_msg_dispose() { LINUX_PORT_ERROR(); }
19+
20+
unsigned long _dispatch_mach_probe(dispatch_mach_t dm) {
21+
LINUX_PORT_ERROR();
22+
}
23+
24+
dispatch_block_t _dispatch_block_create(dispatch_block_flags_t flags,
25+
voucher_t voucher, pthread_priority_t priority,
26+
dispatch_block_t block) {
27+
LINUX_PORT_ERROR();
28+
}
29+
30+
void _dispatch_mach_invoke() { LINUX_PORT_ERROR(); }
31+
32+
size_t _dispatch_mach_msg_debug(dispatch_mach_msg_t dmsg, char* buf, size_t bufsiz) {
33+
LINUX_PORT_ERROR();
34+
}
35+
void _dispatch_mach_dispose() { LINUX_PORT_ERROR(); }
36+
void TRASHIT() { LINUX_PORT_ERROR(); }
37+
void _dispatch_mach_msg_invoke() { LINUX_PORT_ERROR(); }
38+
39+
unsigned long _dispatch_runloop_queue_probe(dispatch_queue_t dq) {
40+
LINUX_PORT_ERROR();
41+
}
42+
void _dispatch_runloop_queue_xref_dispose() { LINUX_PORT_ERROR(); }
43+
44+
void strlcpy() { LINUX_PORT_ERROR(); }
45+
void _dispatch_runloop_queue_dispose() { LINUX_PORT_ERROR(); }
46+
void kevent64() { LINUX_PORT_ERROR(); }
47+
char* mach_error_string(mach_msg_return_t x) {
48+
LINUX_PORT_ERROR();
49+
}
50+
51+
void mach_vm_deallocate() { LINUX_PORT_ERROR(); }
52+
53+
mach_port_t pthread_mach_thread_np() {
54+
return (mach_port_t)pthread_self();
55+
}
56+
57+
mach_port_t mach_task_self() {
58+
return (mach_port_t)pthread_self();
59+
}
60+
61+
int sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
62+
void *newp, size_t newlen) {
63+
LINUX_PORT_ERROR();
64+
}
3965

4066
pthread_key_t dispatch_voucher_key;
4167
pthread_key_t dispatch_pthread_root_queue_observer_hooks_key;
68+
69+
unsigned short dispatch_timer__program_semaphore;
70+
unsigned short dispatch_timer__wake_semaphore;
71+
unsigned short dispatch_timer__fire_semaphore;
72+
unsigned short dispatch_timer__configure_semaphore;
73+
void (*_dispatch_block_special_invoke)(void*);

0 commit comments

Comments
 (0)