libk  Check-in [858eba7607]

Overview
Comment:improve comments
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 858eba7607ec397dd6bd109fb55fd5ffef219be07b54a234d8b86bb98261c134
User & Date: lexi on 2019-08-24 00:20:39
Other Links: manifest | tags
Context
2019-08-24
23:02
stop attempting to auto-detect system constants during build process, and maintain os/arch-specific tables instead check-in: e42b590b45 user: lexi tags: trunk
00:20
improve comments check-in: 858eba7607 user: lexi tags: trunk
2019-08-22
20:04
fix another typo check-in: 8618103a4e user: lexi tags: trunk
Changes

Modified mod/kmem/heapa.fn.c from [c08b42ee14] to [99ad7a3351].

    27     27   		void* raw;
    28     28   		ubyte* byte;
    29     29   		kmbox* header;
    30     30   	} region;
    31     31   	/* we need to allocate space for the
    32     32   	 * header and for the actual object */
    33     33   	sz region_size = sizeof(kmbox) + len;
           34  +
           35  +	/* kmres reply is the struct that shall be returned by the
           36  +	 * function. if an error-condition occurs, the appropriate
           37  +	 * error code should be determined through system-specific
           38  +	 * means, the pointer value should be set to null, and the
           39  +	 * object should be returned immediately. if the object is
           40  +	 * not returned from within the system-specific section it
           41  +	 * will then be filled out with the appropriate values for
           42  +	 * a successful allocation and returned to the caller. */
    34     43   	kmres reply;
    35     44   
    36     45   #	ifdef KFenv_posix
    37     46   		/* posix  APIs  - we've  got  it  easy. currently  for
    38     47   		 * nonlinear  heap  allocation   kmheapa  simply  uses
    39     48   		 * m(un)map  and lets  the kernel  worry about  it. it
    40     49   		 * may  ultimately  be  worth replacing  this  with  a
................................................................................
    56     65   		k_platform_syscall_arg args[] = {
    57     66   			null, region_size, 
    58     67   			posix_prot_read | posix_prot_write,
    59     68   			posix_flag_anonymous | posix_map_shared,
    60     69   			-1, 0
    61     70   		};
    62     71   
    63         -		/* impl note: while per manpage fd is "ignored"
    64         -		 * for MAP_ANONYMOUS, "some implementations" require
    65         -		 * a value of -1 */
           72  +		/* impl note: while per manpage fd is "ignored" for
           73  +		 * MAP_ANONYMOUS,  "some implementations" require a
           74  +		 * value of -1, so we're setting it to that just to
           75  +		 * be safe. */
    66     76   
    67     77   		struct k_platform_syscall_answer r = k_platform_syscall
    68     78   			(k_platform_syscall_mmap, Kmsz(args), args);
    69     79   
    70     80   		if (r.error == 0) region.byte = (ubyte*)r.ret; else {
    71     81   			switch (r.error) {
    72     82   				case k_platform_error_EAGAIN: reply.cond = kmcond_bad_lock; break;
................................................................................
    78     88   			reply.raw = (void*)0;
    79     89   			return reply;
    80     90   		}
    81     91   #	else
    82     92    	   Knoimpl(kmheapa,KVos);
    83     93   #		error missing implementation
    84     94   #	endif
           95  +
           96  +	/* if the system-specific code has not returned early,
           97  +	 * we assume success and return the new pointer to the
           98  +	 * calling function along with a success code. */
    85     99   	
    86    100   	void* const object = (region.byte + sizeof (kmbox));
    87    101   
    88    102   	region.header -> kind = kmkind_heap;
    89    103   	region.header -> size = len;
    90    104   
    91    105   	reply.cond = kmcond_ok;
    92    106   	reply.raw = object;
    93    107   
    94    108   	return reply;
    95    109   }