libk  Diff

Differences From Artifact [6a14dc9781]:

To Artifact [3d67513f54]:


1
2
3
4
5
6
7
8
9
10
11





12
13
14
15

16
17
18
19
20
21
22
23
..
34
35
36
37
38
39
40
41
42
43
44
45
#include <k/mem.h>
#include <k/core.h>
#include <k/def.h>
#include <k/type.h>
#include <posix.h>
/* heapf.c - kmheapf() "heap free"
 * ~ lexi hale <lexi@hale.su>
 * kmheapf() frees a region on the heap à la libc free()
 * see also: kmheapa() "heap alloc"
 */






/* we define all platform functions here,
 * whether or not they're for the correct
 * platform - only the ones actually called
 * by the generated code will be linked,

 * linker errors are our friend here! */
extern int kmem_platform_munmap(void* addr, unsigned long sz);

kmcond kmheapf(void* ptr) {
	/* take an object allocated on the heap and free it,
	 * returning kmcond_ok on success or an appropriate
	 * value on failure. */
	struct kmbox* header = (kmbox*)
................................................................................
		if(kmem_platform_munmap(header, total) == -1) {
			/* we don't need to bother recovering errno;
			 * there's only one possible munmap error */
			return kmcond_bad_address;
		}

#	else
		Knoimpl(kmheapa,KVos);
#		error missing implementation
#	endif
	return kmcond_ok;
}




<






>
>
>
>
>
|
<
|
<
>
|







 







|




1
2
3
4

5
6
7
8
9
10
11
12
13
14
15
16

17

18
19
20
21
22
23
24
25
26
..
37
38
39
40
41
42
43
44
45
46
47
48
#include <k/mem.h>
#include <k/core.h>
#include <k/def.h>
#include <k/type.h>

/* heapf.c - kmheapf() "heap free"
 * ~ lexi hale <lexi@hale.su>
 * kmheapf() frees a region on the heap à la libc free()
 * see also: kmheapa() "heap alloc"
 */

/* arch specific headers */
#ifdef KFenv_posix
#	include <posix/posix.h>
#endif

/* we define all our platform functions here, whether or not

 * they're for the correct platform - only the ones that are

 * called by the preprocessed form of the code will actually
 * be linked, linker errors are our friend here! */
extern int kmem_platform_munmap(void* addr, unsigned long sz);

kmcond kmheapf(void* ptr) {
	/* take an object allocated on the heap and free it,
	 * returning kmcond_ok on success or an appropriate
	 * value on failure. */
	struct kmbox* header = (kmbox*)
................................................................................
		if(kmem_platform_munmap(header, total) == -1) {
			/* we don't need to bother recovering errno;
			 * there's only one possible munmap error */
			return kmcond_bad_address;
		}

#	else
		Knoimpl(kmheapf,KVos);
#		error missing implementation
#	endif
	return kmcond_ok;
}