4.10.6. _sys_write()

Writes the contents of a buffer to a file previously opened with _sys_open().

Syntax

int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode);

Implementation

The mode parameter isa bitmap describing the state of the file connected to fh, whether it is a binary file, and how it is buffered. The mode bits might be important if the file is connected to a terminal device because they specify whether or not the device is to be used raw (for example, whether the terminal input must be echoed). See the _IOxxx constants in stdio.h for definitions of user-accessible mode bits.

The default semihosting implementation of _sys_write() does not pass the mode parameter, because it is not required by the SYS_WRITE (0x05) semihosting SWI. If you are retargeting the C library, and you require the mode parameter, you must reimplement sys_io.o.

Returns

The return value is either:

  • a positive number representing the number of characters not written (so any nonzero return value denotes a failure of some sort)

  • a negative number indicating an error.

Copyright © 1999-2001 ARM Limited. All rights reserved.ARM DUI 0067D
Non-Confidential