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     27   	/* when something truly should
    28     28   	 * never happen: */
    29     29   	kmcond_fail_assert,
    30     30   } kmcond;
    31     31   
    32     32   typedef enum kmkind {
    33     33   	kmkind_none,
    34         -	kmkind_fail,
           34  +	kmkind_broken,
    35     35   	kmkind_linear,
    36     36   	kmkind_heap,
    37     37   	kmkind_pool,
    38     38   	kmkind_ref,
    39     39   	kmkind_tree
    40     40   } kmkind;
    41     41   
................................................................................
    66     66   
    67     67   typedef struct kmptr {
    68     68   	kmkind kind;
    69     69   	kmshred shred;
    70     70   	void* ref;
    71     71   } kmptr;
    72     72   
           73  +/* this struct is used to return both a pointer
           74  + * and an error value at the same time. */
           75  +typedef struct kmres {
           76  +	kmcond cond;
           77  +	union {
           78  +		void* raw;
           79  +		kmptr ptr;
           80  +	};
           81  +} kmres;
    73     82   /* heap functions */
    74     83   
    75         -kmcond kmheapa (void**, sz);
    76         -kmcond kmheapao(kmptr*, sz);
           84  +kmres  kmheapa (sz);
           85  +kmres  kmheapo (sz);
    77     86   kmcond kmheapf (void*);
           87  +kmres  kmlina  (sz);
           88  +void*  kmlini  (void);
    78     89   
    79     90   /* generic functions */
    80     91   
    81     92   kmcond kmfree(kmptr);
    82         -kmkind kmtell(void*);
    83     93   void kmzero(void*,sz);
    84     94   void kmozero(kmptr);
    85     95   
    86     96   
    87     97   #ifdef __cplusplus
    88     98   }
    89     99   #endif
    90    100   
    91    101   #endif