From fae0d6d6a2c8a6545d244a51efa6452576d399f3 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 23 Mar 2009 15:46:24 +0000 Subject: [PATCH] Made intrinsic PROCs take the workspace as a parameter, and turned . to _ in their names (and implemented the RESIZE.MOBILE.ARRAY.1D intrinsic) --- backends/GenerateC.hs | 2 +- support/tock_support.h | 16 ++++++++-------- support/tock_support_cif.h | 9 +++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/backends/GenerateC.hs b/backends/GenerateC.hs index ad0cd6b..d9c5efd 100644 --- a/backends/GenerateC.hs +++ b/backends/GenerateC.hs @@ -1944,7 +1944,7 @@ cgenIntrinsicProc :: Meta -> String -> [A.Actual] -> CGen () cgenIntrinsicProc m "ASSERT" [A.ActualExpression e] = call genAssert m e cgenIntrinsicProc _ "RESCHEDULE" [] = call genReschedule cgenIntrinsicProc m s as = case lookup s intrinsicProcs of - Just amtns -> do tell ["occam_", s, "("] + Just amtns -> do tell ["occam_", [if c == '.' then '_' else c | c <- s], "(wptr,"] seqComma [call genActual (A.Formal am t (A.Name emptyMeta n)) a | ((am, t, n), a) <- zip amtns as] tell [");"] diff --git a/support/tock_support.h b/support/tock_support.h index 901fb8e..bd5433a 100644 --- a/support/tock_support.h +++ b/support/tock_support.h @@ -303,14 +303,14 @@ static inline int occam_check_retype (int src, int dest, const char *pos) { } #define MAKE_STRINGTO(type, occname, flag) \ - static inline void occam_STRINGTO##occname(BOOL*, type*, const unsigned char*) occam_unused; \ - static inline void occam_STRINGTO##occname(BOOL* error, type* n, const unsigned char* string) { \ + static inline void occam_STRINGTO##occname(Workspace, BOOL*, type*, const unsigned char*) occam_unused; \ + static inline void occam_STRINGTO##occname(Workspace wptr, BOOL* error, type* n, const unsigned char* string) { \ *error = 1 != sscanf((const char*)string, flag, n); \ } #define MAKE_STRINGTO_SMALL(type, occname, flag) \ - static inline void occam_STRINGTO##occname(BOOL*, type*, const unsigned char*) occam_unused; \ - static inline void occam_STRINGTO##occname(BOOL* error, type* n, const unsigned char* string) { \ + static inline void occam_STRINGTO##occname(Workspace, BOOL*, type*, const unsigned char*) occam_unused; \ + static inline void occam_STRINGTO##occname(Workspace wptr, BOOL* error, type* n, const unsigned char* string) { \ int t; \ *error = 1 != sscanf((const char*)string, flag, &t) || (int)(type)t != t; \ *n = (type)t; \ @@ -322,8 +322,8 @@ static inline int occam_check_retype (int src, int dest, const char *pos) { #define MAKE_STRINGTO_32 MAKE_STRINGTO #define MAKE_STRINGTO_64 MAKE_STRINGTO -static inline void occam_BOOLTOSTRING(INT*, unsigned char*, const BOOL) occam_unused; -static inline void occam_BOOLTOSTRING(INT* len, unsigned char* str, const BOOL b) { +static inline void occam_BOOLTOSTRING(Workspace, INT*, unsigned char*, const BOOL) occam_unused; +static inline void occam_BOOLTOSTRING(Workspace wptr, INT* len, unsigned char* str, const BOOL b) { if (b) { memcpy(str,"TRUE",4*sizeof(char)); *len = 4; @@ -333,8 +333,8 @@ static inline void occam_BOOLTOSTRING(INT* len, unsigned char* str, const BOOL b } } -static inline void occam_STRINGTOBOOL(BOOL*, BOOL*, const unsigned char*) occam_unused; -static inline void occam_STRINGTOBOOL(BOOL* error, BOOL* b, const unsigned char* str) { +static inline void occam_STRINGTOBOOL(Workspace, BOOL*, BOOL*, const unsigned char*) occam_unused; +static inline void occam_STRINGTOBOOL(Workspace wptr, BOOL* error, BOOL* b, const unsigned char* str) { if (memcmp("TRUE", str, 4*sizeof(char)) == 0) { *b = true; *error = false; diff --git a/support/tock_support_cif.h b/support/tock_support_cif.h index 8d16b69..7410019 100644 --- a/support/tock_support_cif.h +++ b/support/tock_support_cif.h @@ -49,6 +49,15 @@ static inline void tock_init_chan_array (Channel *pointTo, Channel **pointFrom, } //}}} +//{{{ mobile intrinsics +static inline void occam_RESIZE_MOBILE_ARRAY_1D (Workspace wptr, mt_array_t ** pptr, const int count) occam_unused; +static inline void occam_RESIZE_MOBILE_ARRAY_1D (Workspace wptr, mt_array_t ** pptr, const int count) { + *pptr = MTResize1D (wptr, *pptr, count); + (*pptr)->dimensions[0] = count; +} + +//}}} + //{{{ top-level process interface static void tock_tlp_input_bcall (FILE *in, int *ch) occam_unused; static void tock_tlp_input_bcall (FILE *in, int *ch) {