mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-03-03 21:45:51 +08:00
2005-10-28 Bob Wilson <bob.wilson@acm.org>
* libc/sys.tex (Stubs): Format examples consistently. Change sbrk example to use "_end" symbol instead of "end". Change write example to use "outbyte" instead of "writechar".
This commit is contained in:
parent
a306ebc97e
commit
a9c15f6feb
@ -1,3 +1,9 @@
|
||||
2005-10-28 Bob Wilson <bob.wilson@acm.org>
|
||||
|
||||
* libc/sys.tex (Stubs): Format examples consistently. Change sbrk
|
||||
example to use "_end" symbol instead of "end". Change write example
|
||||
to use "outbyte" instead of "writechar".
|
||||
|
||||
2005-10-28 Bob Wilson <bob.wilson@acm.org>
|
||||
|
||||
* libc/ctype/ctype.tex: Use hyphens as appropriate, but not otherwise.
|
||||
|
@ -103,7 +103,7 @@ Create a new process. Minimal implementation (for a system without processes):
|
||||
#include <errno.h>
|
||||
#undef errno
|
||||
extern int errno;
|
||||
int fork() @{
|
||||
int fork(void) @{
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
@}
|
||||
@ -129,7 +129,7 @@ conflict with other processes. Minimal implementation, for a system
|
||||
without processes:
|
||||
|
||||
@example
|
||||
int getpid() @{
|
||||
int getpid(void) @{
|
||||
return 1;
|
||||
@}
|
||||
@end example
|
||||
@ -154,7 +154,7 @@ Send a signal. Minimal implementation:
|
||||
extern int errno;
|
||||
int kill(int pid, int sig) @{
|
||||
errno = EINVAL;
|
||||
return(-1);
|
||||
return -1;
|
||||
@}
|
||||
@end example
|
||||
|
||||
@ -202,22 +202,21 @@ int read(int file, char *ptr, int len)@{
|
||||
Increase program data space. As @code{malloc} and related functions
|
||||
depend on this, it is useful to have a working implementation. The
|
||||
following suffices for a standalone system; it exploits the symbol
|
||||
@code{end} automatically defined by the GNU linker.
|
||||
@code{_end} automatically defined by the GNU linker.
|
||||
|
||||
@example
|
||||
@group
|
||||
caddr_t sbrk(int incr) @{
|
||||
extern char end; /* @r{Defined by the linker} */
|
||||
extern char _end; /* @r{Defined by the linker} */
|
||||
static char *heap_end;
|
||||
char *prev_heap_end;
|
||||
|
||||
if (heap_end == 0) @{
|
||||
heap_end = &end;
|
||||
heap_end = &_end;
|
||||
@}
|
||||
prev_heap_end = heap_end;
|
||||
if (heap_end + incr > stack_ptr)
|
||||
@{
|
||||
_write (1, "Heap and stack collision\n", 25);
|
||||
if (heap_end + incr > stack_ptr) @{
|
||||
write (1, "Heap and stack collision\n", 25);
|
||||
abort ();
|
||||
@}
|
||||
|
||||
@ -272,12 +271,12 @@ int wait(int *status) @{
|
||||
@end example
|
||||
|
||||
@item write
|
||||
Write a character to a file. @file{libc} subroutines will use this
|
||||
Write to a file. @file{libc} subroutines will use this
|
||||
system routine for output to all files, @emph{including}
|
||||
@code{stdout}---so if you need to generate any output, for example to a
|
||||
serial port for debugging, you should make your minimal @code{write}
|
||||
capable of doing this. The following minimal implementation is an
|
||||
incomplete example; it relies on a @code{writechar} subroutine (not
|
||||
incomplete example; it relies on a @code{outbyte} subroutine (not
|
||||
shown; typically, you must write this in assembler from examples
|
||||
provided by your hardware manufacturer) to actually perform the output.
|
||||
|
||||
@ -287,7 +286,7 @@ int write(int file, char *ptr, int len)@{
|
||||
int todo;
|
||||
|
||||
for (todo = 0; todo < len; todo++) @{
|
||||
writechar(*ptr++);
|
||||
outbyte (*ptr++);
|
||||
@}
|
||||
return len;
|
||||
@}
|
||||
|
Loading…
x
Reference in New Issue
Block a user