libk  Diff

Differences From Artifact [bec7e80543]:

To Artifact [d8d36f64f5]:

  • File mod/kmem/mem.h — part of check-in [e50a476efe] at 2019-08-22 02:52:20 on branch trunk — removed sneaky segfault in x86-64 syscall fn where %r8 (the register that contains the pointer to the syscall arguments from the C syscall wrapper, which need to be copied into the correct registers before the kernel is invoked) gets overwritten if the syscall valency > 5, because of overlapping ccall and syscall ABI argument registers - r8 is clobbered by argument 5 and any further attempts to use it as a ptr segfault at best. also modified the report function so that it immediate cancels compilation if a sub-process reports failure. changed allocator function signatures so they can return a condition code if the kernel reports an error; updated example code so it compiles and runs without fault. (user: lexi, size: 1288) [annotate] [blame] [check-ins using]

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
27
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef KImem
#define KImem
#include <k/type.h>


#ifndef KFclean
#	define Kmsz(e) ( sizeof (e) / sizeof (e) [0] )
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef enum kmcond {
	kmcond_ok,
	kmcond_unnecessary,

	kmcond_fail,
	kmcond_unhandled,
	kmcond_mismatch,
	kmcond_bad_address,








} kmcond;

typedef enum kmkind {
	kmkind_none,
	kmkind_fail,
	kmkind_linear,
	kmkind_heap,
................................................................................
	kmkind kind;
	kmshred shred;
	void* ref;
} kmptr;

/* heap functions */

void*  kmheapa(sz);
kmptr  kmheapao(sz);
kmcond kmheapf(void*);

/* generic functions */

kmcond kmfree(kmptr);
kmkind kmtell(void*);
void kmzero(void*,sz);
void kmozero(kmptr);



>










|






>
>
>
>
>
>
>
>







 







|
|
|







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
27
28
29
30
31
32
33
34
35
36
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef KImem
#define KImem
#include <k/type.h>
#include <k/internal.egroup.h>

#ifndef KFclean
#	define Kmsz(e) ( sizeof (e) / sizeof (e) [0] )
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef enum kmcond {
	kmcond_ok = kmcond_id,
	kmcond_unnecessary,

	kmcond_fail,
	kmcond_unhandled,
	kmcond_mismatch,
	kmcond_bad_address,
	kmcond_bad_lock,
	kmcond_bad_size,
	kmcond_no_room,
	kmcond_too_many,

	/* when something truly should
	 * never happen: */
	kmcond_fail_assert,
} kmcond;

typedef enum kmkind {
	kmkind_none,
	kmkind_fail,
	kmkind_linear,
	kmkind_heap,
................................................................................
	kmkind kind;
	kmshred shred;
	void* ref;
} kmptr;

/* heap functions */

kmcond kmheapa (void**, sz);
kmcond kmheapao(kmptr*, sz);
kmcond kmheapf (void*);

/* generic functions */

kmcond kmfree(kmptr);
kmkind kmtell(void*);
void kmzero(void*,sz);
void kmozero(kmptr);