Split the common C99/C++ support code out into a separate header.
Or, rather, add a new CIF-specific header, so tock_support.h is now the common code and each of the backends has its own. This means some of the conditional stuff can go away.
This commit is contained in:
parent
bb419d28b7
commit
50967cba95
|
@ -169,6 +169,7 @@ bin_PROGRAMS = tock
|
|||
noinst_PROGRAMS = tocktest GenTagAST GenOrdAST
|
||||
|
||||
pkginclude_HEADERS = support/tock_support.h
|
||||
pkginclude_HEADERS += support/tock_support_cif.h
|
||||
pkginclude_HEADERS += support/tock_support_cppcsp.h
|
||||
|
||||
clean-local:
|
||||
|
|
|
@ -155,7 +155,7 @@ cgenTLPChannel TLPError = tell ["err"]
|
|||
|
||||
cgenTopLevel :: A.AST -> CGen ()
|
||||
cgenTopLevel s
|
||||
= do tell ["#include <tock_support.h>\n"]
|
||||
= do tell ["#include <tock_support_cif.h>\n"]
|
||||
cs <- get
|
||||
(tlpName, chans) <- tlpInterface
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* C99 support code for Tock programs
|
||||
* C99/C++ common support code for Tock programs
|
||||
* Copyright (C) 2007, 2008 University of Kent
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
|
@ -27,10 +27,6 @@
|
|||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifndef BACKEND_CPPCSP
|
||||
#include <cif.h>
|
||||
#endif
|
||||
|
||||
//{{{ mostneg/mostpos
|
||||
#define occam_mostneg_bool false
|
||||
#define occam_mostpos_bool true
|
||||
|
@ -61,24 +57,7 @@
|
|||
#endif
|
||||
//}}}
|
||||
|
||||
//{{{ channel array initialisation
|
||||
static inline void tock_init_chan_array (Channel *, Channel **, int) occam_unused;
|
||||
static inline void tock_init_chan_array (Channel *pointTo, Channel **pointFrom, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
pointFrom[i] = &(pointTo[i]);
|
||||
}
|
||||
}
|
||||
//}}}
|
||||
|
||||
//{{{ runtime check functions
|
||||
#ifndef BACKEND_CPPCSP
|
||||
#define occam_stop(pos, nargs, format, args...) \
|
||||
do { \
|
||||
ExternalCallN (fprintf, 3 + nargs, stderr, "Program stopped at %s: " format "\n", pos, ##args); \
|
||||
SetErr (); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
static inline int occam_check_slice (int, int, int, const char *) occam_unused;
|
||||
static inline int occam_check_slice (int start, int count, int limit, const char *pos) {
|
||||
int end = start + count;
|
||||
|
|
45
support/tock_support_cif.h
Normal file
45
support/tock_support_cif.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* CIF support code for Tock programs
|
||||
* Copyright (C) 2008 University of Kent
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOCK_SUPPORT_CIF_H
|
||||
#define TOCK_SUPPORT_CIF_H
|
||||
|
||||
#include <cif.h>
|
||||
|
||||
//{{{ occam_stop
|
||||
#define occam_stop(pos, nargs, format, args...) \
|
||||
do { \
|
||||
ExternalCallN (fprintf, 3 + nargs, stderr, \
|
||||
"Program stopped at %s: " format "\n", \
|
||||
pos, ##args); \
|
||||
SetErr (); \
|
||||
} while (0)
|
||||
//}}}
|
||||
|
||||
#include <tock_support.h>
|
||||
|
||||
//{{{ channel array initialisation
|
||||
static inline void tock_init_chan_array (Channel *, Channel **, int) occam_unused;
|
||||
static inline void tock_init_chan_array (Channel *pointTo, Channel **pointFrom, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
pointFrom[i] = &(pointTo[i]);
|
||||
}
|
||||
}
|
||||
//}}}
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* C++ support code for Tock programs
|
||||
* C++CSP support code for Tock programs
|
||||
* Copyright (C) 2007, 2008 University of Kent
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it
|
||||
|
@ -37,10 +37,7 @@ public:
|
|||
throw StopException(""); \
|
||||
} while (0)
|
||||
|
||||
#define BACKEND_CPPCSP
|
||||
#define Channel int
|
||||
|
||||
#include "tock_support.h"
|
||||
#include <tock_support.h>
|
||||
|
||||
#include <cppcsp/cppcsp.h>
|
||||
#include <cppcsp/common/basic.h>
|
||||
|
|
Loading…
Reference in New Issue
Block a user