pike.git / src / post_modules / Nettle / hash.cmod

version» Context lines:

pike.git/src/post_modules/Nettle/hash.cmod:1:   /* -*- c -*-   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: hash.cmod,v 1.35 2010/06/21 12:35:35 mast Exp $ + || $Id$   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "threads.h"      /* For this_object() */   #include "object.h"   #include "module_support.h"
pike.git/src/post_modules/Nettle/hash.cmod:121:    const struct nettle_hash *meta = THIS->meta;       if (!meta)    Pike_error("HashInfo not properly initialized.\n");    NO_WIDE_STRING(in);       ctx = (void *)alloca(meta->context_size);    if(!ctx)    SIMPLE_OUT_OF_MEMORY_ERROR("hash", meta->context_size);    +  /* Only thread this block for significant data size */ +  if (in->len > THREADS_ALLOW_THRESHOLD) {    THREADS_ALLOW();    meta->init(ctx);    meta->update(ctx, in->len, (const uint8_t *)in->str);    THREADS_DISALLOW(); -  +  } else { +  meta->init(ctx); +  meta->update(ctx, in->len, (const uint8_t *)in->str); +  }       digest_length = meta->digest_size;    out = begin_shared_string(digest_length);    meta->digest(ctx, digest_length, (uint8_t *)out->str);       pop_n_elems(args);    push_string(end_shared_string(out));    }       /*! @decl string hash(Stdio.File file, void|int bytes)
pike.git/src/post_modules/Nettle/hash.cmod:278:    optflags OPT_SIDE_EFFECT;    {    void *ctx = THIS->ctx;    const struct nettle_hash *meta =    GET_META(Pike_fp->current_object);       if (!ctx || !meta)    Pike_error("HashState not properly initialized.\n");       NO_WIDE_STRING(data); +  +  /* Only thread this block for significant data size */ +  if (data->len > THREADS_ALLOW_THRESHOLD) {    THREADS_ALLOW();    meta->update(ctx, data->len, (const uint8_t *)data->str);    THREADS_DISALLOW(); -  +  } else { +  meta->update(ctx, data->len, (const uint8_t *)data->str); +  }       push_object(this_object());    }       /*! @decl string digest(int|void length)    *!    *! Generates a digests, and resets the hashing contents.    *!    *! @param length    *! If the length argument is provided, the digest is truncated