Skip to content

bpo-31904 : Python should support VxWorks RTOS #4179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
10d4405
patch configure for VxWorks
kuhlenough Sep 15, 2017
9d53ef2
Any version of python should be OK for cross build.
kuhlenough Sep 15, 2017
db2e0e8
undef DATE TIME for VxWorks
kuhlenough Sep 17, 2017
cb3aa97
limited signal feilds in VxWorks
kuhlenough Sep 17, 2017
de480ac
Perliminary - Get some of the extension modules compiling on VxWorks
kuhlenough Sep 22, 2017
5bfa35c
VxWorks does not have "timezone" and daylight "constants"
kuhlenough Sep 22, 2017
eeb74cf
Update some extension modules to compile on VxWorks
kuhlenough Sep 25, 2017
f6efb4e
setup.py complies all VxWorks compatible modules
kuhlenough Sep 25, 2017
9f5f589
Avoid duplicate macro definition
kuhlenough Sep 27, 2017
3196b82
extra include in faulthandler.c
kuhlenough Sep 28, 2017
a661fb2
fix some warnings with unused functions and macro re-def
kuhlenough Oct 3, 2017
b37d2ee
Add detection for oddly named VxWorks OPENSSL and HASH libraries
kuhlenough Oct 3, 2017
674d078
move configure changes into configure.ac
kuhlenough Oct 11, 2017
7256ca2
If build is configure'd for static, propigate to Makefile
kuhlenough Oct 17, 2017
69010f4
remove gethostbyname_r, link fails, missing system call
kuhlenough Oct 17, 2017
d1c19f9
semicolon as path separator
kuhlenough Oct 23, 2017
3562186
default to UTF-8 (like Android)
kuhlenough Oct 23, 2017
4531ba8
sort out duplicates flags
kuhlenough Oct 24, 2017
ed10017
hardwire encoding for VxWorks
kuhlenough Oct 24, 2017
4d7dbdd
Revert "sort out duplicates flags"
kuhlenough Oct 28, 2017
56a57ee
all doesn't include shared if static build
kuhlenough Oct 28, 2017
e02bcab
bpo-31904 : Python should support VxWorks RTOS
kuhlenough Sep 15, 2017
f0b0a71
Merge branch 'master' of https://github.com/kuhlenough/cpython
kuhlenough Oct 30, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Include/osdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ extern "C" {
#define DELIM L';'
#endif

#ifdef __VXWORKS__
#define DELIM L';'
#endif

/* Filename separator */
#ifndef SEP
#define SEP L'/'
Expand Down
4 changes: 4 additions & 0 deletions Include/symtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
#define SCOPE_OFFSET 11
#define SCOPE_MASK (DEF_GLOBAL | DEF_LOCAL | DEF_PARAM | DEF_NONLOCAL)

#ifdef __VXWORKS__
#undef LOCAL
#endif

#define LOCAL 1
#define GLOBAL_EXPLICIT 2
#define GLOBAL_IMPLICIT 3
Expand Down
21 changes: 17 additions & 4 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ DTRACE_HEADERS= @DTRACE_HEADERS@
DTRACE_OBJS= @DTRACE_OBJS@

GNULD= @GNULD@
PY_ENABLE_SHARED=@PY_ENABLE_SHARED@

# Shell used by make (some versions default to the login shell, which is bad)
SHELL= /bin/sh
Expand Down Expand Up @@ -101,11 +102,19 @@ PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS)
NO_AS_NEEDED= @NO_AS_NEEDED@
LDLAST= @LDLAST@
SGI_ABI= @SGI_ABI@
CCSHARED= @CCSHARED@
LINKFORSHARED= @LINKFORSHARED@
ARFLAGS= @ARFLAGS@

ifeq ($(PY_ENABLE_SHARED),1)
CCSHARED= @CCSHARED@
LINKFORSHARED= @LINKFORSHARED@
# Extra C flags added for building the interpreter object files.
CFLAGSFORSHARED=@CFLAGSFORSHARED@
else
CCSHARED=
LINKFORSHARED=
CFLAGSFORSHARED=
endif

