summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/syscall_windows.c
blob: e7903b517148f886737dabfc24a325981283c5b7 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "runtime.h"
#include "os_GOOS.h"
#include "cgocall.h"
#include "textflag.h"

typedef struct HandleErr HandleErr;
typedef struct SyscallErr SyscallErr;

struct HandleErr {
	uintptr handle;
	uintptr err;
};

struct SyscallErr {
	uintptr r1;
	uintptr r2;
	uintptr err;
};

#pragma textflag NOSPLIT
HandleErr
syscall·loadlibrary(uint16 *filename)
{
	LibCall c;
	HandleErr r;

	c.fn = runtime·LoadLibrary;
	c.n = 1;
	c.args = &filename;
	runtime·cgocall_errno(runtime·asmstdcall, &c);
	r.handle = c.r1;
	if(r.handle == 0)
		r.err = c.err;
	else
		r.err = 0;
	return r;
}

#pragma textflag NOSPLIT
HandleErr
syscall·getprocaddress(uintptr handle, int8 *procname)
{
	LibCall c;
	HandleErr r;

	USED(procname);
	c.fn = runtime·GetProcAddress;
	c.n = 2;
	c.args = &handle;
	runtime·cgocall_errno(runtime·asmstdcall, &c);
	r.handle = c.r1;
	if(r.handle == 0)
		r.err = c.err;
	else
		r.err = 0;
	return r;
}

#pragma textflag NOSPLIT
SyscallErr
syscall·Syscall(uintptr fn, uintptr nargs, uintptr a1, uintptr a2, uintptr a3)
{
	LibCall c;

	USED(a2);
	USED(a3);
	c.fn = (void*)fn;
	c.n = nargs;
	c.args = &a1;
	runtime·cgocall_errno(runtime·asmstdcall, &c);
	return (SyscallErr){c.r1, c.r2, c.err};
}

#pragma textflag NOSPLIT
SyscallErr
syscall·Syscall6(uintptr fn, uintptr nargs, uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5, uintptr a6)
{
	LibCall c;

	USED(a2);
	USED(a3);
	USED(a4);
	USED(a5);
	USED(a6);
	c.fn = (void*)fn;
	c.n = nargs;
	c.args = &a1;
	runtime·cgocall_errno(runtime·asmstdcall, &c);
	return (SyscallErr){c.r1, c.r2, c.err};
}

#pragma textflag NOSPLIT
SyscallErr
syscall·Syscall9(uintptr fn, uintptr nargs, uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5, uintptr a6, uintptr a7, uintptr a8, uintptr a9)
{
	LibCall c;

	USED(a2);
	USED(a3);
	USED(a4);
	USED(a5);
	USED(a6);
	USED(a7);
	USED(a8);
	USED(a9);
	c.fn = (void*)fn;
	c.n = nargs;
	c.args = &a1;
	runtime·cgocall_errno(runtime·asmstdcall, &c);
	return (SyscallErr){c.r1, c.r2, c.err};
}

#pragma textflag NOSPLIT
SyscallErr
syscall·Syscall12(uintptr fn, uintptr nargs, uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5, uintptr a6, uintptr a7, uintptr a8, uintptr a9, uintptr a10, uintptr a11, uintptr a12)
{
	LibCall c;

	USED(a2);
	USED(a3);
	USED(a4);
	USED(a5);
	USED(a6);
	USED(a7);
	USED(a8);
	USED(a9);
	USED(a10);
	USED(a11);
	USED(a12);
	c.fn = (void*)fn;
	c.n = nargs;
	c.args = &a1;
	runtime·cgocall_errno(runtime·asmstdcall, &c);
	return (SyscallErr){c.r1, c.r2, c.err};
}

#pragma textflag NOSPLIT
SyscallErr
syscall·Syscall15(uintptr fn, uintptr nargs, uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5, uintptr a6, uintptr a7, uintptr a8, uintptr a9, uintptr a10, uintptr a11, uintptr a12, uintptr a13, uintptr a14, uintptr a15)
{
	LibCall c;

	USED(a2);
	USED(a3);
	USED(a4);
	USED(a5);
	USED(a6);
	USED(a7);
	USED(a8);
	USED(a9);
	USED(a10);
	USED(a11);
	USED(a12);
	USED(a13);
	USED(a14);
	USED(a15);
	c.fn = (void*)fn;
	c.n = nargs;
	c.args = &a1;
	runtime·cgocall_errno(runtime·asmstdcall, &c);
	return (SyscallErr){c.r1, c.r2, c.err};
}