Adding upstream version 6.02~pre8+dfsg.
[syslinux-debian/hramrach.git] / com32 / include / sys / exec.h
blobf4559d1503e0f7ad8e70756a9d07b9d6f9c061d9
1 /*
2 * exec.h
4 * Created on: Aug 14, 2008
5 * Author: Stefan Bucur <stefanb@zytor.com>
6 */
8 #ifndef EXEC_H_
9 #define EXEC_H_
11 #include <sys/module.h>
12 #include <stdlib.h>
14 /**
15 * EXEC_ROOT_NAME - The name of the ELF module associated with the COM32 module.
17 * This is a shallow ELF module, that contains only the symbol table for
18 * the code and data sections of the loaded COM32 root module.
20 #define EXEC_ROOT_NAME "_root_.c32"
22 /**
23 * spawn_load - Load a library module or executes an executable one
24 * @name the name of the library/executable to use, including the extension
25 * (e.g. 'sort.c32')
26 * @argc: the number of string arguments in @argv
27 * @argv: a NULL-terminated vector of string arguments, starting with
28 * the program name.
30 * This procedure in essence loads takes the name of a module and checks to see what
31 * kind of module it is ( executable or library ), after which is performs the
32 * appropriate action, either spawning or simply loading the module into memory.
34 extern int spawn_load(const char *name, int argc, char **argv);
36 /**
37 * spawnv - Executes a program in the current environment.
38 * @name: the name of the program to spawn, including the extension
39 * (e.g. 'hello.c32')
40 * @argv: a NULL-terminated vector of string arguments, starting with
41 * the program name.
43 * A program is an ELF module that contains a main routine. A program is
44 * loaded into memory, executed, then unloaded, thus remaining in memory only
45 * while the main() function is executing. A program also defines a
46 * memory allocation context, and a simple garbage collection mechanism
47 * it thus provided. This is done by internally associating with the program
48 * module each pointer returned by malloc(). After the program finishes
49 * its execution, all the unallocated memory pertaining to the program
50 * is automatically cleaned up.
52 * Note that this association takes place both for the allocations happening
53 * directly in the program, or indirectly through a library function. Libraries
54 * do not create allocation contexts, thus each allocation they made belong
55 * to the innermost calling program.
57 extern int spawnv(const char *name, const char **argv);
59 /**
60 * spawnl - Executes a program in the current environment.
61 * @name: the name of the program to spawn, including the extension
62 * (e.g. 'hello.c32')
63 * @arg: the first argument (argv[0]) to be passed to the main function
64 * of the program
65 * @...: optional subsequent arguments that are passed o the main function
66 * of the program
68 * This is another version of the spawn routine. Please see 'spawnv' for
69 * a full presentation.
71 extern int spawnl(const char *name, const char *arg, ...);
73 /**
74 * exec_term - Releases the resources of the execution environment.
76 extern void exec_term(void);
79 #endif /* EXEC_H_ */