diff --git a/Demo_ContextParams/cyclic_function/cyclic_function.c b/Demo_ContextParams/cyclic_function/cyclic_function.c index e28b11749894e829873dcd878fdbfe98a023128e..fb2c1c91ce51c2db47901f12f2e9da7ed61f3ef3 100644 --- a/Demo_ContextParams/cyclic_function/cyclic_function.c +++ b/Demo_ContextParams/cyclic_function/cyclic_function.c @@ -2,14 +2,54 @@ #include "cyclic_function.h" -void cyclic_function_startup() +#include + +#ifdef REPORT_MALLOC +#include +#endif + +#include "cyclic_function.h" +#include + +void cyclic_function_startup() { - /* Write your initialization code here, - but do not make any call to a required interface. */ + printf ("[cyclic function] startup done\n"); } void cyclic_function_PI_cyclic_activation() { - /* Write your code here! */ + static asn1SccT_INTEGER i=0, j=0; + asn1SccT_INTEGER result=0; + asn1SccT_SEQUENCE seq; + + seq.x=i; + seq.y=j; + +#if WORD_SIZE==8 + printf("cycle: input i=%lld, j=%lld\n", i, j); +#else + printf("cycle: input i=%ld, j=%ld\n", i, j); +#endif + cyclic_function_RI_compute_data(&seq, &result); + +#if WORD_SIZE==8 + printf(" result of computation: %lld\n", result); +#else + printf(" result of computation: %ld\n", result); +#endif + + i++; + j++; +#ifdef REPORT_MALLOC + printf("Heap used so far:\n"); + printf("total space allocated from system: %d\n", mallinfo().arena); + printf("total allocated space: %d\n", mallinfo().uordblks); + printf("total non-inuse space: %d\n", mallinfo().fordblks); +#endif + +#ifdef COVERAGE + __gcov_flush(); +#endif } + diff --git a/Demo_ContextParams/passive_function/passive_function.c b/Demo_ContextParams/passive_function/passive_function.c index 6dc381fa6b1338421da480a78230719f99a908c1..2f365ebc4c5399ccace27d21c27cbd659afc4e30 100644 --- a/Demo_ContextParams/passive_function/passive_function.c +++ b/Demo_ContextParams/passive_function/passive_function.c @@ -1,19 +1,28 @@ /* User code: This file will not be overwritten by TASTE. */ -#include "passive_function.h" +/* Functions to be filled by the user (never overwritten by buildsupport tool) */ -/* Function static data is declared in this file : */ +#include "passive_function.h" #include "Context-passive-function.h" +#include -void passive_function_startup() +void passive_function_startup() { - /* Write your initialization code here, - but do not make any call to a required interface. */ + printf ("[passive_function] startup done\n"); } -void passive_function_PI_compute_data(const asn1SccT_SEQUENCE *IN_my_in, - asn1SccT_INTEGER *OUT_result) +void passive_function_PI_compute_data(const asn1SccT_SEQUENCE *IN_my_in, asn1SccT_INTEGER *OUT_result) { - /* Write your code here! */ + *OUT_result = IN_my_in->x + IN_my_in->y; + + // passive_function_ctxt.test1 = *OUT_result; + + /* test1 is a context parameter */ + // printf("test1 = %lld\n", passive_function_ctxt.test1); + printf("test1 = %lld\n", *OUT_result); + + if (*OUT_result > 255) *OUT_result = 255; + } +