Example #1
0
extern "C" int _read(int file, char *ptr, int len)
{
    int BytesNotRead;
    
    /* Open stdin/stdout/stderr if needed */
    if (MRI_SEMIHOST_STDIO && file < 3)
    {
        return __mriNewlib_SemihostRead(file, ptr, len);
    }
    else if (!g_StandardHandlesOpened && file < 3)
    {
        __GCC4MBEDOpenStandardHandles();
    }

    /* Call the function in mbed.ar and let it handle the read */
    BytesNotRead = _sys_read(file, (unsigned char*)ptr, len, 0);
    
    /* EOF is indicated by setting the most significant bit so mask it off */
    BytesNotRead &= 0x7FFFFFFF;

    /* The mbed version of the function returns bytes not read and newlib wants bytes read count */
    return len - BytesNotRead;
}
Example #2
0
extern "C" int __wrap__read(int file, char *ptr, int len)
{
    if (MRI_SEMIHOST_STDIO && file < 3)
        return __mriNewlib_SemihostRead(file, ptr, len);
     return __real__read(file, ptr, len);
}