SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /userland/libc.h (Article 8) and /userland/libc.h (Article 9.5)


001 /* Copyright (C) 2005 David Decotigny             001 /* Copyright (C) 2005 David Decotigny
002    Copyright (C) 2003 Thomas Petazzoni            002    Copyright (C) 2003 Thomas Petazzoni
003                                                   003 
004    This program is free software; you can redi    004    This program is free software; you can redistribute it and/or
005    modify it under the terms of the GNU Genera    005    modify it under the terms of the GNU General Public License
006    as published by the Free Software Foundatio    006    as published by the Free Software Foundation; either version 2
007    of the License, or (at your option) any lat    007    of the License, or (at your option) any later version.
008                                                   008    
009    This program is distributed in the hope tha    009    This program is distributed in the hope that it will be useful,
010    but WITHOUT ANY WARRANTY; without even the     010    but WITHOUT ANY WARRANTY; without even the implied warranty of
011    MERCHANTABILITY or FITNESS FOR A PARTICULAR    011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012    GNU General Public License for more details    012    GNU General Public License for more details.
013                                                   013    
014    You should have received a copy of the GNU     014    You should have received a copy of the GNU General Public License
015    along with this program; if not, write to t    015    along with this program; if not, write to the Free Software
016    Foundation, Inc., 59 Temple Place - Suite 3    016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
017    USA.                                           017    USA. 
018 */                                                018 */
019 #ifndef _SOS_USER_LIBC_H_                         019 #ifndef _SOS_USER_LIBC_H_
020 #define _SOS_USER_LIBC_H_                         020 #define _SOS_USER_LIBC_H_
021                                                   021 
022 #include <types.h>                                022 #include <types.h>
023                                                   023 
024 /**                                               024 /**
025  * @file libc.h                                   025  * @file libc.h
026  *                                                026  *
027  * The basic user C library for user programs     027  * The basic user C library for user programs
028  */                                               028  */
029                                                   029 
030 /**                                               030 /**
031  * The most important function of a C program     031  * The most important function of a C program ! ;)
032  */                                               032  */
033 void exit (int status)                         !! 033 void exit (int status);
034      __attribute__((noreturn, alias("_sos_exit << 
035                                                   034 
036                                                   035 
037 /**                                               036 /**
038  * Function to duplicate the current running p    037  * Function to duplicate the current running process
039  */                                               038  */
040 pid_t fork(void)                               !! 039 pid_t fork(void);
041      __attribute__ ((alias("_sos_fork")));     << 
042                                                   040 
043                                                   041 
044 /**                                               042 /**
045  * Function to re-initialize the address space    043  * Function to re-initialize the address space of the current process
046  * with that of the program 'progname'            044  * with that of the program 'progname'
047  */                                               045  */
048 int exec(const char *progname)                 !! 046 int exec(const char *progname);
049      __attribute__ ((alias("_sos_exec")));     << 
050                                                   047 
051                                                   048 
052 int nanosleep(unsigned long int sec,              049 int nanosleep(unsigned long int sec,
053               unsigned long int nanosec)       !! 050               unsigned long int nanosec);
054      __attribute__ ((alias("_sos_nanosleep"))) !! 051 
                                                   >> 052 
                                                   >> 053 int sleep(unsigned int seconds);
                                                   >> 054 
055                                                   055 
056 /**                                               056 /**
057  * These flags (for mmap API) MUST be consiste    057  * These flags (for mmap API) MUST be consistent with those defined in
058  * paging.h and umem_vmm.h                        058  * paging.h and umem_vmm.h
059  */                                               059  */
060 #define PROT_NONE  0                              060 #define PROT_NONE  0
061 #define PROT_READ  (1<<0)                         061 #define PROT_READ  (1<<0)
062 #define PROT_WRITE (1<<1)                         062 #define PROT_WRITE (1<<1)
063 #define PROT_EXEC  (1<<2) /* Not supported on     063 #define PROT_EXEC  (1<<2) /* Not supported on IA32 */
064                                                   064 
065 #define MAP_SHARED (1 << 0)                    !! 065 #define MAP_PRIVATE (0 << 0)
066 #define MAP_FIXED  (1 << 31)                   !! 066 #define MAP_SHARED  (1 << 0)
067                                                !! 067 #define MAP_FIXED   (1 << 31)
068 /**                                            << 
069  * Non standard version of mmap. Differences w << 
070  *  - the resource to map is given by its "pat << 
071  *  - the offset is a signed 64bits, and MUST  << 
072  *  - no errno support                         << 
073  */                                            << 
074 void * fakemmap(void *start, size_t length, in << 
075                 const char *path, loff_t offse << 
076                                                   068 
077                                                   069 
078 /**                                               070 /**
079  * Unmap the given user address interval          071  * Unmap the given user address interval
080  */                                               072  */
081 int munmap(void * start, size_t length)        !! 073 int munmap(void * start, size_t length);
082      __attribute__ ((alias("_sos_munmap")));   << 
083                                                   074 
084                                                   075 
085 /**                                               076 /**
086  * Change the access permissions of the given     077  * Change the access permissions of the given user address interval
087  */                                               078  */
088 int mprotect(const void *addr, size_t len, int !! 079 int mprotect(const void *addr, size_t len, int prot);
089      __attribute__ ((alias("_sos_mprotect"))); << 
090                                                << 
091                                                   080 
092                                                   081 
093 /**                                               082 /**
094  * This flag tells mremap that the underlying     083  * This flag tells mremap that the underlying VR may be moved, when necessary
095  */                                               084  */
096 #define MREMAP_MAYMOVE (1 << 30)                  085 #define MREMAP_MAYMOVE (1 << 30)
097                                                   086 
098 /**                                               087 /**
099  * Grow/shrink the end of the given mapping       088  * Grow/shrink the end of the given mapping
100  */                                               089  */
101 void * mremap(void * old_addr, size_t old_len,    090 void * mremap(void * old_addr, size_t old_len,
102               size_t new_len,                     091               size_t new_len,
103               unsigned long flags);               092               unsigned long flags);
104                                                   093 
105                                                   094 
                                                   >> 095 /** Flags for msync */
                                                   >> 096 #define MS_SYNC  (1 << 0)
                                                   >> 097 #define MS_ASYNC (0 << 0)
                                                   >> 098 
                                                   >> 099 /** Synchronize cache contents with mapped memory */
                                                   >> 100 int msync(void *start, size_t length, int flags);
                                                   >> 101 
                                                   >> 102 
106 /**                                               103 /**
107  * Standard heap management API                   104  * Standard heap management API
108  */                                               105  */
109                                                   106 
110 /** @note MT UNSAFE */                            107 /** @note MT UNSAFE */
111 int brk(void *end_data_seg);                      108 int brk(void *end_data_seg);
112                                                   109 
113 /** @note MT UNSAFE */                            110 /** @note MT UNSAFE */
114 void *sbrk(ptrdiff_t increment);                  111 void *sbrk(ptrdiff_t increment);
115                                                   112 
116 /** @note MT UNSAFE */                            113 /** @note MT UNSAFE */
117 void * calloc (size_t nmemb, size_t size);        114 void * calloc (size_t nmemb, size_t size);
118                                                   115 
119 /** @note MT UNSAFE */                            116 /** @note MT UNSAFE */
120 void * malloc (size_t size);                      117 void * malloc (size_t size);
121                                                   118 
122 /** @note Does nothing (not implemented yet) *    119 /** @note Does nothing (not implemented yet) */
123 void free(void *ptr);                             120 void free(void *ptr);
124                                                   121 
125                                                   122 
126 /*                                                123 /*
127  * Filesystem subsystem                           124  * Filesystem subsystem
128  */                                               125  */
129                                                   126 
130 int mount(const char *source, const char *targ    127 int mount(const char *source, const char *target,
131           const char *filesystemtype, unsigned    128           const char *filesystemtype, unsigned long mountflags,
132           const char *data)                    !! 129           const char *data);
133      __attribute__ ((alias("_sos_mount")));    !! 130 
134 int umount(const char *target)                 !! 131 
135      __attribute__ ((alias("_sos_umount")));   !! 132 int umount(const char *target);
136 void sync(void)                                !! 133 
137      __attribute__ ((alias("_sos_sync")));     !! 134 
                                                   >> 135 void sync(void);
                                                   >> 136 
138                                                   137 
139 struct statvfs                                    138 struct statvfs
140 {                                                 139 {
                                                   >> 140   unsigned int  f_rdev_major;
                                                   >> 141   unsigned int  f_rdev_minor;
141   size_t        f_sz_total;  /**< Total size *    142   size_t        f_sz_total;  /**< Total size */
142   size_t        f_sz_free;   /**< Size left on    143   size_t        f_sz_free;   /**< Size left on device */
143   unsigned int  f_node_total;/**< Total alloca    144   unsigned int  f_node_total;/**< Total allocatable FS nodes */
144   unsigned int  f_node_avail;/**< Number of av    145   unsigned int  f_node_avail;/**< Number of available free FS nodes */
145   unsigned int  f_flags;                          146   unsigned int  f_flags;
146 };                                                147 };
147                                                   148 
148 int statvfs(const char *path, struct statvfs * !! 149 int statvfs(const char *path, struct statvfs *buf);
149      __attribute__ ((alias("_sos_statvfs")));  !! 150 
150                                                   151 
151 #define O_EXCL      (1 << 0)                      152 #define O_EXCL      (1 << 0)
152 #define O_CREAT     (1 << 1)                      153 #define O_CREAT     (1 << 1)
153 #define O_NOFOLLOW  (1 << 2)                   !! 154 #define O_TRUNC     (1 << 2)
154 #define O_DIRECTORY (1 << 3) /* Incompatible w !! 155 #define O_NOFOLLOW  (1 << 3)
155 #define O_SYNC      (1 << 4)                   !! 156 #define O_DIRECTORY (1 << 4) /* Incompatible with CREAT/TRUNC */
                                                   >> 157 #define O_SYNC      (1 << 5)
156                                                   158 
157 #define O_RDONLY    (1 << 16)                     159 #define O_RDONLY    (1 << 16)
158 #define O_WRONLY    (1 << 17)                     160 #define O_WRONLY    (1 << 17)
159 #define O_RDWR      (O_RDONLY | O_WRONLY)         161 #define O_RDWR      (O_RDONLY | O_WRONLY)
160                                                   162 
161 /**                                               163 /**
162  * FS access rights. Same as in kernel fs.h       164  * FS access rights. Same as in kernel fs.h
163  */                                               165  */
164 #define S_IRUSR     00400                         166 #define S_IRUSR     00400
165 #define S_IWUSR     00200                         167 #define S_IWUSR     00200
166 #define S_IXUSR     00100                         168 #define S_IXUSR     00100
167 #define S_IRWXALL   07777 /* For symlinks */      169 #define S_IRWXALL   07777 /* For symlinks */
168                                                   170 
169 int open(const char *pathname, int flags, /* m    171 int open(const char *pathname, int flags, /* mode_t mode */...);
170                                                   172 
171 int close(int fd)                              !! 173 int close(int fd);
172      __attribute__ ((alias("_sos_close")));    !! 174 
173                                                   175 
174 int read(int fd, char * buf, size_t len);         176 int read(int fd, char * buf, size_t len);
175 int write(int fd, const char * buf, size_t len    177 int write(int fd, const char * buf, size_t len);
176                                                   178 
177 /* Same as sos_seek_whence_t in kernel fs.h */    179 /* Same as sos_seek_whence_t in kernel fs.h */
178 #define SEEK_SET 42                               180 #define SEEK_SET 42
179 #define SEEK_CUR 24                               181 #define SEEK_CUR 24
180 #define SEEK_END 84                               182 #define SEEK_END 84
181 off_t lseek(int fd, off_t offset, int whence);    183 off_t lseek(int fd, off_t offset, int whence);
182 loff_t lseek64(int fd, loff_t offset, int when    184 loff_t lseek64(int fd, loff_t offset, int whence);
183 void * mmap(void *start, size_t length, int pr    185 void * mmap(void *start, size_t length, int prot , int flags,
184             int fd, loff_t offset);               186             int fd, loff_t offset);
185 int ftruncate(int fd, off_t length);              187 int ftruncate(int fd, off_t length);
186 int ftruncate64(int fd, loff_t length)         !! 188 int ftruncate64(int fd, loff_t length);
187      __attribute__ ((alias("_sos_ftruncate64") !! 189 int fcntl(int fd, int cmd, int arg);
188 int fcntl(int fd, int cmd, int arg)            !! 190 int ioctl(int fd, int cmd, int arg);
189      __attribute__ ((alias("_sos_fcntl")));    !! 191 
190                                                !! 192 int creat(const char *pathname, mode_t mode);
191 int creat(const char *pathname, mode_t mode)   !! 193 int link (const char *oldpath, const char *newpath);
192      __attribute__ ((alias("_sos_creat")));    !! 194 int unlink(const char *pathname);
193 int link (const char *oldpath, const char *new !! 195 int rename(const char *oldpath, const char *newpath);
194      __attribute__ ((alias("_sos_link")));     !! 196 int symlink(const char *target, const char *path);
195 int unlink(const char *pathname)               !! 197 
196      __attribute__ ((alias("_sos_unlink")));   !! 198 /* Same as sos_fs_node_type_t in kernel fs.h */
197 int rename(const char *oldpath, const char *ne !! 199 #define S_IFREG 0x42
198      __attribute__ ((alias("_sos_rename")));   !! 200 #define S_IFDIR 0x24
199 int symlink(const char *target, const char *pa !! 201 #define S_IFLNK 0x84
200      __attribute__ ((alias("_sos_symlink")));  !! 202 #define S_IFCHR 0x48
201                                                !! 203 #define S_IFBLK 0x12
202 int mkdir(const char *pathname, mode_t mode)   !! 204 int mknod(const char *pathname, mode_t mode,
203      __attribute__ ((alias("_sos_mkdir")));    !! 205           int type,
204 int rmdir(const char *pathname)                !! 206           unsigned int major, unsigned minor);
205      __attribute__ ((alias("_sos_rmdir")));    !! 207 
                                                   >> 208 
                                                   >> 209 int mkdir(const char *pathname, mode_t mode);
                                                   >> 210 
                                                   >> 211 
                                                   >> 212 int rmdir(const char *pathname);
                                                   >> 213 
                                                   >> 214 
                                                   >> 215 int chmod(const char *path, mode_t mode);
206                                                   216 
207 int chmod(const char *path, mode_t mode)       << 
208      __attribute__ ((alias("_sos_chmod")));    << 
209                                                   217 
210 struct dirent                                     218 struct dirent
211 {                                                 219 {
212   unsigned long long int storage_location;        220   unsigned long long int storage_location;
213   unsigned long long int offset_in_dirfile;       221   unsigned long long int offset_in_dirfile;
214                                                << 
215 /* Same as sos_fs_node_type_t in kernel fs.h * << 
216 #define S_IFREG 0x42                           << 
217 #define S_IFDIR 0x24                           << 
218 #define S_IFLNK 0x84                           << 
219   unsigned int type;                              222   unsigned int type;
220   unsigned short namelen;                         223   unsigned short namelen;
221                                                   224 
222 #define SOS_FS_DIRENT_NAME_MAXLEN 128             225 #define SOS_FS_DIRENT_NAME_MAXLEN 128
223   char       name[SOS_FS_DIRENT_NAME_MAXLEN];     226   char       name[SOS_FS_DIRENT_NAME_MAXLEN];
224 };                                                227 };
225                                                   228 
226 /* Forward declaration (defined in libc.c) */     229 /* Forward declaration (defined in libc.c) */
227 struct sos_DIR_struct;                            230 struct sos_DIR_struct;
228 #define DIR struct sos_DIR_struct                 231 #define DIR struct sos_DIR_struct
229                                                   232 
230 DIR *opendir(const char *name);                   233 DIR *opendir(const char *name);
231 int dirfd(const DIR * dir);                       234 int dirfd(const DIR * dir);
232 struct dirent *readdir(DIR *dir);                 235 struct dirent *readdir(DIR *dir);
233 int closedir(DIR *dir);                           236 int closedir(DIR *dir);
234                                                   237 
235 struct stat                                       238 struct stat
236 {                                                 239 {
                                                   >> 240   unsigned int           st_rdev_major;
                                                   >> 241   unsigned int           st_rdev_minor;
237   int                    st_type;                 242   int                    st_type;
238   unsigned long long int st_storage_location;     243   unsigned long long int st_storage_location;
239   int                    st_access_rights;        244   int                    st_access_rights;
240   unsigned int           st_nlink;                245   unsigned int           st_nlink;
241   signed long long int   st_size;                 246   signed long long int   st_size;
242 };                                                247 };
243                                                   248 
244 int stat(const char *file_name, struct stat *b    249 int stat(const char *file_name, struct stat *buf);
245 int lstat(const char *file_name, struct stat *    250 int lstat(const char *file_name, struct stat *buf);
                                                   >> 251 int chroot(const char *path);
                                                   >> 252 int chdir(const char *path);
                                                   >> 253 int fchdir(int fd);
246                                                   254 
247 int chroot(const char *path)                   !! 255 int printf(const char *, ...);
248      __attribute__ ((alias("_sos_chroot")));   << 
249 int chdir(const char *path)                    << 
250      __attribute__ ((alias("_sos_chdir")));    << 
251 int fchdir(int fd)                             << 
252      __attribute__ ((alias("_sos_fchdir")));   << 
253                                                << 
254                                                << 
255                                                   256 
256 #endif /* _SOS_USER_LIBC_H_ */                    257 #endif /* _SOS_USER_LIBC_H_ */
                                                      

source navigation ] diff markup ] identifier search ] general search ]