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      1   #ifndef KImem
     2      2   #define KImem
     3      3   #include <k/type.h>
            4  +#include <k/internal.egroup.h>
     4      5   
     5      6   #ifndef KFclean
     6      7   #	define Kmsz(e) ( sizeof (e) / sizeof (e) [0] )
     7      8   #endif
     8      9   
     9     10   #ifdef __cplusplus
    10     11   extern "C" {
    11     12   #endif
    12     13   
    13     14   typedef enum kmcond {
    14         -	kmcond_ok,
           15  +	kmcond_ok = kmcond_id,
    15     16   	kmcond_unnecessary,
    16     17   
    17     18   	kmcond_fail,
    18     19   	kmcond_unhandled,
    19     20   	kmcond_mismatch,
    20     21   	kmcond_bad_address,
           22  +	kmcond_bad_lock,
           23  +	kmcond_bad_size,
           24  +	kmcond_no_room,
           25  +	kmcond_too_many,
           26  +
           27  +	/* when something truly should
           28  +	 * never happen: */
           29  +	kmcond_fail_assert,
    21     30   } kmcond;
    22     31   
    23     32   typedef enum kmkind {
    24     33   	kmkind_none,
    25     34   	kmkind_fail,
    26     35   	kmkind_linear,
    27     36   	kmkind_heap,
................................................................................
    59     68   	kmkind kind;
    60     69   	kmshred shred;
    61     70   	void* ref;
    62     71   } kmptr;
    63     72   
    64     73   /* heap functions */
    65     74   
    66         -void*  kmheapa(sz);
    67         -kmptr  kmheapao(sz);
    68         -kmcond kmheapf(void*);
           75  +kmcond kmheapa (void**, sz);
           76  +kmcond kmheapao(kmptr*, sz);
           77  +kmcond kmheapf (void*);
    69     78   
    70     79   /* generic functions */
    71     80   
    72     81   kmcond kmfree(kmptr);
    73     82   kmkind kmtell(void*);
    74     83   void kmzero(void*,sz);
    75     84   void kmozero(kmptr);