Hi,
as some of you know I've been working on porting Python to HelenOS. The
initial part of porting is now completed and you can run simple Python scripts
on HelenOS. Due to the fact that HelenOS does not implement float point
functions that Python needs, attempt to use float point objects or modules
using them will terminate Python with a message that some float point function
is not implemented. There are also some issues with close in file object
destructor I haven't yet investigated, anyway basic functionality is there.
To try it:
* build HelenOS with attached patches applied
* git clone https://github.com/zhalas/helenos-build-python.git
* cd helenos-build-python
* git submodule init
* git submodule update
* export HELENOS_HOME=/path/to/your/HelenOS/tree
* make
When the build finishes place the result in HelenOS initramfs:
destdir/app/python2.7 -> /app/python
destdir/lib/python2.7 -> /lib/python2.7
Then boot HelenOS and enjoy Python!
To reduce the size of the initramfs image you can remove *.pyc and *.pyo
files.
I would be grateful for your feedback and reviewing attached patches.
Cheers,
Zbigniew
=== modified file 'uspace/lib/posix/include/posix/stdio.h'
--- uspace/lib/posix/include/posix/stdio.h 2012-09-07 14:27:25 +0000
+++ uspace/lib/posix/include/posix/stdio.h 2013-04-01 19:35:57 +0000
@@ -61,6 +61,17 @@
typedef struct _IO_FILE FILE;
+#ifndef LIBPOSIX_INTERNAL
+ enum _buffer_type {
+ /** No buffering */
+ _IONBF,
+ /** Line buffering */
+ _IOLBF,
+ /** Full buffering */
+ _IOFBF
+ };
+#endif
+
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
=== modified file 'uspace/lib/posix/include/posix/fcntl.h'
--- uspace/lib/posix/include/posix/fcntl.h 2012-08-31 10:18:53 +0000
+++ uspace/lib/posix/include/posix/fcntl.h 2013-04-01 18:58:38 +0000
@@ -43,6 +43,10 @@
#undef O_ACCMODE
#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
+/* Dummy compatibility flag */
+#undef O_NOCTTY
+#define O_NOCTTY 0
+
/* fcntl commands */
#undef F_DUPFD
#undef F_DUPFD_CLOEXEC
=== modified file 'uspace/lib/posix/include/posix/limits.h'
--- uspace/lib/posix/include/posix/limits.h 2012-08-31 09:55:22 +0000
+++ uspace/lib/posix/include/posix/limits.h 2013-04-01 19:15:58 +0000
@@ -48,6 +48,10 @@
#undef PATH_MAX
#define PATH_MAX 256
+/* it's probably a safe assumption */
+#undef CHAR_BIT
+#define CHAR_BIT 8
+
#endif /* POSIX_LIMITS_H_ */
/** @}
=== modified file 'uspace/lib/posix/include/posix/float.h'
--- uspace/lib/posix/include/posix/float.h 2012-08-31 09:55:22 +0000
+++ uspace/lib/posix/include/posix/float.h 2013-04-01 19:09:50 +0000
@@ -35,7 +35,32 @@
#ifndef POSIX_FLOAT_H_
#define POSIX_FLOAT_H_
-/* Empty. Just to satisfy preprocessor. */
+/* Rouding direction -1 - unknown */
+#define FLT_ROUNDS (-1)
+
+/* define some standard C constants in terms of GCC built-ins */
+#ifdef __GNUC__
+ #undef DBL_MANT_DIG
+ #define DBL_MANT_DIG __DBL_MANT_DIG__
+ #undef DBL_MIN_EXP
+ #define DBL_MIN_EXP __DBL_MIN_EXP__
+ #undef DBL_MAX_EXP
+ #define DBL_MAX_EXP __DBL_MAX_EXP__
+ #undef DBL_MAX
+ #define DBL_MAX __DBL_MAX__
+ #undef DBL_MAX_10_EXP
+ #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
+ #undef DBL_MIN_10_EXP
+ #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
+ #undef DBL_MIN
+ #define DBL_MIN __DBL_MIN__
+ #undef DBL_DIG
+ #define DBL_DIG __DBL_DIG__
+ #undef DBL_EPSILON
+ #define DBL_EPSILON __DBL_EPSILON__
+ #undef FLT_RADIX
+ #define FLT_RADIX __FLT_RADIX__
+#endif
#endif /* POSIX_FLOAT_H_ */
=== modified file 'uspace/lib/posix/include/posix/math.h'
--- uspace/lib/posix/include/posix/math.h 2013-04-01 19:18:51 +0000
+++ uspace/lib/posix/include/posix/math.h 2013-04-01 19:32:02 +0000
@@ -43,9 +43,33 @@
extern double posix_ldexp(double x, int exp);
extern double posix_frexp(double num, int *exp);
+double posix_fabs(double x);
+double posix_floor(double x);
+double posix_modf(double x, double *iptr);
+double posix_fmod(double x, double y);
+double posix_pow(double x, double y);
+double posix_exp(double x);
+double posix_sqrt(double x);
+double posix_log(double x);
+double posix_sin(double x);
+double posix_cos(double x);
+double posix_atan2(double y, double x);
+
#ifndef LIBPOSIX_INTERNAL
#define ldexp posix_ldexp
#define frexp posix_frexp
+
+ #define fabs posix_fabs
+ #define floor posix_floor
+ #define modf posix_modf
+ #define fmod posix_fmod
+ #define pow posix_pow
+ #define exp posix_exp
+ #define sqrt posix_sqrt
+ #define log posix_log
+ #define sin posix_sin
+ #define cos posix_cos
+ #define atan2 posix_atan2
#endif
#endif /* POSIX_MATH_H_ */
=== modified file 'uspace/lib/posix/source/math.c'
--- uspace/lib/posix/source/math.c 2012-08-31 09:55:22 +0000
+++ uspace/lib/posix/source/math.c 2013-04-01 19:32:02 +0000
@@ -61,5 +61,130 @@
not_implemented();
}
+/**
+ *
+ * @param x
+ * @return
+ */
+double posix_cos(double x)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @param y
+ * @return
+ */
+double posix_pow(double x, double y)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @return
+ */
+double posix_floor(double x)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @return
+ */
+double posix_fabs(double x)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @param iptr
+ * @return
+ */
+double posix_modf(double x, double *iptr)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @param y
+ * @return
+ */
+double posix_fmod(double x, double y)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @return
+ */
+double posix_log(double x)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @param y
+ * @return
+ */
+double posix_atan2(double y, double x)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @return
+ */
+double posix_sin(double x)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @return
+ */
+double posix_exp(double x)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
+/**
+ *
+ * @param x
+ * @return
+ */
+double posix_sqrt(double x)
+{
+ // TODO: Python dependency
+ not_implemented();
+}
+
/** @}
*/
=== modified file 'uspace/lib/posix/include/posix/math.h'
--- uspace/lib/posix/include/posix/math.h 2012-08-31 09:55:22 +0000
+++ uspace/lib/posix/include/posix/math.h 2013-04-01 19:18:51 +0000
@@ -35,6 +35,10 @@
#ifndef POSIX_MATH_H_
#define POSIX_MATH_H_
+#ifdef __GNUC__
+ #define HUGE_VAL (__builtin_huge_val())
+#endif
+
/* Normalization Functions */
extern double posix_ldexp(double x, int exp);
extern double posix_frexp(double num, int *exp);
_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/cgi-bin/listinfo/helenos-devel