| 1 |
|
| BOOT: |
| 2 |
|
| { |
| 3 |
|
| #if defined(dTHX) && !defined(PERL_NO_GET_CONTEXT) |
| 4 |
|
| dTHX; |
| 5 |
|
| #endif |
| 6 |
1 |
| HV *symbol_table = get_hv("Socket::Linux::", GV_ADD); |
| 7 |
|
| |
| 8 |
|
| static const struct iv_s values_for_iv[] = |
| 9 |
|
| { |
| 10 |
|
| #ifdef TCP_NODELAY |
| 11 |
|
| { "TCP_NODELAY", 11, TCP_NODELAY }, |
| 12 |
|
| #endif |
| 13 |
|
| #ifdef TCP_MAXSEG |
| 14 |
|
| { "TCP_MAXSEG", 10, TCP_MAXSEG }, |
| 15 |
|
| #endif |
| 16 |
|
| #ifdef TCP_CORK |
| 17 |
|
| { "TCP_CORK", 8, TCP_CORK }, |
| 18 |
|
| #endif |
| 19 |
|
| #ifdef TCP_KEEPIDLE |
| 20 |
|
| { "TCP_KEEPIDLE", 12, TCP_KEEPIDLE }, |
| 21 |
|
| #endif |
| 22 |
|
| #ifdef TCP_KEEPINTVL |
| 23 |
|
| { "TCP_KEEPINTVL", 13, TCP_KEEPINTVL }, |
| 24 |
|
| #endif |
| 25 |
|
| #ifdef TCP_KEEPCNT |
| 26 |
|
| { "TCP_KEEPCNT", 11, TCP_KEEPCNT }, |
| 27 |
|
| #endif |
| 28 |
|
| #ifdef TCP_SYNCNT |
| 29 |
|
| { "TCP_SYNCNT", 10, TCP_SYNCNT }, |
| 30 |
|
| #endif |
| 31 |
|
| #ifdef TCP_LINGER2 |
| 32 |
|
| { "TCP_LINGER2", 11, TCP_LINGER2 }, |
| 33 |
|
| #endif |
| 34 |
|
| #ifdef TCP_DEFER_ACCEPT |
| 35 |
|
| { "TCP_DEFER_ACCEPT", 16, TCP_DEFER_ACCEPT }, |
| 36 |
|
| #endif |
| 37 |
|
| #ifdef TCP_WINDOW_CLAMP |
| 38 |
|
| { "TCP_WINDOW_CLAMP", 16, TCP_WINDOW_CLAMP }, |
| 39 |
|
| #endif |
| 40 |
|
| #ifdef TCP_INFO |
| 41 |
|
| { "TCP_INFO", 8, TCP_INFO }, |
| 42 |
|
| #endif |
| 43 |
|
| #ifdef TCP_QUICKACK |
| 44 |
|
| { "TCP_QUICKACK", 12, TCP_QUICKACK }, |
| 45 |
|
| #endif |
| 46 |
|
| #ifdef TCP_CONGESTION |
| 47 |
|
| { "TCP_CONGESTION", 14, TCP_CONGESTION }, |
| 48 |
|
| #endif |
| 49 |
|
| #ifdef TCP_MD5SIG |
| 50 |
|
| { "TCP_MD5SIG", 10, TCP_MD5SIG }, |
| 51 |
|
| #endif |
| 52 |
|
| #ifdef TCPOPT_EOL |
| 53 |
|
| { "TCPOPT_EOL", 10, TCPOPT_EOL }, |
| 54 |
|
| #endif |
| 55 |
|
| #ifdef TCPOPT_NOP |
| 56 |
|
| { "TCPOPT_NOP", 10, TCPOPT_NOP }, |
| 57 |
|
| #endif |
| 58 |
|
| #ifdef TCPOPT_MAXSEG |
| 59 |
|
| { "TCPOPT_MAXSEG", 13, TCPOPT_MAXSEG }, |
| 60 |
|
| #endif |
| 61 |
|
| #ifdef TCPOLEN_MAXSEG |
| 62 |
|
| { "TCPOLEN_MAXSEG", 14, TCPOLEN_MAXSEG }, |
| 63 |
|
| #endif |
| 64 |
|
| #ifdef TCPOPT_WINDOW |
| 65 |
|
| { "TCPOPT_WINDOW", 13, TCPOPT_WINDOW }, |
| 66 |
|
| #endif |
| 67 |
|
| #ifdef TCPOLEN_WINDOW |
| 68 |
|
| { "TCPOLEN_WINDOW", 14, TCPOLEN_WINDOW }, |
| 69 |
|
| #endif |
| 70 |
|
| #ifdef TCPOPT_SACK_PERMITTED |
| 71 |
|
| { "TCPOPT_SACK_PERMITTED", 21, TCPOPT_SACK_PERMITTED }, |
| 72 |
|
| #endif |
| 73 |
|
| #ifdef TCPOLEN_SACK_PERMITTED |
| 74 |
|
| { "TCPOLEN_SACK_PERMITTED", 22, TCPOLEN_SACK_PERMITTED }, |
| 75 |
|
| #endif |
| 76 |
|
| #ifdef TCPOPT_SACK |
| 77 |
|
| { "TCPOPT_SACK", 11, TCPOPT_SACK }, |
| 78 |
|
| #endif |
| 79 |
|
| #ifdef TCPOPT_TIMESTAMP |
| 80 |
|
| { "TCPOPT_TIMESTAMP", 16, TCPOPT_TIMESTAMP }, |
| 81 |
|
| #endif |
| 82 |
|
| #ifdef TCPOLEN_TIMESTAMP |
| 83 |
|
| { "TCPOLEN_TIMESTAMP", 17, TCPOLEN_TIMESTAMP }, |
| 84 |
|
| #endif |
| 85 |
|
| #ifdef TCPOLEN_TSTAMP_APPA |
| 86 |
|
| { "TCPOLEN_TSTAMP_APPA", 19, TCPOLEN_TSTAMP_APPA }, |
| 87 |
|
| #endif |
| 88 |
|
| #ifdef TCPOPT_TSTAMP_HDR |
| 89 |
|
| { "TCPOPT_TSTAMP_HDR", 17, TCPOPT_TSTAMP_HDR }, |
| 90 |
|
| #endif |
| 91 |
|
| #ifdef TCP_MSS |
| 92 |
|
| { "TCP_MSS", 7, TCP_MSS }, |
| 93 |
|
| #endif |
| 94 |
|
| #ifdef TCP_MAXWIN |
| 95 |
|
| { "TCP_MAXWIN", 10, TCP_MAXWIN }, |
| 96 |
|
| #endif |
| 97 |
|
| #ifdef TCP_MAX_WINSHIFT |
| 98 |
|
| { "TCP_MAX_WINSHIFT", 16, TCP_MAX_WINSHIFT }, |
| 99 |
|
| #endif |
| 100 |
|
| #ifdef SOL_TCP |
| 101 |
|
| { "SOL_TCP", 7, SOL_TCP }, |
| 102 |
|
| #endif |
| 103 |
|
| #ifdef TCPI_OPT_TIMESTAMPS |
| 104 |
|
| { "TCPI_OPT_TIMESTAMPS", 19, TCPI_OPT_TIMESTAMPS }, |
| 105 |
|
| #endif |
| 106 |
|
| #ifdef TCPI_OPT_SACK |
| 107 |
|
| { "TCPI_OPT_SACK", 13, TCPI_OPT_SACK }, |
| 108 |
|
| #endif |
| 109 |
|
| #ifdef TCPI_OPT_WSCALE |
| 110 |
|
| { "TCPI_OPT_WSCALE", 15, TCPI_OPT_WSCALE }, |
| 111 |
|
| #endif |
| 112 |
|
| #ifdef TCPI_OPT_ECN |
| 113 |
|
| { "TCPI_OPT_ECN", 12, TCPI_OPT_ECN }, |
| 114 |
|
| #endif |
| 115 |
|
| #ifdef TCP_MD5SIG_MAXKEYLEN |
| 116 |
|
| { "TCP_MD5SIG_MAXKEYLEN", 20, TCP_MD5SIG_MAXKEYLEN }, |
| 117 |
|
| #endif |
| 118 |
|
| { NULL, 0, 0 } }; |
| 119 |
1 |
| const struct iv_s *value_for_iv = values_for_iv; |
| 120 |
37 |
▶ | while (value_for_iv->name) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (value_for_iv->name) { |
36 |
1 |
37 |
|
| 121 |
72 |
| constant_add_symbol(aTHX_ symbol_table, value_for_iv->name, |
| 122 |
36 |
| value_for_iv->namelen, newSViv(value_for_iv->value)); |
| 123 |
36 |
| ++value_for_iv; |
| 124 |
|
| } |
| 125 |
|
| if (C_ARRAY_LENGTH(values_for_notfound) > 1) { |
| 126 |
|
| #ifndef SYMBIAN |
| 127 |
|
| HV *const constant_missing = get_missing_hash(aTHX); |
| 128 |
|
| #endif |
| 129 |
|
| const struct notfound_s *value_for_notfound = values_for_notfound; |
| 130 |
|
| do { |
| 131 |
|
| |
| 132 |
|
| /* Need to add prototypes, else parsing will vary by platform. */ |
| 133 |
|
| HE *he = (HE*) hv_common_key_len(symbol_table, |
| 134 |
|
| value_for_notfound->name, |
| 135 |
|
| value_for_notfound->namelen, |
| 136 |
|
| HV_FETCH_LVALUE, NULL, 0); |
| 137 |
|
| SV *sv; |
| 138 |
|
| #ifndef SYMBIAN |
| 139 |
|
| HEK *hek; |
| 140 |
|
| #endif |
| 141 |
|
| if (!he) { |
| 142 |
|
| croak("Couldn't add key '%s' to %%Socket::Linux::", |
| 143 |
|
| value_for_notfound->name); |
| 144 |
|
| } |
| 145 |
|
| sv = HeVAL(he); |
| 146 |
|
| if (!SvOK(sv) && SvTYPE(sv) != SVt_PVGV) { |
| 147 |
|
| /* Nothing was here before, so mark a prototype of "" */ |
| 148 |
|
| sv_setpvn(sv, "", 0); |
| 149 |
|
| } else if (SvPOK(sv) && SvCUR(sv) == 0) { |
| 150 |
|
| /* There is already a prototype of "" - do nothing */ |
| 151 |
|
| } else { |
| 152 |
|
| /* Someone has been here before us - have to make a real |
| 153 |
|
| typeglob. */ |
| 154 |
|
| /* It turns out to be incredibly hard to deal with all the |
| 155 |
|
| corner cases of sub foo (); and reporting errors correctly, |
| 156 |
|
| so lets cheat a bit. Start with a constant subroutine */ |
| 157 |
|
| CV *cv = newCONSTSUB(symbol_table, |
| 158 |
|
| value_for_notfound->name, |
| 159 |
|
| &PL_sv_yes); |
| 160 |
|
| /* and then turn it into a non constant declaration only. */ |
| 161 |
|
| SvREFCNT_dec(CvXSUBANY(cv).any_ptr); |
| 162 |
|
| CvCONST_off(cv); |
| 163 |
|
| CvXSUB(cv) = NULL; |
| 164 |
|
| CvXSUBANY(cv).any_ptr = NULL; |
| 165 |
|
| } |
| 166 |
|
| #ifndef SYMBIAN |
| 167 |
|
| hek = HeKEY_hek(he); |
| 168 |
|
| if (!hv_common(constant_missing, NULL, HEK_KEY(hek), |
| 169 |
|
| HEK_LEN(hek), HEK_FLAGS(hek), HV_FETCH_ISSTORE, |
| 170 |
|
| &PL_sv_yes, HEK_HASH(hek))) |
| 171 |
|
| croak("Couldn't add key '%s' to missing_hash", |
| 172 |
|
| value_for_notfound->name); |
| 173 |
|
| #endif |
| 174 |
|
| } while ((++value_for_notfound)->name); |
| 175 |
|
| } |
| 176 |
|
| /* As we've been creating subroutines, we better invalidate any cached |
| 177 |
|
| methods */ |
| 178 |
1 |
| mro_method_changed_in(symbol_table); |
| 179 |
|
| } |
| 180 |
|
| |
| 181 |
|
| void |
| 182 |
|
| constant(sv) |
| 183 |
|
| INPUT: |
| 184 |
|
| SV * sv; |
| 185 |
|
| PPCODE: |
| 186 |
|
| #ifndef SYMBIAN |
| 187 |
|
| /* It's not obvious how to calculate this at C pre-processor time. |
| 188 |
|
| However, any compiler optimiser worth its salt should be able to |
| 189 |
|
| remove the dead code, and hopefully the now-obviously-unused static |
| 190 |
|
| function too. */ |
| 191 |
0 |
| HV *constant_missing = (C_ARRAY_LENGTH(values_for_notfound) > 1) |
| 192 |
|
| ? get_missing_hash(aTHX) : NULL; |
| 193 |
|
| if ((C_ARRAY_LENGTH(values_for_notfound) > 1) |
| 194 |
|
| ? hv_exists_ent(constant_missing, sv, 0) : 0) { |
| 195 |
|
| sv = newSVpvf("Your vendor has not defined Socket::Linux macro %" SVf |
| 196 |
|
| ", used", sv); |
| 197 |
|
| } else |
| 198 |
|
| #endif |
| 199 |
|
| { |
| 200 |
0 |
| sv = newSVpvf("%" SVf " is not a valid Socket::Linux macro", |
| 201 |
|
| sv); |
| 202 |
|
| } |
| 203 |
0 |
| PUSHs(sv_2mortal(sv)); |