ARFLAGS= @ARFLAGS@
# C flags used for building the interpreter object files
PY_CORE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
# Strict or non-strict aliasing flags used to compile dtoa.c, see above
Expand Down Expand Up @@ -440,7 +449,11 @@ DTRACE_DEPS = \

# Default target
all: @DEF_MAKE_ALL_RULE@
build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config
ifeq ($(PY_ENABLE_SHARED),1)
build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config
else
build_all: $(BUILDPYTHON) gdbhooks Programs/_testembed python-config
endif

# Compile a binary with profile guided optimization.
profile-opt:
Expand Down
8 changes: 6 additions & 2 deletions Modules/_multiprocessing/multiprocessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
# define BOOL int
# define UINT32 uint32_t
# define INT32 int32_t
# define TRUE 1
# define FALSE 0
# ifndef TRUE
# define TRUE 1
# endif
# ifndef FALSE
# define FALSE 0
# endif
# define INVALID_HANDLE_VALUE (-1)
#endif

Expand Down
4 changes: 3 additions & 1 deletion Modules/faulthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif

#ifdef __VXWORKS__
# include <ioLib.h>
#endif
/* Allocate at maximum 100 MB of the stack to raise the stack overflow */
#define STACK_OVERFLOW_MAX_SIZE (100*1024*1024)

Expand Down
4 changes: 4 additions & 0 deletions Modules/fcntlmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <stropts.h>
#endif

#ifdef __VXWORKS__
#include <ioLib.h> /* ioctl() */
#endif

/*[clinic input]
module fcntl
[clinic start generated code]*/
Expand Down
5 changes: 5 additions & 0 deletions Modules/getbuildinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include <stdio.h>
#endif

#ifdef __VXWORKS__
#undef DATE
#undef TIME
#endif

#ifndef DATE
#ifdef __DATE__
#define DATE __DATE__
Expand Down
4 changes: 2 additions & 2 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,9 +1463,9 @@ PyInit_mmap(void)
#endif

setint(dict, "PAGESIZE", (long)my_getpagesize());

#ifndef __VXWORKS__
setint(dict, "ALLOCATIONGRANULARITY", (long)my_getallocationgranularity());

#endif
setint(dict, "ACCESS_READ", ACCESS_READ);
setint(dict, "ACCESS_WRITE", ACCESS_WRITE);
setint(dict, "ACCESS_COPY", ACCESS_COPY);
Expand Down
2 changes: 2 additions & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ corresponding Unix manual entries for more information on calls.");
#define HAVE_FSYNC 1
#define fsync _commit
#else
#ifndef __VXWORKS__
/* Unix functions that the configure script doesn't check for */
#define HAVE_EXECV 1
#define HAVE_FORK 1
Expand All @@ -184,6 +185,7 @@ corresponding Unix manual entries for more information on calls.");
#define HAVE_GETEUID 1
#define HAVE_GETGID 1
#define HAVE_GETPPID 1
#endif
#define HAVE_GETUID 1
#define HAVE_KILL 1
#define HAVE_OPENDIR 1
Expand Down
7 changes: 7 additions & 0 deletions Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,11 +965,18 @@ fill_siginfo(siginfo_t *si)

PyStructSequence_SET_ITEM(result, 0, PyLong_FromLong((long)(si->si_signo)));
PyStructSequence_SET_ITEM(result, 1, PyLong_FromLong((long)(si->si_code)));
#ifdef __VXWORKS__
PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(0L));
PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(0L));
PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(0L));
PyStructSequence_SET_ITEM(result, 5, PyLong_FromLong(0L));
#else
PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong((long)(si->si_errno)));
PyStructSequence_SET_ITEM(result, 3, PyLong_FromPid(si->si_pid));
PyStructSequence_SET_ITEM(result, 4, _PyLong_FromUid(si->si_uid));
PyStructSequence_SET_ITEM(result, 5,
PyLong_FromLong((long)(si->si_status)));
#endif
#ifdef HAVE_SIGINFO_T_SI_BAND
PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));
#else
Expand Down
34 changes: 23 additions & 11 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Local naming conventions:
# pragma weak inet_aton
#endif


