Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[3d19a6]: src / runtime / x86-bsd-os.c Maximize Restore History

Download this file

x86-bsd-os.c    94 lines (83 with data), 2.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <signal.h>
#include "runtime.h"
#include "target-os.h"
/* KLUDGE: There is strong family resemblance in the signal context
* stuff in FreeBSD and OpenBSD, but in detail they're different in
* almost every line of code. It would be nice to find some way to
* factor out the commonality better; failing that, it might be best
* just to split this generic-BSD code into one variant for each BSD.
*
* KLUDGE II: this split has begun with the addition of the Darwin BSD
* flavour, with the cross-architecture complications that this
* entails; unfortunately, currently the situation is worse, not
* better, than in the above paragraph. */
#if defined(__FreeBSD__) || defined(__OpenBSD__)
int *
os_context_register_addr(os_context_t *context, int offset)
{
switch(offset) {
case 0:
return CONTEXT_ADDR_FROM_STEM(eax);
case 2:
return CONTEXT_ADDR_FROM_STEM(ecx);
case 4:
return CONTEXT_ADDR_FROM_STEM(edx);
case 6:
return CONTEXT_ADDR_FROM_STEM(ebx);
case 8:
return CONTEXT_ADDR_FROM_STEM(esp);
case 10:
return CONTEXT_ADDR_FROM_STEM(ebp);
case 12:
return CONTEXT_ADDR_FROM_STEM(esi);
case 14:
return CONTEXT_ADDR_FROM_STEM(edi);
default:
return 0;
}
}
int *
os_context_sp_addr(os_context_t *context)
{
return CONTEXT_ADDR_FROM_STEM(esp);
}
#endif /* __FreeBSD__ || __OpenBSD__ */
#ifdef __NetBSD__
int *
os_context_register_addr(os_context_t *context, int offset)
{
switch(offset) {
case 0:
return CONTEXT_ADDR_FROM_STEM(EAX);
case 2:
return CONTEXT_ADDR_FROM_STEM(ECX);
case 4:
return CONTEXT_ADDR_FROM_STEM(EDX);
case 6:
return CONTEXT_ADDR_FROM_STEM(EBX);
case 8:
return CONTEXT_ADDR_FROM_STEM(ESP);
case 10:
return CONTEXT_ADDR_FROM_STEM(EBP);
case 12:
return CONTEXT_ADDR_FROM_STEM(ESI);
case 14:
return CONTEXT_ADDR_FROM_STEM(EDI);
default:
return 0;
}
}
int *
os_context_sp_addr(os_context_t *context)
{
return &(_UC_MACHINE_SP(context));
}
#endif /* __NetBSD__ */
/* FIXME: If this can be a no-op on BSD/x86, then it
* deserves a more precise name.
*
* (Perhaps os_prepare_data_area_to_be_executed()?) */
void
os_flush_icache(os_vm_address_t address, os_vm_size_t length)
{
}