]> pd.if.org Git - pdclib/blob - internals/_PDCLIB_glue.h
PDCLIB-8: First phase of intergation of new I/O backend system (with minimal
[pdclib] / internals / _PDCLIB_glue.h
1 #ifndef _PDCLIB_GLUE_H
2 #define _PDCLIB_GLUE_H
3 /* $Id$ */
4
5 /* OS glue functions declaration <_PDCLIB_glue.h>
6
7    This file is part of the Public Domain C Library (PDCLib).
8    Permission is granted to use, modify, and / or redistribute at will.
9 */
10
11 #include <_PDCLIB_int.h>
12 #include <_PDCLIB_io.h>
13 #include <stdbool.h>
14 #include <stddef.h>
15 _PDCLIB_BEGIN_EXTERN_C
16
17 /* -------------------------------------------------------------------------- */
18 /* OS "glue", part 2                                                          */
19 /* These are the functions you will have to touch, as they are where PDCLib   */
20 /* interfaces with the operating system.                                      */
21 /* They operate on data types partially defined by _PDCLIB_config.h.          */
22 /* -------------------------------------------------------------------------- */
23
24 /* stdlib.h */
25
26 /* A system call that terminates the calling process, returning a given status
27    to the environment.
28 */
29 _PDCLIB_noreturn void _PDCLIB_Exit( int status );
30
31 /* A system call which allocates n pages of memory and returns a pointer to 
32    them. On failure, returns NULL
33 */
34 void * _PDCLIB_allocpages( size_t n );
35
36 /* A system call which frees the n pages of memory pointed to by p */
37 void _PDCLIB_freepages( void * p, size_t n );
38
39 #ifdef _PDCLIB_HAVE_REALLOCPAGES
40 /* A system call which attempts to reallocate the group of \p on pages starting
41    at \p p, resizing the chunk to be \p nn pages long. If \p mayMove is true, 
42    then then the group of pages may move; otherwise, if the group cannot be 
43    resized in its current position, failure must be reported.
44
45    On failure, returns NULL; on success, returns the address of the group of 
46    pages (if mayMove == false, then this must be equal to \p p)
47 */
48 void * _PDCLIB_reallocpages( void* p, size_t on, size_t nn, bool mayMove);
49 #endif
50
51 /* stdio.h */
52
53 /* Open the file with the given name and mode. Return the file descriptor in 
54  * *fd and a pointer to the operations structure in **ops on success.
55  *
56  * Return true on success and false on failure.
57  */
58 bool _PDCLIB_open( 
59    _PDCLIB_fd_t* fd, const _PDCLIB_fileops_t** ops,
60    char const * filename, unsigned int mode );
61
62 /* A system call that removes a file identified by name. Return zero on success,
63    non-zero otherwise.
64 */
65 int _PDCLIB_remove( const char * filename );
66
67 /* A system call that renames a file from given old name to given new name.
68    Return zero on success, non-zero otherwise. In case of failure, the file
69    must still be accessible by old name. Any handling of open files etc. is
70    done by standard rename() already.
71 */
72 int _PDCLIB_rename( const char * old, const char * newn);
73
74 _PDCLIB_END_EXTERN_C
75 #endif