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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 77de449e was 77de449e, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Workaround for mips32/binutils coastline build

  • Property mode set to 100644
File size: 4.9 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#include <stddef.h>
40#include <sys/types.h>
41
42#define SEEK_SET 0
43#define SEEK_CUR 1
44#define SEEK_END 2
45
46/* Process Termination */
47#define _exit exit
48
49/* Standard Streams */
50#define STDIN_FILENO (fileno(stdin))
51#define STDOUT_FILENO (fileno(stdout))
52#define STDERR_FILENO (fileno(stderr))
53
54#define F_OK 0 /* Test for existence. */
55#define X_OK 1 /* Test for execute permission. */
56#define W_OK 2 /* Test for write permission. */
57#define R_OK 4 /* Test for read permission. */
58
59__C_DECLS_BEGIN;
60
61extern char *optarg;
62extern int optind, opterr, optopt;
63extern int getopt(int, char *const [], const char *);
64
65/* Environment */
66extern char **environ;
67
68/* Sleeping */
69extern unsigned int sleep(unsigned int);
70
71/* Login Information */
72extern char *getlogin(void);
73extern int getlogin_r(char *name, size_t namesize);
74
75/* Identifying Terminals */
76extern int isatty(int fd);
77
78/* Working Directory */
79extern char *getcwd(char *buf, size_t size);
80extern int chdir(const char *path);
81
82/* Query Memory Parameters */
83extern int getpagesize(void);
84
85/* Process Identification */
86extern pid_t getpid(void);
87extern uid_t getuid(void);
88extern gid_t getgid(void);
89
90/* File Manipulation */
91extern int close(int fildes);
92extern ssize_t read(int fildes, void *buf, size_t nbyte);
93extern ssize_t write(int fildes, const void *buf, size_t nbyte);
94extern int fsync(int fildes);
95extern int rmdir(const char *path);
96extern int unlink(const char *path);
97extern int dup(int fildes);
98extern int dup2(int fildes, int fildes2);
99
100#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
101// FIXME: this should just be defined in <sys/types.h>, but for some reason
102// build of coastline binutils on mips32 doesn't see the definition there
103typedef int64_t off64_t;
104
105extern off64_t lseek64(int fildes, off64_t offset, int whence);
106extern int ftruncate64(int fildes, off64_t length);
107#endif
108
109#if _FILE_OFFSET_BITS == 64 && LONG_MAX == INT_MAX
110#ifdef __GNUC__
111extern off_t lseek(int fildes, off_t offset, int whence) __asm__("lseek64");
112extern int ftruncate(int fildes, off_t length) __asm__("ftruncate64");
113#else
114extern off_t lseek64(int fildes, off_t offset, int whence);
115extern int ftruncate64(int fildes, off_t length);
116#define lseek lseek64
117#define ftruncate ftruncate64
118#endif
119#else
120extern off_t lseek(int fildes, off_t offset, int whence);
121extern int ftruncate(int fildes, off_t length);
122#endif
123
124/* File Accessibility */
125extern int access(const char *path, int amode);
126
127/* System Parameters */
128enum {
129 _SC_PHYS_PAGES,
130 _SC_AVPHYS_PAGES,
131 _SC_PAGESIZE,
132 _SC_CLK_TCK
133};
134extern long sysconf(int name);
135
136/* Path Configuration Parameters */
137enum {
138 _PC_2_SYMLINKS,
139 _PC_ALLOC_SIZE_MIN,
140 _PC_ASYNC_IO,
141 _PC_CHOWN_RESTRICTED,
142 _PC_FILESIZEBITS,
143 _PC_LINK_MAX,
144 _PC_MAX_CANON,
145 _PC_MAX_INPUT,
146 _PC_NAME_MAX,
147 _PC_NO_TRUNC,
148 _PC_PATH_MAX,
149 _PC_PIPE_BUF,
150 _PC_PRIO_IO,
151 _PC_REC_INCR_XFER_SIZE,
152 _PC_REC_MIN_XFER_SIZE,
153 _PC_REC_XFER_ALIGN,
154 _PC_SYMLINK_MAX,
155 _PC_SYNC_IO,
156 _PC_VDISABLE
157};
158extern long pathconf(const char *path, int name);
159
160/* Creating a Process */
161extern pid_t fork(void);
162
163/* Executing a File */
164extern int execv(const char *path, char *const argv[]);
165extern int execvp(const char *file, char *const argv[]);
166
167/* Creating a Pipe */
168extern int pipe(int fildes[2]);
169
170/* Issue alarm signal. */
171extern unsigned int alarm(unsigned int);
172
173__C_DECLS_END;
174
175#endif /* POSIX_UNISTD_H_ */
176
177/** @}
178 */
Note: See TracBrowser for help on using the repository browser.