Changeset 445 for trunk/libs/mini-libc
- Timestamp:
- May 29, 2018, 9:27:23 AM (7 years ago)
- Location:
- trunk/libs/mini-libc
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/mini-libc/Makefile
r444 r445 1 1 ############################################################################ 2 # Makefile for the ALMOS-MKH "mini-libc"#2 # Makefile for the "mini-libc" library. # 3 3 ############################################################################ 4 4 5 5 -include ../../params-soft.mk 6 6 7 ifeq ($(ARCH_NAME),) 7 8 $(error Please define in ARCH_NAME parameter in params-soft.mk!) 8 9 endif 9 10 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 11 SRCS = 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 11 25 OBJS = $(addprefix build/, $(SRCS:.c=.o)) \ 12 26 $(HAL_ARCH)/build/core/hal_user.o 13 27 14 INCLUDES = -I. -I$(HAL)/generic -I$(LIBPTHREAD_INCLUDE) -I$(LIBALMOSMKH_INCLUDE) -I$(SHARED_INCLUDE) 28 INCLUDES = -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) 15 35 16 libs : build/lib/libc.a headers36 libs : build/lib/libc.a headers 17 37 18 38 build : 19 39 @mkdir build 20 @mkdir build/sys21 40 @mkdir build/lib 22 41 @mkdir build/include … … 26 45 $(MAKE) -C $(HAL_ARCH) 27 46 28 29 47 build/%.o : %.c %.h 30 48 $(CC) $(INCLUDES) $(CFLAGS) -c -o $@ $< … … 32 50 33 51 headers: 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/. 36 65 37 66 build/lib/libc.a: build $(OBJS) 38 67 $(AR) rc $@ $(OBJS) 39 ranlib $@40 68 $(RANLIB) $@ 41 69 42 70 .PHONY = build clean headers 43 71 44 45 72 clean: 46 73 rm -rf build/ -
trunk/libs/mini-libc/stdio.c
r444 r445 1 1 /* 2 * stdio.c - User side system callsimplementation.2 * stdio.c - User level <stdio> library implementation. 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 24 24 #include <stdio.h> 25 25 #include <stdarg.h> 26 #include <almosmkh.h> 26 27 #include <unistd.h> 27 #include <almos-mkh.h> 28 28 29 ////////////////////////////////////////// 29 30 static int xprintf( char * string, -
trunk/libs/mini-libc/stdio.h
r444 r445 1 1 /* 2 * stdio.h - User side syscallsdefinition.2 * stdio.h - User level <stdio> library definition. 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 25 25 #define _STDIO_H_ 26 26 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 ********************************************************************************************/ 28 32 29 #define NULL (void *)0 33 30 34 /********************************************************************************************* 31 35 * This function writes a formated string to the standard "stdout" stream. … … 54 58 * it cheks that the formated string fit in the buffer length. 55 59 ********************************************************************************************* 56 * @ string : 60 * @ string : pointer on target buffer. 57 61 * @ length : max bumber of characters in target buffer. 58 62 * @ format : formated string. -
trunk/libs/mini-libc/stdlib.c
r444 r445 1 1 /* 2 * stdlib.c - User level Clibrary implementation.2 * stdlib.c - User level <stdlib> library implementation. 3 3 * 4 4 * Author Alain Greiner (2016,2017) … … 23 23 24 24 #include <stdlib.h> 25 #include <hal_types.h> 26 #include <hal_user.h> 27 #include <almosmkh.h> 25 28 #include <stdio.h> 26 #include <almos-mkh.h>27 #include <hal_user.h>28 29 #include <syscalls_numbers.h> 29 30 30 #define reg_t int31 31 ////////////////////////// 32 32 int atoi(const char * str) … … 114 114 } 115 115 116 117 118 116 ////////// 119 117 int rand() … … 141 139 } 142 140 143 144 145 146 141 ////////////////////////////////// 147 142 void * malloc( unsigned int size ) … … 154 149 return remote_malloc( size, cxy ); 155 150 } 156 157 158 151 159 152 /////////////////////////////////// -
trunk/libs/mini-libc/stdlib.h
r444 r445 1 1 /* 2 * stdlib.h - User level library definition.2 * stdlib.h - User level <stdlib> library definition. 3 3 * 4 4 * Author Alain Greiner (2016,2017) … … 25 25 #define _STDLIB_H 26 26 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> 28 35 29 36 /***************************************************************************************** … … 34 41 void exit( int status ); 35 42 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 ********************************************************************************************/ 49 int atoi(const char * str ); 36 50 37 51 /********************************************************************************************* 38 * This function TODO52 * This function translates an ascii character string to a float value. 39 53 ********************************************************************************************* 54 * @ str : pointer on charactter string. 55 * @ return a double value. 40 56 ********************************************************************************************/ 41 int atoi(const char *str); 42 43 /********************************************************************************************* 44 * This function TODO 45 ********************************************************************************************* 46 ********************************************************************************************/ 47 double atof(const char *str); 57 double atof(const char * str ); 48 58 49 59 /********************************************************************************************* … … 72 82 ****************************************************************************************/ 73 83 void * malloc( unsigned int size ); 74 75 84 76 85 /***************************************************************************************** … … 109 118 void * calloc( unsigned int count, 110 119 unsigned int size ); 120 111 121 #endif // _STDLIB_H_ -
trunk/libs/mini-libc/string.c
r444 r445 1 1 /* 2 * string.c - Character string handling APIimplementation.2 * string.c - User level <string> library implementation. 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites -
trunk/libs/mini-libc/string.h
r444 r445 1 1 /* 2 * string.h - Caracter string handling APIdefinition.2 * string.h - User level <string> library definition. 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 25 25 #define _STRING_H_ 26 26 27 /***************************************************************************************** 28 * This file defines the user level, character string related <string> library. 29 * These functions do not use any syscall. 30 ****************************************************************************************/ 31 32 27 33 /******************************************************************************************** 28 34 * This function returns the length of a character string. … … 41 47 *******************************************************************************************/ 42 48 unsigned int strnlen( const char * str, 43 unsigned int maxlen );49 unsigned int maxlen ); 44 50 45 51 /********************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.