cvs socketmodule.c and IPV6 disabled

Hello, Porting Python to the open source realtime OS called RTEMS I get a compile error on line 2797 of socketmodule.c. This is from CVS and I suspect a result of the SF patch #658327. More problems exist on lines 2814, 2835 and 2850. Should this code check ENABLE_IPV6 as IPV6 is not support on RTEMS yet. Also where is INET_ADDRSTRLEN suppose to be defined ? Regards -- Chris Johns, cjohns at cybertec.com.au

Chris Johns <cjohns@cybertec.com.au> writes:
Porting Python to the open source realtime OS called RTEMS I get a compile error on line 2797 of socketmodule.c.
In my copy, this is the line char packed[MAX(sizeof(struct in_addr), sizeof(struct in6_addr))]; Can you report more on the nature of the compile error (such as its *message*)?
Should this code check ENABLE_IPV6 as IPV6 is not support on RTEMS yet.
(assuming this is a question): I'm unsure. It should not cause a compile time failure, period.
Also where is INET_ADDRSTRLEN suppose to be defined ?
<netinet/in.h> Regards, Martin

Martin v. Löwis wrote:
#ifdef ENABLE_IPV6 char packed[MAX(sizeof(struct in_addr), sizeof(struct in6_addr))]; #else char packed[sizeof(struct in_addr)]; #endif
Can you report more on the nature of the compile error (such as its *message*)?
(I do not use the Python build system as I have to cross-compile and so use an automake makefile in a RISCOS type layout) Sure. The output is from gcc-3.2.3: m68k-rtems-gcc -DHAVE_CONFIG_H -I. -I../python-cvs/dist/src/RTEMS -I. -I../python-cvs/dist/src/RTEMS/../Include -I../python-cvs/dist/src/RTEMS/../Python -I/opt/rtems/m68k-rtems/lib/include -m5200 -O4 -g -DPLATFORM="\"RTEMS (m5200)\"" -c -o socketmodule.o `test -f '../python-cvs/dist/src/RTEMS/../Modules/socketmodule.c' || echo '../python-cvs/dist/src/RTEMS/'`../python-cvs/dist/src/RTEMS/../Modules/socketmodule.c ../python-cvs/dist/src/Modules/socketmodule.c: In function `socket_inet_pton': ../python-cvs/dist/src/Modules/socketmodule.c:2797: sizeof applied to an incomplete type ../python-cvs/dist/src/Modules/socketmodule.c:2797: sizeof applied to an incomplete type ../python-cvs/dist/src/Modules/socketmodule.c:2816: sizeof applied to an incomplete type ../python-cvs/dist/src/Modules/socketmodule.c: In function `socket_inet_ntop': ../python-cvs/dist/src/Modules/socketmodule.c:2835: `INET_ADDRSTRLEN' undeclared (first use in this function) ../python-cvs/dist/src/Modules/socketmodule.c:2835: (Each undeclared identifier is reported only once ../python-cvs/dist/src/Modules/socketmodule.c:2835: for each function it appears in.) ../python-cvs/dist/src/Modules/socketmodule.c:2835: `INET6_ADDRSTRLEN' undeclared (first use in this function) ../python-cvs/dist/src/Modules/socketmodule.c:2851: sizeof applied to an incomplete type
Sorry, it was a question. See above.
Also where is INET_ADDRSTRLEN suppose to be defined ?
<netinet/in.h>
Thanks. The RTEMS TCP/IP stack is an old port of the FreeBSD stack and does not have this. The current FreeBSD does so I will fix RTEMS. I will not add INET6_ADDRSTRLEN as no other IPV6 support is currently provided. -- Chris Johns, cjohns at cybertec.com.au

Chris Johns wrote:
../python-cvs/dist/src/Modules/socketmodule.c:2797: sizeof applied to an incomplete type
I see. And the system does have inet_pton? *That* sounds like a bug to me - there should be no inet_pton if the IPv6 API is unsupported. So I think the configure test should be changed to define HAVE_PTON only if all prerequisites of its usage are met (or the entire function should be hidden if IPv6 is disabled). Regards, Martin

Martin v. Lvwis wrote:
I see. And the system does have inet_pton? *That* sounds like a bug to me - there should be no inet_pton if the IPv6 API is unsupported.
Agreed. I will disable them.
It would make Python more robust, but this is a mistake on my part. Thanks for the help. -- Chris Johns, cjohns at cybertec.com.au

Chris Johns <cjohns@cybertec.com.au> writes:
It's a trade-off between maintainability and robustness, and in this specific case, we favoured maintainability over robustness: We simply assume that the code ought to compile on all systems that have pton(3). It might be that this assumption is wrong. If so, we need to consider whether we want to support the systems for which it is wrong, in which case my proposal would be to strengthen the pton test (thus ignoring the buggy pton from the platform). In this case, I read your message that it really is your fault and not the system's (for hand-editing pyconfig.h); if you did indeed run autoconf to determine presence of pton, I'd encourage you to contribute a patch that analyses pton in more detail. Regards, Martin

Chris Johns wrote:
I disabled HAVE_INET_PTON in the pyconfig.h although the functions are present in the RTEMS header files as suggested. This throws up another error. When disabled the inet_pton and inet_ntop funtions in socketmodule.c are built. The RTEMS prototypes and the ones provided in socketmodule.c are not extactly the same giving a compile time error. The RTEMS history is the IP stack is a port of the FreeBSD stack from a while ago. It must have some IPV6 things how-ever as far as I know is not working on RTEMS. I suspect it is not complete/current. I feel the best solution is to define HAVE_INET_PTON in pyconfig.h.
I wrapped 'socket_inet_pton' and friend with ENABLE_IPV6 and sockets under RTEMS work. -- Chris Johns, cjohns at cybertec.com.au

Chris Johns <cjohns@cybertec.com.au> writes:
Porting Python to the open source realtime OS called RTEMS I get a compile error on line 2797 of socketmodule.c.
In my copy, this is the line char packed[MAX(sizeof(struct in_addr), sizeof(struct in6_addr))]; Can you report more on the nature of the compile error (such as its *message*)?
Should this code check ENABLE_IPV6 as IPV6 is not support on RTEMS yet.
(assuming this is a question): I'm unsure. It should not cause a compile time failure, period.
Also where is INET_ADDRSTRLEN suppose to be defined ?
<netinet/in.h> Regards, Martin

Martin v. Löwis wrote:
#ifdef ENABLE_IPV6 char packed[MAX(sizeof(struct in_addr), sizeof(struct in6_addr))]; #else char packed[sizeof(struct in_addr)]; #endif
Can you report more on the nature of the compile error (such as its *message*)?
(I do not use the Python build system as I have to cross-compile and so use an automake makefile in a RISCOS type layout) Sure. The output is from gcc-3.2.3: m68k-rtems-gcc -DHAVE_CONFIG_H -I. -I../python-cvs/dist/src/RTEMS -I. -I../python-cvs/dist/src/RTEMS/../Include -I../python-cvs/dist/src/RTEMS/../Python -I/opt/rtems/m68k-rtems/lib/include -m5200 -O4 -g -DPLATFORM="\"RTEMS (m5200)\"" -c -o socketmodule.o `test -f '../python-cvs/dist/src/RTEMS/../Modules/socketmodule.c' || echo '../python-cvs/dist/src/RTEMS/'`../python-cvs/dist/src/RTEMS/../Modules/socketmodule.c ../python-cvs/dist/src/Modules/socketmodule.c: In function `socket_inet_pton': ../python-cvs/dist/src/Modules/socketmodule.c:2797: sizeof applied to an incomplete type ../python-cvs/dist/src/Modules/socketmodule.c:2797: sizeof applied to an incomplete type ../python-cvs/dist/src/Modules/socketmodule.c:2816: sizeof applied to an incomplete type ../python-cvs/dist/src/Modules/socketmodule.c: In function `socket_inet_ntop': ../python-cvs/dist/src/Modules/socketmodule.c:2835: `INET_ADDRSTRLEN' undeclared (first use in this function) ../python-cvs/dist/src/Modules/socketmodule.c:2835: (Each undeclared identifier is reported only once ../python-cvs/dist/src/Modules/socketmodule.c:2835: for each function it appears in.) ../python-cvs/dist/src/Modules/socketmodule.c:2835: `INET6_ADDRSTRLEN' undeclared (first use in this function) ../python-cvs/dist/src/Modules/socketmodule.c:2851: sizeof applied to an incomplete type
Sorry, it was a question. See above.
Also where is INET_ADDRSTRLEN suppose to be defined ?
<netinet/in.h>
Thanks. The RTEMS TCP/IP stack is an old port of the FreeBSD stack and does not have this. The current FreeBSD does so I will fix RTEMS. I will not add INET6_ADDRSTRLEN as no other IPV6 support is currently provided. -- Chris Johns, cjohns at cybertec.com.au

