genericopenlibs/openenvcore/backend/inc/sysreent.h
changeset 31 ce057bb09d0b
child 45 4b03adbd26ca
child 63 a117ad66e027
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * The reentrant system calls here serve two purposes:
       
    16 * 1) Provide reentrant versions of the system calls the ANSI C library
       
    17 * requires.
       
    18 * 2) Provide these system calls in a namespace clean way.
       
    19 * It is intended that *all* system calls that the ANSI C library needs
       
    20 * be declared here.  It documents them all in one place.  All library access
       
    21 * to the system is via some form of these functions.
       
    22 * There are three ways a target may provide the needed syscalls.
       
    23 * 1) Define the reentrant versions of the syscalls directly.
       
    24 * (eg: _open_r, _close_r, etc.).  Please keep the namespace clean.
       
    25 * When you do this, set "syscall_dir" to "syscalls" in configure.in,
       
    26 * and add -DREENTRANT_SYSCALLS_PROVIDED to target_cflags in configure.in.
       
    27 * 2) Define namespace clean versions of the system calls by prefixing
       
    28 * them with '_' (eg: _open, _close, etc.).  Technically, there won't be
       
    29 * true reentrancy at the syscall level, but the library will be namespace
       
    30 * clean.
       
    31 * When you do this, set "syscall_dir" to "syscalls" in configure.in.
       
    32 * 3) Define or otherwise provide the regular versions of the syscalls
       
    33 * (eg: open, close, etc.).  The library won't be reentrant nor namespace
       
    34 * clean, but at least it will work.
       
    35 * When you do this, add -DMISSING_SYSCALL_NAMES to target_cflags in
       
    36 * configure.in.
       
    37 * Stubs of the reentrant versions of the syscalls exist in the libc/reent
       
    38 * source directory and are used if REENTRANT_SYSCALLS_PROVIDED isn't defined.
       
    39 * They use the native system calls: _open, _close, etc. if they're available
       
    40 * (MISSING_SYSCALL_NAMES is *not* defined), otherwise open, close, etc.
       
    41 * (MISSING_SYSCALL_NAMES *is* defined).
       
    42 * WARNING: All identifiers here must begin with an underscore.  This file is
       
    43 * included by stdio.h and others and we therefore must only use identifiers
       
    44 * in the namespace allotted to us.  
       
    45 * @file
       
    46 * @internalComponent
       
    47 * 
       
    48 *
       
    49 */
       
    50 
       
    51 
       
    52 
       
    53 #ifndef _SYSREENT_H_
       
    54 #define _SYSREENT_H_
       
    55 
       
    56 #ifdef __cplusplus
       
    57 extern "C" {
       
    58 #endif
       
    59 
       
    60 #define __need_size_t
       
    61 #include <stddef.h>
       
    62 #include <sys/_types.h>
       
    63 #include <sys/types.h>
       
    64 #include <dirent.h>
       
    65 #include <sys/select.h>
       
    66 #include <spawn.h>
       
    67 
       
    68 /* FIXME: not namespace clean */
       
    69 /*
       
    70 @internalTechnology
       
    71 */
       
    72 struct stat;
       
    73 /*
       
    74 @internalTechnology
       
    75 */
       
    76 struct sockaddr;
       
    77 struct TProtocolDesc;
       
    78 
       
    79 /*
       
    80 Reentrant versions of system calls.
       
    81 Most of these are thread-safe in EPOC32 anyway
       
    82 */
       
    83 IMPORT_C int	_chdir_r	(int *, const wchar_t *);
       
    84 IMPORT_C int	_wchdir_r	(int *, const wchar_t *);
       
    85 IMPORT_C int	_chmod_r	(int *, const wchar_t *, mode_t);
       
    86 IMPORT_C int	_fchmod_r	(int *, int, mode_t);
       
    87 IMPORT_C int	_wchmod_r	(int *, const wchar_t *, mode_t);
       
    88 IMPORT_C int	_close_r	(int *, int);
       
    89 IMPORT_C int	_dup_r		(int *, int);
       
    90 IMPORT_C int	_dup2_r	(int *, int, int);
       
    91 IMPORT_C int	_fcntl_r	(int *, int, int, long);
       
    92 IMPORT_C int	_fstat_r	(int *, int, struct stat *);
       
    93 IMPORT_C int	_fsync_r	(int *, int);
       
    94 IMPORT_C wchar_t*	_wgetcwd_r	(int *, wchar_t *, size_t);
       
    95 IMPORT_C int	_ioctl_r	(int *, int, int, void *);
       
    96 IMPORT_C int	_link_r		(int *, const wchar_t *, const wchar_t *);
       
    97 IMPORT_C off_t	_lseek_r	(int *, int, off_t, int);
       
    98 IMPORT_C int	_mkdir_r	(int *, const wchar_t *, mode_t);
       
    99 IMPORT_C int	_wmkdir_r	(int *, const wchar_t *, mode_t);
       
   100 IMPORT_C int	_open_r	(int *, const wchar_t *, int, int);
       
   101 IMPORT_C int	_wopen_r	(int *, const wchar_t *, int, int);
       
   102 IMPORT_C int	_read_r	(int *, int, char *, size_t);
       
   103 IMPORT_C wchar_t*	_wrealpath_r	(int *, const wchar_t *, wchar_t *);
       
   104 IMPORT_C int	_rename_r	(int *, const wchar_t *_old, const wchar_t *_new);
       
   105 IMPORT_C int	_wrename_r	(int *, const wchar_t *_old, const wchar_t *_new);
       
   106 IMPORT_C int	_rmdir_r	(int *, const wchar_t *);
       
   107 IMPORT_C int	_wrmdir_r	(int *, const wchar_t *);
       
   108 IMPORT_C int	_stat_r		(int *, const wchar_t *, struct stat *);
       
   109 IMPORT_C int    _lstat_r    (int *, const wchar_t *, struct stat *);
       
   110 IMPORT_C int	_wstat_r	(int *, const wchar_t *, struct stat *);
       
   111 IMPORT_C int	_unlink_r	(int *, const wchar_t *);
       
   112 IMPORT_C int	_wunlink_r	(int *, const wchar_t *);
       
   113 IMPORT_C int	_wait_r		(int *, int *);
       
   114 IMPORT_C int	_waitpid_r	(int *, int, int *, int);
       
   115 IMPORT_C int	_write_r	(int *, int, const char *, size_t);
       
   116 
       
   117 IMPORT_C int	_accept_r	(int *, int, struct sockaddr *, size_t *);
       
   118 IMPORT_C int	_bind_r	(int *, int, const struct sockaddr *, size_t);
       
   119 IMPORT_C int	_connect_r	(int *, int, const struct sockaddr *, size_t);
       
   120 IMPORT_C int	_getpeername_r	(int *, int, struct sockaddr *, size_t *);
       
   121 IMPORT_C int	_getsockname_r	(int *, int, struct sockaddr *, size_t *);
       
   122 IMPORT_C int	_getsockopt_r	(int *, int, int, int, void *, size_t *);
       
   123 IMPORT_C int	_getprotobynumber_r (int*, int, struct TProtocolDesc*);
       
   124 IMPORT_C int	_getprotobyname_r (int*, const char*, struct TProtocolDesc*);
       
   125 IMPORT_C int	_gethostname_r (int*, char*, size_t);
       
   126 IMPORT_C int	_listen_r	(int *, int, int);
       
   127 IMPORT_C int	_recvfrom_r	(int *, int, char *, size_t, int, struct sockaddr *, size_t *);
       
   128 IMPORT_C int	_sendto_r	(int *, int, const char *, size_t, int, struct sockaddr *, size_t);
       
   129 IMPORT_C int	_setsockopt_r	(int *, int, int, int, void *, size_t);
       
   130 IMPORT_C int	_socket_r	(int *, int, int, int);
       
   131 IMPORT_C int	_shutdown_r	(int *, int, int);
       
   132 
       
   133 #ifdef SYMBIAN_OE_POSIX_SIGNALS
       
   134 IMPORT_C int _kill_r (int *, pid_t, int);
       
   135 IMPORT_C int _raise_r (int *, int);
       
   136 IMPORT_C int _sigqueue_r (int *, pid_t, int, const union sigval);
       
   137 
       
   138 IMPORT_C int _sigfillset_r(int *, sigset_t *);
       
   139 IMPORT_C int _sigaddset_r(int *, sigset_t *, int );
       
   140 IMPORT_C int _sigdelset_r(int *, sigset_t *, int );
       
   141 IMPORT_C int _sigismember_r(int *, const sigset_t *, int );
       
   142 IMPORT_C int _sigandset_r(int *, sigset_t * , const sigset_t * , const sigset_t * );
       
   143 IMPORT_C int _sigorset_r(int *, sigset_t * , const sigset_t * , const sigset_t * );
       
   144 IMPORT_C int _sigisemptyset_r(int *, const sigset_t * );
       
   145 IMPORT_C int _sigemptyset_r(int *, sigset_t* set);
       
   146 
       
   147 IMPORT_C int _sigprocmask_r(int*, int , const sigset_t *, sigset_t *);
       
   148 IMPORT_C int _sighold_r(int*, int);
       
   149 IMPORT_C int _sigrelse_r(int*, int);
       
   150 IMPORT_C int _sigpause_r(int*, int);
       
   151 
       
   152 IMPORT_C int _sigwait_r(int*, const sigset_t*, int*);
       
   153 IMPORT_C int _sigtimedwait_r(int*, const sigset_t*, siginfo_t*,
       
   154        const struct timespec*);
       
   155 IMPORT_C int _sigwaitinfo_r(int*, const sigset_t*, siginfo_t*);
       
   156 
       
   157 IMPORT_C int _sigaction_r(int *aErrno, int sig, const struct sigaction *act, struct sigaction *oact);
       
   158 IMPORT_C void (*_sigset_r(int *aErrno, int sig, void (*disp)(int)))(int);
       
   159 IMPORT_C void (*_bsd_signal_r(int *aErrno, int sig, void (*disp)(int)))(int);
       
   160 IMPORT_C void (*_signal_r(int *aErrno, int sig, void (*disp)(int)))(int);
       
   161 IMPORT_C int _sigignore_r(int *aErrno, int sig);
       
   162 IMPORT_C unsigned int _alarm_r(unsigned int seconds);
       
   163 IMPORT_C int _sigpending_r(int *aErrno,sigset_t *aSet);
       
   164 IMPORT_C int _sigenable_r(int *aErrno);
       
   165 #endif // SYMBIAN_OE_POSIX_SIGNALS
       
   166 //forward declaration
       
   167 struct utimbuf;
       
   168 IMPORT_C int 	_utime_r (int *, const wchar_t*, const struct utimbuf*);
       
   169 
       
   170 IMPORT_C DIR* _opendir_r (int*, const wchar_t* _path) ;
       
   171 IMPORT_C int _wclosedir_r (int*, WDIR *dp) ;
       
   172 IMPORT_C struct dirent* _readdir_r (int*, DIR *dp) ;
       
   173 IMPORT_C void _wrewinddir_r(WDIR *dp);
       
   174 IMPORT_C struct wdirent* _wreaddir_r(WDIR *dp);
       
   175 IMPORT_C int _fchdir_r (int *aErrno, int filedesc);
       
   176 IMPORT_C wchar_t* _getcwd_r (int *aErrno, wchar_t *_buf, size_t _size);
       
   177 IMPORT_C int 	_mkfifo_r (int *aErrno, const wchar_t *pathname, mode_t mode);
       
   178 IMPORT_C int 	_pipe_r (int *aErrno, int fildes[2]);
       
   179 IMPORT_C int 	_wpopen3_r	(int *aErrno, const wchar_t *file, const wchar_t *cmd, wchar_t** envp, int fids[3]);
       
   180 
       
   181 IMPORT_C int _posix_spawn_r (int* pid, const wchar_t* wpath,
       
   182 							 const posix_spawn_file_actions_t* file_actions,
       
   183 							 const posix_spawnattr_t* attrp,
       
   184 							 const wchar_t* wargs,
       
   185 							 wchar_t** wenvp);
       
   186 
       
   187 IMPORT_C void _exit_r (int code);
       
   188 /*
       
   189 New function introduced for MRT2.0
       
   190 Reentrant version of popen() function
       
   191 */
       
   192 IMPORT_C int _wpopen_r (int *aErrno, const wchar_t* command, const char* mode);
       
   193 IMPORT_C int _pclose_r (int *aErrno, int aFid);
       
   194 
       
   195 IMPORT_C int _shmget_r	(int *aErrno, key_t key, int size, int shmflg);
       
   196 IMPORT_C void* _shmat_r	(int *aErrno, int shmid, const void *shmaddr, int shmflg);
       
   197 IMPORT_C int _shmdt_r	(int *aErrno, const void *shmaddr);
       
   198 
       
   199 //forward declarations
       
   200 struct shmid_ds;
       
   201 struct sembuf;
       
   202 
       
   203 IMPORT_C int _shmctl_r	(int *aErrno,int shmid, int cmd, struct shmid_ds *buf);
       
   204 
       
   205 IMPORT_C int _semget_r	(int *aErrno, key_t key, int nsems, int semflg);
       
   206 IMPORT_C int _semop_r	(int *aErrno, int semid, struct sembuf *sops, unsigned nsops);
       
   207 IMPORT_C int _semctl_r	(int *aErrno, int semid, int semnum, int cmd, ...);
       
   208 
       
   209 IMPORT_C int _select_r	(int *aErrno, int maxfd, fd_set *readfds,
       
   210 						 fd_set *writefds, fd_set *exceptfds, struct timeval *tvptr);
       
   211 
       
   212 IMPORT_C int _wsystem_r	(int *aErrno, const wchar_t *command);
       
   213 
       
   214 typedef void* iconv_t;
       
   215 IMPORT_C iconv_t _iconv_open_r(int* aErrno, const char* tocharset, const char* fromcharset);
       
   216 
       
   217 IMPORT_C size_t _iconv_r(int* aErrno, iconv_t conversion_descriptor, const char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft);
       
   218 
       
   219 IMPORT_C int _iconv_close_r(int* aErrno, iconv_t conversion_descriptor);
       
   220 /*
       
   221 Functions to allocate/deallocate on the backend's private heap
       
   222 */
       
   223 IMPORT_C void* BackendAlloc(size_t aNBytes);
       
   224 IMPORT_C void* BackendReAlloc(void* aPtr, size_t aNBytes);
       
   225 IMPORT_C void BackendFree(void* aPtr);
       
   226 IMPORT_C void* BackendAllocTLD(size_t aSize);
       
   227 
       
   228 #define _remove_r(r,x)	_unlink_r(r,x)
       
   229 #define _wremove_r(r,x)	_wunlink_r(r,x)
       
   230 
       
   231 
       
   232 //forward declarations
       
   233 struct msqid_ds;
       
   234 
       
   235 IMPORT_C int _msgget_r(key_t aKey, int aMsgFlag, int* aErrno);
       
   236 IMPORT_C int _msgsnd_r(int msqid, const void *msgp, size_t msgsz, int msgflg, int* aErrno);
       
   237 IMPORT_C int _msgrcv_r(int msqid, void* msgp, size_t msgsz, long msgtyp, int msgflg, int* aErrno);
       
   238 IMPORT_C int _msgctl_r(int msqid, int cmd, struct msqid_ds* buf, int* aErrno);
       
   239 
       
   240 IMPORT_C int _setecho_r(int *aErrno, int aFd, uint8_t aEchoVal);
       
   241 
       
   242 //forward declarations
       
   243 struct ifreq;
       
   244 
       
   245 IMPORT_C int _setdefaultif_r(int *aErrno, const struct ifreq* aIfReq);
       
   246 
       
   247 IMPORT_C void *_memcpy_r(void *dst0, const void *src0, size_t length);
       
   248 IMPORT_C void *_memmove_r(void *dst0, const void *src0, size_t length);
       
   249 
       
   250 #ifdef __cplusplus
       
   251 }	// extern "C"
       
   252 #endif
       
   253 #endif /* _SYSREENT_H_ */