Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Bugs

#1046: exp2 portability

 

 

Varnish bugs RSS feed   Index | Next | Previous | View Threaded


varnish-bugs at varnish-cache

Oct 30, 2011, 6:11 AM

Post #1 of 3 (237 views)
Permalink
#1046: exp2 portability

#1046: exp2 portability
------------------------+---------------------------------------------------
Reporter: msporleder | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: 3.0.2 | Severity: normal
Keywords: |
------------------------+---------------------------------------------------
exp2 isn't in netbsd 5 so varnish fails to compile. The following patches
should work:


--- configure.ac.orig 2011-10-30 12:53:05.000000000 +0000
+++ configure.ac
@@ -380,6 +380,8 @@ else
ac_cv_func_port_create=no
fi

+AC_CHECK_FUNCS([exp2])
+
AM_MISSING_HAS_RUN
AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6
python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build
Varnish, please install python.])])



--- bin/varnishd/cache_dir_random.c.orig 2011-10-24
07:25:09.000000000 +0000
+++ bin/varnishd/cache_dir_random.c
@@ -62,6 +62,11 @@
#include "vsha256.h"
#include "vend.h"

+#ifndef HAVE_EXP2
+ #define EXP2_32 4294967296
+ #define EXP2_31 2147483648
+#endif
+
/*--------------------------------------------------------------------*/

struct vdi_random_host {
@@ -97,7 +102,11 @@ vdi_random_sha(const char *input, ssize_
SHA256_Init(&ctx);
SHA256_Update(&ctx, input, len);
SHA256_Final(sign, &ctx);
+#ifndef HAVE_EXP2
+ return (vle32dec(sign) / EXP2_32);
+#else
return (vle32dec(sign) / exp2(32));
+#endif
}

/*
@@ -119,11 +128,19 @@ vdi_random_init_seed(const struct vdi_ra
break;
case c_hash:
AN(sp->digest);
+#ifndef HAVE_EXP2
+ retval = vle32dec(sp->digest) / EXP2_32;
+#else
retval = vle32dec(sp->digest) / exp2(32);
+#endif
break;
case c_random:
default:
+#ifndef HAVE_EXP2
+ retval = random() / EXP2_31;
+#else
retval = random() / exp2(31);
+#endif
break;
}
return (retval);

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1046>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs


varnish-bugs at varnish-cache

Oct 31, 2011, 4:25 AM

Post #2 of 3 (222 views)
Permalink
Re: #1046: exp2 portability [In reply to]

#1046: exp2 portability
------------------------+---------------------------------------------------
Reporter: msporleder | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: 3.0.2 | Severity: normal
Keywords: |
------------------------+---------------------------------------------------
Description changed by kristian:

Old description:

> exp2 isn't in netbsd 5 so varnish fails to compile. The following
> patches should work:
>

> --- configure.ac.orig 2011-10-30 12:53:05.000000000 +0000
> +++ configure.ac
> @@ -380,6 +380,8 @@ else
> ac_cv_func_port_create=no
> fi
>
> +AC_CHECK_FUNCS([exp2])
> +
> AM_MISSING_HAS_RUN
> AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6
> python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build
> Varnish, please install python.])])
>

>
> --- bin/varnishd/cache_dir_random.c.orig 2011-10-24
> 07:25:09.000000000 +0000
> +++ bin/varnishd/cache_dir_random.c
> @@ -62,6 +62,11 @@
> #include "vsha256.h"
> #include "vend.h"
>
> +#ifndef HAVE_EXP2
> + #define EXP2_32 4294967296
> + #define EXP2_31 2147483648
> +#endif
> +
> /*--------------------------------------------------------------------*/
>
> struct vdi_random_host {
> @@ -97,7 +102,11 @@ vdi_random_sha(const char *input, ssize_
> SHA256_Init(&ctx);
> SHA256_Update(&ctx, input, len);
> SHA256_Final(sign, &ctx);
> +#ifndef HAVE_EXP2
> + return (vle32dec(sign) / EXP2_32);
> +#else
> return (vle32dec(sign) / exp2(32));
> +#endif
> }
>
> /*
> @@ -119,11 +128,19 @@ vdi_random_init_seed(const struct vdi_ra
> break;
> case c_hash:
> AN(sp->digest);
> +#ifndef HAVE_EXP2
> + retval = vle32dec(sp->digest) / EXP2_32;
> +#else
> retval = vle32dec(sp->digest) / exp2(32);
> +#endif
> break;
> case c_random:
> default:
> +#ifndef HAVE_EXP2
> + retval = random() / EXP2_31;
> +#else
> retval = random() / exp2(31);
> +#endif
> break;
> }
> return (retval);

New description:

exp2 isn't in netbsd 5 so varnish fails to compile. The following patches
should work:

{{{

--- configure.ac.orig 2011-10-30 12:53:05.000000000 +0000
+++ configure.ac
@@ -380,6 +380,8 @@ else
ac_cv_func_port_create=no
fi

+AC_CHECK_FUNCS([exp2])
+
AM_MISSING_HAS_RUN
AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6
python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build
Varnish, please install python.])])



--- bin/varnishd/cache_dir_random.c.orig 2011-10-24
07:25:09.000000000 +0000
+++ bin/varnishd/cache_dir_random.c
@@ -62,6 +62,11 @@
#include "vsha256.h"
#include "vend.h"

+#ifndef HAVE_EXP2
+ #define EXP2_32 4294967296
+ #define EXP2_31 2147483648
+#endif
+
/*--------------------------------------------------------------------*/

struct vdi_random_host {
@@ -97,7 +102,11 @@ vdi_random_sha(const char *input, ssize_
SHA256_Init(&ctx);
SHA256_Update(&ctx, input, len);
SHA256_Final(sign, &ctx);
+#ifndef HAVE_EXP2
+ return (vle32dec(sign) / EXP2_32);
+#else
return (vle32dec(sign) / exp2(32));
+#endif
}

/*
@@ -119,11 +128,19 @@ vdi_random_init_seed(const struct vdi_ra
break;
case c_hash:
AN(sp->digest);
+#ifndef HAVE_EXP2
+ retval = vle32dec(sp->digest) / EXP2_32;
+#else
retval = vle32dec(sp->digest) / exp2(32);
+#endif
break;
case c_random:
default:
+#ifndef HAVE_EXP2
+ retval = random() / EXP2_31;
+#else
retval = random() / exp2(31);
+#endif
break;
}
return (retval);
}}}

--

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1046#comment:1>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs


varnish-bugs at varnish-cache

Nov 1, 2011, 2:41 AM

Post #3 of 3 (235 views)
Permalink
Re: #1046: exp2 portability [In reply to]

#1046: exp2 portability
-------------------------+--------------------------------------------------
Reporter: msporleder | Type: defect
Status: closed | Priority: normal
Milestone: | Component: build
Version: 3.0.2 | Severity: normal
Resolution: fixed | Keywords:
-------------------------+--------------------------------------------------
Changes (by Poul-Henning Kamp <phk@…>):

* status: new => closed
* resolution: => fixed


Comment:

(In [f6536dac9a6c9fdda4236e0ad92cfc4cdd6dd34a]) Use scalbn(3) rather than
exp2(3), it should be faster and more portable.

Fixes #1046

--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1046#comment:2>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator

_______________________________________________
varnish-bugs mailing list
varnish-bugs [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-bugs

Varnish bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.