source: mainline/uspace/lib/posix/include/posix/unistd.h@ e3480d5

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since e3480d5 was e3480d5, checked in by Maurizio Lombardi <m.lombardi85@…>, 12 years ago

add lseek() to the posix library, move SEEK_CUR, SEEK_SET and SEEK_END from stdio.h to unistd.h

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*
2 * Copyright (c) 2011 Jiri Zarevucky
3 * Copyright (c) 2011 Petr Koupy
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup libposix
31 * @{
32 */
33/** @file Miscellaneous standard definitions.
34 */
35
36#ifndef POSIX_UNISTD_H_
37#define POSIX_UNISTD_H_
38
39#ifndef __POSIX_DEF__
40#define __POSIX_DEF__(x) x
41#endif
42
43#include "sys/types.h"
44#include "stddef.h"
45
46#define SEEK_SET 0
47#define SEEK_CUR 1
48#define SEEK_END 2
49
50/* Process Termination */
51#define _exit exit
52
53extern char *__POSIX_DEF__(optarg);
54extern int optind, opterr, optopt;
55extern int __POSIX_DEF__(getopt)(int, char * const [], const char *);
56
57/* Environment */
58extern char **__POSIX_DEF__(environ);
59
60/* Login Information */
61extern char *__POSIX_DEF__(getlogin)(void);
62extern int __POSIX_DEF__(getlogin_r)(char *name, size_t namesize);
63
64/* Identifying Terminals */
65extern int __POSIX_DEF__(isatty)(int fd);
66
67/* Working Directory */
68extern char *__POSIX_DEF__(getcwd)(char *buf, size_t size);
69extern int __POSIX_DEF__(chdir)(const char *path);
70
71/* Query Memory Parameters */
72extern int __POSIX_DEF__(getpagesize)(void);
73
74/* Process Identification */
75extern __POSIX_DEF__(pid_t) __POSIX_DEF__(getpid)(void);
76extern __POSIX_DEF__(uid_t) __POSIX_DEF__(getuid)(void);
77extern __POSIX_DEF__(gid_t) __POSIX_DEF__(getgid)(void);
78
79/* File Manipulation */
80extern int __POSIX_DEF__(close)(int fildes);
81extern ssize_t __POSIX_DEF__(read)(int fildes, void *buf, size_t nbyte);
82extern ssize_t __POSIX_DEF__(write)(int fildes, const void *buf, size_t nbyte);
83extern __POSIX_DEF__(off_t) __POSIX_DEF__(lseek)(int fildes,
84 __POSIX_DEF__(off_t) offset, int whence);
85extern int __POSIX_DEF__(fsync)(int fildes);
86extern int __POSIX_DEF__(ftruncate)(int fildes, __POSIX_DEF__(off_t) length);
87extern int __POSIX_DEF__(rmdir)(const char *path);
88extern int __POSIX_DEF__(unlink)(const char *path);
89extern int __POSIX_DEF__(dup)(int fildes);
90extern int __POSIX_DEF__(dup2)(int fildes, int fildes2);
91
92/* Standard Streams */
93#undef STDIN_FILENO
94#define STDIN_FILENO (fileno(stdin))
95#undef STDOUT_FILENO
96#define STDOUT_FILENO (fileno(stdout))
97#undef STDERR_FILENO
98#define STDERR_FILENO (fileno(stderr))
99
100/* File Accessibility */
101#undef F_OK
102#undef X_OK
103#undef W_OK
104#undef R_OK
105#define F_OK 0 /* Test for existence. */
106#define X_OK 1 /* Test for execute permission. */
107#define W_OK 2 /* Test for write permission. */
108#define R_OK 4 /* Test for read permission. */
109extern int __POSIX_DEF__(access)(const char *path, int amode);
110
111/* System Parameters */
112enum {
113 _SC_PHYS_PAGES,
114 _SC_AVPHYS_PAGES,
115 _SC_PAGESIZE,
116 _SC_CLK_TCK
117};
118extern long __POSIX_DEF__(sysconf)(int name);
119
120/* Path Configuration Parameters */
121enum {
122 _PC_2_SYMLINKS,
123 _PC_ALLOC_SIZE_MIN,
124 _PC_ASYNC_IO,
125 _PC_CHOWN_RESTRICTED,
126 _PC_FILESIZEBITS,
127 _PC_LINK_MAX,
128 _PC_MAX_CANON,
129 _PC_MAX_INPUT,
130 _PC_NAME_MAX,
131 _PC_NO_TRUNC,
132 _PC_PATH_MAX,
133 _PC_PIPE_BUF,
134 _PC_PRIO_IO,
135 _PC_REC_INCR_XFER_SIZE,
136 _PC_REC_MIN_XFER_SIZE,
137 _PC_REC_XFER_ALIGN,
138 _PC_SYMLINK_MAX,
139 _PC_SYNC_IO,
140 _PC_VDISABLE
141};
142extern long __POSIX_DEF__(pathconf)(const char *path, int name);
143
144/* Creating a Process */
145extern __POSIX_DEF__(pid_t) __POSIX_DEF__(fork)(void);
146
147/* Executing a File */
148extern int __POSIX_DEF__(execv)(const char *path, char *const argv[]);
149extern int __POSIX_DEF__(execvp)(const char *file, char *const argv[]);
150
151/* Creating a Pipe */
152extern int __POSIX_DEF__(pipe)(int fildes[2]);
153
154/* Issue alarm signal. */
155extern unsigned int __POSIX_DEF__(alarm)(unsigned int);
156
157#endif /* POSIX_UNISTD_H_ */
158
159/** @}
160 */
Note: See TracBrowser for help on using the repository browser.