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

Last change on this file since 1972 was 1972, checked in by bird, 21 years ago

[lf]utimes.

  • Property cvs2svn:cvs-rev set to 1.22
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 29.9 KB
Line 
1/* $Id: backend.h 1972 2005-05-06 03:36:47Z 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 <signal.h>
37#include <emx/io.h>
38
39
40__BEGIN_DECLS
41
42#ifndef __LIBC_THREAD_DECLARED
43#define __LIBC_THREAD_DECLARED
44typedef struct __libc_thread *__LIBC_PTHREAD, **__LIBC_PPTHREAD;
45#endif
46struct statfs;
47struct stat;
48
49
50/** @defgroup __libc_Back_thread LIBC Backend - Threads
51 * @{ */
52
53/**
54 * Initiatlize a new thread structure.
55 *
56 * @param pThrd Pointer to the thread structure.
57 * @param pParentThrd Pointer to the thread structure for the parent thread.
58 * If NULL and thread id is 1 then inherit from parent process.
59 * If NULL and thread is not null or no record of parent then
60 * use defaults.
61 */
62void __libc_Back_threadInit(__LIBC_PTHREAD pThrd, const __LIBC_PTHREAD pParentThrd);
63
64/**
65 * Called before the thread structure is freed so the backend
66 * can cleanup its members.
67 *
68 * @param pThrd Pointer to the thread in question.
69 */
70void __libc_Back_threadCleanup(__LIBC_PTHREAD pThrd);
71
72/**
73 * Called in the context of the newly started thread to register
74 * exception handler and to do other init stuff.
75 *
76 * @param pExpRegRec Exception handler registration record on the stack.
77 * To be used for any exception handler registration.
78 */
79void __libc_Back_threadStartup(void *pExpRegRec);
80
81/**
82 * Called in the context of the thread which is to be terminated to
83 * unregister exception handler and to do other final term stuff.
84 *
85 * @param pExpRegRec Exception handler registration record on the stack.
86 * To be used for any exception handler registration.
87 * @remark This is called after __libc_Back_threadCleanup().
88 * @remark It is not called by thread which calls _endthread(), nor for the
89 * main thread.
90 */
91void __libc_Back_threadEnd(void *pExpRegRec);
92
93/**
94 * Suspend execution of the current thread for a given number of nanoseconds
95 * or till a signal is received.
96 *
97 * @returns 0 on success.
98 * @returns -EINVAL if the pReqTS is invalid.
99 * @returns -EINTR if the interrupted by signal.
100
101 * @param ullNanoReq Time to sleep, in nano seconds.
102 * @param pullNanoRem Where to store remaining time (also nano seconds).
103
104 * @remark For relativly small sleeps this api temporarily changes the thread
105 * priority to timecritical (that is, if it's in the normal or idle priority
106 * classes) to increase precision. This means that if a signal or other
107 * asyncronous event is executed, it will be executed at wrong priority.
108 * It also means that if such code changes the priority it will be undone.
109 */
110int __libc_Back_threadSleep(unsigned long long ullNanoReq, unsigned long long *pullNanoRem);
111
112/** @} */
113
114
115/** @defgroup __libc_Back_fs LIBC Backend - File System
116 * @{ */
117
118/**
119 * Get the statistics for the filesystem which pszPath is located on.
120 *
121 * @returns 0 on success.
122 * @returns Negative error code (errno.h) on failure.
123 * @param pszPath The path to somewhere in the filesystem.
124 * @param pStatFs Where to store the obtained information.
125 */
126int __libc_Back_fsStat(const char *pszPath, struct statfs *pStatFs);
127
128/**
129 * Get file system statistics
130 *
131 * @returns 0 on success.
132 * @returns Negative error code (errno.h) on failure.
133 * @param fh The filehandle of any file within the mounted file system.
134 * @param pStatFs Where to store the statistics.
135 */
136int __libc_Back_fsStatFH(int fh, struct statfs *pStatFs);
137
138/**
139 * Get the statistics for all the mounted filesystems.
140 *
141 * @returns Number of returned statfs structs on success.
142 * @returns Number of mounted filesystems on success if paStatFS is NULL
143 * @returns Negative error code (errno.h) on failure.
144 * @param paStatFs Where to to store the statistics.
145 * @param cStatFS Number of structures the array pointed to by paStatFs can hold.
146 * @param fFlags Flags, currently ignored.
147 */
148int __libc_Back_fsStats(struct statfs *paStatFs, unsigned cStatFs, unsigned fFlags);
149
150/**
151 * Schedules all file system buffers for writing.
152 *
153 * See sync() for OS/2 limitations.
154 */
155void __libc_Back_fsSync(void);
156
157/**
158 * Resolves the path into an canonicalized absolute path.
159 *
160 * @returns 0 on success.
161 * @returns Negative error code (errno.h) on failure.
162 * @param pszPath The path to resolve.
163 * @param pszBuf Where to store the resolved path.
164 * @param cchBuf Size of the buffer.
165 * @param fFlags Combination of __LIBC_BACKFS_FLAGS_RESOLVE_* defines.
166 */
167int __libc_Back_fsPathResolve(const char *pszPath, char *pszBuf, size_t cchBuf, unsigned fFlags);
168/** Flags for __libc_Back_fsPathResolve().
169 * @{ */
170#define __LIBC_BACKFS_FLAGS_RESOLVE_FULL 0
171/** Get the native path instead, no unix root translations. */
172#define __LIBC_BACKFS_FLAGS_RESOLVE_NATIVE 0x10
173/** @} */
174
175
176/**
177 * Changes the default drive of the process.
178 *
179 * @returns 0 on success.
180 * @returns Negative error code (errno.h) on failure.
181 * @param chDrive New default drive.
182 */
183int __libc_Back_fsDriveDefaultSet(char chDrive);
184
185/**
186 * Gets the default drive of the process.
187 *
188 * @returns 0 on success.
189 * @returns Negative error code (errno.h) on failure.
190 * @param pchDrive Where to store the default drive.
191 */
192int __libc_Back_fsDriveDefaultGet(char *pchDrive);
193
194/**
195 * Sets or change the unixroot of the current process.
196 *
197 * @returns 0 on success.
198 * @returns Negative error code (errno.h) on failure.
199 * @param pszNewRoot The new root.
200 */
201int __libc_Back_fsDirChangeRoot(const char *pszNewRoot);
202
203/**
204 * Gets the current directory of the process on a
205 * specific drive or on the current one.
206 *
207 * @returns 0 on success.
208 * @returns Negative error code (errno.h) on failure.
209 * @param pszPath Where to store the path to the current directory.
210 * This will be prefixed with a drive letter if we're
211 * not in the unix tree.
212 * @param cchPath The size of the path buffer.
213 * @param chDrive The drive letter of the drive to get it for.
214 * If '\0' the current dir for the current drive is returned.
215 * @param fFlags Flags for skipping drive letter and slash.
216 */
217int __libc_Back_fsDirCurrentGet(char *pszPath, size_t cchPath, char chDrive, int fFlags);
218
219/** Flags for __libc_Back_fsDirCurrentGet().
220 * @{ */
221#define __LIBC_BACK_FSCWD_NO_DRIVE 1
222#define __LIBC_BACK_FSCWD_NO_ROOT_SLASH 2
223/** @} */
224
225/**
226 * Changes the current directory of the process.
227 *
228 * @returns 0 on success.
229 * @returns Negative error code (errno.h) on failure.
230 * @param pszPath Path to the new current directory of the process.
231 * @param fDrive Force a change of the current drive too.
232 */
233int __libc_Back_fsDirCurrentSet(const char *pszPath, int fDrive);
234
235/**
236 * Creates a new directory.
237 *
238 * @returns 0 on success.
239 * @returns Negative error code (errno.h) on failure.
240 * @param pszPath Path of the new directory.
241 * @param Mode Permissions on the created directory.
242 */
243int __libc_Back_fsDirCreate(const char *pszPath, mode_t Mode);
244
245/**
246 * Removes a new directory.
247 *
248 * @returns 0 on success.
249 * @returns Negative error code (errno.h) on failure.
250 * @param pszPath Path to the directory which is to be removed.
251 */
252int __libc_Back_fsDirRemove(const char *pszPath);
253
254/**
255 * Creates a symbolic link.
256 *
257 * @returns 0 on success.
258 * @returns Negative error code (errno.h) on failure.
259 * @param pszTarget The target of the symlink link.
260 * @param pszSymlink The path to the symbolic link to create.
261 */
262int __libc_Back_fsSymlinkCreate(const char *pszTarget, const char *pszSymlink);
263
264/**
265 * Reads the content of a symbolic link.
266 *
267 * This is weird interface as it will return a truncated result if not
268 * enough buffer space. It is also weird in that there is no string
269 * terminator.
270 *
271 * @returns Number of bytes returned in pachBuf.
272 * @returns Negative error code (errno.h) on failure.
273 * @param pszPath The path to the symlink directory.
274 * @param pachBuf Where to store the symlink value.
275 * @param cchBuf Size of buffer.
276 */
277int __libc_Back_fsSymlinkRead(const char *pszPath, char *pachBuf, size_t cchBuf);
278
279/**
280 * Stats a symbolic link.
281 *
282 * @returns 0 on success.
283 * @returns Negative error code (errno.h) on failure.
284 * @param pszPath Path to the file to stat. If this is a symbolic link
285 * the link it self will be stat'ed.
286 * @param pStat Where to store the file stats.
287 */
288int __libc_Back_fsSymlinkStat(const char *pszPath, struct stat *pStat);
289
290/**
291 * Sets the file access mode of a symlink.
292 *
293 * @returns 0 on success.
294 * @returns Negative error code (errno.h) on failure.
295 * @param pszPath The path to the file to set the mode of.
296 * @param Mode The filemode.
297 */
298int __libc_Back_fsSymlinkModeSet(const char *pszPath, mode_t Mode);
299
300/**
301 * Sets the file times of a symlink.
302 *
303 * @returns 0 on success.
304 * @returns Negative error code (errno.h) on failure.
305 * @param pszPath The path to the file to set the mode of.
306 * @param paTimes Two timevalue structures. If NULL the current time is used.
307 */
308int __libc_Back_fsSymlinkTimesSet(const char *pszPath, const struct timeval *paTimes);
309
310/**
311 * Stats a file.
312 *
313 * @returns 0 on success.
314 * @returns Negative error code (errno.h) on failure.
315 * @param pszPath Path to the file to stat.
316 * @param pStat Where to store the file stats.
317 */
318int __libc_Back_fsFileStat(const char *pszPath, struct stat *pStat);
319
320/**
321 * Gets the file stats for a file by filehandle.
322 *
323 * @returns 0 on success.
324 * @returns Negative error code (errno.h) on failure. The content
325 * of *pStat is undefined.
326 * @param fh Handle to file.
327 * @param pStat Where to store the stats.
328 */
329int __libc_Back_fsFileStatFH(int fh, struct stat *pStat);
330
331/**
332 * Sets the file access mode of a file.
333 *
334 * @returns 0 on success.
335 * @returns Negative error code (errno.h) on failure.
336 * @param pszPath The path to the file to set the mode of.
337 * @param Mode The filemode.
338 */
339int __libc_Back_fsFileModeSet(const char *pszPath, mode_t Mode);
340
341/**
342 * Sets the file access mode of a file by filehandle.
343 *
344 * @returns 0 on success.
345 * @returns Negative error code (errno.h) on failure.
346 * @param fh Handle to file.
347 * @param Mode The filemode.
348 */
349int __libc_Back_fsFileModeSetFH(int fh, mode_t Mode);
350
351/**
352 * Sets the file the times of a file.
353 *
354 * @returns 0 on success.
355 * @returns Negative error code (errno.h) on failure.
356 * @param pszPath The path to the file to set the times of.
357 * @param paTimes Two timevalue structures. If NULL the current time is used.
358 */
359int __libc_Back_fsFileTimesSet(const char *pszPath, const struct timeval *paTimes);
360
361/**
362 * Sets the file the times of a file by filehandle.
363 *
364 * @returns 0 on success.
365 * @returns Negative error code (errno.h) on failure.
366 * @param fh Handle to file.
367 * @param paTimes Two timevalue structures. If NULL the current time is used.
368 */
369int __libc_Back_fsFileTimesSetFH(int fh, const struct timeval *paTimes);
370
371/**
372 * Renames a file or directory.
373 *
374 * @returns 0 on success.
375 * @returns Negative error code (errno.h) on failure.
376 * @param pszPathOld Old file path.
377 * @param pszPathNew New file path.
378 *
379 * @remark OS/2 doesn't preform the deletion of the pszPathNew atomically.
380 */
381int __libc_Back_fsRename(const char *pszPathOld, const char *pszPathNew);
382
383/**
384 * Unlinks a file, directory, symlink, dev, pipe or socket.
385 *
386 * @returns 0 on success.
387 * @returns Negative error code (errno.h) on failure.
388 * @param pszPath Path to the filesystem file/dir/symlink/whatever to remove.
389 */
390int __libc_Back_fsUnlink(const char *pszPath);
391
392
393/** @defgroup __libc_Back_io LIBC Backend - I/O and File Management.
394 * @{ */
395
396/**
397 * Opens a file.
398 *
399 * @returns Filehandle to the opened file on success.
400 * @returns Negative error code (errno.h) on failure.
401 * @param pszFile Path to the file.
402 * @param fFlags Open flags.
403 * @param cbInitial Initial filesize.
404 * @param Mode The specified permission mask.
405 * @param fLibc LIBC filehandle flags.
406 * @param ppFH Where to store the LIBC filehandle structure which was created
407 * for the opened file.
408 */
409int __libc_Back_ioFileOpen(const char *pszFile, int fFlags, off_t cbInitial, mode_t Mode, unsigned fLibc, PLIBCFH *ppFH);
410
411/**
412 * Change the current position of a file stream and get the new position.
413 *
414 * @returns new file offset on success.
415 * @returns Negative error code (errno) on failure.
416 * @param hFile File handle to preform seek operation on.
417 * @param off Offset to seek to.
418 * @param iMethod The seek method. SEEK_CUR, SEEK_SET or SEEK_END.
419 */
420off_t __libc_Back_ioSeek(int hFile, off_t off, int iMethod);
421
422/**
423 * Sets the size of an open file.
424 *
425 * When expanding a file the contents of the allocated
426 * space is undefined.
427 *
428 * @returns 0 on success.
429 * @returns Negative error code (errno.h) on failure.
430 * @param fh Handle to the file which size should be changed.
431 * @param cbFile The new filesize.
432 * @param fZero If set any new allocated file space will be
433 * initialized to zero.
434 */
435int __libc_Back_ioFileSizeSet(int fh, __off_t cbFile, int fZero);
436
437/**
438 * Try resolve a filehandle to a path.
439 *
440 * @returns 0 on success.
441 * @returns Negative error code (errno.h) on failure.
442 * @param fh The file handle.
443 * @param pszPath Where to store the path.
444 * @param cchPath The size of he buffer pointed to by pszPath.
445 */
446int __libc_Back_ioFHToPath(int fh, char *pszPath, size_t cchPath);
447
448/** @} */
449
450/** @} */
451
452
453/** @defgroup __libc_Back_ldr LIBC Backend - Loader
454 * @{ */
455
456/**
457 * Opens a shared library.
458 *
459 * @returns 0 on success.
460 * @returns Native error number.
461 * @param pszLibrary Name of library to load.
462 * @param fFlags Flags - ignored.
463 * @param ppvModule Where to store the handle.
464 * @param pszError Where to store error information.
465 * @param cchError Size of error buffer.
466 */
467int __libc_Back_ldrOpen(const char *pszLibrary, int fFlags, void **ppvModule, char *pszError, size_t cchError);
468
469/**
470 * Finds a symbol in an open shared library.
471 *
472 * @returns 0 on success.
473 * @returns Native error number.
474 * @param pvModule Module handle returned by __libc_Back_ldrOpen();
475 * @param pszSymbol Name of the symbol we're to find in pvModule.
476 * @param ppfn Where to store the symbol address.
477 */
478int __libc_Back_ldrSymbol(void *pvHandle, const char *pszSymbol, void **ppfn);
479
480/**
481 * Closes a shared library.
482 *
483 * @returns 0 on success.
484 * @returns Native error number.
485 * @param pvModule Module handle returned by __libc_Back_ldrOpen();
486 */
487int __libc_Back_ldrClose(void *pvModule);
488
489
490/** @} */
491
492
493
494
495
496/** @defgroup __libc_Back_misc LIBC Backend - Miscellaneous
497 * @{ */
498
499/**
500 * Gets the system load averages.
501 * The load is the average values of ready and running threads(/processes)
502 * over the last 1, 5 and 15 minuttes.
503 *
504 * @returns 0 on success.
505 * @returns Negative error code (errno.h) on failure.
506 * @param pardAvgs Where to store the samples.
507 * @param cAvgs Number of samples to get. Max is 3.
508 * @remark See OS/2 limitations in getloadavg().
509 */
510int __libc_Back_miscLoadAvg(double *pardAvgs, unsigned cAvgs);
511
512/** @} */
513
514
515/** @defgroup __libc_Back_Signals LIBC Backend - Signals and Exceptions
516 * @{ */
517
518#if defined(END_OF_CHAIN) && defined(INCL_DOSEXCEPTIONS)
519/**
520 * The LIBC Sys Backend exception handler.
521 *
522 * @returns XCPT_CONTINUE_SEARCH or XCPT_CONTINUE_EXECUTION.
523 * @param pXcptRepRec Report record.
524 * @param pXcptRegRec Registration record.
525 * @param pCtx Context record.
526 * @param pvWhatEver Not quite sure what this is...
527 */
528ULONG _System __libc_Back_exceptionHandler(PEXCEPTIONREPORTRECORD pXcptRepRec,
529 PEXCEPTIONREGISTRATIONRECORD pXcptRegRec,
530 PCONTEXTRECORD pCtx,
531 PVOID pvWhatEver);
532#endif
533
534/** @} */
535
536
537/** @defgroup __libc_Back_MMan LIBC Backend - Memory Management
538 * @{ */
539
540/**
541 * Change the memory protection attributes of a range of pages.
542 * This function supports the crossing of object boundaries and works
543 * on any memory the native apis works on.
544 *
545 * @returns Negative error code (errno.h) on failure.
546 * @param pv Pointer to first page - page aligned!
547 * @param cb Size of the ranage - page aligned!
548 * @param fFlags The PROT_* flags to replace the current flags with.
549 */
550int __libc_Back_mmanProtect(void *pv, size_t cb, unsigned fFlags);
551
552/** @} */
553
554
555/** @defgroup __libc_Back_signal LIBC Backend - Signals
556 * @{
557 */
558
559/** @defgroup __libc_Back_signalRaise_return __libc_back_signalRaise() returns.
560 * These are only valid for positive return values.
561 * @{ */
562/** Try restart any interrupted system call. */
563#define __LIBC_BSRR_RESTART 0x01
564/** Go ahead interrupt system call in progress. */
565#define __LIBC_BSRR_INTERRUPT 0x02
566/** If set execution should be resumed. */
567#define __LIBC_BSRR_CONTINUE 0x10
568/** If set execution should not be resumed but the signal should be passed
569 * on to the system. */
570#define __LIBC_BSRR_PASSITON 0x20
571/** If set the passed in SIGQUEUED structure was used. */
572#define __LIBC_BSRR_USED_QUEUED 0x40
573/** @} */
574
575/** @defgroup __libc_back_signalRaise_flags __libc_back_signalRaise() flags.
576 * @{ */
577/** The signal is thread specific and must be delivered to the current thread. */
578#define __LIBC_BSRF_THREAD 0x01
579/** The signal was send from an unknown process. */
580#define __LIBC_BSRF_EXTERNAL 0x02
581/** The signal was generated by the hardware (i.e. CPUs and such). */
582#define __LIBC_BSRF_HARDWARE 0x04
583/** The signal should be queued. */
584#define __LIBC_BSRF_QUEUED 0x08
585/** @} */
586
587
588/**
589 * Raises a signal in the current process.
590 *
591 * @returns On success a flag mask out of the __LIBC_BSRR_* #defines is returned.
592 * @returns On failure a negative error code (errno.h) is returned.
593 * @param iSignalNo Signal to raise.
594 * @param pSigInfo Pointer to signal info for this signal.
595 * NULL is allowed.
596 * @param pvXcptOrQueued Exception handler parameter list.
597 * Or if __LIBC_BSRF_QUEUED is set, a pointer to locally malloced
598 * SIGQUEUED node.
599 * @param fFlags Flags of the #defines __LIBC_BSRF_* describing how to
600 * deliver the signal.
601 */
602int __libc_Back_signalRaise(int iSignalNo, const siginfo_t *pSigInfo, void *pvXcptOrQueued, unsigned fFlags);
603
604/**
605 * Queue a signal.
606 *
607 * @returns 0 on success.
608 * @returns -1 on failure, errno set.
609 * @param pid The target process id.
610 * @param iSignalNo Signal to queue.
611 * @param SigVal The value to associate with the signal.
612 */
613int __libc_Back_signalQueue(pid_t pid, int iSignalNo, const union sigval SigVal);
614
615/**
616 * Send a signal to a process.
617 *
618 * Special case for iSignalNo equal to 0, where no signal is sent but permissions to
619 * do so is checked.
620 *
621 * @returns 0 on if signal sent.
622 * @returns -errno on failure.
623 *
624 * @param pid Process Id of the process which the signal is to be sent to.
625 * @param iSignalNo The signal to send.
626 * If 0 no signal is sent, but error handling is done as if.
627 */
628int __libc_Back_signalSendPid(pid_t pid, int iSignalNo);
629
630/**
631 * Sends a signal to a process group.
632 *
633 * Special case for iSignalNo equal to 0, where no signal is sent but permissions to
634 * do so is checked.
635 *
636 * @returns 0 on if signal sent.
637 * @returns -errno on failure.
638 *
639 * @param pgrp Process group (positive).
640 * 0 means the process group of this process.
641 * 1 means all process in the system. (not implemented!)
642 * @param iSignalNo Signal to send to all the processes in the group.
643 * If 0 no signal is sent, but error handling is done as if.
644 */
645int __libc_Back_signalSendPGrp(pid_t pgrp, int iSignalNo);
646
647/**
648 * sigaction worker; queries and/or sets the action for a signal.
649 *
650 * @returns 0 on success.
651 * @returns Negative error code (errno) on failure.
652 * @param iSignalNo Signal number.
653 * @param pSigAct Pointer to new signal action.
654 * If NULL no update is done.
655 * @param pSigActOld Where to store the old signal action.
656 * If NULL nothing is attempted stored.
657 */
658int __libc_Back_signalAction(int iSignalNo, const struct sigaction *pSigAct, struct sigaction *pSigActOld);
659
660/**
661 * Change interrupt/restart system call properties for a signal.
662 *
663 * @returns 0 on success.
664 * @returns Negative error code (errno) on failure.
665 * @param iSignalNo Signal number to change interrupt/restart
666 * properties for.
667 * @param fFlag If set Then clear the SA_RESTART from the handler action.
668 * If clear Then set the SA_RESTART from the handler action.
669 * @remark The SA_RESTART flag is inherited when using signal().
670 */
671int __libc_Back_signalInterrupt(int iSignalNo, int fFlag);
672
673/**
674 * Changes and/or queries the alternative signal stack settings of a thread.
675 *
676 * @returns 0 on success.
677 * @returns Negative error number (errno.h) on failure.
678 * @param pThrd Thread which signal stack to change and/or query.
679 * @param pStack New stack settings. (Optional)
680 * @param pOldStack Old stack settings. (Optional)
681 */
682int __libc_Back_signalStack(__LIBC_PTHREAD pThrd, const stack_t *pStack, stack_t *pOldStack);
683
684/**
685 * Block or unblock signal deliveries of a thread.
686 *
687 * @returns 0 on success.
688 * @returns Negative error code (errno) on failure.
689 * @param pThrd Thread to apply this to.
690 * @param iHow Describes the action taken if pSigSetNew not NULL. Recognized
691 * values are SIG_BLOCK, SIG_UNBLOCK or SIG_SETMASK.
692 *
693 * SIG_BLOCK means to or the sigset pointed to by pSigSetNew with
694 * the signal mask for the current thread.
695 * SIG_UNBLOCK means to and the 0 complement of the sigset pointed
696 * to by pSigSetNew with the signal mask of the current thread.
697 * SIG_SETMASK means to set the signal mask of the current thread
698 * to the sigset pointed to by pSigSetNew.
699 *
700 * @param pSigSetNew Pointer to signal set which will be applied to the current
701 * threads signal mask according to iHow. If NULL no change
702 * will be made the the current threads signal mask.
703 * @param pSigSetOld Where to store the current threads signal mask prior to applying
704 * pSigSetNew to it. This parameter can be NULL.
705 */
706int __libc_Back_signalMask(__LIBC_PTHREAD pThrd, int iHow, const sigset_t * __restrict pSigSetNew, sigset_t * __restrict pSigSetOld);
707
708/**
709 * Wait for one or more signals and remove and return the first of them
710 * to occur.
711 *
712 * Will return immediately if one of the signals is already pending. If more than
713 * one signal is pending the signal with highest priority will be returned.
714 *
715 * @returns Signal number on success.
716 * @returns Negative error code (errno) on failure.
717 * @param pSigSet Signals to wait for.
718 * @param pSigInfo Where to store the signal info for the signal
719 * that we accepted.
720 * @param pTimeout Timeout specification. If NULL wait for ever.
721 */
722int __libc_Back_signalWait(const sigset_t *pSigSet, siginfo_t *pSigInfo, const struct timespec *pTimeout);
723
724/**
725 * Suspends the current thread till a signal have been handled.
726 *
727 * @returns Negative error code (errno) on failure. (always fails)
728 * @param pSigSet Temporary signal mask for the thread.
729 */
730int __libc_Back_signalSuspend(const sigset_t *pSigSet);
731
732/**
733 * Gets the set of signals which are blocked by the current thread and are
734 * pending on the process or the calling thread.
735 *
736 * @returns 0 indicating success.
737 * @returns Negative error code (errno) on failure.
738 * @param pSigSet Pointer to signal set where the result is to be stored.
739 */
740int __libc_Back_signalPending(sigset_t *pSigSet);
741
742/**
743 * Queries and/or starts/stops a timer.
744 *
745 * @returns 0 on success.
746 * @returns Negative error code (errno.h) on failure.
747 * @param iWhich Which timer to get, any of the ITIMER_* #defines.
748 * OS/2 only supports ITIMER_REAL.
749 * @param pValue Where to store the value.
750 * Optional. If NULL pOldValue must not be NULL.
751 * @param pOldValue Where to store the old value.
752 * Optional. If NULL pValue must not be NULL.
753 */
754int __libc_Back_signalTimer(int iWhich, const struct itimerval *pValue, struct itimerval *pOldValue);
755
756
757
758/** @} */
759
760
761
762/** @defgroup grp_Back_process LIBC Backend - Process Management
763 * @{ */
764
765/**
766 * Waits/polls for on one or more processes to change it's running status.
767 *
768 * @returns 0 on success, pSigInfo containing status info.
769 * @returns -1 and errno on failure.
770 * @param enmIdType What kind of process specification Id contains.
771 * @param Id Process specification of the enmIdType sort.
772 * @param pSigInfo Where to store the result.
773 * @param fOptions The WEXITED, WUNTRACED, WSTOPPED and WCONTINUED flags are used to
774 * select the events to report. WNOHANG is used for preventing the api
775 * from blocking. And WNOWAIT is used for peeking.
776 * @param pResUsage Where to store the reported resources usage for the child.
777 * Optional and not implemented on OS/2.
778 */
779int __libc_Back_processWait(idtype_t enmIdType, id_t Id, siginfo_t *pSigInfo, unsigned fOptions, struct rusage *pUsage);
780
781/**
782 * Gets the real user id of the current process.
783 * @returns Real user id.
784 */
785uid_t __libc_Back_processGetUid(void);
786
787/**
788 * Gets the effective user id of the current process.
789 * @returns Effective user id.
790 */
791uid_t __libc_Back_processGetEffUid(void);
792
793/**
794 * Sets the effective user id of the current process.
795 * If the caller is superuser real and saved user id are also set.
796 *
797 * @returns 0 on success.
798 * @returns Negative error code (errno) on failure.
799 * @param uid New effective user id.
800 * For superusers this is also the new real and saved user id.
801 */
802int __libc_Back_processSetUid(uid_t uid);
803
804/**
805 * Sets the real, effective and saved user ids of the current process.
806 * Unprivilegde users can only set them to the real user id, the
807 * effective user id or the saved user id.
808 *
809 * @returns 0 on success.
810 * @returns Negative error code (errno) on failure.
811 * @param ruid New real user id. Ignore if -1.
812 * @param euid New effective user id. Ignore if -1.
813 * @param svuid New Saved user id. Ignore if -1.
814 */
815int __libc_Back_processSetUidAll(uid_t ruid, uid_t euid, uid_t svuid);
816
817
818/**
819 * Gets the real group id of the current process.
820 * @returns Real group id.
821 */
822gid_t __libc_Back_processGetGid(void);
823
824/**
825 * Gets the effective group id of the current process.
826 * @returns Effective group id.
827 */
828gid_t __libc_Back_processGetEffGid(void);
829
830/**
831 * Sets the effective group id of the current process.
832 * If the caller is superuser real and saved group id are also set.
833 *
834 * @returns 0 on success.
835 * @returns Negative error code (errno) on failure.
836 */
837int __libc_Back_processSetGid(gid_t gid);
838
839/**
840 * Sets the real, effective and saved group ids of the current process.
841 * Unprivilegde users can only set them to the real group id, the
842 * effective group id or the saved group id.
843 *
844 * @returns 0 on success.
845 * @returns Negative error code (errno) on failure.
846 * @param rgid New real group id. Ignore if -1.
847 * @param egid New effective group id. Ignore if -1.
848 * @param svgid New Saved group id. Ignore if -1.
849 */
850int __libc_Back_processSetGidAll(gid_t rgid, gid_t egid, gid_t svgid);
851
852/**
853 * Gets the most favourable priority of a process, group of processes
854 * or all processed owned by a user.
855 *
856 * @returns 0 on success.
857 * @returns Negative error code (errno.h) on failure.
858 * @param iWhich PRIO_PROCESS, PRIO_PGRP, or PRIO_USER.
859 * @param idWho Id of the type specified by iWhich. 0 means the current process/pgrp/user.
860 * @param piPrio Where to store the priority.
861 */
862int __libc_Back_processGetPriority(int iWhich, id_t idWho, int *piPrio);
863
864/**
865 * Sets the priority of a process, a group of processes
866 * or all processed owned by a user.
867 *
868 * @returns 0 on success.
869 * @returns Negative error code (errno.h) on failure.
870 * @param iWhich PRIO_PROCESS, PRIO_PGRP, or PRIO_USER.
871 * @param idWho Id of the type specified by iWhich. 0 means the current process/pgrp/user.
872 * @param iPrio The new priority.
873 */
874int __libc_Back_processSetPriority(int iWhich, id_t idWho, int iPrio);
875
876
877/** @} */
878
879
880/** @defgroup grp_Back_time LIBC Backend - Time Management
881 * @{ */
882
883/**
884 * Gets the current high-resolution timestamp as nanoseconds.
885 *
886 * @returns nanosecond timestamp.
887 */
888hrtime_t __libc_Back_timeHighResNano(void);
889
890/** @} */
891
892__END_DECLS
893
894#endif
Note: See TracBrowser for help on using the repository browser.