1 /* OS glue functions declaration <_PDCLIB_glue.h>
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
7 #ifndef __PDCLIB_GLUE_H
8 #define __PDCLIB_GLUE_H __PDCLIB_GLUE_H
10 #include "_PDCLIB_int.h"
11 #include "_PDCLIB_io.h"
20 /* -------------------------------------------------------------------------- */
21 /* OS "glue", part 2 */
22 /* These are the functions you will have to touch, as they are where PDCLib */
23 /* interfaces with the operating system. */
24 /* They operate on data types partially defined by _PDCLIB_config.h. */
25 /* -------------------------------------------------------------------------- */
29 /* A system call that terminates the calling process, returning a given status
32 _PDCLIB_noreturn void _PDCLIB_Exit( int status );
34 /* A system call which allocates n pages of memory and returns a pointer to
35 them. On failure, returns NULL
37 void * _PDCLIB_allocpages( size_t n );
39 /* A system call which frees the n pages of memory pointed to by p */
40 void _PDCLIB_freepages( void * p, size_t n );
42 #ifdef _PDCLIB_HAVE_REALLOCPAGES
43 /* A system call which attempts to reallocate the group of \p on pages starting
44 at \p p, resizing the chunk to be \p nn pages long. If \p mayMove is true,
45 then then the group of pages may move; otherwise, if the group cannot be
46 resized in its current position, failure must be reported.
48 On failure, returns NULL; on success, returns the address of the group of
49 pages (if mayMove == false, then this must be equal to \p p)
51 void * _PDCLIB_reallocpages( void* p, size_t on, size_t nn, bool mayMove);
56 /* Open the file with the given name and mode. Return the file descriptor in
57 * *fd and a pointer to the operations structure in **ops on success.
59 * Return true on success and false on failure.
62 _PDCLIB_fd_t* fd, const _PDCLIB_fileops_t** ops,
63 char const * filename, unsigned int mode );
65 /* A system call that renames a file from given old name to given new name.
66 Return zero on success, non-zero otherwise. In case of failure, the file
67 must still be accessible by old name. Any handling of open files etc. is
68 done by standard rename() already.
70 int _PDCLIB_rename( const char * old, const char * newn);