diff --git a/Changes b/Changes index cbd427b..28a30d2 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for Perl extension NetAddr::IP +4.018 Fri Nov 28 23:19:01 PST 2008 + revised XS code to be full re-entrant, thread safe in Util.xs v1.26 + removed all traces of mutex locks in Util.xs v1.26 + removed function 'threads' here an in UtilPP v1.6 + 4.017 Sun Nov 23 19:32:59 PST 2008 Extended the capability of 'splitref' to allow splitting of objects into multiple pieces with differing CIDR masks. @@ -14,7 +19,7 @@ Thanks to Rob Riepel for a faster and more accurate _compV6 function. - in Util_PP v1.5 + in UtitPP v1.5 correct documentation error add threads reporting (empty string) diff --git a/IP.pm b/IP.pm index 8f377ea..015946b 100644 --- a/IP.pm +++ b/IP.pm @@ -34,7 +34,7 @@ @ISA = qw(Exporter NetAddr::IP::Lite); -$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.17 $ =~ /\d+/g) }; +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.18 $ =~ /\d+/g) }; =pod diff --git a/Lite/Util/Changes b/Lite/Util/Changes index de776d9..c0f178e 100644 --- a/Lite/Util/Changes +++ b/Lite/Util/Changes @@ -1,9 +1,14 @@ Revision history for Perl extension NetAddr::IP::Util +1.26 Fri Nov 28 23:19:01 PST 2008 + revised XS code to be full re-entrant... thread safe. + removed all traces of mutex locks + removed function 'threads' here an in UtilPP v1.6 + 1.25 Tue Nov 18 19:08:56 PST 2008 correct documentation error in Util_PP v1.5 - add threads reporting to Util.xs and Util_PP + add threads reporting to Util.xs and UtilPP added what is hopefully thread safe operation via serializaton. Must be invoked by "--with-threads" diff --git a/Lite/Util/Makefile.PL b/Lite/Util/Makefile.PL index 36c57bd..8af7a00 100644 --- a/Lite/Util/Makefile.PL +++ b/Lite/Util/Makefile.PL @@ -17,7 +17,6 @@ # my($withthreads,$useXS); GetOptions( - 'with-threads' => \$withthreads, 'xs!' => \$useXS, 'pm' => sub { warn "\n\t".'WARNING: Use of "--pm" is deprecated, use "-noxs" instead'."\n\n"; @@ -56,7 +55,6 @@ if (test_cc()) { print "You have a working compiler.\n"; $useXS = 1; - $withthreads = 1 if $withthreads; # $makeparms{'MYEXTLIB'} = 'netdns$(LIB_EXT)', } else { @@ -113,16 +111,6 @@ * */ |; - print F q|#define I_REALLY_WANT_ALPHA_THREADS 1 -| if $withthreads; - print F q|#define LOCAL_PERL_WANTS_PTHREAD_H 1 -| if $Config{i_pthread} eq 'define'; - print F q|#define LOCAL_PERL_USE_THREADS 1 -| if $Config{usethreads} eq 'define'; - print F q|#define LOCAL_PERL_USE_I_THREADS 1 -| if $Config{useithreads} eq 'define'; - print F q|#define LOCAL_PERL_USE_5005THREADS 1 -| if $Config{use5005threads} eq 'define'; close F; $begin = q| diff --git a/Lite/Util/README b/Lite/Util/README index 1c83167..850c27e 100644 --- a/Lite/Util/README +++ b/Lite/Util/README @@ -26,7 +26,6 @@ bin2bcd bcd2bin mode - threads ); use NetAddr::IP::Util qw(:all :inet :ipv4 :ipv6 :math) @@ -74,7 +73,6 @@ $bcdtext = bin2bcd($bits128); $bits128 = bcd2bin($bcdtxt); $modetext = mode; - $threadtxt = threads; INSTALLATION Un-tar the distribution in an appropriate directory and type: @@ -300,21 +298,6 @@ returns: "Pure Perl" or "CC XS" - * $threadtxt = threads - Returns the build flags for various thread options as a comma - seperated string. - - input: none - returns: empty string - or some combination of the following: - - HAVE_PTHREAD_H perl built with - HAVE_THREAD_H perl built with - LOCAL_PERL_WANTS_PTHREAD_H $Config{i_pthread} - LOCAL_PERL_USE_THREADS $Config{usethreads} - LOCAL_PERL_USE_I_THREADS $Config{useithreads} - LOCAL_PERL_USE_5005_THREADS $Config{use5005threads} - EXAMPLES # convert any textual IP address into a 128 bit vector # @@ -429,7 +412,6 @@ bin2bcd bcd2bin mode - threads AUTHOR Michael Robinton diff --git a/Lite/Util/Util.pm b/Lite/Util/Util.pm index 5e4a81e..08b6e1f 100644 --- a/Lite/Util/Util.pm +++ b/Lite/Util/Util.pm @@ -13,7 +13,7 @@ @ISA = qw(Exporter DynaLoader); -$VERSION = do { my @r = (q$Revision: 1.25 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.26 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @EXPORT_OK = qw( inet_aton @@ -44,7 +44,6 @@ bcdn2bin simple_pack comp128 - threads ); %EXPORT_TAGS = ( @@ -128,7 +127,7 @@ return &yinet_aton; } -# sub DESTROY {}; is in the XS file +sub DESTROY {}; 1; __END__ @@ -163,7 +162,6 @@ bin2bcd bcd2bin mode - threads ); use NetAddr::IP::Util qw(:all :inet :ipv4 :ipv6 :math) @@ -211,7 +209,6 @@ $bcdtext = bin2bcd($bits128); $bits128 = bcd2bin($bcdtxt); $modetext = mode; - $threadtxt = threads; =head1 INSTALLATION @@ -590,22 +587,6 @@ returns: "Pure Perl" or "CC XS" -=item * $threadtxt = threads - -Returns the build flags for various thread options -as a comma seperated string. - - input: none - returns: empty string - or some combination of the following: - - HAVE_PTHREAD_H perl built with - HAVE_THREAD_H perl built with - LOCAL_PERL_WANTS_PTHREAD_H $Config{i_pthread} - LOCAL_PERL_USE_THREADS $Config{usethreads} - LOCAL_PERL_USE_I_THREADS $Config{useithreads} - LOCAL_PERL_USE_5005_THREADS $Config{use5005threads} - =back =head1 EXAMPLES @@ -726,7 +707,6 @@ bin2bcd bcd2bin mode - threads =head1 AUTHOR diff --git a/Lite/Util/Util.xs b/Lite/Util/Util.xs index a1fa7f6..f6b758a 100644 --- a/Lite/Util/Util.xs +++ b/Lite/Util/Util.xs @@ -46,35 +46,33 @@ /* workaround for OS's without inet_aton */ #include "xs_include/inet_aton.c" -/* if kernel threading is in use, provide mutex locks for global variables */ -#ifdef LOCAL_USE_THREADS -lcl_mutx_init m_lock = DEFAULT_MUTEX_INIT; -#endif - typedef union { u_int32_t u[4]; unsigned char c[16]; } n128; -n128 c128, a128; +char * is_ipv6to4 = "ipv6to4", * is_shiftleft = "shiftleft", * is_comp128 = "comp128"; +char * is_sub128 = "sub128", * is_add128 = "add128"; +char * is_hasbits = "hasbits", * is_isIPv4 = "isIPv4"; +char * is_bcd2bin = "bcd2bin", * is_simple_pack = "simple_pack", * is_bcdn2bin = "bcdn2bin"; +char * is_mask4to6 = "mask4to6", * is_ipv4to6 = "ipv4to6"; +char * is_maskanyto6 = "maskanyto6", * is_ipanyto6 = "ipanyto6"; -char errorbuffer[256], *eb = errorbuffer; /* error buff */ +typedef struct bcdstuff +{ /* character array of 40 bytes */ + char txt[21]; /* 20 bytes + string terminator */ + u_int32_t bcd[5]; /* 20 bytes, 40 digits */ +} BCD; -u_int32_t wa[4], wb[4]; /* working registers */ - -struct -{ /* character array of 40 bytes */ - char txt[20]; /* 20 bytes */ - u_int32_t bcd[5]; /* 20 bytes, 40 digits */ -} n; +BCD xn; #define zero ('0' & 0x7f) void -extendipv4(void * aa) +extendipv4(void * aa, void * ux) { - register u_int32_t * a = wa; + register u_int32_t * a = ux; *a++ = 0; *a++ = 0; *a++ = 0; @@ -82,9 +80,9 @@ } void -extendmask4(void *aa) +extendmask4(void * aa, void * ux) { - register u_int32_t * a = wa; + register u_int32_t * a = ux; *a++ = 0xffffffff; *a++ = 0xffffffff; *a++ = 0xffffffff; @@ -108,7 +106,7 @@ */ int -adder128(void * aa, void * bb, int carry) +adder128(void * aa, void * bb, n128 * ap128, int carry) { int i; register u_int32_t a, b, r; @@ -127,13 +125,13 @@ else carry = a; - *((u_int32_t *)a128.u + i) = b; + *((u_int32_t *)(ap128->u) + i) = b; } return carry; } int -addercon(void * aa, int32_t con) +addercon(void * aa, u_int32_t * bb, n128 * ap128, int32_t con) { register u_int32_t tmp = 0x80000000; @@ -142,11 +140,11 @@ else tmp = 0; - wb[0] = tmp; - wb[1] = tmp; - wb[2] = tmp; - wb[3] = (u_int32_t)con; - return adder128(aa,wb,0); + bb[0] = tmp; + bb[1] = tmp; + bb[2] = tmp; + bb[3] = (u_int32_t)con; + return adder128(aa,bb,ap128,0); } int @@ -237,9 +235,9 @@ /* multiply 128 bit number x 2 */ void -_128x2(void * ap) +_128x2(u_int32_t * ap) { - register u_int32_t * p = (u_int32_t *)ap +3, tmpc, carry = 0; + register u_int32_t * p = ap +3, tmpc, carry = 0; do { tmpc = *p & 0x80000000; /* propagate hi bit to next word */ @@ -247,51 +245,53 @@ if (carry) *p += 1; carry = tmpc; - } while (p-- > (u_int32_t *)ap); -/* printf("2o %04X:%04X:%04X:%04X\n",*((u_int32_t *)ap),*((u_int32_t *)ap +1),*((u_int32_t *)ap +2),*((u_int32_t *)ap +3)); */ + } while (p-- > ap); +/* printf("2o %04X:%04X:%04X:%04X\n",*(ap),*(ap +1),*(ap +2),*(ap +3)); */ } /* multiply 128 bit number X10 */ int -_128x10(void * ap, void * tp) +_128x10(n128 * ap128, n128 * tp128) { + register u_int32_t * ap = ap128->u, * tp = tp128->u; _128x2(ap); /* multiply by two */ - *(u_int32_t *)tp = *(u_int32_t *)ap; /* temp save */ - *((u_int32_t *)tp +1) = *((u_int32_t *)ap +1); - *((u_int32_t *)tp +2) = *((u_int32_t *)ap +2); - *((u_int32_t *)tp +3) = *((u_int32_t *)ap +3); + *tp = *ap; /* temp save */ + *(tp +1) = *(ap +1); + *(tp +2) = *(ap +2); + *(tp +3) = *(ap +3); _128x2(ap); _128x2(ap); /* times 8 */ - (void) adder128(ap,tp,0); + (void) adder128(ap,tp,ap128,0); /* printf("x %04X:%04X:%04X:%04X\n",*((u_int32_t *)ap),*((u_int32_t *)ap +1),*((u_int32_t *)ap +2),*((u_int32_t *)ap +3)); */ } /* multiply 128 bit number by 10, add bcd digit to result */ void -_128x10plusbcd(void * ap, void * tp, char digit) +_128x10plusbcd(n128 * ap128, n128 * tp128, char digit) { -/* printf("digit %X + %X = ",digit,*((u_int32_t *)ap +3)); */ - _128x10(ap,tp); - *(u_int32_t *)tp = 0; - *((u_int32_t *)tp + 1) = 0; - *((u_int32_t *)tp + 2) = 0; - *((u_int32_t *)tp + 3) = digit; - (void) adder128(ap,tp,0); + register u_int32_t * ap = ap128->u, * tp = tp128->u; +/* printf("digit %X + %X = ",digit,*(ap +3)); */ + _128x10(ap128,tp128); + *tp = 0; + *(tp + 1) = 0; + *(tp + 2) = 0; + *(tp + 3) = digit; + (void) adder128(ap,tp,ap128,0); /* printf("%d %04X:%04X:%04X:%04X\n",digit,*((u_int32_t *)ap),*((u_int32_t *)ap +1),*((u_int32_t *)ap +2),*((u_int32_t *)ap +3)); */ } char -_simple_pack(void * str,int len) +_simple_pack(void * str,int len, BCD * n) { int i = len -1, j=19, lo=1; - register unsigned char c, * bcdn = (unsigned char *)n.bcd, * sp = (unsigned char *) str; + register unsigned char c, * bcdn = (unsigned char *)(n->bcd), * sp = (unsigned char *) str; if (len > 40) return '*'; /* error, input string too long */ - memset (n.bcd, 0, 20); + memset (bcdn, 0, 20); do { c = *(sp + i) & 0x7f; @@ -315,34 +315,34 @@ /* convert a packed bcd string to 128 bit binary string */ void -_bcdn2bin(void * bp, int len) +_bcdn2bin(void * bp, n128 * ap128, n128 * cp128, int len) { int i = 0, hasdigits = 0, lo; register unsigned char c, * cp = (unsigned char *)bp; - memset(a128.c, 0, 16); - memset(c128.c, 0, 16); + memset(ap128->c, 0, 16); + memset(cp128->c, 0, 16); while (i < len ) { c = *cp++; for (lo=0;lo<2;lo+=1) { if (lo) { if (hasdigits) /* suppress leading zero multiplications */ - _128x10plusbcd(a128.u,c128.u, c & 0xF); + _128x10plusbcd(ap128, cp128, c & 0xF); else { if (c & 0xF) { hasdigits = 1; - a128.u[3] = c & 0xF; + ap128->u[3] = c & 0xF; } } } else { if (hasdigits) /* suppress leading zero multiplications */ - _128x10plusbcd(a128.u,c128.u, c >> 4); + _128x10plusbcd(ap128, cp128, c >> 4); else { if (c & 0XF0) { hasdigits = 1; - a128.u[3] = c >> 4; + ap128->u[3] = c >> 4; } } } @@ -357,14 +357,14 @@ returns the length of the bcd string === 20 */ int -_bin2bcd (unsigned char * binary) +_bin2bcd (unsigned char * binary, BCD * n) { - register u_int32_t tmp, add3, msk8, bcd8, carry; + register u_int32_t tmp, add3, msk8, bcd8, carry; u_int32_t word; unsigned char binmsk = 0; int c = 0,i, j, p; - memset (n.bcd, 0, 20); + memset (n->bcd, 0, 20); for (p=0;p<128;p++) { /* bit pointer */ if (! binmsk) { @@ -375,7 +375,7 @@ carry = word & binmsk; /* bit to convert */ binmsk >>= 1; for (i=4;i>=0;i--) { - bcd8 = n.bcd[i]; + bcd8 = n->bcd[i]; if (carry | bcd8) { /* if something to do */ add3 = 3; msk8 = 8; @@ -391,12 +391,12 @@ bcd8 <<= 1; /* x 2 */ if (carry) bcd8 += 1; - n.bcd[i] = bcd8; + n->bcd[i] = bcd8; carry = tmp; } } } - netswap(n.bcd,5); + netswap(n->bcd,5); return 20; } @@ -404,7 +404,7 @@ returns the number of digits */ int -_bcd2txt(unsigned char * bcd2p) +_bcd2txt(unsigned char * bcd2p, BCD * n) { register unsigned char bcd, dchar; int i, j = 0; @@ -413,16 +413,16 @@ dchar = *(bcd2p + i); bcd = dchar >> 4; if (j || bcd) { - n.txt[j] = bcd + zero; + n->txt[j] = bcd + zero; j++; } bcd = dchar & 0xF; if (j || bcd || i == 19) { /* must be at least one digit */ - n.txt[j] = bcd + zero; + n->txt[j] = bcd + zero; j++; } } - n.txt[j] = 0; /* string terminator */ + n->txt[j] = 0; /* string terminator */ return j; } @@ -440,31 +440,24 @@ NetAddr::IP::Util::shiftleft = 1 PREINIT: unsigned char * ap; + char * subname; + u_int32_t wa[4]; STRLEN len; int i; PPCODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -#endif ap = (unsigned char *) SvPV(s,len); if (len != 16) { if (ix == 2) - strcpy(eb,"ipv6to4"); + subname = is_ipv6to4; else if (ix == 1) - strcpy(eb,"shiftleft"); + subname = is_shiftleft; else - strcpy(eb,"comp128"); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif + subname = is_comp128; croak("Bad arg length for %s%s, length is %d, should be %d", - "NetAddr::IP::Util::",eb,len *8,128); + "NetAddr::IP::Util::",subname,len *8,128); } if (ix == 2) { XPUSHs(sv_2mortal(newSVpvn((char *)(ap +12),4))); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); } else if (ix == 1) { @@ -475,9 +468,6 @@ memcpy(wa,ap,16); } else if (i < 0 || i > 128) { -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif croak("Bad arg value for %s, is %d, should be 0 thru 128", "NetAddr::IP::Util::shiftleft",i); } @@ -495,9 +485,6 @@ fastcomp128(wa); } XPUSHs(sv_2mortal(newSVpvn((char *)wa,16))); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); void @@ -508,23 +495,20 @@ NetAddr::IP::Util::sub128 = 1 PREINIT: unsigned char * ap, *bp; + char * subname; + u_int32_t wa[4], wb[4]; + n128 a128; STRLEN len; PPCODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -#endif ap = (unsigned char *) SvPV(as,len); if (len != 16) { Bail: if (ix == 1) - strcpy(eb,"sub128"); + subname = is_sub128; else - strcpy(eb,"add128"); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif + subname = is_add128; croak("Bad arg length for %s%s, length is %d, should be %d", - "NetAddr::IP::Util::",eb,len *8,128); + "NetAddr::IP::Util::",subname,len *8,128); } bp = (unsigned char *) SvPV(bs,len); @@ -535,22 +519,16 @@ netswap_copy(wb,bp,4); if (ix == 1) { fastcomp128(wb); - XPUSHs(sv_2mortal(newSViv((I32)adder128(wa,wb,1)))); + XPUSHs(sv_2mortal(newSViv((I32)adder128(wa,wb,&a128,1)))); } else { - XPUSHs(sv_2mortal(newSViv((I32)adder128(wa,wb,0)))); + XPUSHs(sv_2mortal(newSViv((I32)adder128(wa,wb,&a128,0)))); } if (GIMME_V == G_ARRAY) { netswap(a128.u,4); XPUSHs(sv_2mortal(newSVpvn((char *)a128.c,16))); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(2); } -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); void @@ -558,35 +536,26 @@ SV * s I32 cnst PREINIT: + n128 a128; unsigned char * ap; + u_int32_t wa[4], wb[4]; STRLEN len; PPCODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -#endif ap = (unsigned char *) SvPV(s,len); if (len != 16) { -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif croak("Bad arg length for %s, length is %d, should be %d", "NetAddr::IP::Util::addconst",len *8,128); } netswap_copy(wa,ap,4); - XPUSHs(sv_2mortal(newSViv((I32)addercon(wa,cnst)))); + XPUSHs(sv_2mortal(newSViv((I32)addercon(wa,wb,&a128,cnst)))); if (GIMME_V == G_ARRAY) { netswap(a128.u,4); XPUSHs(sv_2mortal(newSVpvn((char *)a128.c,16))); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(2); } -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); + int hasbits(s) SV * s @@ -594,22 +563,17 @@ NetAddr::IP::Util::isIPv4 = 1 PREINIT: unsigned char * bp; + char * subname; STRLEN len; CODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -#endif bp = (unsigned char *) SvPV(s,len); if (len != 16) { if (ix == 1) - strcpy(eb,"isIPv4"); + subname = is_isIPv4; else - strcpy(eb,"hasbits"); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif + subname = is_hasbits; croak("Bad arg length for %s%s, length is %d, should be %d", - "NetAddr::IP::Util::",eb,len *8,128); + "NetAddr::IP::Util::",subname,len *8,128); } if (ix == 1) { RETVAL = _isipv4(bp); @@ -617,9 +581,6 @@ else { RETVAL = have128(bp); } -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif OUTPUT: RETVAL @@ -630,47 +591,33 @@ NetAddr::IP::Util::bcdn2txt = 2 NetAddr::IP::Util::bin2bcdn = 1 PREINIT: + BCD n; unsigned char * cp; STRLEN len; PPCODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -#endif cp = (unsigned char *) SvPV(s,len); if (ix == 0) { if (len != 16) { -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif croak("Bad arg length for %s, length is %d, should be %d", "NetAddr::IP::Util::bin2bcd",len *8,128); } - (void) _bin2bcd(cp); - XPUSHs(sv_2mortal(newSVpvn((char *)n.txt,_bcd2txt((unsigned char *)n.bcd)))); + (void) _bin2bcd(cp,&n); + XPUSHs(sv_2mortal(newSVpvn((char *)n.txt,_bcd2txt((unsigned char *)n.bcd,&n)))); } else if (ix == 1) { if (len != 16) { -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif croak("Bad arg length for %s, length is %d, should be %d", "NetAddr::IP::Util::bin2bcdn",len *8,128); } - XPUSHs(sv_2mortal(newSVpvn((char *)n.bcd,_bin2bcd(cp)))); + XPUSHs(sv_2mortal(newSVpvn((char *)n.bcd,_bin2bcd(cp,&n)))); } else { if (len > 20) { -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif croak("Bad arg length for %s, length is %d, should %d digits or less", "NetAddr::IP::Util::bcdn2txt",len *2,40); } - XPUSHs(sv_2mortal(newSVpvn((char *)n.txt,_bcd2txt(cp)))); + XPUSHs(sv_2mortal(newSVpvn((char *)n.txt,_bcd2txt(cp,&n)))); } -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); #* @@ -686,70 +633,55 @@ NetAddr::IP::Util::bcdn2bin = 2 NetAddr::IP::Util::simple_pack = 1 PREINIT: + BCD n; + n128 c128, a128; unsigned char * cp, badc; + char * subname; STRLEN len; PPCODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -#endif cp = (unsigned char *) SvPV(s,len); if (len > 40) { if (ix == 0) - strcpy(eb,"bcd2bin"); + subname = is_bcd2bin; else if (ix ==1) - strcpy(eb,"simple_pack"); + subname = is_simple_pack; Badigits: -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif croak("Bad arg length for %s%s, length is %d, should be %d digits or less", - "NetAddr::IP::Util::",eb,len,40); + "NetAddr::IP::Util::",subname,len,40); } if (ix == 2) { if (len > 20) { len <<= 1; /* times 2 */ - strcpy(eb,"bcdn2bin"); + subname = is_bcdn2bin; goto Badigits; } if (items < 2) { -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif croak("Bad usage, should have %s('packedbcd,length)", "NetAddr::IP::Util::bcdn2bin"); } len = SvIV(ST(1)); - _bcdn2bin(cp,(int)len); + _bcdn2bin(cp,&a128,&c128,(int)len); netswap(a128.u,4); XPUSHs(sv_2mortal(newSVpvn((char *)a128.c,16))); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); } - badc = _simple_pack(cp,(int)len); + badc = _simple_pack(cp,(int)len, &n); if (badc) { if (ix == 1) - strcpy(eb,"simple_pack"); + subname = is_simple_pack; else - strcpy(eb,"bcd2bin"); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif + subname = is_bcd2bin; croak("Bad char in string for %s%s, character is '%c', allowed are 0-9", - "NetAddr::IP::Util::",eb,badc); + "NetAddr::IP::Util::",subname,badc); } if (ix == 0) { - _bcdn2bin(n.bcd,40); + _bcdn2bin((void *)n.bcd,&a128,&c128,40); netswap(a128.u,4); XPUSHs(sv_2mortal(newSVpvn((char *)a128.c,16))); } else { /* ix == 1 */ XPUSHs(sv_2mortal(newSVpvn((char *)n.bcd,20))); } -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); void @@ -757,16 +689,11 @@ SV * s PREINIT: unsigned char * ap, count; + u_int32_t wa[4]; STRLEN len; PPCODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -#endif ap = (unsigned char *) SvPV(s,len); if (len != 16) { -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif croak("Bad arg length for %s, length is %d, should be %d", "NetAddr::IP::Util::countbits",len *8,128); } @@ -775,14 +702,8 @@ XPUSHs(sv_2mortal(newSViv((I32)have128(wa)))); if (GIMME_V == G_ARRAY) { XPUSHs(sv_2mortal(newSViv((I32)count))); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(2); } -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); void @@ -792,31 +713,24 @@ NetAddr::IP::Util::mask4to6 = 1 PREINIT: unsigned char * ip; + char * subname; + u_int32_t wa[4]; STRLEN len; PPCODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -#endif ip = (unsigned char *) SvPV(s,len); if (len != 4) { if (ix == 1) - strcpy(eb,"mask4to6"); + subname = is_mask4to6; else - strcpy(eb,"ipv4to6"); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif + subname = is_ipv4to6; croak("Bad arg length for %s%s, length is %d, should be 32", - "NetAddr::IP::Util::",eb,len *8); + "NetAddr::IP::Util::",subname,len *8); } if (ix == 0) - extendipv4(ip); + extendipv4(ip, wa); else - extendmask4(ip); + extendmask4(ip, wa); XPUSHs(sv_2mortal(newSVpvn((char *)wa,16))); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); void @@ -826,73 +740,27 @@ NetAddr::IP::Util::maskanyto6 = 1 PREINIT: unsigned char * ip; + char * subname; + u_int32_t wa[4]; STRLEN len; PPCODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -#endif ip = (unsigned char *) SvPV(s,len); if (len == 16) /* if already 128 bits, return input */ XPUSHs(sv_2mortal(newSVpvn((char *)ip,16))); else if (len == 4) { if (ix == 0) - extendipv4(ip); + extendipv4(ip, wa); else - extendmask4(ip); + extendmask4(ip, wa); XPUSHs(sv_2mortal(newSVpvn((char *)wa,16))); } else { if (ix == 1) - strcpy(eb,"maskanyto6"); + subname = is_maskanyto6; else - strcpy(eb,"ipanyto6"); -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif + subname = is_ipanyto6; croak("Bad arg length for %s%s, length is %d, should be 32 or 128", - "NetAddr::IP::Util::",eb,len *8); + "NetAddr::IP::Util::",subname,len *8); } -#ifdef LOCAL_USE_THREADS - lcl_mutx_ulck(&m_lock); -#endif XSRETURN(1); -void -threads() - PPCODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_lck(&m_lock); -# ifdef HAVE_PTHREAD_H - strcpy(eb,"HAVE_PTHREAD_H"); -# else -# ifdef HAVE_THREAD_H - strcpy(eb,"HAVE_THREAD_H"); /* gotta have one of them */ -# else -# strcpy(eb,"thread error, look at code"); -# endif -# endif -# ifdef xLOCAL_PERL_WANTS_PTHREAD_H - strcat(eb,",LOCAL_PERL_WANTS_PTHREAD_H"); -# endif -# ifdef xLOCAL_PERL_USE_THREADS - strcat(eb,",LOCAL_PERL_USE_THREADS"); -# endif -# ifdef xLOCAL_PERL_USE_I_THREADS - strcat(eb,",LOCAL_PERL_USE_I_THREADS"); -# endif -# ifdef xLOCAL_PERL_USE_5005_THREADS - strcat(eb,",LOCAL_PERL_USE_5005_THREADS"); -# endif - XPUSHs(sv_2mortal(newSVpv(eb,0))); - lcl_mutx_ulck(&m_lock); -#else - XPUSHs(sv_2mortal(newSVpv("",0))); -#endif - XSRETURN(1); - -void -DESTROY() - CODE: -#ifdef LOCAL_USE_THREADS - lcl_mutx_dsty(&m_lock); -#endif diff --git a/Lite/Util/config.h.in b/Lite/Util/config.h.in index ffb94d4..3292a42 100644 --- a/Lite/Util/config.h.in +++ b/Lite/Util/config.h.in @@ -30,9 +30,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H -/* Define to 1 if you have . */ -#undef HAVE_PTHREAD_H - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H @@ -54,9 +51,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H -/* Define to 1 if you have . */ -#undef HAVE_THREAD_H - /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H diff --git a/Lite/Util/configure b/Lite/Util/configure index 9e9da08..4843d9f 100755 --- a/Lite/Util/configure +++ b/Lite/Util/configure @@ -4236,450 +4236,6 @@ fi - -if test "${ac_cv_header_pthread_h+set}" = set; then - { echo "$as_me:$LINENO: checking for pthread.h" >&5 -echo $ECHO_N "checking for pthread.h... $ECHO_C" >&6; } -if test "${ac_cv_header_pthread_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_pthread_h" >&5 -echo "${ECHO_T}$ac_cv_header_pthread_h" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking pthread.h usability" >&5 -echo $ECHO_N "checking pthread.h usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } - -# Is the header present? -{ echo "$as_me:$LINENO: checking pthread.h presence" >&5 -echo $ECHO_N "checking pthread.h presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: pthread.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: pthread.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: pthread.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: pthread.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: pthread.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: pthread.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: pthread.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: pthread.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: pthread.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: pthread.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: pthread.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: pthread.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: pthread.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: pthread.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: pthread.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: pthread.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ echo "$as_me:$LINENO: checking for pthread.h" >&5 -echo $ECHO_N "checking for pthread.h... $ECHO_C" >&6; } -if test "${ac_cv_header_pthread_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_header_pthread_h=$ac_header_preproc -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_pthread_h" >&5 -echo "${ECHO_T}$ac_cv_header_pthread_h" >&6; } - -fi -if test $ac_cv_header_pthread_h = yes; then - - -cat >>confdefs.h <<\_ACEOF -#define HAVE_PTHREAD_H 1 -_ACEOF - - { echo "$as_me:$LINENO: checking for library containing pthread_mutex_init" >&5 -echo $ECHO_N "checking for library containing pthread_mutex_init... $ECHO_C" >&6; } -if test "${ac_cv_search_pthread_mutex_init+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_func_search_save_LIBS=$LIBS -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char pthread_mutex_init (); -int -main () -{ -return pthread_mutex_init (); - ; - return 0; -} -_ACEOF -for ac_lib in '' pthreads; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - ac_cv_search_pthread_mutex_init=$ac_res -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext - if test "${ac_cv_search_pthread_mutex_init+set}" = set; then - break -fi -done -if test "${ac_cv_search_pthread_mutex_init+set}" = set; then - : -else - ac_cv_search_pthread_mutex_init=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ echo "$as_me:$LINENO: result: $ac_cv_search_pthread_mutex_init" >&5 -echo "${ECHO_T}$ac_cv_search_pthread_mutex_init" >&6; } -ac_res=$ac_cv_search_pthread_mutex_init -if test "$ac_res" != no; then - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - { echo "$as_me:$LINENO: ...have pthreads, do not check for thread.h" >&5 -echo "$as_me: ...have pthreads, do not check for thread.h" >&6;} -else - - if test "${ac_cv_header_thread_h+set}" = set; then - { echo "$as_me:$LINENO: checking for thread.h" >&5 -echo $ECHO_N "checking for thread.h... $ECHO_C" >&6; } -if test "${ac_cv_header_thread_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_thread_h" >&5 -echo "${ECHO_T}$ac_cv_header_thread_h" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking thread.h usability" >&5 -echo $ECHO_N "checking thread.h usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } - -# Is the header present? -{ echo "$as_me:$LINENO: checking thread.h presence" >&5 -echo $ECHO_N "checking thread.h presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: thread.h: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: thread.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: thread.h: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: thread.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: thread.h: present but cannot be compiled" >&5 -echo "$as_me: WARNING: thread.h: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: thread.h: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: thread.h: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: thread.h: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: thread.h: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: thread.h: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: thread.h: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: thread.h: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: thread.h: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: thread.h: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: thread.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ echo "$as_me:$LINENO: checking for thread.h" >&5 -echo $ECHO_N "checking for thread.h... $ECHO_C" >&6; } -if test "${ac_cv_header_thread_h+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_cv_header_thread_h=$ac_header_preproc -fi -{ echo "$as_me:$LINENO: result: $ac_cv_header_thread_h" >&5 -echo "${ECHO_T}$ac_cv_header_thread_h" >&6; } - -fi -if test $ac_cv_header_thread_h = yes; then - - -cat >>confdefs.h <<\_ACEOF -#define HAVE_THREAD_H 1 -_ACEOF - - { echo "$as_me:$LINENO: checking for library containing mutex_init" >&5 -echo $ECHO_N "checking for library containing mutex_init... $ECHO_C" >&6; } -if test "${ac_cv_search_mutex_init+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - ac_func_search_save_LIBS=$LIBS -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char mutex_init (); -int -main () -{ -return mutex_init (); - ; - return 0; -} -_ACEOF -for ac_lib in '' thread; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && - $as_test_x conftest$ac_exeext; then - ac_cv_search_mutex_init=$ac_res -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext - if test "${ac_cv_search_mutex_init+set}" = set; then - break -fi -done -if test "${ac_cv_search_mutex_init+set}" = set; then - : -else - ac_cv_search_mutex_init=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ echo "$as_me:$LINENO: result: $ac_cv_search_mutex_init" >&5 -echo "${ECHO_T}$ac_cv_search_mutex_init" >&6; } -ac_res=$ac_cv_search_mutex_init -if test "$ac_res" != no; then - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - -fi - - - -fi - - - { echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } if test "${ac_cv_c_bigendian+set}" = set; then diff --git a/Lite/Util/configure.ac b/Lite/Util/configure.ac index 78bda55..9a45de3 100644 --- a/Lite/Util/configure.ac +++ b/Lite/Util/configure.ac @@ -37,17 +37,6 @@ AC_SEARCH_LIBS([inet_addr],[socket],[ AC_DEFINE([HAVE_INET_ADDR])]) - -AC_CHECK_HEADER([pthread.h],[ - AC_DEFINE([HAVE_PTHREAD_H],[1],[Define to 1 if you have .]) - AC_SEARCH_LIBS([pthread_mutex_init],[pthreads],[],[]) - AC_MSG_NOTICE([...have pthreads, do not check for thread.h])],[ - AC_CHECK_HEADER([thread.h],[ - AC_DEFINE([HAVE_THREAD_H],[1],[Define to 1 if you have .]) - AC_SEARCH_LIBS([mutex_init],[thread],[],[])] - ) -]) - AC_C_BIGENDIAN AC_CHECK_SIZEOF([uint8_t]) AC_CHECK_SIZEOF([uint16_t]) diff --git a/Lite/Util/lib/NetAddr/IP/UtilPP.pm b/Lite/Util/lib/NetAddr/IP/UtilPP.pm index a6b7a1d..2626092 100644 --- a/Lite/Util/lib/NetAddr/IP/UtilPP.pm +++ b/Lite/Util/lib/NetAddr/IP/UtilPP.pm @@ -12,7 +12,7 @@ @ISA = qw(Exporter); -$VERSION = do { my @r = (q$Revision: 1.5 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.6 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @EXPORT_OK = qw( hasbits @@ -34,7 +34,6 @@ bcdn2txt bcdn2bin simple_pack - threads ); %EXPORT_TAGS = ( @@ -67,7 +66,6 @@ ipv6to4 bin2bcd bcd2bin - threads ); use NetAddr::IP::UtilPP qw(:all) @@ -89,7 +87,6 @@ $netaddr = ipv6to4($pv6naddr); $bcdtext = bin2bcd($bits128); $bits128 = bcd2bin($bcdtxt); - $threadtxt = threads(); =head1 DESCRIPTION @@ -470,16 +467,7 @@ goto &_bcd2bin; } -=item * $threadtxt = threads(); - -Returns an empty string in Pure Perl mode. See the description for XS mode -for more detail. - -=cut - -sub threads { - return ''; -} +=pod =back diff --git a/Lite/Util/localconf.h b/Lite/Util/localconf.h index 0cf375f..0a1a524 100644 --- a/Lite/Util/localconf.h +++ b/Lite/Util/localconf.h @@ -78,55 +78,3 @@ #include "localperl.h" -/* - * defined if the C program should include - * LOCAL_PERL_WANTS_PTHREAD_H - * - * defined if perl was compiled to use threads - * LOCAL_PERL_USE_THREADS - * - * defined if perl was compiled to use interpreter threads - * LOCAL_PERL_USE_I_THREADS - * - * defined if perl was compiled to use 5005 threads - * LOCAL_PERL_USE_5005_THREADS - * - * - * THREAD code is definetly ALPHA in Util.xs - * Benchmarks indicate that it runs up to 50% slower - * Use at your own risk for now - * - * does not yet address the FreeBSD mutex mtx_xxx functions - * mtx_lock - * mtx_unlock - * mtx_destroy - * #include - * #include - * #include - */ - -#if defined I_REALLY_WANT_ALPHA_THREADS -#if defined (HAVE_PTHREAD_H) && defined (LOCAL_PERL_WANTS_PTHREAD_H) -#include -#define LOCAL_USE_THREADS -#define DEFAULT_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER -#define lcl_mutx_init pthread_mutex_t -#define lcl_mutx_lck(m) pthread_mutex_lock(m) -#define lcl_mutx_ulck(m) pthread_mutex_unlock(m) -#define lcl_mutx_dsty(m) pthread_mutex_destroy(m) -# ifdef HAVE_THREAD_H -# undef HAVE_THREAD_H -# endif -#endif - -#if defined (HAVE_THREAD_H) && defined (LOCAL_PERL_USE_THREADS) -#include -#include -#define LOCAL_USE_THREADS -#define DEFAULT_MUTEX_INIT DEFAULTMUTEX -#define lcl_mutx_init mutex_t -#define lcl_mutx_lck(m) mutex_lock(m) -#define lcl_mutx_ulck(m) mutex_unlock(m) -#define lcl_mutx_dsty(m) mutex_destroy(m) -#endif -#endif diff --git a/Lite/Util/t/mode.t b/Lite/Util/t/mode.t index 9b78e12..66d3136 100644 --- a/Lite/Util/t/mode.t +++ b/Lite/Util/t/mode.t @@ -10,7 +10,6 @@ use NetAddr::IP::Util qw( mode - threads ); $loaded = 1; @@ -22,8 +21,6 @@ # of the test code): my $mode = mode(); -my $thrd = threads(); my $txt = "\tmode $mode"; -$txt .= " => $thrd" if $thrd; print STDERR $txt,"\n"; print "ok 2\n"; diff --git a/META.yml b/META.yml index b297c09..f394bdd 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- #YAML:1.0 name: NetAddr-IP -version: 4.017 +version: 4.018 abstract: Manages IPv4 and IPv6 addresses and subnets license: ~ author: diff --git a/Makefile.PL b/Makefile.PL index de47a08..29f1362 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -22,26 +22,6 @@ sleep $view if $view; } -unless (grep { m/with-threads/ } @ARGV) { - print q{ -This version of NetAddr::IP incorporates ALPHA support for THREADS -on the underlying platform (not perl threads). If perl was built -with or then this module can be linked to -those libraries if desired. Documentation about perl suggests this -might be a good idea maybe??? The additional thread code is designed -to make the XS library thread safe via serialization with mutex locks. -However, there is no assurance that the present NetAddr::IP threads -code works as expected or improves anything at all. I confess I -don't know that much about threads. - -Use at your own risk as follows: - - perl Makefile.PL --with-threads - -}; - sleep $view if $view; -} - eval q{ use Test::Pod; $check0 = 1; };