libk  Check-in [f37ee769c9]

Overview
Comment:add tests for linear allocators, fix dumb bug in kmheapf() that caused it to return an error on success
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f37ee769c91b088425abf2df679370c4c9d82a0d738c1f4d37902a2c65b82bd8
User & Date: lexi on 2019-08-22 08:52:25
Other Links: manifest | tags
Context
2019-08-22
20:04
fix typo check-in: 957b5fa848 user: lexi tags: trunk
08:52
add tests for linear allocators, fix dumb bug in kmheapf() that caused it to return an error on success check-in: f37ee769c9 user: lexi tags: trunk
08:45
check in missing files check-in: 269baab90a user: lexi tags: trunk
Changes

Modified mod/kcore/testbin.exe.c from [2c9c964882] to [175e42b805].

26
27
28
29
30
31
32







33
34
	if (alloc.cond != kmcond_ok) return kbad_mem;
	
	void* region = alloc.raw;
	kmzero(region,2048);

	if (kmheapf(region) >= kmcond_fail) return kbad_mem;








	return kbad_ok;
}







>
>
>
>
>
>
>


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
	if (alloc.cond != kmcond_ok) return kbad_mem;
	
	void* region = alloc.raw;
	kmzero(region,2048);

	if (kmheapf(region) >= kmcond_fail) return kbad_mem;

	void* top = kmlini();
	kmres rst = kmlina(1230);
	if(rst.cond != kmcond_ok) return kbad_mem;

	kmres rst2 = kmlina(789);
	if(rst2.cond != kmcond_ok) return kbad_mem;

	return kbad_ok;
}

Modified mod/kmem/heapf.fn.c from [fd2ee0e61b] to [868113c60d].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
		 * of MAP_ANONYMOUS. munmap needs to be told the size of
		 * the region to unmap (free), which kmheapa() stores at
		 * (ptr - sizeof sz). see kmheap.c for details. */
		k_platform_syscall_arg args[] = { (sz)header, total };
		struct k_platform_syscall_answer r = k_platform_syscall
			(k_platform_syscall_munmap, Kmsz(args), args);

		if(r.error==0) {
			/* we don't need to bother recovering the error
			 * code, there's only one possible munmap error */
			return kmcond_bad_address;
		}

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







|











33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
		 * of MAP_ANONYMOUS. munmap needs to be told the size of
		 * the region to unmap (free), which kmheapa() stores at
		 * (ptr - sizeof sz). see kmheap.c for details. */
		k_platform_syscall_arg args[] = { (sz)header, total };
		struct k_platform_syscall_answer r = k_platform_syscall
			(k_platform_syscall_munmap, Kmsz(args), args);

		if(r.error!=0) {
			/* we don't need to bother recovering the error
			 * code, there's only one possible munmap error */
			return kmcond_bad_address;
		}

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