mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-02 01:08:13 +00:00
port of PCG random number generator library
http://www.pcg-random.org/ http://www.pcg-random.org/using-pcg-c.html Ref #2477 Fix #2499
This commit is contained in:
parent
1fce8d0d74
commit
2c4f0e5505
44
repos/libports/include/pcg-c/genode_inttypes.h
Normal file
44
repos/libports/include/pcg-c/genode_inttypes.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* \brief Integer definitons for PCG
|
||||
* \author Emery Hemingway
|
||||
* \date 2017-08-18
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef __INCLUDE__PCG_C__GENODE_INTTYPES_H_
|
||||
#define __INCLUDE__PCG_C__GENODE_INTTYPES_H_
|
||||
|
||||
#include <base/fixed_stdint.h>
|
||||
|
||||
#ifndef _UINT8_T_DECLARED
|
||||
typedef genode_uint8_t uint8_t;
|
||||
#define _UINT8_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef _UINT16_T_DECLARED
|
||||
typedef genode_uint16_t uint16_t;
|
||||
#define _UINT16_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef _UINT32_T_DECLARED
|
||||
typedef genode_uint32_t uint32_t;
|
||||
#define _UINT32_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef _UINT64_T_DECLARED
|
||||
typedef genode_uint64_t uint64_t;
|
||||
#define _UINT64_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef _INTPTR_T_DECLARED
|
||||
typedef unsigned long intptr_t;
|
||||
#define _INTPTR_T_DECLARED
|
||||
#endif
|
||||
|
||||
#endif
|
3
repos/libports/lib/import/import-libpcg_random.mk
Normal file
3
repos/libports/lib/import/import-libpcg_random.mk
Normal file
@ -0,0 +1,3 @@
|
||||
INC_DIR += \
|
||||
$(call select_from_ports,pcg-c)/include/pcg-c \
|
||||
$(call select_from_repositories,/include/pcg-c) \
|
18
repos/libports/lib/mk/libpcg_random.mk
Normal file
18
repos/libports/lib/mk/libpcg_random.mk
Normal file
@ -0,0 +1,18 @@
|
||||
include $(REP_DIR)/lib/import/import-libpcg_random.mk
|
||||
PCG_SRC_DIR = $(call select_from_ports,pcg-c)/src/lib/pcg-c/src
|
||||
|
||||
CC_OPT += -std=c99
|
||||
|
||||
pcg_srcs = $(notdir $(wildcard $(PCG_SRC_DIR)/*-$(1).c))
|
||||
|
||||
SRC_C += $(call pcg_srcs,8)
|
||||
SRC_C += $(call pcg_srcs,16)
|
||||
SRC_C += $(call pcg_srcs,32)
|
||||
SRC_C += $(call pcg_srcs,64)
|
||||
|
||||
# 128bit state generators only available on 64bit platforms
|
||||
ifeq ($(filter-out $(SPECS),64bit),)
|
||||
SRC_C += $(call pcg_srcs,128)
|
||||
endif
|
||||
|
||||
vpath %.c $(PCG_SRC_DIR)
|
1
repos/libports/ports/pcg-c.hash
Normal file
1
repos/libports/ports/pcg-c.hash
Normal file
@ -0,0 +1 @@
|
||||
f2d29f6c5f6505f8b13f8c5b129abb3496db5885
|
16
repos/libports/ports/pcg-c.port
Normal file
16
repos/libports/ports/pcg-c.port
Normal file
@ -0,0 +1,16 @@
|
||||
LICENSE = Apache
|
||||
VERSION = 0.94
|
||||
DOWNLOADS = pcg-c.archive
|
||||
|
||||
OWNER = imneme
|
||||
REPO = pcg-c
|
||||
REV = 03a84f9db5782a3f5a66185836f3db73c832251a
|
||||
URL(pcg-c) := https://github.com/$(OWNER)/$(REPO)/archive/$(REV).tar.gz
|
||||
SHA(pcg-c) := 4137d821a99fb8b4b5b0ca2285d14ec071305bd2
|
||||
DIR(pcg-c) := src/lib/pcg-c
|
||||
|
||||
_dirs: include/pcg-c/pcg_variants.h
|
||||
|
||||
include/pcg-c/pcg_variants.h: src/lib/pcg-c/include/pcg_variants.h
|
||||
$(VERBOSE)mkdir -p include/pcg-c
|
||||
$(VERBOSE)sed 's/<inttypes.h>/<genode_inttypes.h>/' $< > $@
|
59
repos/libports/run/pcg32.run
Normal file
59
repos/libports/run/pcg32.run
Normal file
@ -0,0 +1,59 @@
|
||||
#
|
||||
# \brief Test of the PCG32 library
|
||||
# \author Emery Hemingway
|
||||
# \date 2017-08-23
|
||||
#
|
||||
|
||||
|
||||
build "core init test/pcg32"
|
||||
|
||||
create_boot_directory
|
||||
|
||||
install_config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
<default caps="200"/>
|
||||
<start name="test-pcg32">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<config>
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
</vfs>
|
||||
<libc stdout="/dev/log"/>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
build_boot_image {
|
||||
core init test-pcg32
|
||||
ld.lib.so libc.lib.so libm.lib.so posix.lib.so
|
||||
}
|
||||
|
||||
append qemu_args " -nographic "
|
||||
|
||||
run_genode_until "child .* exited with exit value 0.*\n" 10
|
||||
|
||||
set fd [open "bin/test-pcg32.out"]
|
||||
set expected [read $fd]
|
||||
close $fd
|
||||
|
||||
grep_output {init -> test-pcg32}
|
||||
|
||||
unify_output {\[init -> test-pcg32\] } {}
|
||||
|
||||
compare_output_to $expected
|
||||
|
||||
puts "\nGlobal PCG32 output verified."
|
17
repos/libports/src/test/pcg32/target.mk
Normal file
17
repos/libports/src/test/pcg32/target.mk
Normal file
@ -0,0 +1,17 @@
|
||||
TARGET = test-pcg32
|
||||
LIBS = libpcg_random posix
|
||||
|
||||
PCG_SRC_DIR = $(call select_from_ports,pcg-c)/src/lib/pcg-c
|
||||
|
||||
INC_DIR += $(PCG_SRC_DIR)/extras
|
||||
SRC_C = check-pcg32-global.c entropy.c
|
||||
|
||||
vpath %.c $(PCG_SRC_DIR)/test-high
|
||||
vpath %.c $(PCG_SRC_DIR)/extras
|
||||
|
||||
.PHONY: test-pcg32.out
|
||||
|
||||
$(TARGET): test-pcg32.out
|
||||
|
||||
test-pcg32.out: $(PCG_SRC_DIR)/test-high/expected/check-pcg32-global.out
|
||||
$(VERBOSE)cp $< $(PWD)/bin/$@
|
Loading…
x
Reference in New Issue
Block a user