Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/stdlib.c

    r102a729 rca1f1ec  
    3131 * @{
    3232 */
    33 /** @file Standard library definitions.
     33/** @file
    3434 */
    3535
     
    4040
    4141#include "errno.h"
    42 #include "limits.h"
    4342
    4443#include "libc/sort.h"
     
    6059
    6160/**
    62  * Integer absolute value.
    6361 *
    6462 * @param i Input value.
     
    7169
    7270/**
    73  * Long integer absolute value.
    7471 *
    7572 * @param i Input value.
     
    8279
    8380/**
    84  * Long long integer absolute value.
    8581 *
    8682 * @param i Input value.
     
    9288}
    9389
    94 /**
    95  * Compute the quotient and remainder of an integer division.
    96  *
    97  * @param numer Numerator.
    98  * @param denom Denominator.
    99  * @return Quotient and remainder packed into structure.
    100  */
    10190posix_div_t posix_div(int numer, int denom)
    10291{
     
    10493}
    10594
    106 /**
    107  * Compute the quotient and remainder of a long integer division.
    108  *
    109  * @param numer Numerator.
    110  * @param denom Denominator.
    111  * @return Quotient and remainder packed into structure.
    112  */
    11395posix_ldiv_t posix_ldiv(long numer, long denom)
    11496{
     
    11698}
    11799
    118 /**
    119  * Compute the quotient and remainder of a long long integer division.
    120  *
    121  * @param numer Numerator.
    122  * @param denom Denominator.
    123  * @return Quotient and remainder packed into structure.
    124  */
    125100posix_lldiv_t posix_lldiv(long long numer, long long denom)
    126101{
     
    134109 * @param elem2 Second element to compare.
    135110 * @param compare Comparison function without userdata parameter.
     111 *
    136112 * @return Relative ordering of the elements.
    137113 */
     
    139115{
    140116        int (*compare)(const void *, const void *) = userdata;
    141         int ret = compare(elem1, elem2);
    142        
    143         /* Native qsort internals expect this. */
    144         if (ret < 0) {
    145                 return -1;
    146         } else if (ret > 0) {
    147                 return 1;
    148         } else {
    149                 return 0;
    150         }
     117        return compare(elem1, elem2);
    151118}
    152119
     
    154121 * Array sorting utilizing the quicksort algorithm.
    155122 *
    156  * @param array Array of elements to sort.
    157  * @param count Number of elements in the array.
    158  * @param size Width of each element.
    159  * @param compare Decides relative ordering of two elements.
     123 * @param array
     124 * @param count
     125 * @param size
     126 * @param compare
    160127 */
    161128void posix_qsort(void *array, size_t count, size_t size,
     
    204171/**
    205172 * Retrieve a value of the given environment variable.
    206  *
    207173 * Since HelenOS doesn't support env variables at the moment,
    208174 * this function always returns NULL.
    209175 *
    210  * @param name Name of the variable.
    211  * @return Value of the variable or NULL if such variable does not exist.
     176 * @param name
     177 * @return Always NULL.
    212178 */
    213179char *posix_getenv(const char *name)
     
    229195
    230196/**
    231  * Issue a command.
    232  *
    233  * @param string String to be passed to a command interpreter or NULL.
    234  * @return Termination status of the command if the command is not NULL,
    235  *     otherwise indicate whether there is a command interpreter (non-zero)
    236  *     or not (zero).
     197 *
     198 * @param string String to be passed to a command interpreter.
     199 * @return
    237200 */
    238201int posix_system(const char *string) {
     
    242205
    243206/**
    244  * Resolve absolute pathname.
    245  *
    246  * @param name Pathname to be resolved.
    247  * @param resolved Either buffer for the resolved absolute pathname or NULL.
    248  * @return On success, either resolved (if it was not NULL) or pointer to the
    249  *     newly allocated buffer containing the absolute pathname (if resolved was
    250  *     NULL). Otherwise NULL.
    251  *
    252  */
    253 char *posix_realpath(const char *restrict name, char *restrict resolved)
     207 *
     208 * @param name
     209 * @param resolved
     210 * @return
     211 */
     212char *posix_realpath(const char *name, char *resolved)
    254213{
    255214        #ifndef PATH_MAX
     
    295254 * its native representation. See posix_strtold().
    296255 *
    297  * @param nptr String representation of a floating-point number.
    298  * @return Double-precision number resulting from the string conversion.
     256 * @param nptr
     257 * @return
    299258 */
    300259double posix_atof(const char *nptr)
     
    307266 * its native representation. See posix_strtold().
    308267 *
    309  * @param nptr String representation of a floating-point number.
    310  * @param endptr Pointer to the final part of the string which
    311  *     was not used for conversion.
    312  * @return Single-precision number resulting from the string conversion.
     268 * @param nptr
     269 * @param endptr
     270 * @return
    313271 */
    314272float posix_strtof(const char *restrict nptr, char **restrict endptr)
     
    321279 * its native representation. See posix_strtold().
    322280 *
    323  * @param nptr String representation of a floating-point number.
    324  * @param endptr Pointer to the final part of the string which
    325  *     was not used for conversion.
    326  * @return Double-precision number resulting from the string conversion.
     281 * @param nptr
     282 * @param endptr
     283 * @return
    327284 */
    328285double posix_strtod(const char *restrict nptr, char **restrict endptr)
     
    332289
    333290/**
    334  * Allocate memory chunk.
    335  *
    336  * @param size Size of the chunk to allocate.
    337  * @return Either pointer to the allocated chunk or NULL if not possible.
     291 *
     292 * @param size
     293 * @return
    338294 */
    339295void *posix_malloc(size_t size)
     
    343299
    344300/**
    345  * Allocate memory for an array of elements.
    346  *
    347  * @param nelem Number of elements in the array.
    348  * @param elsize Size of each element.
    349  * @return Either pointer to the allocated array or NULL if not possible.
     301 *
     302 * @param nelem
     303 * @param elsize
     304 * @return
    350305 */
    351306void *posix_calloc(size_t nelem, size_t elsize)
     
    355310
    356311/**
    357  * Reallocate memory chunk to a new size.
    358  *
    359  * @param ptr Memory chunk to reallocate. Might be NULL.
    360  * @param size Size of the reallocated chunk. Might be zero.
    361  * @return Either NULL or the pointer to the newly reallocated chunk.
     312 *
     313 * @param ptr
     314 * @param size
     315 * @return
    362316 */
    363317void *posix_realloc(void *ptr, size_t size)
    364318{
    365         if (ptr != NULL && size == 0) {
    366                 /* Native realloc does not handle this special case. */
    367                 free(ptr);
    368                 return NULL;
    369         } else {
    370                 return realloc(ptr, size);
    371         }
    372 }
    373 
    374 /**
    375  * Free allocated memory chunk.
    376  *
    377  * @param ptr Memory chunk to be freed.
     319        return realloc(ptr, size);
     320}
     321
     322/**
     323 *
     324 * @param ptr
    378325 */
    379326void posix_free(void *ptr)
     
    396343
    397344/**
    398  * Get system load average statistics.
    399  *
    400  * Not supported. Always returns -1.
    401  *
    402  * @param loadavg Array where the load averages shall be placed.
    403  * @param nelem Maximum number of elements to be placed into the array.
    404  * @return Number of elements placed into the array on success, -1 otherwise.
     345 * Should read system load statistics. Not supported. Always returns -1.
     346 *
     347 * @param loadavg
     348 * @param nelem
     349 * @return
    405350 */
    406351int bsd_getloadavg(double loadavg[], int nelem)
Note: See TracChangeset for help on using the changeset viewer.