CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
/****************************************************************************
2
3
This is a prototype of a HELLO_WORLD example implemented as a kernel module.
4
5
An example of its compilation:
6
7
dyn-194-155:src alexk$ ~/gap4r4/bin/i686-apple-darwin10.4.0-gcc/gac -d hellod.c
8
gcc -fPIC -o /var/folders/NB/NBxYeZaRHxGpf4haob7SqE+++TQ/-Tmp-//gac36146/36146_hellod.o -I/Users/alexk/gap4r4/bin/i686-apple-darwin10.4.0-gcc/../.. -I/Users/alexk/gap4r4/bin/i686-apple-darwin10.4.0-gcc -DCONFIG_H -c hellod.c
9
ld -bundle -bundle_loader /Users/alexk/gap4r4/bin/i686-apple-darwin10.4.0-gcc/gap /usr/lib/bundle1.o -lc -lm -o hellod.so /var/folders/NB/NBxYeZaRHxGpf4haob7SqE+++TQ/-Tmp-//gac36146/36146_hellod.o
10
rm -f /var/folders/NB/NBxYeZaRHxGpf4haob7SqE+++TQ/-Tmp-//gac36146/36146_hellod.o
11
12
It works as follows:
13
14
gap> LoadDynamicModule("hellod.so");
15
gap> HELLO_WORLD();
16
Hello World!
17
gap>
18
19
It may be included in one of the future versions of the Example package.
20
However, this will require documenting more rules of kernel programming.
21
22
****************************************************************************/
23
24
#include <stdio.h>
25
#include "src/compiled.h"
26
27
Obj FuncHELLO_WORLD( Obj self ) {
28
Pr("Hello World!\n",0L, 0L);
29
return (Obj) 0;
30
}
31
32
static StructGVarFunc GVarFuncs [] = {
33
34
{ "HELLO_WORLD", 0, "", FuncHELLO_WORLD, "src/string.c:FuncHELLO_WORLD" },
35
36
};
37
38
39
/**************************************************************************
40
41
*F InitKernel( <module> ) . . . . . . . . initialise kernel data structures
42
*/
43
static Int InitKernel (
44
StructInitInfo * module )
45
{
46
47
/* init filters and functions */
48
InitHdlrFuncsFromTable( GVarFuncs );
49
50
/* return success */
51
return 0;
52
}
53
54
55
/****************************************************************************
56
**
57
*F InitLibrary( <module> ) . . . . . . . initialise library data structures
58
*/
59
static Int InitLibrary (
60
StructInitInfo * module )
61
{
62
/* UInt gvar;
63
Obj tmp; */
64
65
/* init filters and functions */
66
/* printf("Init El..Small\n");fflush(stdout); */
67
InitGVarFuncsFromTable( GVarFuncs );
68
69
/* return success */
70
return 0;
71
}
72
73
74
/****************************************************************************
75
**
76
*F InitInfopl() . . . . . . . . . . . . . . . . . table of init functions
77
*/
78
/* <name> returns the description of this module */
79
static StructInitInfo module = {
80
#ifdef EDIVSTATIC
81
/* type = */ MODULE_STATIC,
82
#else
83
/* type = */ MODULE_DYNAMIC,
84
#endif
85
/* name = */ "hello",
86
/* revision_c = */ 0,
87
/* revision_h = */ 0,
88
/* version = */ 0,
89
/* crc = */ 0,
90
/* initKernel = */ InitKernel,
91
/* initLibrary = */ InitLibrary,
92
/* checkInit = */ 0,
93
/* preSave = */ 0,
94
/* postSave = */ 0,
95
/* postRestore = */ 0
96
};
97
98
#ifndef EDIVSTATIC
99
StructInitInfo * Init__Dynamic ( void )
100
{
101
return &module;
102
}
103
#endif
104
105
StructInitInfo * Init__ediv ( void )
106
{
107
return &module;
108
}
109