OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / stdio / _cs_funcs.c
1 /* Copyright (C) 2004-2005 Manuel Novoa III    <mjn3@codepoet.org>
2  *
3  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
4  *
5  * Dedicated to Toni.  See uClibc/DEDICATION.mjn3 for details.
6  */
7
8 #include "_stdio.h"
9
10 libc_hidden_proto(read)
11 libc_hidden_proto(write)
12 libc_hidden_proto(close)
13 #ifdef __UCLIBC_HAS_LFS__
14 libc_hidden_proto(lseek64)
15 #else
16 libc_hidden_proto(lseek)
17 #endif
18
19 /**********************************************************************/
20 #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
21 /**********************************************************************/
22
23 ssize_t attribute_hidden _cs_read(void *cookie, char *buf, size_t bufsize)
24 {
25         return read(*((int *) cookie), buf, bufsize);
26 }
27
28 /**********************************************************************/
29
30 ssize_t attribute_hidden _cs_write(void *cookie, const char *buf, size_t bufsize)
31 {
32         return write(*((int *) cookie), (char *) buf, bufsize);
33 }
34
35 /**********************************************************************/
36
37 int attribute_hidden _cs_seek(void *cookie, register __offmax_t *pos, int whence)
38 {
39         __offmax_t res;
40
41 #ifdef __UCLIBC_HAS_LFS__
42         res = lseek64(*((int *) cookie), *pos, whence);
43 #else
44         res = lseek(*((int *) cookie), *pos, whence);
45 #endif
46
47         return (res >= 0) ? ((*pos = res), 0) : ((int) res);
48 }
49
50 /**********************************************************************/
51
52 int attribute_hidden _cs_close(void *cookie)
53 {
54         return close(*((int *) cookie));
55 }
56
57 /**********************************************************************/
58 #else
59 /**********************************************************************/
60
61 int attribute_hidden __stdio_seek(FILE *stream, register __offmax_t *pos, int whence)
62 {
63         __offmax_t res;
64
65 #ifdef __UCLIBC_HAS_LFS__
66         res = lseek64(stream->__filedes, *pos, whence);
67 #else
68         res = lseek(stream->__filedes, *pos, whence);
69 #endif
70
71         return (res >= 0) ? ((*pos = res), 0) : ((int) res);
72 }
73
74 /**********************************************************************/
75 #endif
76 /**********************************************************************/