Differences From
Artifact [6a14dc9781]:
1 1 #include <k/mem.h>
2 2 #include <k/core.h>
3 3 #include <k/def.h>
4 4 #include <k/type.h>
5 -#include <posix.h>
6 5 /* heapf.c - kmheapf() "heap free"
7 6 * ~ lexi hale <lexi@hale.su>
8 7 * kmheapf() frees a region on the heap à la libc free()
9 8 * see also: kmheapa() "heap alloc"
10 9 */
11 10
12 -/* we define all platform functions here,
13 - * whether or not they're for the correct
14 - * platform - only the ones actually called
15 - * by the generated code will be linked,
16 - * linker errors are our friend here! */
11 +/* arch specific headers */
12 +#ifdef KFenv_posix
13 +# include <posix/posix.h>
14 +#endif
15 +
16 +/* we define all our platform functions here, whether or not
17 + * they're for the correct platform - only the ones that are
18 + * called by the preprocessed form of the code will actually
19 + * be linked, linker errors are our friend here! */
17 20 extern int kmem_platform_munmap(void* addr, unsigned long sz);
18 21
19 22 kmcond kmheapf(void* ptr) {
20 23 /* take an object allocated on the heap and free it,
21 24 * returning kmcond_ok on success or an appropriate
22 25 * value on failure. */
23 26 struct kmbox* header = (kmbox*)
................................................................................
34 37 if(kmem_platform_munmap(header, total) == -1) {
35 38 /* we don't need to bother recovering errno;
36 39 * there's only one possible munmap error */
37 40 return kmcond_bad_address;
38 41 }
39 42
40 43 # else
41 - Knoimpl(kmheapa,KVos);
44 + Knoimpl(kmheapf,KVos);
42 45 # error missing implementation
43 46 # endif
44 47 return kmcond_ok;
45 48 }