From 7029dd7e4c65ad40ea71bc385e4415fb4d1a4839 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Sat, 9 Mar 2019 20:01:58 +0100 Subject: demo for volatile --- test/monniaux/volatile/Makefile | 18 ++++++++++++++++++ test/monniaux/volatile/volatile.c | 19 ++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 test/monniaux/volatile/Makefile (limited to 'test/monniaux/volatile') diff --git a/test/monniaux/volatile/Makefile b/test/monniaux/volatile/Makefile new file mode 100644 index 00000000..59c8b459 --- /dev/null +++ b/test/monniaux/volatile/Makefile @@ -0,0 +1,18 @@ +all: volatile.ccomp.k1c volatile.gcc.k1c + +volatile.ccomp.k1c : volatile.ccomp.k1c.s + k1-cos-gcc $< -o $@ + +volatile.gcc.k1c : volatile.gcc.k1c.s + k1-cos-gcc $< -o $@ + +volatile.ccomp.k1c.s : volatile.c + ../../../ccomp -Dvolatile= -O2 -Wall -Wno-c11-extensions -S $< -o $@ + +volatile.gcc.k1c.s : volatile.c + k1-cos-gcc -O2 -Wall -Werror=implicit -std=gnu99 -S $< -o $@ + +clean: + -rm -f *.k1c *.s + +.PHONY: clean diff --git a/test/monniaux/volatile/volatile.c b/test/monniaux/volatile/volatile.c index 75f8ce3b..442ccff4 100644 --- a/test/monniaux/volatile/volatile.c +++ b/test/monniaux/volatile/volatile.c @@ -1,32 +1,33 @@ -#include #include #include -#define VOLATILE volatile +int pthread_create(pthread_t *thread, const pthread_attr_t *attr, + void *(*start_routine) (void *), void *arg); +int pthread_join(pthread_t thread, void **retval); typedef unsigned data; -static data powm(data x, unsigned e, data m) { +static inline data powM(data x, unsigned e) { data y = 1; for(unsigned i=0; i