-
Notifications
You must be signed in to change notification settings - Fork 67
/
a_os_slow_init.go
425 lines (350 loc) · 19.1 KB
/
a_os_slow_init.go
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
// This file is generated by generate-std.joke script. Do not edit manually!
package os
import (
"fmt"
. "github.com/candid82/joker/core"
"os"
)
func InternsOrThunks() {
if VerbosityLevel > 0 {
fmt.Fprintln(os.Stderr, "Lazily running slow version of os.InternsOrThunks().")
}
osNamespace.ResetMeta(MakeMeta(nil, `Provides a platform-independent interface to operating system functionality.`, "1.0"))
osNamespace.InternVar("SIGABRT", SIGABRT_,
MakeMeta(
nil,
`SIGABRT`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGALRM", SIGALRM_,
MakeMeta(
nil,
`SIGALRM`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGFPE", SIGFPE_,
MakeMeta(
nil,
`SIGFPE`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGHUP", SIGHUP_,
MakeMeta(
nil,
`SIGHUP`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGILL", SIGILL_,
MakeMeta(
nil,
`SIGILL`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGINT", SIGINT_,
MakeMeta(
nil,
`SIGINT`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGKILL", SIGKILL_,
MakeMeta(
nil,
`SIGKILL`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGPIPE", SIGPIPE_,
MakeMeta(
nil,
`SIGPIPE`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGQUIT", SIGQUIT_,
MakeMeta(
nil,
`SIGQUIT`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGSEGV", SIGSEGV_,
MakeMeta(
nil,
`SIGSEGV`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGTERM", SIGTERM_,
MakeMeta(
nil,
`SIGTERM`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("SIGTRAP", SIGTRAP_,
MakeMeta(
nil,
`SIGTRAP`, "1.0.1").Plus(MakeKeyword("const"), String{S: "true"}).Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("args", args_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns a sequence of the command line arguments, starting with the program name (normally, joker).`, "1.0"))
osNamespace.InternVar("chdir", chdir_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("dirname"))),
`Changes the current working directory to the named directory.`, "1.0"))
osNamespace.InternVar("chmod", chmod_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("mode"))),
`Changes the mode of the named file to mode. If the file is a symbolic link, it changes the mode of the link's target.`, "1.0"))
osNamespace.InternVar("chown", chown_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("uid"), MakeSymbol("gid"))),
`Changes the numeric uid and gid of the named file. If the file is a symbolic link,
it changes the uid and gid of the link's target. A uid or gid of -1 means to not change that value.`, "1.0"))
osNamespace.InternVar("chtimes", chtimes_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("atime"), MakeSymbol("mtime"))),
`Changes the access and modification times of the named file, similar to the Unix utime() or utimes() functions.`, "1.0"))
osNamespace.InternVar("clearenv", clearenv_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Deletes all environment variables.`, "1.0"))
osNamespace.InternVar("close", close_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("f"))),
`Closes the file, rendering it unusable for I/O.`, "1.0"))
osNamespace.InternVar("create", create_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"))),
`Creates the named file with mode 0666 (before umask), truncating it if it already exists.`, "1.0").Plus(MakeKeyword("tag"), String{S: "File"}))
osNamespace.InternVar("create-temp", create_temp_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("dir"), MakeSymbol("pattern"))),
`Creates a new temporary file in the directory dir, opens the file for reading and writing,
and returns the resulting File. The filename is generated by taking pattern and adding a
random string to the end. If pattern includes a "*", the random string replaces the last "*".
If dir is the empty string, uses the default directory for temporary files (see joker.os/temp-dir).
Multiple programs calling joker.os/make-temp-file simultaneously will not choose the same file.
The caller can use (name f) to find the pathname of the file.
It is the caller's responsibility to remove the file when no longer needed.`, "1.0").Plus(MakeKeyword("tag"), String{S: "File"}))
osNamespace.InternVar("cwd", cwd_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns a rooted path name corresponding to the current directory. If the current directory can
be reached via multiple paths (due to symbolic links), cwd may return any one of them.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
osNamespace.InternVar("egid", egid_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the numeric effective group id of the caller.`, "1.0").Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("env", env_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns a map representing the environment.`, "1.0"))
osNamespace.InternVar("euid", euid_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the numeric effective user id of the caller.`, "1.0").Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("exec", exec_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("opts"))),
`Executes the named program with the given arguments. opts is a map with the following keys (all optional):
:args - vector of arguments (all arguments must be strings),
:dir - if specified, working directory will be set to this value before executing the program,
:stdin - if specified, provides stdin for the program. Can be either a string or an IOReader.
If it's a string, the string's content will serve as stdin for the program. IOReader can be, for example,
*in* (in which case Joker's stdin will be redirected to the program's stdin) or the value returned by (joker.os/open).
:stdout - if specified, must be an IOWriter. It can be, for example, *out* (in which case the program's stdout will be redirected
to Joker's stdout) or the value returned by (joker.os/create).
:stderr - the same as :stdout, but for stderr.
Returns a map with the following keys:
:success - whether or not the execution was successful,
:err-msg (present iff :success if false) - string capturing error object returned by Go runtime
:exit - exit code of program (or attempt to execute it),
:out - string capturing stdout of the program (unless :stdout option was passed)
:err - string capturing stderr of the program (unless :stderr option was passed).`, "1.0"))
osNamespace.InternVar("executable", executable_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the path name for the executable that started the current process.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
osNamespace.InternVar("exists?", isexists_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("path"))),
`Returns true if file or directory with the given path exists. Otherwise returns false.`, "1.0").Plus(MakeKeyword("tag"), String{S: "Boolean"}))
osNamespace.InternVar("exit", exit_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("code")), NewVectorFrom()),
`Causes the current program to exit with the given status code (defaults to 0).`, "1.0"))
osNamespace.InternVar("expand-env", expand_env_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("s"))),
`Replaces ${var} or $var in the string according to the values of the current environment variables.
References to undefined variables are replaced by the empty string.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
osNamespace.InternVar("get-env", get_env_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("key"))),
`Returns the value of the environment variable named by the key or nil if the variable is not present in the environment.`, "1.0"))
osNamespace.InternVar("gid", gid_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the numeric group id of the caller.`, "1.0").Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("groups", groups_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns a list of the numeric ids of groups that the caller belongs to.`, "1.0").Plus(MakeKeyword("tag"), String{S: "[Int]"}))
osNamespace.InternVar("hostname", hostname_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the host name reported by the kernel.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
osNamespace.InternVar("kill", kill_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("pid"))),
`Causes the process with the given PID to exit immediately.
Only kills the process itself, not any other processes it may have started.`, "1.0.1"))
osNamespace.InternVar("lchown", lchown_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("uid"), MakeSymbol("gid"))),
`Changes the numeric uid and gid of the named file. If the file is a symbolic link,
it changes the uid and gid of the link itself.`, "1.0"))
osNamespace.InternVar("link", link_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("oldname"), MakeSymbol("newname"))),
`Creates newname as a hard link to the oldname file.`, "1.0"))
osNamespace.InternVar("ls", ls_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("dirname"))),
`Reads the directory named by dirname and returns a list of directory entries sorted by filename.
Each entry is a map with the following keys:
:name - name (String)
:size - size in bytes (Int)
:mode - mode (Int)
:dir? - true if the file is a directory (Boolean)
:modtime - modification time (unix timestamp) (Int)`, "1.0"))
osNamespace.InternVar("lstat", lstat_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("filename"))),
`Like stat, but if the file is a symbolic link, the result describes the symbolic link.`, "1.0"))
osNamespace.InternVar("mkdir", mkdir_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("perm"))),
`Creates a new directory with the specified name and permission bits.`, "1.0"))
osNamespace.InternVar("mkdir-all", mkdir_all_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("perm"))),
`Creates a directory named path, along with any necessary parents, and returns nil, or else throws an error.
The permission bits perm (before umask) are used for all directories that mkdir-all creates.
If path is already a directory, mkdir-all does nothing and returns nil.`, "1.0"))
osNamespace.InternVar("mkdir-temp", mkdir_temp_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("dir"), MakeSymbol("pattern"))),
`Creates a new temporary directory in the directory dir.
The directory name is generated by taking pattern and applying a random string to the end.
If pattern includes a "*", the random string replaces the last "*".
Returns the name of the new directory. If dir is the empty string,
uses the default directory for temporary files (see joker.os/temp-dir).
Multiple programs calling joker.os/mkdir-temp simultaneously will not choose the same directory.
It is the caller's responsibility to remove the directory when no longer needed.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
osNamespace.InternVar("open", open_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"))),
`Opens the named file for reading. If successful, the file can be used for reading;
the associated file descriptor has mode O_RDONLY.`, "1.0").Plus(MakeKeyword("tag"), String{S: "File"}))
osNamespace.InternVar("pagesize", pagesize_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the underlying system's memory page size.`, "1.0").Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("path-separator?", ispath_separator_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("c"))),
`Reports whether c is a directory separator character.`, "1.0").Plus(MakeKeyword("tag"), String{S: "Boolean"}))
osNamespace.InternVar("pid", pid_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the process id of the caller.`, "1.0").Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("ppid", ppid_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the process id of the caller's parent.`, "1.0").Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("read-link", read_link_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"))),
`Returns the destination of the named symbolic link.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
osNamespace.InternVar("remove", remove_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"))),
`Removes the named file or (empty) directory.`, "1.0"))
osNamespace.InternVar("remove-all", remove_all_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("path"))),
`Removes path and any children it contains.
It removes everything it can, then panics with the first error (if
any) it encountered.`, "1.0"))
osNamespace.InternVar("rename", rename_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("oldpath"), MakeSymbol("newpath"))),
`Renames (moves) oldpath to newpath. If newpath already exists and is not a directory, rename replaces it.`, "1.0"))
osNamespace.InternVar("set-env", set_env_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("key"), MakeSymbol("value"))),
`Sets the value of the environment variable named by the key.`, "1.0"))
osNamespace.InternVar("sh", sh_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("&"), MakeSymbol("arguments"))),
`Executes the named program with the given arguments. Returns a map with the following keys:
:success - whether or not the execution was successful,
:err-msg (present iff :success if false) - string capturing error object returned by Go runtime
:exit - exit code of program (or attempt to execute it),
:out - string capturing stdout of the program,
:err - string capturing stderr of the program.`, "1.0"))
osNamespace.InternVar("sh-from", sh_from_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("dir"), MakeSymbol("name"), MakeSymbol("&"), MakeSymbol("arguments"))),
`Executes the named program with the given arguments and working directory set to dir.
Returns a map with the following keys:
:success - whether or not the execution was successful,
:err-msg (present iff :success if false) - string capturing error object returned by Go runtime
:exit - exit code of program (or attempt to execute it),
:out - string capturing stdout of the program,
:err - string capturing stderr of the program.`, "1.0"))
osNamespace.InternVar("signal", signal_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("pid"), MakeSymbol("signal"))),
`Sends signal to the process with the given PID.`, "1.0.1"))
osNamespace.InternVar("start", start_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("opts"))),
`Starts a new process with the program specified by name.
opts is a map with the same keys as in exec.
Doesn't wait for the process to finish.
Returns the process's PID.`, "1.0.1").Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("stat", stat_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("filename"))),
`Returns a map describing the named file. The info map has the following attributes:
:name - base name of the file
:size - length in bytes for regular files; system-dependent for others
:mode - file mode bits
:modtime - modification time
:dir? - true if file is a directory`, "1.0"))
osNamespace.InternVar("symlink", symlink_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("oldname"), MakeSymbol("newname"))),
`Creates newname as a symbolic link to oldname.`, "1.0"))
osNamespace.InternVar("temp-dir", temp_dir_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the default directory to use for temporary files.
On Unix systems, it returns $TMPDIR if non-empty, else /tmp.
On Windows, it uses GetTempPath, returning the first non-empty
value from %TMP%, %TEMP%, %USERPROFILE%, or the Windows directory.
The directory is neither guaranteed to exist nor have accessible permissions.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
osNamespace.InternVar("truncate", truncate_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("name"), MakeSymbol("size"))),
`Changes the size of the named file. If the file is a symbolic link, it changes the size of the link's target.`, "1.0"))
osNamespace.InternVar("uid", uid_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the numeric user id of the caller.`, "1.0").Plus(MakeKeyword("tag"), String{S: "Int"}))
osNamespace.InternVar("unset-env", unset_env_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("key"))),
`Unsets a single environment variable.`, "1.0"))
osNamespace.InternVar("user-cache-dir", user_cache_dir_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the default root directory to use for user-specific cached data.
Users should create their own application-specific subdirectory within this one and use that.
On Unix systems, it returns $XDG_CACHE_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
if non-empty, else $HOME/.cache. On Darwin, it returns $HOME/Library/Caches. On Windows, it returns %LocalAppData%.
On Plan 9, it returns $home/lib/cache.
If the location cannot be determined (for example, $HOME is not defined), then it will throw an error.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
osNamespace.InternVar("user-config-dir", user_config_dir_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the default root directory to use for user-specific configuration data.
Users should create their own application-specific subdirectory within this one and use that.
On Unix systems, it returns $XDG_CONFIG_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
if non-empty, else $HOME/.config. On Darwin, it returns $HOME/Library/Application Support. On Windows, it returns %AppData%.
On Plan 9, it returns $home/lib.
If the location cannot be determined (for example, $HOME is not defined), then it will throw an error.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
osNamespace.InternVar("user-home-dir", user_home_dir_,
MakeMeta(
NewListFrom(NewVectorFrom()),
`Returns the current user's home directory.
On Unix, including macOS, it returns the $HOME environment variable. On Windows, it returns %USERPROFILE%.
On Plan 9, it returns the $home environment variable.`, "1.0").Plus(MakeKeyword("tag"), String{S: "String"}))
}