#include "Python.h"
#include "structmember.h"

Expand Down Expand Up @@ -159,7 +160,7 @@ if_indextoname(index) -- return the corresponding interface name\n\
# undef HAVE_GETHOSTBYNAME_R_6_ARG
#endif

#if defined(__OpenBSD__)
#if defined(__OpenBSD__) || defined(__VXWORKS__)
# include <sys/uio.h>
#endif

Expand All @@ -181,6 +182,12 @@ if_indextoname(index) -- return the corresponding interface name\n\
# endif
#endif

#ifdef __VXWORKS__
# include <ipcom_sock2.h>
# define gethostbyaddr_r( a1, a2, a3, a4, a5, a6, a7 ) ipcom_gethostbyaddr_r( a1, a2, a3, a4, a5, a6, a7 )
# include <hostLib.h>
#endif

#if !defined(HAVE_GETHOSTBYNAME_R) && !defined(MS_WINDOWS)
# define USE_GETHOSTBYNAME_LOCK
#endif
Expand Down Expand Up @@ -532,7 +539,7 @@ set_error(void)
return PyErr_SetFromErrno(PyExc_OSError);
}


#ifndef __VXWORKS__
static PyObject *
set_herror(int h_error)
{
Expand All @@ -550,7 +557,7 @@ set_herror(int h_error)

return NULL;
}

#endif

static PyObject *
set_gaierror(int error)
Expand Down Expand Up @@ -903,7 +910,7 @@ init_sockobject(PySocketSockObject *s,
return 0;
}


#ifdef HAVE_SOCKETPAIR
/* Create a new socket object.
This just creates the object and initializes it.
If the creation fails, return NULL and set an exception (implicit
Expand All @@ -923,7 +930,7 @@ new_sockobject(SOCKET_T fd, int family, int type, int proto)
}
return s;
}

#endif

/* Lock to allow python interpreter to continue, but only allow one
thread to be in gethostbyname or getaddrinfo */
Expand Down Expand Up @@ -2314,17 +2321,17 @@ cmsg_min_space(struct msghdr *msg, struct cmsghdr *cmsgh, size_t space)
#endif
if (msg->msg_controllen < 0)
return 0;
if (space < cmsg_len_end)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mistake will have recall the pull request and move this back where it was orignally

space = cmsg_len_end;
cmsg_offset = (char *)cmsgh - (char *)msg->msg_control;
return (cmsg_offset <= (size_t)-1 - space &&
cmsg_offset + space <= msg->msg_controllen);
#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5)))
#pragma GCC diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
if (space < cmsg_len_end)
space = cmsg_len_end;
cmsg_offset = (char *)cmsgh - (char *)msg->msg_control;
return (cmsg_offset <= (size_t)-1 - space &&
cmsg_offset + space <= msg->msg_controllen);
}

/* If pointer CMSG_DATA(cmsgh) is in buffer msg->msg_control, set
Expand Down Expand Up @@ -5079,7 +5086,9 @@ gethost_common(struct hostent *h, struct sockaddr *addr, size_t alen, int af)

if (h == NULL) {
/* Let's get real error message to return */
#ifndef __VXWORKS__
set_herror(h_errno);
#endif
return NULL;
}

Expand Down Expand Up @@ -5426,6 +5435,7 @@ Return the service name from a port number and protocol name.\n\
The optional protocol name, if given, should be 'tcp' or 'udp',\n\
otherwise any protocol will match.");

