Changeset 445 for trunk/libs/mini-libc


Ignore:
Timestamp:
May 29, 2018, 9:27:23 AM (4 years ago)
Author:
alain
Message:

Restructure the mini_libc.

Location:
trunk/libs/mini-libc
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/mini-libc/Makefile

    r444 r445  
    11############################################################################
    2 #                  Makefile for the ALMOS-MKH "mini-libc"                  #
     2#          Makefile for the "mini-libc" library.                           #
    33############################################################################
    44
    55-include ../../params-soft.mk
     6
    67ifeq ($(ARCH_NAME),)
    78$(error Please define in ARCH_NAME parameter in params-soft.mk!)
    89endif
    910
    10 SRCS = ctype.c  dirent.c  fcntl.c  signal.c  stdio.c  stdlib.c  string.c  strings.c  sys/mman.c  sys/stat.c  sys/time.c  sys/wait.c  unistd.c
     11SRCS = ctype.c   \
     12       dirent.c  \
     13       fcntl.c   \
     14       mman.c    \
     15       signal.c  \
     16       stat.c    \
     17       stdio.c   \
     18       stdlib.c  \
     19       string.c  \
     20       strings.c \
     21       time.c    \
     22       unistd.c  \
     23       wait.c 
     24
    1125OBJS = $(addprefix build/, $(SRCS:.c=.o)) \
    1226       $(HAL_ARCH)/build/core/hal_user.o
    1327
    14 INCLUDES = -I. -I$(HAL)/generic -I$(LIBPTHREAD_INCLUDE) -I$(LIBALMOSMKH_INCLUDE) -I$(SHARED_INCLUDE)
     28INCLUDES = -I.                     \
     29           -I$(LIBPTHREAD_PATH)    \
     30           -I$(LIBALMOSMKH_PATH)   \
     31           -I$(SHARED_INCLUDE)     \
     32           -I$(HAL)/generic        \
     33           -I$(HAL_ARCH)/core      \
     34           -I$(KERNEL)
    1535
    16 libs : build/lib/libc.a headers
     36libs : build/lib/libc.a  headers
    1737
    1838build :
    1939        @mkdir build
    20         @mkdir build/sys
    2140        @mkdir build/lib
    2241        @mkdir build/include
     
    2645        $(MAKE) -C $(HAL_ARCH)
    2746
    28 
    2947build/%.o : %.c %.h
    3048        $(CC) $(INCLUDES) $(CFLAGS) -c -o  $@ $<
     
    3250
    3351headers: build
    34         cp $(SRCS:.c=.h) assert.h build/include/.
    35         cp sys/*.h build/include/sys/.
     52        cp ctype.h   build/include/.
     53        cp dirent.h  build/include/.
     54        cp fcntl.h   build/include/.
     55        cp mman.h    build/include/sys/.
     56        cp signal.h  build/include/.
     57        cp stat.h    build/include/sys/.
     58        cp stdio.h   build/include/.
     59        cp stdlib.h  build/include/.
     60        cp string.h  build/include/.
     61        cp strings.h build/include/.
     62        cp time.h    build/include/.
     63        cp unistd.h  build/include/.
     64        cp wait.h    build/include/sys/.
    3665
    3766build/lib/libc.a: build $(OBJS)
    3867        $(AR) rc $@ $(OBJS)
    39         ranlib $@
    4068        $(RANLIB) $@
    4169
    4270.PHONY = build clean headers
    4371
    44 
    4572clean:
    4673        rm -rf build/
  • trunk/libs/mini-libc/stdio.c

    r444 r445  
    11/*
    2  * stdio.c - User side system calls implementation.
     2 * stdio.c - User level <stdio> library implementation.
    33 *
    4  * Author     Alain Greiner (2016,2017)
     4 * Author     Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2424#include <stdio.h>
    2525#include <stdarg.h>
     26#include <almosmkh.h>
    2627#include <unistd.h>
    27 #include <almos-mkh.h>
     28
    2829//////////////////////////////////////////
    2930static int xprintf( char         * string,
  • trunk/libs/mini-libc/stdio.h

    r444 r445  
    11/*
    2  * stdio.h - User side syscalls definition.
     2 * stdio.h - User level <stdio> library definition.
    33 *
    4  * Author     Alain Greiner (2016,2017)
     4 * Author     Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2525#define _STDIO_H_
    2626
    27 #include <almos-mkh/stdio.h>
     27/*********************************************************************************************
     28 * This file defines the user level, TXT related <stdio> library.
     29 * These functions call the read() and write() functions defined in the <unistd> library
     30 * to access the TXT terminal.
     31 ********************************************************************************************/
    2832
    29 #define  NULL  (void *)0
     33
    3034/*********************************************************************************************
    3135 * This function writes a formated string to the standard "stdout" stream.
     
    5458 * it cheks that the formated string fit in the buffer length.
    5559 *********************************************************************************************
    56  * @ string    :  pointer on target buffer.
     60 * @ string    : pointer on target buffer.
    5761 * @ length    : max bumber of characters in target buffer.
    5862 * @ format    : formated string.
  • trunk/libs/mini-libc/stdlib.c

    r444 r445  
    11/*
    2  * stdlib.c - User level C library implementation.
     2 * stdlib.c - User level <stdlib> library implementation.
    33 *
    44 * Author     Alain Greiner (2016,2017)
     
    2323
    2424#include <stdlib.h>
     25#include <hal_types.h>
     26#include <hal_user.h>
     27#include <almosmkh.h>
    2528#include <stdio.h>
    26 #include <almos-mkh.h>
    27 #include <hal_user.h>
    2829#include <syscalls_numbers.h>
    2930
    30 #define  reg_t     int
    3131//////////////////////////
    3232int atoi(const char * str)
     
    114114}
    115115
    116 
    117 
    118116//////////
    119117int rand()
     
    141139}
    142140
    143 
    144 
    145 
    146141//////////////////////////////////
    147142void * malloc( unsigned int size )
     
    154149    return remote_malloc( size, cxy );
    155150}
    156 
    157 
    158151
    159152///////////////////////////////////
  • trunk/libs/mini-libc/stdlib.h

    r444 r445  
    11/*
    2  * stdlib.h - User level library definition.
     2 * stdlib.h - User level <stdlib> library definition.
    33 *
    44 * Author     Alain Greiner (2016,2017)
     
    2525#define _STDLIB_H
    2626
    27 #include <almos-mkh/stdlib.h>
     27/*****************************************************************************************
     28 * This file defines the user side <stdlib> library.
     29 * Some functions make a system call to access the kernel VFS.
     30 * The user/kernel shared structures and mnemonics are defined in
     31 * the <syscalls/shared_include/shared_fcntl.h> file.
     32 ****************************************************************************************/
     33
     34#include <shared_stdlib.h>
    2835
    2936/*****************************************************************************************
     
    3441void exit( int status );
    3542
     43/*********************************************************************************************
     44 * This function translates an ascii character string to an integer value.
     45 *********************************************************************************************
     46 * @ str   : pointer on charactter string.
     47 * @ return an integer value.
     48 ********************************************************************************************/
     49int atoi(const char * str );
    3650
    3751/*********************************************************************************************
    38  * This function TODO
     52 * This function translates an ascii character string to a float value.
    3953 *********************************************************************************************
     54 * @ str   : pointer on charactter string.
     55 * @ return a double value.
    4056 ********************************************************************************************/
    41 int atoi(const char *str);
    42 
    43 /*********************************************************************************************
    44  * This function TODO
    45  *********************************************************************************************
    46  ********************************************************************************************/
    47 double atof(const char *str);
     57double atof(const char * str );
    4858
    4959/*********************************************************************************************
     
    7282 ****************************************************************************************/
    7383void * malloc( unsigned int size );
    74 
    7584
    7685/*****************************************************************************************
     
    109118void * calloc( unsigned int count,
    110119               unsigned int size );
     120
    111121#endif  // _STDLIB_H_
  • trunk/libs/mini-libc/string.c

    r444 r445  
    11/*
    2  * string.c - Character string handling API implementation.
     2 * string.c - User level <string> library implementation.
    33 *
    4  * Author     Alain Greiner (2016,2017)
     4 * Author     Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
  • trunk/libs/mini-libc/string.h

    r444 r445  
    11/*
    2  * string.h - Caracter string handling API definition.
     2 * string.h - User level <string> library definition.
    33 *
    4  * Author     Alain Greiner (2016,2017)
     4 * Author     Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2525#define _STRING_H_
    2626
     27/*****************************************************************************************
     28 * This file defines the user level, character string related <string> library.
     29 * These functions do not use any syscall.
     30 ****************************************************************************************/
     31
     32
    2733/********************************************************************************************
    2834 * This function returns the length of a character string.
     
    4147 *******************************************************************************************/
    4248unsigned int strnlen( const char * str,
    43                   unsigned int     maxlen );
     49                      unsigned int     maxlen );
    4450
    4551/********************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.