blob: fb5a41f19ed91d8ce3fe6275d8be03d73dd20ef5 [file] [log] [blame]
%%{
/* --COPYRIGHT--,ESD
* Copyright (c) 2008-2019 Texas Instruments Incorporated
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License
* v. 1.0 which accompanies this distribution. The Eclipse Public License is
* available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse
* Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Texas Instruments - initial implementation
* --/COPYRIGHT--*/
%%}
%var SysMin = xdc.module("xdc.runtime.SysMin");
%if (SysMin.bufSize != 0 && SysMin.outputFxn == null) {
#if defined(__ti__)
extern int HOSTwrite(int, const char *, unsigned);
#elif (defined(gnu_targets_arm_STD_) && defined(xdc_target__os_undefined))
extern int _write(int, char *, int);
#define HOSTwrite(x,y,z) _write((int)(x),(char *)(y),(int)(z))
#elif defined(__IAR_SYSTEMS_ICC__)
#include <yfuns.h>
#define HOSTwrite(x,y,z) __write((x),(unsigned char *)(y),(z))
#else
#include <stdio.h>
#endif
/*
* ======== SysMin_output__I ========
* HOSTWrite only writes a max of N chars at a time. The amount it writes
* is returned. This function loops until the entire buffer is written.
* Being a static function allows it to conditionally compile out.
*/
xdc_Void xdc_runtime_SysMin_output__I(xdc_Char *buf, xdc_UInt size)
{
#if defined(__ti__) || (defined(gnu_targets_arm_STD_) && defined(xdc_target__os_undefined)) || defined (__IAR_SYSTEMS_ICC__)
xdc_Int printCount;
while (size != 0) {
printCount = HOSTwrite(1, buf, size);
if ((printCount <= 0) || ((xdc_UInt)printCount > size)) {
break; /* ensure we never get stuck in an infinite loop */
}
size -= printCount;
buf = buf + printCount;
}
#else
fwrite(buf, 1, size, stdout);
#endif
}
%}
%else {
/*
* ======== SysMin_output__I ========
*/
xdc_Void xdc_runtime_SysMin_output__I(xdc_Char *buf, xdc_UInt size)
{
% if (SysMin.bufSize != 0 && SysMin.outputFxn != null) {
% var cname = SysMin.outputFxn.$name;
% cname = cname.replace(/\./g,'_');
`cname`(buf, size);
% }
% else {
/* SysMin.bufSize == 0, so this function does not need to do anything */
% }
}
%} /* bufSize != 0 */