diff --git a/repos/libports/include/pcg-c/genode_inttypes.h b/repos/libports/include/pcg-c/genode_inttypes.h new file mode 100644 index 000000000..aefbbcb61 --- /dev/null +++ b/repos/libports/include/pcg-c/genode_inttypes.h @@ -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 + +#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 diff --git a/repos/libports/lib/import/import-libpcg_random.mk b/repos/libports/lib/import/import-libpcg_random.mk new file mode 100644 index 000000000..dec2f3aa1 --- /dev/null +++ b/repos/libports/lib/import/import-libpcg_random.mk @@ -0,0 +1,3 @@ +INC_DIR += \ + $(call select_from_ports,pcg-c)/include/pcg-c \ + $(call select_from_repositories,/include/pcg-c) \ diff --git a/repos/libports/lib/mk/libpcg_random.mk b/repos/libports/lib/mk/libpcg_random.mk new file mode 100644 index 000000000..b2ff09fd3 --- /dev/null +++ b/repos/libports/lib/mk/libpcg_random.mk @@ -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) diff --git a/repos/libports/ports/pcg-c.hash b/repos/libports/ports/pcg-c.hash new file mode 100644 index 000000000..cd11dcd58 --- /dev/null +++ b/repos/libports/ports/pcg-c.hash @@ -0,0 +1 @@ +f2d29f6c5f6505f8b13f8c5b129abb3496db5885 diff --git a/repos/libports/ports/pcg-c.port b/repos/libports/ports/pcg-c.port new file mode 100644 index 000000000..cc3e8b8b2 --- /dev/null +++ b/repos/libports/ports/pcg-c.port @@ -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///' $< > $@ diff --git a/repos/libports/run/pcg32.run b/repos/libports/run/pcg32.run new file mode 100644 index 000000000..a7b162549 --- /dev/null +++ b/repos/libports/run/pcg32.run @@ -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 { + + + + + + + + + + + + + + + + + + + + + + + + + +} + +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." diff --git a/repos/libports/src/test/pcg32/target.mk b/repos/libports/src/test/pcg32/target.mk new file mode 100644 index 000000000..5ae723ed1 --- /dev/null +++ b/repos/libports/src/test/pcg32/target.mk @@ -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/$@