nsprpub/pr/src/misc/prrng.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/src/misc/prrng.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "primpl.h"
    1.10 +
    1.11 +/*
    1.12 + * We were not including <string.h> in optimized builds.  On AIX this
    1.13 + * caused libnspr4.so to export memcpy and some binaries linked with
    1.14 + * libnspr4.so resolved their memcpy references with libnspr4.so.  To
    1.15 + * be backward compatible with old libnspr4.so binaries, we do not
    1.16 + * include <string.h> in optimized builds for AIX.  (bug 200561)
    1.17 + */
    1.18 +#if !(defined(AIX) && !defined(DEBUG))
    1.19 +#include <string.h>
    1.20 +#endif
    1.21 +
    1.22 +PRSize _pr_CopyLowBits( 
    1.23 +    void *dst, 
    1.24 +    PRSize dstlen, 
    1.25 +    void *src, 
    1.26 +    PRSize srclen )
    1.27 +{
    1.28 +    if (srclen <= dstlen) {
    1.29 +    	memcpy(dst, src, srclen);
    1.30 +	    return srclen;
    1.31 +    }
    1.32 +#if defined IS_BIG_ENDIAN
    1.33 +    memcpy(dst, (char*)src + (srclen - dstlen), dstlen);
    1.34 +#else
    1.35 +    memcpy(dst, src, dstlen);
    1.36 +#endif
    1.37 +    return dstlen;
    1.38 +}    
    1.39 +
    1.40 +PR_IMPLEMENT(PRSize) PR_GetRandomNoise( 
    1.41 +    void    *buf,
    1.42 +    PRSize  size
    1.43 +)
    1.44 +{
    1.45 +    return( _PR_MD_GET_RANDOM_NOISE( buf, size ));
    1.46 +} /* end PR_GetRandomNoise() */
    1.47 +/* end prrng.c */

mercurial