arch/m68k-amiga: Define the gcc symbol 'start' instead of using .bss
[AROS.git] / compiler / clib / setvbuf.c
blob3408429f9c7fc72f4b4b7a2832c6fb530b3361f2
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function setvbuf().
6 */
8 #include <dos/stdio.h>
9 #include <proto/dos.h>
10 #include <errno.h>
11 #include "__fdesc.h"
13 /*****************************************************************************
15 NAME */
16 #include <stdio.h>
18 int setvbuf (
20 /* SYNOPSIS */
21 FILE *stream,
22 char *buf,
23 int mode,
24 size_t size)
26 /* FUNCTION
28 INPUTS
30 RESULT
32 NOTES
34 EXAMPLE
36 BUGS
38 SEE ALSO
40 INTERNALS
42 ******************************************************************************/
44 fdesc *desc;
46 if (!stream)
48 errno = EFAULT;
49 return EOF;
52 /* Fail if provided buffer is smaller than minimum required by DOS */
53 if (buf && size < 208)
55 errno = EFAULT;
56 return EOF;
59 switch (mode)
61 case _IOFBF: mode = BUF_FULL; break;
62 case _IOLBF: mode = BUF_LINE; break;
63 case _IONBF: mode = BUF_NONE; break;
64 default:
65 errno = EINVAL;
66 return EOF;
69 desc = __getfdesc(stream->fd);
70 if (!desc)
72 errno = EBADF;
73 return EOF;
76 return SetVBuf(desc->fcb->fh, buf, mode, size ? size : -1);
77 } /* setvbuf */