#ifndef __VXWORKS__
/* Python interface to getprotobyname(name).
This only returns the protocol number, since the other info is
already known or not useful (like the list of aliases). */
Expand All @@ -5452,7 +5462,7 @@ PyDoc_STRVAR(getprotobyname_doc,
"getprotobyname(name) -> integer\n\
\n\
Return the protocol number for the named protocol. (Rarely used.)");

#endif

#ifndef NO_DUP
/* dup() function for socket fds */
Expand Down Expand Up @@ -6392,8 +6402,10 @@ static PyMethodDef socket_methods[] = {
METH_VARARGS, getservbyname_doc},
{"getservbyport", socket_getservbyport,
METH_VARARGS, getservbyport_doc},
#ifndef __VXWORKS__
{"getprotobyname", socket_getprotobyname,
METH_VARARGS, getprotobyname_doc},
#endif
#ifndef NO_DUP
{"dup", socket_dup,
METH_O, dup_doc},
Expand Down
4 changes: 4 additions & 0 deletions Modules/syslogmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Revision history:

#include <syslog.h>

#ifndef LOG_UPTO
#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
#endif

/* only one instance, only one syslog, so globals should be ok */
static PyObject *S_ident_o = NULL; /* identifier, held by openlog() */
static char S_log_open = 0;
Expand Down
2 changes: 2 additions & 0 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,13 +1215,15 @@ PyInit_timezone(PyObject *m) {
#if defined(HAVE_TZNAME) && !defined(__GLIBC__) && !defined(__CYGWIN__)
PyObject *otz0, *otz1;
tzset();
#ifndef __VXWORKS__
PyModule_AddIntConstant(m, "timezone", timezone);
#ifdef HAVE_ALTZONE
PyModule_AddIntConstant(m, "altzone", altzone);
#else
PyModule_AddIntConstant(m, "altzone", timezone-3600);
#endif
PyModule_AddIntConstant(m, "daylight", daylight);
#endif
otz0 = PyUnicode_DecodeLocale(tzname[0], "surrogateescape");
otz1 = PyUnicode_DecodeLocale(tzname[1], "surrogateescape");
PyModule_AddObject(m, "tzname", Py_BuildValue("(NN)", otz0, otz1));
Expand Down
4 changes: 4 additions & 0 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,10 @@ initfsencoding(PyInterpreterState *interp)
Py_FileSystemDefaultEncoding = "utf-8";
Py_FileSystemDefaultEncodeErrors = "surrogatepass";
}
#elif defined(__VXWORKS__)
{
Py_FileSystemDefaultEncoding = "ascii";
}
#else
if (Py_FileSystemDefaultEncoding == NULL)
{
Expand Down
12 changes: 11 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -3258,6 +3258,9 @@ then
*-*-cygwin*)
ac_sys_system=Cygwin
;;
*-*-vxworks*)
ac_sys_system=VxWorks
;;
*)
# for now, limit cross builds to known configurations
MACHDEP="unknown"
Expand Down Expand Up @@ -3302,6 +3305,9 @@ if test "$cross_compiling" = yes; then
*-*-cygwin*)
_host_cpu=
;;
*-*-vxworks*)
_host_cpu=
;;
*)
# for now, limit cross builds to known configurations
MACHDEP="unknown"
Expand All @@ -3320,6 +3326,10 @@ fi
# wildcard, and that the wildcard does not include future systems
# (which may remove their limitations).
case $ac_sys_system/$ac_sys_release in
# On VxWorks if _XOPEN_SOURCE is defined the socket.h header
# has undefined types.
VxWorks* )
define_xopen_source=no;;
# On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
# even though select is a POSIX function. Reported by J. Ribbens.
# Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Expand Down Expand Up @@ -13299,7 +13309,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_char_unsigned" >&5
$as_echo "$ac_cv_c_char_unsigned" >&6; }
if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes && test "$ac_sys_system" != "VxWorks" ; then
$as_echo "#define __CHAR_UNSIGNED__ 1" >>confdefs.h

fi
Expand Down
Loading