예제 #1
0
extern "C" int _write(int file, char *ptr, int len)
{
    int BytesNotWritten;
    
    /* Open stdin/stdout/stderr if needed */
    if (MRI_SEMIHOST_STDIO && file < 3)
    {
        return __mriNewlib_SemihostWrite(file, ptr, len);
    }
    else if (!g_StandardHandlesOpened && file < 3)
    {
        __GCC4MBEDOpenStandardHandles();
    }

    /* Call the function in mbed.ar and let it handle the writes */
    BytesNotWritten = _sys_write(file, (const unsigned char*)ptr, len, 0);
    
    /* The mbed version of the function returns bytes not written and newlib wants byte written count */
    if (BytesNotWritten >= 0)
    {
        return len - BytesNotWritten;
    }
    else
    {
        /* In this case it did return an error */
        return BytesNotWritten;
    }
}
예제 #2
0
extern "C" int __wrap__write(int file, char *ptr, int len)
{
    if (MRI_SEMIHOST_STDIO && file < 3)
        return __mriNewlib_SemihostWrite(file, ptr, len);
    return __real__write(file, ptr, len);
}