Changes in / [021c508:4d4988e] in mainline
- Location:
- uspace/lib/posix
- Files:
-
- 4 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/Makefile
r021c508 r4d4988e 41 41 ctype.c \ 42 42 fcntl.c \ 43 math.c \44 43 stdio.c \ 45 44 stdlib.c \ … … 48 47 strings.c \ 49 48 sys/stat.c \ 50 sys/wait.c \51 49 time.c \ 52 50 unistd.c -
uspace/lib/posix/ctype.c
r021c508 r4d4988e 38 38 #include "ctype.h" 39 39 40 // TODO: propose for inclusion in libc41 42 40 /** 43 * Checks whether character is a hexadecimal digit. 44 * 45 * @param c 41 * 42 * @param ch 46 43 * @return 47 44 */ 48 int posix_isxdigit(int c )45 int posix_isxdigit(int ch) 49 46 { 50 return isdigit(c) || 51 (c >= 'a' && c <= 'f') || 52 (c >= 'A' && c <= 'F'); 53 } 54 55 /** 56 * Checks whether character is a word separator. 57 * 58 * @param c 59 * @return 60 */ 61 int posix_isblank(int c) 62 { 63 return c == ' ' || c == '\t'; 64 } 65 66 /** 67 * Checks whether character is a control character. 68 * 69 * @param c 70 * @return 71 */ 72 int posix_iscntrl(int c) 73 { 74 return c < 0x20 || c == 0x7E; 75 } 76 77 /** 78 * Checks whether character is any printing character except space. 79 * 80 * @param c 81 * @return 82 */ 83 int posix_isgraph(int c) 84 { 85 return posix_isprint(c) && c != ' '; 86 } 87 88 /** 89 * Checks whether character is a printing character. 90 * 91 * @param c 92 * @return 93 */ 94 int posix_isprint(int c) 95 { 96 return !posix_iscntrl(c); 97 } 98 99 /** 100 * Checks whether character is a punctuation. 101 * 102 * @param c 103 * @return 104 */ 105 int posix_ispunct(int c) 106 { 107 return !isspace(c) && !isalnum(c); 47 return isdigit(ch) || 48 (ch >= 'a' && ch <= 'f') || 49 (ch >= 'A' && ch <= 'F'); 108 50 } 109 51 -
uspace/lib/posix/ctype.h
r021c508 r4d4988e 40 40 41 41 /* Classification of Characters */ 42 extern int posix_isxdigit(int c); 43 extern int posix_isblank(int c); 44 extern int posix_iscntrl(int c); 45 extern int posix_isgraph(int c); 46 extern int posix_isprint(int c); 47 extern int posix_ispunct(int c); 42 extern int posix_isxdigit(int ch); 48 43 49 44 #ifndef LIBPOSIX_INTERNAL 50 45 #define isxdigit posix_isxdigit 51 #define isblank posix_isblank52 #define iscntrl posix_iscntrl53 #define isgraph posix_isgraph54 #define isprint posix_isprint55 #define ispunct posix_ispunct56 46 #endif 57 47 -
uspace/lib/posix/limits.h
r021c508 r4d4988e 36 36 #define POSIX_LIMITS_H_ 37 37 38 #include " stdint.h"38 #include "libc/stdint.h" 39 39 #include "libc/sys/types.h" 40 40 -
uspace/lib/posix/math.h
r021c508 r4d4988e 36 36 #define POSIX_MATH_H_ 37 37 38 /* Normalization Functions */ 39 extern double posix_ldexp(double x, int exp); 40 extern double posix_frexp(double num, int *exp); 41 42 #ifndef LIBPOSIX_INTERNAL 43 #define ldexp posix_ldexp 44 #define frexp posix_frexp 45 #endif 38 /* Empty. Just to satisfy preprocessor. */ 46 39 47 40 #endif /* POSIX_MATH_H_ */ -
uspace/lib/posix/signal.h
r021c508 r4d4988e 56 56 #define signal(sig,func) (errno = ENOTSUP, SIG_ERR) 57 57 #define raise(sig) ((int) -1) 58 #define kill(pid,sig) (errno = ENOTSUP, (int) -1)59 58 60 59 typedef int posix_sig_atomic_t; -
uspace/lib/posix/stdint.h
r021c508 r4d4988e 36 36 #define POSIX_STDINT_H_ 37 37 38 #undef INT8_MAX 39 #undef INT8_MIN 40 #define INT8_MAX 127 41 #define INT8_MIN (-128) 42 43 #undef UINT8_MAX 44 #undef UINT8_MIN 45 #define UINT8_MAX 255 46 #define UINT8_MIN 0 47 48 #undef INT16_MAX 49 #undef INT16_MIN 50 #define INT16_MAX 32767 51 #define INT16_MIN (-32768) 52 53 #undef UINT16_MAX 54 #undef UINT16_MIN 55 #define UINT16_MAX 65535 56 #define UINT16_MIN 0 57 58 #undef INT32_MAX 59 #undef INT32_MIN 60 #define INT32_MAX 2147483647 61 #define INT32_MIN (-INT32_MAX - 1) 62 63 #undef UINT32_MAX 64 #undef UINT32_MIN 65 #define UINT32_MAX 4294967295U 66 #define UINT32_MIN 0U 67 68 #undef INT64_MAX 69 #undef INT64_MIN 70 #define INT64_MAX 9223372036854775807LL 71 #define INT64_MIN (-INT64_MAX - 1LL) 72 73 #undef UINT64_MAX 74 #undef UINT64_MIN 75 #define UINT64_MAX 18446744073709551615ULL 76 #define UINT64_MIN 0ULL 77 78 #undef OFF64_MAX 79 #undef OFF64_MIN 80 #define OFF64_MAX INT64_MAX 81 #define OFF64_MIN INT64_MIN 82 83 #undef AOFF64_MAX 84 #undef AOFF64_MIN 85 #define AOFF64_MAX UINT64_MAX 86 #define AOFF64_MIN UINT64_MIN 87 88 #include "libc/sys/types.h" 38 #include "libc/stdint.h" 89 39 90 40 typedef int64_t posix_intmax_t; -
uspace/lib/posix/stdio.c
r021c508 r4d4988e 167 167 * @return 168 168 */ 169 int posix_vsprintf(char *s, const char *format, va_list ap)170 {171 // TODO: low priority, just a compile-time dependency of binutils172 not_implemented();173 }174 175 /**176 *177 * @param s178 * @param format179 * @param ...180 * @return181 */182 169 int posix_sscanf(const char *s, const char *format, ...) 183 170 { … … 186 173 } 187 174 188 /**189 *190 * @param path191 * @return192 */193 int posix_remove(const char *path)194 {195 // TODO: low priority, just a compile-time dependency of binutils196 not_implemented();197 }198 199 /**200 *201 * @param s202 * @return203 */204 char *posix_tmpnam(char *s)205 {206 // TODO: low priority, just a compile-time dependency of binutils207 not_implemented();208 }209 210 175 /** @} 211 176 */ -
uspace/lib/posix/stdio.h
r021c508 r4d4988e 39 39 #include "libc/stdio.h" 40 40 #include "sys/types.h" 41 #include "libc/stdarg.h"42 41 43 42 /* Character Input/Output */ … … 61 60 /* Formatted Input/Output */ 62 61 extern int posix_sprintf(char *restrict s, const char *restrict format, ...); 63 extern int posix_vsprintf(char *restrict s, const char *restrict format, va_list ap);64 62 extern int posix_sscanf(const char *restrict s, const char *restrict format, ...); 65 66 /* Deleting Files */67 extern int posix_remove(const char *path);68 69 /* Temporary Files */70 extern char *posix_tmpnam(char *s);71 63 72 64 #ifndef LIBPOSIX_INTERNAL … … 81 73 82 74 #define sprintf posix_sprintf 83 #define vsprintf posix_vsprintf84 75 #define sscanf posix_sscanf 85 86 #define remove posix_remove87 88 #define tmpnam posix_tmpnam89 76 #endif 90 77 -
uspace/lib/posix/stdlib.c
r021c508 r4d4988e 40 40 41 41 /** 42 *43 * @param array44 * @param count45 * @param size46 * @param compare47 */48 int posix_atexit(void (*func)(void))49 {50 // TODO: low priority, just a compile-time dependency of binutils51 not_implemented();52 }53 54 /**55 *56 * @param array57 * @param count58 * @param size59 * @param compare60 */61 int posix_abs(int i)62 {63 // TODO64 not_implemented();65 }66 67 /**68 42 * 69 43 * @param array … … 87 61 { 88 62 // TODO 89 not_implemented();90 }91 92 /**93 *94 * @param name95 * @param resolved96 * @return97 */98 int posix_putenv(char *string)99 {100 // TODO: low priority, just a compile-time dependency of binutils101 63 not_implemented(); 102 64 } … … 151 113 } 152 114 153 /**154 *155 * @param size156 * @return157 */158 void *posix_malloc(size_t size)159 {160 return malloc(size);161 }162 163 /**164 *165 * @param nelem166 * @param elsize167 * @return168 */169 void *posix_calloc(size_t nelem, size_t elsize)170 {171 return calloc(nelem, elsize);172 }173 174 /**175 *176 * @param ptr177 * @param size178 * @return179 */180 void *posix_realloc(void *ptr, size_t size)181 {182 return realloc(ptr, size);183 }184 185 /**186 *187 * @param ptr188 */189 void posix_free(void *ptr)190 {191 free(ptr);192 }193 194 /**195 *196 * @param tmpl197 * @return198 */199 char *posix_mktemp(char *tmpl)200 {201 // TODO: low priority, just a compile-time dependency of binutils202 not_implemented();203 }204 205 115 /** @} 206 116 */ -
uspace/lib/posix/stdlib.h
r021c508 r4d4988e 49 49 #define EXIT_SUCCESS 0 50 50 #define _Exit exit 51 extern int posix_atexit(void (*func)(void));52 53 /* Absolute Value */54 extern int posix_abs(int i);55 51 56 52 /* Array Sort Function */ … … 60 56 /* Environment Access */ 61 57 extern char *posix_getenv(const char *name); 62 extern int posix_putenv(char *string);63 58 64 59 /* Symbolic Links */ … … 73 68 extern int posix_atoi(const char *str); 74 69 75 /* Memory Allocation */76 extern void *posix_malloc(size_t size);77 extern void *posix_calloc(size_t nelem, size_t elsize);78 extern void *posix_realloc(void *ptr, size_t size);79 extern void posix_free(void *ptr);80 81 /* Legacy Declarations */82 extern char *posix_mktemp(char *tmpl);83 84 70 #ifndef LIBPOSIX_INTERNAL 85 #define atexit posix_atexit86 87 #define abs posix_abs88 89 71 #define qsort posix_qsort 90 91 72 #define getenv posix_getenv 92 93 73 #define realpath posix_realpath 94 74 … … 98 78 99 79 #define atoi posix_atoi 100 101 #define malloc posix_malloc102 #define calloc posix_calloc103 #define realloc posix_realloc104 #define free posix_free105 106 #define mktemp posix_mktemp107 80 #endif 108 81 -
uspace/lib/posix/stdlib/strtold.c
r021c508 r4d4988e 41 41 #include <errno.h> // TODO: use POSIX errno 42 42 #include "../libc/bool.h" 43 #include "../ stdint.h"43 #include "../libc/stdint.h" 44 44 #include "../stdlib.h" 45 45 #include "../strings.h" -
uspace/lib/posix/string.h
r021c508 r4d4988e 103 103 104 104 /* Legacy declarations */ 105 #ifndef POSIX_STRINGS_H_106 105 extern int posix_ffs(int i); 107 #endif108 106 109 107 #ifndef LIBPOSIX_INTERNAL -
uspace/lib/posix/strings.h
r021c508 r4d4988e 37 37 #define POSIX_STRINGS_H_ 38 38 39 #ifndef POSIX_STRING_H_40 39 /* Search Functions */ 41 40 extern int posix_ffs(int i); 42 #endif43 41 44 42 /* String/Array Comparison */ -
uspace/lib/posix/time.c
r021c508 r4d4988e 87 87 } 88 88 89 /**90 *91 * @return92 */93 posix_clock_t posix_clock(void)94 {95 // TODO96 not_implemented();97 }98 99 89 /** @} 100 90 */ -
uspace/lib/posix/time.h
r021c508 r4d4988e 55 55 }; 56 56 57 typedef long posix_clock_t;58 59 57 /* Broken-down Time */ 60 58 extern struct posix_tm *posix_localtime(const time_t *timep); … … 65 63 extern size_t posix_strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct posix_tm *restrict tm); 66 64 67 /* CPU Time */68 extern posix_clock_t posix_clock(void);69 70 65 #ifndef LIBPOSIX_INTERNAL 71 66 #define tm posix_tm 72 73 #define clock_t posix_clock_t74 67 75 68 #define localtime posix_localtime … … 78 71 #define ctime posix_ctime 79 72 #define strftime posix_strftime 80 81 #define clock posix_clock82 73 #endif 83 74 -
uspace/lib/posix/unistd.c
r021c508 r4d4988e 38 38 #include "internal/common.h" 39 39 #include "unistd.h" 40 #include <task.h>41 40 42 41 /* Array of environment variable strings (NAME=VALUE). */ … … 44 43 45 44 /** 46 * Dummy function. Always returns false, because there is no easy way to find 47 * out under HelenOS. 48 * 45 * 49 46 * @param fd 50 * @return Always false.47 * @return 51 48 */ 52 49 int posix_isatty(int fd) 53 50 { 54 return false; 51 // TODO 52 not_implemented(); 55 53 } 56 54 … … 62 60 { 63 61 return getpagesize(); 64 }65 66 /**67 *68 * @return69 */70 posix_pid_t posix_getpid(void)71 {72 return task_get_id();73 62 } 74 63 … … 116 105 } 117 106 118 /**119 *120 * @param path121 * @param name122 * @return123 */124 long posix_pathconf(const char *path, int name)125 {126 // TODO: low priority, just a compile-time dependency of binutils127 not_implemented();128 }129 130 /**131 *132 * @return133 */134 posix_pid_t posix_fork(void)135 {136 // TODO: low priority, just a compile-time dependency of binutils137 not_implemented();138 }139 140 /**141 *142 * @param path143 * @param argv144 * @return145 */146 int posix_execv(const char *path, char *const argv[])147 {148 // TODO: low priority, just a compile-time dependency of binutils149 not_implemented();150 }151 152 /**153 *154 * @param file155 * @param argv156 * @return157 */158 int posix_execvp(const char *file, char *const argv[])159 {160 // TODO: low priority, just a compile-time dependency of binutils161 not_implemented();162 }163 164 /**165 *166 * @param fildes167 * @return168 */169 int posix_pipe(int fildes[2])170 {171 // TODO: low priority, just a compile-time dependency of binutils172 not_implemented();173 }174 175 107 /** @} 176 108 */ -
uspace/lib/posix/unistd.h
r021c508 r4d4988e 58 58 59 59 /* Process Identification */ 60 extern posix_pid_t posix_getpid(void); 60 #define getpid task_get_id 61 61 extern posix_uid_t posix_getuid(void); 62 62 extern posix_gid_t posix_getgid(void); … … 112 112 _PC_VDISABLE 113 113 }; 114 extern long posix_pathconf(const char *path, int name);115 116 /* Creating a Process */117 extern posix_pid_t posix_fork(void);118 119 /* Executing a File */120 extern int posix_execv(const char *path, char *const argv[]);121 extern int posix_execvp(const char *file, char *const argv[]);122 123 /* Creating a Pipe */124 extern int posix_pipe(int fildes[2]);125 114 126 115 #ifndef LIBPOSIX_INTERNAL … … 132 121 #define getpagesize posix_getpagesize 133 122 134 #define getpid posix_getpid135 123 #define getuid posix_getuid 136 124 #define getgid posix_getgid … … 139 127 140 128 #define sysconf posix_sysconf 141 142 #define pathconf posix_pathconf143 144 #define fork posix_fork145 146 #define execv posix_execv147 #define execvp posix_execvp148 149 #define pipe posix_pipe150 129 #endif 151 130
Note:
See TracChangeset
for help on using the changeset viewer.