tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

prrng.c (1184B)


      1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #include "primpl.h"
      7 
      8 /*
      9 * We were not including <string.h> in optimized builds.  On AIX this
     10 * caused libnspr4.so to export memcpy and some binaries linked with
     11 * libnspr4.so resolved their memcpy references with libnspr4.so.  To
     12 * be backward compatible with old libnspr4.so binaries, we do not
     13 * include <string.h> in optimized builds for AIX.  (bug 200561)
     14 */
     15 #if !(defined(AIX) && !defined(DEBUG))
     16 #  include <string.h>
     17 #endif
     18 
     19 PRSize _pr_CopyLowBits(void* dst, PRSize dstlen, void* src, PRSize srclen) {
     20  if (srclen <= dstlen) {
     21    memcpy(dst, src, srclen);
     22    return srclen;
     23  }
     24 #if defined IS_BIG_ENDIAN
     25  memcpy(dst, (char*)src + (srclen - dstlen), dstlen);
     26 #else
     27  memcpy(dst, src, dstlen);
     28 #endif
     29  return dstlen;
     30 }
     31 
     32 PR_IMPLEMENT(PRSize) PR_GetRandomNoise(void* buf, PRSize size) {
     33  return (_PR_MD_GET_RANDOM_NOISE(buf, size));
     34 } /* end PR_GetRandomNoise() */
     35 /* end prrng.c */