Chris Johns wrote:
../python-cvs/dist/src/Modules/socketmodule.c:2797: sizeof applied to an incomplete type
I see. And the system does have inet_pton? *That* sounds like a bug to me - there should be no inet_pton if the IPv6 API is unsupported. So I think the configure test should be changed to define HAVE_PTON only if all prerequisites of its usage are met (or the entire function should be hidden if IPv6 is disabled). Regards, Martin

Martin v. Lvwis wrote:
I see. And the system does have inet_pton? *That* sounds like a bug to me - there should be no inet_pton if the IPv6 API is unsupported.
Agreed. I will disable them.
It would make Python more robust, but this is a mistake on my part. Thanks for the help. -- Chris Johns, cjohns at cybertec.com.au

Chris Johns <cjohns@cybertec.com.au> writes:
It's a trade-off between maintainability and robustness, and in this specific case, we favoured maintainability over robustness: We simply assume that the code ought to compile on all systems that have pton(3). It might be that this assumption is wrong. If so, we need to consider whether we want to support the systems for which it is wrong, in which case my proposal would be to strengthen the pton test (thus ignoring the buggy pton from the platform). In this case, I read your message that it really is your fault and not the system's (for hand-editing pyconfig.h); if you did indeed run autoconf to determine presence of pton, I'd encourage you to contribute a patch that analyses pton in more detail. Regards, Martin

Chris Johns wrote:
I disabled HAVE_INET_PTON in the pyconfig.h although the functions are present in the RTEMS header files as suggested. This throws up another error. When disabled the inet_pton and inet_ntop funtions in socketmodule.c are built. The RTEMS prototypes and the ones provided in socketmodule.c are not extactly the same giving a compile time error. The RTEMS history is the IP stack is a port of the FreeBSD stack from a while ago. It must have some IPV6 things how-ever as far as I know is not working on RTEMS. I suspect it is not complete/current. I feel the best solution is to define HAVE_INET_PTON in pyconfig.h.
I wrapped 'socket_inet_pton' and friend with ENABLE_IPV6 and sockets under RTEMS work. -- Chris Johns, cjohns at cybertec.com.au
participants (3)
-
"Martin v. Löwis"
-
Chris Johns
-
martin@v.loewis.de