]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/python/interpreter/python.cc
Inital import
[l4.git] / l4 / pkg / python / interpreter / python.cc
1 /* Minimal main program -- everything is loaded from the library */
2
3 #include <l4/re/elf_aux.h>
4 L4RE_ELF_AUX_ELEM_T(l4re_elf_aux_mword_t, _stack_size,
5                      L4RE_ELF_AUX_T_STACK_SIZE, 8 * 1024 * 1024);
6 #include "Python.h"
7
8 #ifdef __FreeBSD__
9 #include <floatingpoint.h>
10 #endif
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <dlfcn.h>
14 void test_dlopen() {
15         void *handle;
16         handle = dlopen("rom/_functools.so", 2);
17         if (!handle) {
18                 printf("%s: %s\n", __func__, dlerror());
19                 exit(-1);
20         }
21         dlclose(handle);
22         exit(0);
23 }
24 void test_input() {
25   char *buf = (char *)malloc(sizeof(char) * 100);
26   if (fgets(buf, 100, stdin) == NULL) {
27     printf("fgets error\n");
28   } else {
29     printf("buf=%s\n", buf);
30   }
31 /*while(1) {
32     c = fgetc(stdin);
33         printf("%i", c);
34   }*/
35 }
36
37 void test_fstat() {
38   struct stat statb;
39   FILE *fp = NULL;
40   fp = fopen("_collections.so", "r");
41   if (fp == NULL) {
42     printf("fopen failed\n");
43         exit(-1);
44   }
45
46   if (fstat(fileno(fp), &statb) != 0) {
47           printf("fstat failed\n");
48           exit(-1);
49   }
50
51   printf("fstat dev=%lld ino=%ld\n", statb.st_dev, statb.st_ino);
52   exit(0);
53
54 }
55
56 int
57 main(int argc, char **argv)
58 {
59 //      test_input();
60 //    test_dlopen();
61 //    test_fstat();
62         /* 754 requires that FP exceptions run in "no stop" mode by default,
63          * and until C vendors implement C99's ways to control FP exceptions,
64          * Python requires non-stop mode.  Alas, some platforms enable FP
65          * exceptions by default.  Here we disable them.
66          */
67 #ifdef __FreeBSD__
68         fp_except_t m;
69
70         m = fpgetmask();
71         fpsetmask(m & ~FP_X_OFL);
72 #endif
73         return Py_Main(argc, argv);
74 }