File: System.k

package info (click to toggle)
kaya 0.2.0-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,012 kB
  • ctags: 1,307
  • sloc: cpp: 6,691; haskell: 4,833; sh: 2,868; yacc: 768; makefile: 700; perl: 87
file content (51 lines) | stat: -rw-r--r-- 1,594 bytes parent folder | download
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
/** -*-C-*-ish
    Kaya standard library
    Copyright (C) 2004, 2005 Edwin Brady

    This file is distributed under the terms of the GNU Lesser General
    Public Licence. See COPYING for licence.
*/

module System;

import IO;
import Array;

%include "stdlib.h";
%include "unistd.h";

public data Resource = VirtualMem | Core | CPU | Data 
                     | FileSize | Locks | MemLock | NumFiles
                     | NumProcs | RSS | Stack;

foreign "stdfuns.o" {
    "Exit immediately.
    Exits with the given exit code."
    public Void exit(Int code) = exit;
    "Exit immediately, without calling signal handlers.
    Exits with the given exit code."
    public Void _exit(Int code) = _exit;
    "Get arguments.
    Return the arguments passed to the program on the command line."
    public [String] getArgs() = getArgs;
    "Get the value of an environment variable."
    public String getEnv(String env) = do_getenv;
    "Create and open a temporary file.
     Returns handle of temporary file."
    public File tmpFile() = tmpfile;
    "Change directory"
    public Void chdir(String path) = do_chdir;
    "Get process ID"
    public Int getPID() = dogetpid;
    "Sleep for the specified number of seconds."
    public Void sleep(Int secs) = do_sleep;
    "Sleep for the specified number of microseconds (subject to system limitations)"
    public Void microSleep(Int microsecs) = do_usleep;
}

"Get program name.
Returns the name of the executable we're running."
public String progName() = getArgs()[0];

"DEPRECATED synonym for tmpFile"
public File tmpfile() = tmpFile();