sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * The reentrant system calls here serve two purposes: sl@0: * 1) Provide reentrant versions of the system calls the ANSI C library sl@0: * requires. sl@0: * 2) Provide these system calls in a namespace clean way. sl@0: * It is intended that *all* system calls that the ANSI C library needs sl@0: * be declared here. It documents them all in one place. All library access sl@0: * to the system is via some form of these functions. sl@0: * There are three ways a target may provide the needed syscalls. sl@0: * 1) Define the reentrant versions of the syscalls directly. sl@0: * (eg: _open_r, _close_r, etc.). Please keep the namespace clean. sl@0: * When you do this, set "syscall_dir" to "syscalls" in configure.in, sl@0: * and add -DREENTRANT_SYSCALLS_PROVIDED to target_cflags in configure.in. sl@0: * 2) Define namespace clean versions of the system calls by prefixing sl@0: * them with '_' (eg: _open, _close, etc.). Technically, there won't be sl@0: * true reentrancy at the syscall level, but the library will be namespace sl@0: * clean. sl@0: * When you do this, set "syscall_dir" to "syscalls" in configure.in. sl@0: * 3) Define or otherwise provide the regular versions of the syscalls sl@0: * (eg: open, close, etc.). The library won't be reentrant nor namespace sl@0: * clean, but at least it will work. sl@0: * When you do this, add -DMISSING_SYSCALL_NAMES to target_cflags in sl@0: * configure.in. sl@0: * Stubs of the reentrant versions of the syscalls exist in the libc/reent sl@0: * source directory and are used if REENTRANT_SYSCALLS_PROVIDED isn't defined. sl@0: * They use the native system calls: _open, _close, etc. if they're available sl@0: * (MISSING_SYSCALL_NAMES is *not* defined), otherwise open, close, etc. sl@0: * (MISSING_SYSCALL_NAMES *is* defined). sl@0: * WARNING: All identifiers here must begin with an underscore. This file is sl@0: * included by stdio.h and others and we therefore must only use identifiers sl@0: * in the namespace allotted to us. sl@0: * @file sl@0: * @internalComponent sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #ifndef _SYSREENT_H_ sl@0: #define _SYSREENT_H_ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: #define __need_size_t sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /* FIXME: not namespace clean */ sl@0: /* sl@0: @internalTechnology sl@0: */ sl@0: struct stat; sl@0: /* sl@0: @internalTechnology sl@0: */ sl@0: struct sockaddr; sl@0: struct TProtocolDesc; sl@0: sl@0: /* sl@0: Reentrant versions of system calls. sl@0: Most of these are thread-safe in EPOC32 anyway sl@0: */ sl@0: IMPORT_C int _chdir_r (int *, const wchar_t *); sl@0: IMPORT_C int _wchdir_r (int *, const wchar_t *); sl@0: IMPORT_C int _chmod_r (int *, const wchar_t *, mode_t); sl@0: IMPORT_C int _fchmod_r (int *, int, mode_t); sl@0: IMPORT_C int _wchmod_r (int *, const wchar_t *, mode_t); sl@0: IMPORT_C int _close_r (int *, int); sl@0: IMPORT_C int _dup_r (int *, int); sl@0: IMPORT_C int _dup2_r (int *, int, int); sl@0: IMPORT_C int _fcntl_r (int *, int, int, long); sl@0: IMPORT_C int _fstat_r (int *, int, struct stat *); sl@0: IMPORT_C int _fsync_r (int *, int); sl@0: IMPORT_C wchar_t* _wgetcwd_r (int *, wchar_t *, size_t); sl@0: IMPORT_C int _ioctl_r (int *, int, int, void *); sl@0: IMPORT_C int _link_r (int *, const wchar_t *, const wchar_t *); sl@0: IMPORT_C off_t _lseek_r (int *, int, off_t, int); sl@0: IMPORT_C int _mkdir_r (int *, const wchar_t *, mode_t); sl@0: IMPORT_C int _wmkdir_r (int *, const wchar_t *, mode_t); sl@0: IMPORT_C int _open_r (int *, const wchar_t *, int, int); sl@0: IMPORT_C int _wopen_r (int *, const wchar_t *, int, int); sl@0: IMPORT_C int _read_r (int *, int, char *, size_t); sl@0: IMPORT_C wchar_t* _wrealpath_r (int *, const wchar_t *, wchar_t *); sl@0: IMPORT_C int _rename_r (int *, const wchar_t *_old, const wchar_t *_new); sl@0: IMPORT_C int _wrename_r (int *, const wchar_t *_old, const wchar_t *_new); sl@0: IMPORT_C int _rmdir_r (int *, const wchar_t *); sl@0: IMPORT_C int _wrmdir_r (int *, const wchar_t *); sl@0: IMPORT_C int _stat_r (int *, const wchar_t *, struct stat *); sl@0: IMPORT_C int _lstat_r (int *, const wchar_t *, struct stat *); sl@0: IMPORT_C int _wstat_r (int *, const wchar_t *, struct stat *); sl@0: IMPORT_C int _unlink_r (int *, const wchar_t *); sl@0: IMPORT_C int _wunlink_r (int *, const wchar_t *); sl@0: IMPORT_C int _wait_r (int *, int *); sl@0: IMPORT_C int _waitpid_r (int *, int, int *, int); sl@0: IMPORT_C int _write_r (int *, int, const char *, size_t); sl@0: sl@0: IMPORT_C int _accept_r (int *, int, struct sockaddr *, size_t *); sl@0: IMPORT_C int _bind_r (int *, int, const struct sockaddr *, size_t); sl@0: IMPORT_C int _connect_r (int *, int, const struct sockaddr *, size_t); sl@0: IMPORT_C int _getpeername_r (int *, int, struct sockaddr *, size_t *); sl@0: IMPORT_C int _getsockname_r (int *, int, struct sockaddr *, size_t *); sl@0: IMPORT_C int _getsockopt_r (int *, int, int, int, void *, size_t *); sl@0: IMPORT_C int _getprotobynumber_r (int*, int, struct TProtocolDesc*); sl@0: IMPORT_C int _getprotobyname_r (int*, const char*, struct TProtocolDesc*); sl@0: IMPORT_C int _gethostname_r (int*, char*, size_t); sl@0: IMPORT_C int _listen_r (int *, int, int); sl@0: IMPORT_C int _recvfrom_r (int *, int, char *, size_t, int, struct sockaddr *, size_t *); sl@0: IMPORT_C int _sendto_r (int *, int, const char *, size_t, int, struct sockaddr *, size_t); sl@0: IMPORT_C int _setsockopt_r (int *, int, int, int, void *, size_t); sl@0: IMPORT_C int _socket_r (int *, int, int, int); sl@0: IMPORT_C int _shutdown_r (int *, int, int); sl@0: sl@0: #ifdef SYMBIAN_OE_POSIX_SIGNALS sl@0: IMPORT_C int _kill_r (int *, pid_t, int); sl@0: IMPORT_C int _raise_r (int *, int); sl@0: IMPORT_C int _sigqueue_r (int *, pid_t, int, const union sigval); sl@0: sl@0: IMPORT_C int _sigfillset_r(int *, sigset_t *); sl@0: IMPORT_C int _sigaddset_r(int *, sigset_t *, int ); sl@0: IMPORT_C int _sigdelset_r(int *, sigset_t *, int ); sl@0: IMPORT_C int _sigismember_r(int *, const sigset_t *, int ); sl@0: IMPORT_C int _sigandset_r(int *, sigset_t * , const sigset_t * , const sigset_t * ); sl@0: IMPORT_C int _sigorset_r(int *, sigset_t * , const sigset_t * , const sigset_t * ); sl@0: IMPORT_C int _sigisemptyset_r(int *, const sigset_t * ); sl@0: IMPORT_C int _sigemptyset_r(int *, sigset_t* set); sl@0: sl@0: IMPORT_C int _sigprocmask_r(int*, int , const sigset_t *, sigset_t *); sl@0: IMPORT_C int _sighold_r(int*, int); sl@0: IMPORT_C int _sigrelse_r(int*, int); sl@0: IMPORT_C int _sigpause_r(int*, int); sl@0: sl@0: IMPORT_C int _sigwait_r(int*, const sigset_t*, int*); sl@0: IMPORT_C int _sigtimedwait_r(int*, const sigset_t*, siginfo_t*, sl@0: const struct timespec*); sl@0: IMPORT_C int _sigwaitinfo_r(int*, const sigset_t*, siginfo_t*); sl@0: sl@0: IMPORT_C int _sigaction_r(int *aErrno, int sig, const struct sigaction *act, struct sigaction *oact); sl@0: IMPORT_C void (*_sigset_r(int *aErrno, int sig, void (*disp)(int)))(int); sl@0: IMPORT_C void (*_bsd_signal_r(int *aErrno, int sig, void (*disp)(int)))(int); sl@0: IMPORT_C void (*_signal_r(int *aErrno, int sig, void (*disp)(int)))(int); sl@0: IMPORT_C int _sigignore_r(int *aErrno, int sig); sl@0: IMPORT_C unsigned int _alarm_r(unsigned int seconds); sl@0: IMPORT_C int _sigpending_r(int *aErrno,sigset_t *aSet); sl@0: IMPORT_C int _sigenable_r(int *aErrno); sl@0: #endif // SYMBIAN_OE_POSIX_SIGNALS sl@0: //forward declaration sl@0: struct utimbuf; sl@0: IMPORT_C int _utime_r (int *, const wchar_t*, const struct utimbuf*); sl@0: sl@0: IMPORT_C DIR* _opendir_r (int*, const wchar_t* _path) ; sl@0: IMPORT_C int _wclosedir_r (int*, WDIR *dp) ; sl@0: IMPORT_C struct dirent* _readdir_r (int*, DIR *dp) ; sl@0: IMPORT_C void _wrewinddir_r(WDIR *dp); sl@0: IMPORT_C struct wdirent* _wreaddir_r(WDIR *dp); sl@0: IMPORT_C int _fchdir_r (int *aErrno, int filedesc); sl@0: IMPORT_C wchar_t* _getcwd_r (int *aErrno, wchar_t *_buf, size_t _size); sl@0: IMPORT_C int _mkfifo_r (int *aErrno, const wchar_t *pathname, mode_t mode); sl@0: IMPORT_C int _pipe_r (int *aErrno, int fildes[2]); sl@0: IMPORT_C int _wpopen3_r (int *aErrno, const wchar_t *file, const wchar_t *cmd, wchar_t** envp, int fids[3]); sl@0: sl@0: IMPORT_C int _posix_spawn_r (int* pid, const wchar_t* wpath, sl@0: const posix_spawn_file_actions_t* file_actions, sl@0: const posix_spawnattr_t* attrp, sl@0: const wchar_t* wargs, sl@0: wchar_t** wenvp); sl@0: sl@0: IMPORT_C void _exit_r (int code); sl@0: /* sl@0: New function introduced for MRT2.0 sl@0: Reentrant version of popen() function sl@0: */ sl@0: IMPORT_C int _wpopen_r (int *aErrno, const wchar_t* command, const char* mode); sl@0: IMPORT_C int _pclose_r (int *aErrno, int aFid); sl@0: sl@0: IMPORT_C int _shmget_r (int *aErrno, key_t key, int size, int shmflg); sl@0: IMPORT_C void* _shmat_r (int *aErrno, int shmid, const void *shmaddr, int shmflg); sl@0: IMPORT_C int _shmdt_r (int *aErrno, const void *shmaddr); sl@0: sl@0: //forward declarations sl@0: struct shmid_ds; sl@0: struct sembuf; sl@0: sl@0: IMPORT_C int _shmctl_r (int *aErrno,int shmid, int cmd, struct shmid_ds *buf); sl@0: sl@0: IMPORT_C int _semget_r (int *aErrno, key_t key, int nsems, int semflg); sl@0: IMPORT_C int _semop_r (int *aErrno, int semid, struct sembuf *sops, unsigned nsops); sl@0: IMPORT_C int _semctl_r (int *aErrno, int semid, int semnum, int cmd, ...); sl@0: sl@0: IMPORT_C int _select_r (int *aErrno, int maxfd, fd_set *readfds, sl@0: fd_set *writefds, fd_set *exceptfds, struct timeval *tvptr); sl@0: sl@0: IMPORT_C int _wsystem_r (int *aErrno, const wchar_t *command); sl@0: sl@0: typedef void* iconv_t; sl@0: IMPORT_C iconv_t _iconv_open_r(int* aErrno, const char* tocharset, const char* fromcharset); sl@0: sl@0: IMPORT_C size_t _iconv_r(int* aErrno, iconv_t conversion_descriptor, const char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft); sl@0: sl@0: IMPORT_C int _iconv_close_r(int* aErrno, iconv_t conversion_descriptor); sl@0: /* sl@0: Functions to allocate/deallocate on the backend's private heap sl@0: */ sl@0: IMPORT_C void* BackendAlloc(size_t aNBytes); sl@0: IMPORT_C void* BackendReAlloc(void* aPtr, size_t aNBytes); sl@0: IMPORT_C void BackendFree(void* aPtr); sl@0: IMPORT_C void* BackendAllocTLD(size_t aSize); sl@0: sl@0: #define _remove_r(r,x) _unlink_r(r,x) sl@0: #define _wremove_r(r,x) _wunlink_r(r,x) sl@0: sl@0: sl@0: //forward declarations sl@0: struct msqid_ds; sl@0: sl@0: IMPORT_C int _msgget_r(key_t aKey, int aMsgFlag, int* aErrno); sl@0: IMPORT_C int _msgsnd_r(int msqid, const void *msgp, size_t msgsz, int msgflg, int* aErrno); sl@0: IMPORT_C int _msgrcv_r(int msqid, void* msgp, size_t msgsz, long msgtyp, int msgflg, int* aErrno); sl@0: IMPORT_C int _msgctl_r(int msqid, int cmd, struct msqid_ds* buf, int* aErrno); sl@0: sl@0: IMPORT_C int _setecho_r(int *aErrno, int aFd, uint8_t aEchoVal); sl@0: sl@0: //forward declarations sl@0: struct ifreq; sl@0: sl@0: IMPORT_C int _setdefaultif_r(int *aErrno, const struct ifreq* aIfReq); sl@0: IMPORT_C int _unsetdefaultif_r(int *aErrno); sl@0: sl@0: IMPORT_C void *_memcpy_r(void *dst0, const void *src0, size_t length); sl@0: IMPORT_C void *_memmove_r(void *dst0, const void *src0, size_t length); sl@0: sl@0: #ifdef __cplusplus sl@0: } // extern "C" sl@0: #endif sl@0: #endif /* _SYSREENT_H_ */