libk  Diff

Differences From 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]

To Artifact [0dc09a3b20]:


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
..
66
67
68
69
70
71
72









73
74
75
76

77


78
79
80
81
82
83
84
85
86
87
88
89
90
91
	/* when something truly should
	 * never happen: */
	kmcond_fail_assert,
} kmcond;

typedef enum kmkind {
	kmkind_none,
	kmkind_fail,
	kmkind_linear,
	kmkind_heap,
	kmkind_pool,
	kmkind_ref,
	kmkind_tree
} kmkind;

................................................................................

typedef struct kmptr {
	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);


#ifdef __cplusplus
}
#endif

#endif







|







 







>
>
>
>
>
>
>
>
>


|
<
>

>
>




<









27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92

93
94
95
96
97
98
99
100
101
	/* when something truly should
	 * never happen: */
	kmcond_fail_assert,
} kmcond;

typedef enum kmkind {
	kmkind_none,
	kmkind_broken,
	kmkind_linear,
	kmkind_heap,
	kmkind_pool,
	kmkind_ref,
	kmkind_tree
} kmkind;

................................................................................

typedef struct kmptr {
	kmkind kind;
	kmshred shred;
	void* ref;
} kmptr;

/* this struct is used to return both a pointer
 * and an error value at the same time. */
typedef struct kmres {
	kmcond cond;
	union {
		void* raw;
		kmptr ptr;
	};
} kmres;
/* heap functions */

kmres  kmheapa (sz);

kmres  kmheapo (sz);
kmcond kmheapf (void*);
kmres  kmlina  (sz);
void*  kmlini  (void);

/* generic functions */

kmcond kmfree(kmptr);

void kmzero(void*,sz);
void kmozero(kmptr);


#ifdef __cplusplus
}
#endif

#endif