Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/tools/testing/selftests/bpf/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 3 kB image not shown  

Quelle  bpf_rand.h

  Sprache: C
 

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __BPF_RAND__
#define __BPF_RAND__

#include <stdint.h>
#include <stdlib.h>
#include <time.h>

static inline uint64_t bpf_rand_mask(uint64_t mask)
{
 return (((uint64_t)(uint32_t)rand()) |
         ((uint64_t)(uint32_t)rand() << 32)) & mask;
}

#define bpf_rand_ux(x, m)   \
static inline uint64_t bpf_rand_u##x(int shift) \
{      \
 return bpf_rand_mask((m)) << shift; \
}

bpf_rand_ux( 8,               0xffULL)
bpf_rand_ux(16,             0xffffULL)
bpf_rand_ux(24,           0xffffffULL)
bpf_rand_ux(32,         0xffffffffULL)
bpf_rand_ux(40,       0xffffffffffULL)
bpf_rand_ux(48,     0xffffffffffffULL)
bpf_rand_ux(56,   0xffffffffffffffULL)
bpf_rand_ux(640xffffffffffffffffULL)

static inline void bpf_semi_rand_init(void)
{
 srand(time(NULL));
}

static inline uint64_t bpf_semi_rand_get(void)
{
 switch (rand() % 39) {
 case  0return 0x000000ff00000000ULL | bpf_rand_u8(0);
 case  1return 0xffffffff00000000ULL | bpf_rand_u16(0);
 case  2return 0x00000000ffff0000ULL | bpf_rand_u16(0);
 case  3return 0x8000000000000000ULL | bpf_rand_u32(0);
 case  4return 0x00000000f0000000ULL | bpf_rand_u32(0);
 case  5return 0x0000000100000000ULL | bpf_rand_u24(0);
 case  6return 0x800ff00000000000ULL | bpf_rand_u32(0);
 case  7return 0x7fffffff00000000ULL | bpf_rand_u32(0);
 case  8return 0xffffffffffffff00ULL ^ bpf_rand_u32(24);
 case  9return 0xffffffffffffff00ULL | bpf_rand_u8(0);
 case 10return 0x0000000010000000ULL | bpf_rand_u32(0);
 case 11return 0xf000000000000000ULL | bpf_rand_u8(0);
 case 12return 0x0000f00000000000ULL | bpf_rand_u8(8);
 case 13return 0x000000000f000000ULL | bpf_rand_u8(16);
 case 14return 0x0000000000000f00ULL | bpf_rand_u8(32);
 case 15return 0x00fff00000000f00ULL | bpf_rand_u8(48);
 case 16return 0x00007fffffffffffULL ^ bpf_rand_u32(1);
 case 17return 0xffff800000000000ULL | bpf_rand_u8(4);
 case 18return 0xffff800000000000ULL | bpf_rand_u8(20);
 case 19return (0xffffffc000000000ULL + 0x80000ULL) | bpf_rand_u32(0);
 case 20return (0xffffffc000000000ULL - 0x04000000ULL) | bpf_rand_u32(0);
 case 21return 0x0000000000000000ULL | bpf_rand_u8(55) | bpf_rand_u32(20);
 case 22return 0xffffffffffffffffULL ^ bpf_rand_u8(3) ^ bpf_rand_u32(40);
 case 23return 0x0000000000000000ULL | bpf_rand_u8(bpf_rand_u8(0) % 64);
 case 24return 0x0000000000000000ULL | bpf_rand_u16(bpf_rand_u8(0) % 64);
 case 25return 0xffffffffffffffffULL ^ bpf_rand_u8(bpf_rand_u8(0) % 64);
 case 26return 0xffffffffffffffffULL ^ bpf_rand_u40(bpf_rand_u8(0) % 64);
 case 27return 0x0000800000000000ULL;
 case 28return 0x8000000000000000ULL;
 case 29return 0x0000000000000000ULL;
 case 30return 0xffffffffffffffffULL;
 case 31return bpf_rand_u16(bpf_rand_u8(0) % 64);
 case 32return bpf_rand_u24(bpf_rand_u8(0) % 64);
 case 33return bpf_rand_u32(bpf_rand_u8(0) % 64);
 case 34return bpf_rand_u40(bpf_rand_u8(0) % 64);
 case 35return bpf_rand_u48(bpf_rand_u8(0) % 64);
 case 36return bpf_rand_u56(bpf_rand_u8(0) % 64);
 case 37return bpf_rand_u64(bpf_rand_u8(0) % 64);
 defaultreturn bpf_rand_u64(0);
 }
}

#endif /* __BPF_RAND__ */

Messung V0.5 in Prozent
C=97 H=93 G=94

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-06-07) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.