Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 578de30

Browse files
committed
Some systems (e.g. Linux) use enums for some symbols (like IPPROTO_IP)
so that our #ifdef test has the wrong effect. Substitute hardcoded values for some important symbols (but not for the whole range -- some are pretty obscure so it's not worth it).
1 parent 617c1b0 commit 578de30

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Modules/socketmodule.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,14 +1668,19 @@ initsocket()
16681668
#endif
16691669

16701670
/* Protocol level and numbers, usable for [gs]etsockopt */
1671+
/* Sigh -- some systems (e.g. Linux) use enums for these. */
16711672
#ifdef SOL_SOCKET
16721673
insint(d, "SOL_SOCKET", SOL_SOCKET);
16731674
#endif
16741675
#ifdef IPPROTO_IP
16751676
insint(d, "IPPROTO_IP", IPPROTO_IP);
1677+
#else
1678+
insint(d, "IPPROTO_IP", 0);
16761679
#endif
16771680
#ifdef IPPROTO_ICMP
16781681
insint(d, "IPPROTO_ICMP", IPPROTO_ICMP);
1682+
#else
1683+
insint(d, "IPPROTO_ICMP", 1);
16791684
#endif
16801685
#ifdef IPPROTO_IGMP
16811686
insint(d, "IPPROTO_IGMP", IPPROTO_IGMP);
@@ -1685,6 +1690,8 @@ initsocket()
16851690
#endif
16861691
#ifdef IPPROTO_TCP
16871692
insint(d, "IPPROTO_TCP", IPPROTO_TCP);
1693+
#else
1694+
insint(d, "IPPROTO_TCP", 6);
16881695
#endif
16891696
#ifdef IPPROTO_EGP
16901697
insint(d, "IPPROTO_EGP", IPPROTO_EGP);
@@ -1694,6 +1701,8 @@ initsocket()
16941701
#endif
16951702
#ifdef IPPROTO_UDP
16961703
insint(d, "IPPROTO_UDP", IPPROTO_UDP);
1704+
#else
1705+
insint(d, "IPPROTO_UDP", 17);
16971706
#endif
16981707
#ifdef IPPROTO_IDP
16991708
insint(d, "IPPROTO_IDP", IPPROTO_IDP);
@@ -1719,6 +1728,8 @@ initsocket()
17191728
/**/
17201729
#ifdef IPPROTO_RAW
17211730
insint(d, "IPPROTO_RAW", IPPROTO_RAW);
1731+
#else
1732+
insint(d, "IPPROTO_RAW", 255);
17221733
#endif
17231734
#ifdef IPPROTO_MAX
17241735
insint(d, "IPPROTO_MAX", IPPROTO_MAX);

0 commit comments

Comments
 (0)