[Varnish] #1046: exp2 portability

Varnish varnish-bugs at varnish-cache.org
Sun Oct 30 14:11:15 CET 2011


#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




More information about the varnish-bugs mailing list