]> pd.if.org Git - pdclib/blob - internals/_PDCLIB_glue.h
remove() implemented directly without glue trampoline.
[pdclib] / internals / _PDCLIB_glue.h
1 /* OS glue functions declaration <_PDCLIB_glue.h>
2
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6
7 #ifndef __PDCLIB_GLUE_H
8 #define __PDCLIB_GLUE_H __PDCLIB_GLUE_H
9
10 #include "_PDCLIB_int.h"
11 #include "_PDCLIB_io.h"
12
13 #include <stdbool.h>
14 #include <stddef.h>
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
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 /* -------------------------------------------------------------------------- */
26
27 /* stdlib.h */
28
29 /* A system call that terminates the calling process, returning a given status
30    to the environment.
31 */
32 _PDCLIB_noreturn void _PDCLIB_Exit( int status );
33
34 /* A system call which allocates n pages of memory and returns a pointer to 
35    them. On failure, returns NULL
36 */
37 void * _PDCLIB_allocpages( size_t n );
38
39 /* A system call which frees the n pages of memory pointed to by p */
40 void _PDCLIB_freepages( void * p, size_t n );
41
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.
47
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)
50 */
51 void * _PDCLIB_reallocpages( void* p, size_t on, size_t nn, bool mayMove);
52 #endif
53
54 /* stdio.h */
55
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.
58  *
59  * Return true on success and false on failure.
60  */
61 bool _PDCLIB_open( 
62    _PDCLIB_fd_t* fd, const _PDCLIB_fileops_t** ops,
63    char const * filename, unsigned int mode );
64
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.
69 */
70 int _PDCLIB_rename( const char * old, const char * newn);
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif