source: trunk/src/emx/include/InnoTekLIBC/backend.h@ 2299

Last change on this file since 2299 was 2299, checked in by bird, 20 years ago

Merged the signal semaphore handling into the safe sems and made signals use them.

  • Property cvs2svn:cvs-rev set to 1.32
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 37.9 KB
Line 
1/* $Id: backend.h 2299 2005-08-22 01:56:25Z bird $ */
2/** @file
3 *
4 * LIBC - Backend header.
5 *
6 * Copyright (c) 2004 knut st. osmundsen <[email protected]>
7 *
8 *
9 * This file is part of InnoTek LIBC.
10 *
11 * InnoTek LIBC is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * InnoTek LIBC is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with InnoTek LIBC; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#ifndef __InnoTekLIBC_backend_h__
28#define __InnoTekLIBC_backend_h__
29
30#include <sys/cdefs.h>
31#include <sys/types.h>
32#include <sys/_timeval.h>
33#include <sys/resource.h>
34#include <sys/time.h>
35#include <sys/wait.h>
36#include <sys/sem.h>
37#include <sys/shm.h>
38#include <signal.h>
39#include <emx/io.h>
40#include <stdarg.h>
41
42
43__BEGIN_DECLS
44
45#ifndef __LIBC_THREAD_DECLARED
46#define __LIBC_THREAD_DECLARED
47typedef struct __libc_thread *__LIBC_PTHREAD, **__LIBC_PPTHREAD;
48#endif
49struct statfs;
50struct stat;
51
52
53/** @defgroup __libc_Back_thread LIBC Backend - Threads
54 * @{ */
55
56/**
57 * Initiatlize a new thread structure.
58 *
59 * @param pThrd Pointer to the thread structure.
60 * @param pParentThrd Pointer to the thread structure for the parent thread.
61 * If NULL and thread id is 1 then inherit from parent process.
62 * If NULL and thread is not null or no record of parent then
63 * use defaults.
64 */
65void __libc_Back_threadInit(__LIBC_PTHREAD pThrd, const __LIBC_PTHREAD pParentThrd);
66
67/**
68 * Called before the thread structure is freed so the backend
69 * can cleanup its members.
70 *
71 * @param pThrd Pointer to the thread in question.
72 */
73void __libc_Back_threadCleanup(__LIBC_PTHREAD pThrd);
74
75/**
76 * Called in the context of the newly started thread to register
77 * exception handler and to do other init stuff.
78 *
79 * @param pExpRegRec Exception handler registration record on the stack.
80 * To be used for any exception handler registration.
81 */
82void __libc_Back_threadStartup(void *pExpRegRec);
83
84/**
85 * Called in the context of the thread which is to be terminated to
86 * unregister exception handler and to do other final term stuff.
87 *
88 * @param pExpRegRec Exception handler registration record on the stack.
89 * To be used for any exception handler registration.
90 * @remark This is called after __libc_Back_threadCleanup().
91 * @remark It is not called by thread which calls _endthread(), nor for the
92 * main thread.
93 */
94void __libc_Back_threadEnd(void *pExpRegRec);
95
96/**
97 * Suspend execution of the current thread for a given number of nanoseconds
98 * or till a signal is received.
99 *
100 * @returns 0 on success.
101 * @returns -EINVAL if the pReqTS is invalid.
102 * @returns -EINTR if the interrupted by signal.
103
104 * @param ullNanoReq Time to sleep, in nano seconds.
105 * @param pullNanoRem Where to store remaining time (also nano seconds).
106
107 * @remark For relativly small sleeps this api temporarily changes the thread
108 * priority to timecritical (that is, if it's in the normal or idle priority
109 * classes) to increase precision. This means that if a signal or other
110 * asyncronous event is executed, it will be executed at wrong priority.
111 * It also means that if such code changes the priority it will be undone.
112 */
113int __libc_Back_threadSleep(unsigned long long ullNanoReq, unsigned long long *pullNanoRem);
114
115/** @} */
116
117
118/** @defgroup __libc_Back_fs LIBC Backend - File System
119 * @{ */
120
121/**
122 * Get the statistics for the filesystem which pszPath is located on.
123 *
124 * @returns 0 on success.
125 * @returns Negative error code (errno.h) on failure.
126 * @param pszPath The path to somewhere in the filesystem.
127 * @param pStatFs Where to store the obtained information.
128 */
129int __libc_Back_fsStat(const char *pszPath, struct statfs *pStatFs);
130
131/**
132 * Get file system statistics
133 *
134 * @returns 0 on success.
135 * @returns Negative error code (errno.h) on failure.
136 * @param fh The filehandle of any file within the mounted file system.
137 * @param pStatFs Where to store the statistics.
138 */
139int __libc_Back_fsStatFH(int fh, struct statfs *pStatFs);
140
141/**
142 * Get the statistics for all the mounted filesystems.
143 *
144 * @returns Number of returned statfs structs on success.
145 * @returns Number of mounted filesystems on success if paStatFS is NULL
146 * @returns Negative error code (errno.h) on failure.
147 * @param paStatFs Where to to store the statistics.
148 * @param cStatFS Number of structures the array pointed to by paStatFs can hold.
149 * @param fFlags Flags, currently ignored.
150 */
151int __libc_Back_fsStats(struct statfs *paStatFs, unsigned cStatFs, unsigned fFlags);
152
153/**
154 * Schedules all file system buffers for writing.
155 *
156 * See sync() for OS/2 limitations.
157 */
158void __libc_Back_fsSync(void);
159
160/**
161 * Resolves the path into an canonicalized absolute path.
162 *