Tizen RT Libs&Environment  v1.0 D5
unistd.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * include/unistd.h
20  *
21  * Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ****************************************************************************/
60 
63 #ifndef __INCLUDE_UNISTD_H
64 #define __INCLUDE_UNISTD_H
65 
66 /****************************************************************************
67  * Included Files
68  ****************************************************************************/
69 
70 #include <sys/types.h>
71 #include <tinyara/compiler.h>
72 
73 /****************************************************************************
74  * Pre-processor Definitions
75  ****************************************************************************/
76 
77 /* The number of functions that may be registered to be called
78  * at program exit.
79  */
80 
81 #define ATEXIT_MAX 1
82 
83 /* Values for seeking */
84 
85 #define SEEK_SET 0 /* From the start of the file */
86 #define SEEK_CUR 1 /* From the current file offset */
87 #define SEEK_END 2 /* From the end of the file */
88 
89 /* Bit values for the second argument to access */
90 
91 #define F_OK 0 /* Test existence */
92 #define R_OK 1 /* Test read permission */
93 #define W_OK 2 /* Test write permission */
94 #define X_OK 4 /* Test execute permission */
95 
96 /* POSIX feature set macros */
97 
98 #define POSIX_VERSION
99 #undef _POSIX_SAVED_IDS
100 #undef _POSIX_JOB_CONTROL
101 #define _POSIX_REALTIME_SIGNALS 1
102 #define _POSIX_MESSAGE_PASSING 1
103 #undef _POSIX_MAPPED_FILES
104 #undef _POSIX_SHARED_MEMORY_OBJECTS
105 #define _POSIX_PRIORITY_SCHEDULING 1
106 #define _POSIX_TIMERS 1
107 #undef _POSIX_MEMLOCK
108 #undef _POSIX_MEMLOCK_RANGE
109 #undef _POSIX_FSYNC
110 #define _POSIX_SYNCHRONIZED_IO 1
111 #undef _POSIX_ASYNCHRONOUS_IO
112 #undef _POSIX_PRIORITIZED_IO
113 
114 /* Execution time constants (not supported) */
115 
116 #undef _POSIX_CHOWN_RESTRICTED
117 #undef _POSIX_NO_TRUNC
118 #undef _POSIX_VDISABLE
119 
120 #define _POSIX_SYNC_IO 1
121 #undef _POSIX_ASYNC_IO
122 #undef _POSIX_PRIO_IO
123 
124 #define fdatasync(f) fsync(f)
125 
126 /****************************************************************************
127  * Global Variables
128  ****************************************************************************/
129 
130 #undef EXTERN
131 #if defined(__cplusplus)
132 #define EXTERN extern "C"
133 extern "C" {
134 #else
135 #define EXTERN extern
136 #endif
137 
138 /* Used by getopt (obviously NOT thread safe!). These variables cannot be
139  * accessed directly by an external NXFLAT module. In that case, accessor
140  * functions must be used.
141  */
142 
143 #ifndef __NXFLAT__
144 EXTERN FAR char *optarg; /* Optional argument following option */
145 EXTERN int optind; /* Index into argv */
146 EXTERN int optopt; /* unrecognized option character */
147 #else
148 #define optarg (*(getoptargp()))
149 #define optind (*(getoptindp()))
150 #define optopt (*(getoptoptp()))
151 #endif
152 
153 /****************************************************************************
154  * Global Function Prototypes
155  ****************************************************************************/
156 
157 /* Task Control Interfaces */
158 
193 pid_t vfork(void);
199 pid_t getpid(void);
204 void _exit(int status) noreturn_function;
213 unsigned int sleep(unsigned int seconds);
219 int usleep(useconds_t usec);
225 int pause(void);
226 
227 /* File descriptor operations */
228 
238 int close(int fd);
244 int dup(int fd);
250 int dup2(int fd1, int fd2);
256 int fsync(int fd);
262 off_t lseek(int fd, off_t offset, int whence);
268 ssize_t read(int fd, FAR void *buf, size_t nbytes);
274 ssize_t write(int fd, FAR const void *buf, size_t nbytes);
280 ssize_t pread(int fd, FAR void *buf, size_t nbytes, off_t offset);
286 ssize_t pwrite(int fd, FAR const void *buf, size_t nbytes, off_t offset);
287 //end for UNISTD_KERNEL
290 /* Memory management */
291 
292 #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_MM_PGALLOC) && \
293  defined(CONFIG_ARCH_USE_MMU)
294 
298 FAR void *sbrk(intptr_t incr);
302 #endif
303 
304 /* Special devices */
305 
312 int pipe(int fd[2]);
313 
314 /* Working directory operations */
315 
321 int chdir(FAR const char *path);
327 FAR char *getcwd(FAR char *buf, size_t size);
328 
329 /* File path operations */
330 
335 int access(FAR const char *path, int amode);
345 int rmdir(FAR const char *pathname);
352 int unlink(FAR const char *pathname);
353 
354 /* Execution of programs from files */
355 
356 #ifdef CONFIG_LIBC_EXECFUNCS
357 
362 int execl(FAR const char *path, ...);
363 int execv(FAR const char *path, FAR char *const argv[]);
367 #endif
368 
369 /* Other */
375 int getopt(int argc, FAR char *const argv[], FAR const char *optstring);
376 
377 /* Accessor functions intended for use only by external NXFLAT
378  * modules. The global variables optarg, optind, and optopt cannot
379  * be referenced directly from external modules.
380  */
386 FAR char **getoptargp(void); /* Optional argument following option */
387 int *getoptindp(void); /* Index into argv */
388 int *getoptoptp(void); /* unrecognized option character */
392 #undef EXTERN
393 #if defined(__cplusplus)
394 }
395 #endif
396 
397 #endif /* __INCLUDE_UNISTD_H */
398 
unsigned int sleep(unsigned int seconds)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
EXTERN int optopt
Definition: unistd.h:146
int dup(int fd)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int pipe(int fd[2])
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
ssize_t pread(int fd, FAR void *buf, size_t nbytes, off_t offset)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
pid_t getpid(void)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int usleep(useconds_t usec)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
ssize_t write(int fd, FAR const void *buf, size_t nbytes)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int unlink(FAR const char *pathname)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
ssize_t pwrite(int fd, FAR const void *buf, size_t nbytes, off_t offset)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int rmdir(FAR const char *pathname)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int close(int fd)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
off_t lseek(int fd, off_t offset, int whence)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
FAR char * getcwd(FAR char *buf, size_t size)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
#define EXTERN
Definition: unistd.h:135
int chdir(FAR const char *path)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
ssize_t read(int fd, FAR void *buf, size_t nbytes)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int getopt(int argc, FAR char *const argv[], FAR const char *optstring)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fsync(int fd)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int dup2(int fd1, int fd2)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
EXTERN FAR char * optarg
Definition: unistd.h:144
pid_t vfork(void)
The vfork() function has the same effect as fork(), except that the behavior is undefined if the proc...
int pause(void)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
EXTERN int optind
Definition: unistd.h:145