|
|
1.1 root 1:
2: Standard C library for the SLOF firmware project
3: ================================================
4:
5: To use this library, link your target against the "libc.a" archive.
6:
7: However, there are some prerequisites before you can use certain parts of the
8: library:
9:
10: 1) If you want to use malloc() and the like, you have to supply an implemen-
11: tation of sbrk() in your own code. malloc() uses sbrk() to get new, free
12: memory regions.
13:
14: Prototype: void *sbrk(int incr);
15: Description: sbrk() increments the available data space by incr bytes and
16: returns a pointer to the start of the new area.
17:
18: See the man-page of sbrk for details about this function.
19:
20: 2) Before you can use the stdio output functions like printf(), puts() and the
21: like, you have to provide a standard write() function in your code.
22: printf() and the like use write() to print out the strings to the standard
23: output.
24:
25: Prototype: ssize_t write(int fd, const void *buf, size_t cnt);
26: Description: Write cnt byte from the buffer buf to the stream associated
27: with the file descriptor fd.
28:
29: The stdio functions will print their output to the stdout channel which is
30: assigned with the file descriptor 1 by default. Note that the stdio
31: functions will not use open() before calling write(), so if the stdout
32: cannel needs to be opened first, you should do that in your start-up code
33: before using the libc functions for the first time.
34:
35: 3) Before you can use the stdio input functions like scanf() and the
36: like, you have to provide a standard read() function in your code.
37: scanf() and the like use read() to get the characters from the standard
38: input.
39:
40: Prototype: ssize_t read(int fd, void *buf, size_t cnt);
41: Description: Read cnt byte from the stream associated with the file
42: descriptor fd and put them into the buffer buf.
43:
44: The stdio functions will get their input from the stdin channel which is
45: assigned with the file descriptor 0 by default. Note that the stdio
46: functions will not use open() before calling read(), so if the stdin
47: cannel needs to be opened first, you should do that in your start-up code
48: before using the libc functions for the first time.
49:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.