1 #ifndef __PDCLIB_GLUE_H
2 #define __PDCLIB_GLUE_H __PDCLIB_GLUE_H
3 /* OS glue functions declaration <_PDCLIB_glue.h>
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
9 #include <_PDCLIB_int.h>
10 #include <_PDCLIB_io.h>
13 _PDCLIB_BEGIN_EXTERN_C
15 /* -------------------------------------------------------------------------- */
16 /* OS "glue", part 2 */
17 /* These are the functions you will have to touch, as they are where PDCLib */
18 /* interfaces with the operating system. */
19 /* They operate on data types partially defined by _PDCLIB_config.h. */
20 /* -------------------------------------------------------------------------- */
24 /* A system call that terminates the calling process, returning a given status
27 _PDCLIB_noreturn void _PDCLIB_Exit( int status );
29 /* A system call which allocates n pages of memory and returns a pointer to
30 them. On failure, returns NULL
32 void * _PDCLIB_allocpages( size_t n );
34 /* A system call which frees the n pages of memory pointed to by p */
35 void _PDCLIB_freepages( void * p, size_t n );
37 #ifdef _PDCLIB_HAVE_REALLOCPAGES
38 /* A system call which attempts to reallocate the group of \p on pages starting
39 at \p p, resizing the chunk to be \p nn pages long. If \p mayMove is true,
40 then then the group of pages may move; otherwise, if the group cannot be
41 resized in its current position, failure must be reported.
43 On failure, returns NULL; on success, returns the address of the group of
44 pages (if mayMove == false, then this must be equal to \p p)
46 void * _PDCLIB_reallocpages( void* p, size_t on, size_t nn, bool mayMove);
51 /* Open the file with the given name and mode. Return the file descriptor in
52 * *fd and a pointer to the operations structure in **ops on success.
54 * Return true on success and false on failure.
57 _PDCLIB_fd_t* fd, const _PDCLIB_fileops_t** ops,
58 char const * filename, unsigned int mode );
60 /* A system call that removes a file identified by name. Return zero on success,
63 int _PDCLIB_remove( const char * filename );
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);