Each time storage is reserved for a heap area, eight-byte heap area management data is written from the ending address
(ansi_ucEndAlloc) toward the beginning address. Be careful to avoid rewriting areas specified as heap areas by the
ansi_InitMalloc() function by a stack pointer, etc.
* The ansi_InitMalloc() function is not found in the crt0.o or libstdio.a libraries. Be aware that it must be called
from the user routine before calling malloc() or a similar function. (A heap area cannot be allocated if the
ansi_InitMalloc() function is not called.)
5.4.4
Lower-level Functions
The following three functions (read, write, and _exit) are the lower-level functions called by library functions.
With gcc4, for the write and _exit functions, the debugging implementation is defined within the libg.a library.
With gcc3, the read and write functions are defined in the libstdio.a library. Before these functions can be used, include
libstdio.h in the C source program and call the _init_sys() function.
Functions not defined in libraries must be defined in the user program.
read function
Contents of read function
int read(int fd, char *buf, int nbytes);
Format:
Argument:
int fd;
char *buf;
int nbytes; Number of bytes transferred
Functionality:
This function reads up to nbytes of data from the user-defined input buffer, and stores it in the buffer
indicated by buf.
Returned value: Number of bytes actually read from the input buffer
If the input buffer is empty (EOF) or nbytes = 0, 0 is returned.
If an error occurs, -1 is returned.
Library functions that call the read function:
Direct call:
Indirect call: fgetc, fgets, getchar, gets (calls getc)
write function
Contents of write function
int write(int fd, char *buf, int nbytes);
Format:
Argument:
int fd;
char *buf;
int nbytes; Number of transferred bytes
Functionality:
The data stored in the buffer indicated by buf is written as much as indicated by nbytes to the
user-defined output buffer.
Returned value: Number of bytes actually written to the output buffer
If data is written normally, nbytes is returned.
If a write error occurs, a value other than nbytes is returned.
Library function that calls the write function:
Direct call:
Indirect call:
S5U1C17001C Manual
(Rev. 1.0)
File descriptor denoting input
When called from a library function, 0 (stdin) is passed.
Pointer to the buffer that stores input data
fread, getc, _doscan (_doscan is a scanf-series internal function)
scanf, fscanf, sscanf (calls _doscan)
File descriptor denoting output
When called from a library function, 1 (stdout) or 2 (stderr) is passed.
Pointer to the buffer that stores output data
fwrite, putc, _doprint (_doprint is printf-series internal function)
fputc, fputs, putchar, puts (calls putcc)
printf, fprintf, sprintf, vprintf, vfprintf (calls _doprint)
perror (calls fprintf)
Seiko Epson Corporation
5 Library
5-19
Need help?
Do you have a question about the S5U1C17001C and is the answer not in the manual?