Changeset 684


Ignore:
Timestamp:
Jan 13, 2021, 12:40:22 AM (3 months ago)
Author:
alain
Message:

Introduce the socket.c & socket.h files.

Location:
trunk/libs/mini-libc
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/mini-libc/stdio.c

    r677 r684  
    142142            }
    143143            case ('x'):             // up to 8 digits hexa after "0x"
    144             case ('X'):             // exactly 8 digits hexa after "0x"
    145144            {
    146145                unsigned int val = va_arg( *args , unsigned int );
     
    150149                {
    151150                    buf[7 - i] = HexaTab[val & 0xF];
    152                     if( (*format == 'x') && ((val >> 4) == 0) )  break;
    153151                    val = val >> 4;
     152                    if( val == 0)  break;
    154153                }
    155154                len =  i + 1;
     
    157156                break;
    158157            }
     158            case ('X'):             // exactly 8 digits hexa after "0x"
     159            {
     160                unsigned int val = va_arg( *args , unsigned int );
     161                TO_STREAM( '0' );
     162                TO_STREAM( 'x' );
     163                for(i = 0 ; i < 8 ; i++)
     164                {
     165                    buf[7 - i] = (val != 0) ? HexaTab[val & 0xF] : '0';
     166                    val = val >> 4;
     167                }
     168                len = 8;
     169                pbuf = &buf[0];
     170                break;
     171            }
    159172            case ('l'):             // up to 16 digits hexa after "0x"
    160             case ('L'):             // exactly 16 digits hexa after "0x"
    161173            {
    162174                unsigned long long val = ((unsigned long long)va_arg( *args, unsigned int)) |
     
    167179                {
    168180                    buf[15 - i] = HexaTab[val & 0xF];
    169                     if( (*format == 'l') && ((val >> 4) == 0) )  break;
    170181                    val = val >> 4;
     182                    if( val == 0)  break;
    171183                }
    172184                len =  i + 1;
    173185                pbuf = &buf[15 - i];
     186                break;
     187            }
     188            case ('L'):             // exactly 16 digits hexa after "0x"
     189            {
     190                unsigned long long val = ((unsigned long long)va_arg( *args, unsigned int)) |
     191                                         ((unsigned long long)va_arg( *args, unsigned int) << 32);
     192                TO_STREAM( '0' );
     193                TO_STREAM( 'x' );
     194                for(i = 0 ; i < 16 ; i++)
     195                {
     196                    buf[15 - i] = (val != 0) ? HexaTab[val & 0xF] : '0';
     197                    val = val >> 4;
     198                }
     199                len =  16;
     200                pbuf = &buf[0];
    174201                break;
    175202            }
  • trunk/libs/mini-libc/stdlib.c

    r650 r684  
    4848        while( str[i] != 0 )
    4949        {
    50             if     ( (str[i] >= '0') && (str[i] <= '9') ) res = (res<<4) + (str[i] - '0');
    51             else if( (str[i] >= 'A') && (str[i] <= 'F') ) res = (res<<4) + (str[i] - 'A');
    52             else if( (str[i] >= 'a') && (str[i] <= 'f') ) res = (res<<4) + (str[i] - 'a');
     50            if     ( (str[i] >= '0') && (str[i] <= '9') ) res = (res<<4) +      (str[i] - '0');
     51            else if( (str[i] >= 'A') && (str[i] <= 'F') ) res = (res<<4) + 10 + (str[i] - 'A');
     52            else if( (str[i] >= 'a') && (str[i] <= 'f') ) res = (res<<4) + 10 + (str[i] - 'a');
    5353            else return 0;
    5454            i++;
  • trunk/libs/mini-libc/unistd.h

    r677 r684  
    7575 * The old process descriptor, and all its threads are blocked, and marked for deletion.
    7676 * Therefore the exec syscall does not return to the calling thread in case of success.
    77  * This function build an exec_info_t structure containing the new process arguments,
    78  * as defined by the <arv> argument, and the new process environment variables,
    79  * as defined by the <envp>  argument.
     77 * This function initializes the exec_info_t structure (embedded in process descriptor),
     78 * and containing the <filename>, <args> and <envs> arguments.
     79 *
    8080 * TODO : the <envs> argument is not supported yet (must be NULL).
    8181 *****************************************************************************************
    8282 * @ filename : string pointer on .elf filename (virtual pointer in user space)
    83  * @ args     : array of pointers on process arguments (strings in user space)
    84  * @ envs     : array of pointers on environment variables (strings in user space)
     83 * @ args     : NULL terminated array of strings pointers on process arguments.
     84 * @ envs     : NULL terminated array of strings pointers on environment variables.
    8585 * @ does not return if success / returns -1 if failure.
    8686 ****************************************************************************************/
     
    201201
    202202/*****************************************************************************************
     203 * This function implements the <sleep> system call.
     204 * It suspends execution of the calling thread until either <seconds> have elapsed,
     205 * or a signal is delivered to the thread and its action is to terminate the thread.
     206 * System activity may lengthen the sleep by an indeterminate amount.
     207 *****************************************************************************************
     208 * @ seconds   : sleep duration in seconds.
     209 * @ return 0 if success / returns number of unslept seconds if signal delivery.
     210 ****************************************************************************************/
     211unsigned int sleep( unsigned int seconds );
     212
     213/*****************************************************************************************
    203214 * This function implements the <sync> system call.
    204215 * It forces all kernel mappers (file caches) to be copied to the IOC device.
Note: See TracChangeset for help on using the changeset viewer.