Changeset bc56f30 in mainline for uspace/lib/c/include
- Timestamp:
- 2019-05-27T12:38:26Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0d14c25
- Parents:
- 4d51c60
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-13 16:06:49)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2019-05-27 12:38:26)
- Location:
- uspace/lib/c/include
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/list.h
r4d51c60 rbc56f30 42 42 #include <stdint.h> 43 43 #include <trace.h> 44 45 /** Doubly linked list link. */ 46 typedef struct link { 47 struct link *prev; /**< Pointer to the previous item in the list. */ 48 struct link *next; /**< Pointer to the next item in the list. */ 49 } link_t; 50 51 /** Doubly linked list. */ 52 typedef struct list { 53 link_t head; /**< List head. Does not have any data. */ 54 } list_t; 55 56 extern bool list_member(const link_t *, const list_t *); 57 extern void list_splice(list_t *, link_t *); 58 extern unsigned long list_count(const list_t *); 44 #include <_bits/decls.h> 45 46 #ifndef __cplusplus 47 48 /** 49 * We don't define the macros in C++ to avoid polluting headers with 50 * namespaceless names. We don't actually need them, so this is fine. 51 * We still allow including the rest of the file (in `helenos` namespace) 52 * so that we can expose publicly visible types that have list_t members. 53 */ 59 54 60 55 /** Declare and initialize statically allocated list. … … 138 133 assert(!link_used(link)) 139 134 135 #define list_pop(list, type, member) \ 136 ((type *) list_pop_internal(list, \ 137 (list_link_to_void(&(((type *) NULL)->member)) - NULL))) 138 139 #endif /* !__cplusplus */ 140 141 __HELENOS_DECLS_BEGIN; 142 143 /** Doubly linked list link. */ 144 typedef struct __adt_list_link { 145 struct __adt_list_link *prev; /**< Pointer to the previous item in the list. */ 146 struct __adt_list_link *next; /**< Pointer to the next item in the list. */ 147 } link_t; 148 149 /** Doubly linked list. */ 150 typedef struct { 151 link_t head; /**< List head. Does not have any data. */ 152 } list_t; 153 154 extern bool list_member(const link_t *, const list_t *); 155 extern void list_splice(list_t *, link_t *); 156 extern unsigned long list_count(const list_t *); 157 140 158 /** Returns true if the link is definitely part of a list. False if not sure. */ 141 159 static inline bool link_in_use(const link_t *link) … … 425 443 } 426 444 427 #define list_pop(list, type, member) \ 428 ((type *) list_pop_internal(list, \ 429 (list_link_to_void(&(((type *) NULL)->member)) - NULL))) 445 __HELENOS_DECLS_END; 430 446 431 447 #endif -
uspace/lib/c/include/assert.h
r4d51c60 rbc56f30 41 41 #define _LIBC_ASSERT_H_ 42 42 43 #include <_bits/decls.h> 44 43 45 #ifndef __cplusplus 44 46 #define static_assert _Static_assert 45 47 #endif 48 49 __C_DECLS_BEGIN; 46 50 47 51 extern void __helenos_assert_abort(const char *, const char *, unsigned int) … … 50 54 extern void __helenos_assert_quick_abort(const char *, const char *, unsigned int) 51 55 __attribute__((noreturn)); 56 57 __C_DECLS_END; 52 58 53 59 #endif -
uspace/lib/c/include/bsearch.h
r4d51c60 rbc56f30 37 37 38 38 #include <stddef.h> 39 #include <_bits/decls.h> 40 41 __C_DECLS_BEGIN; 39 42 40 43 extern void *bsearch(const void *, const void *, size_t, size_t, 41 44 int (*)(const void *, const void *)); 45 46 __C_DECLS_END; 42 47 43 48 #endif -
uspace/lib/c/include/ctype.h
r4d51c60 rbc56f30 30 30 #define _LIBC_CTYPE_H_ 31 31 32 #include <_bits/decls.h> 33 34 __C_DECLS_BEGIN; 32 35 int islower(int); 33 36 int isupper(int); … … 44 47 int tolower(int); 45 48 int toupper(int); 49 __C_DECLS_END; 46 50 47 51 #endif -
uspace/lib/c/include/dirent.h
r4d51c60 rbc56f30 36 36 #define _LIBC_DIRENT_H_ 37 37 38 #define NAME_MAX 256 38 #include <limits.h> 39 #include <_bits/decls.h> 40 41 __C_DECLS_BEGIN; 39 42 40 43 struct dirent { 41 char d_name[ NAME_MAX + 1];44 char d_name[__NAME_MAX + 1]; 42 45 }; 43 46 … … 49 52 extern int closedir(DIR *); 50 53 54 __C_DECLS_END; 55 51 56 #endif 52 57 -
uspace/lib/c/include/dlfcn.h
r4d51c60 rbc56f30 37 37 #define _LIBC_DLFCN_H_ 38 38 39 #include <_bits/decls.h> 40 41 __C_DECLS_BEGIN; 42 39 43 void *dlopen(const char *, int); 40 44 void *dlsym(void *, const char *); 45 46 __C_DECLS_END; 41 47 42 48 #endif -
uspace/lib/c/include/errno.h
r4d51c60 rbc56f30 38 38 #include <_bits/errno.h> 39 39 #include <abi/errno.h> 40 #include <_bits/decls.h> 40 41 41 #define errno (*(__errno())) 42 __HELENOS_DECLS_BEGIN; 42 43 43 44 extern errno_t *__errno(void) __attribute__((const)); 45 46 __HELENOS_DECLS_END; 47 48 #ifdef __cplusplus 49 #define errno (*(::helenos::__errno())) 50 #else 51 #define errno (*(__errno())) 52 #endif 44 53 45 54 #endif -
uspace/lib/c/include/fibril.h
r4d51c60 rbc56f30 36 36 #define _LIBC_FIBRIL_H_ 37 37 38 #include <types/common.h>39 38 #include <time.h> 39 #include <_bits/errno.h> 40 40 #include <_bits/__noreturn.h> 41 #include <_bits/decls.h> 42 43 __HELENOS_DECLS_BEGIN; 41 44 42 45 typedef struct fibril fibril_t; … … 71 74 extern __noreturn void fibril_exit(long); 72 75 76 __HELENOS_DECLS_END; 77 73 78 #endif 74 79 -
uspace/lib/c/include/fibril_synch.h
r4d51c60 rbc56f30 40 40 #include <time.h> 41 41 #include <stdbool.h> 42 43 typedef struct { 44 fibril_owner_info_t oi; /**< Keep this the first thing. */ 45 int counter; 46 list_t waiters; 47 } fibril_mutex_t; 42 #include <_bits/decls.h> 43 44 #ifndef __cplusplus 48 45 49 46 #define FIBRIL_MUTEX_INITIALIZER(name) \ … … 58 55 #define FIBRIL_MUTEX_INITIALIZE(name) \ 59 56 fibril_mutex_t name = FIBRIL_MUTEX_INITIALIZER(name) 60 61 typedef struct {62 fibril_owner_info_t oi; /**< Keep this the first thing. */63 unsigned int writers;64 unsigned int readers;65 list_t waiters;66 } fibril_rwlock_t;67 57 68 58 #define FIBRIL_RWLOCK_INITIALIZER(name) \ … … 79 69 fibril_rwlock_t name = FIBRIL_RWLOCK_INITIALIZER(name) 80 70 81 typedef struct {82 list_t waiters;83 } fibril_condvar_t;84 85 71 #define FIBRIL_CONDVAR_INITIALIZER(name) \ 86 72 { \ … … 90 76 #define FIBRIL_CONDVAR_INITIALIZE(name) \ 91 77 fibril_condvar_t name = FIBRIL_CONDVAR_INITIALIZER(name) 78 79 #define FIBRIL_SEMAPHORE_INITIALIZER(name, cnt) \ 80 { \ 81 .count = (cnt), \ 82 .waiters = LIST_INITIALIZER((name).waiters), \ 83 } 84 85 #define FIBRIL_SEMAPHORE_INITIALIZE(name, cnt) \ 86 fibril_semaphore_t name = FIBRIL_SEMAPHORE_INITIALIZER(name, cnt) 87 88 #endif 89 90 __HELENOS_DECLS_BEGIN; 91 92 typedef struct { 93 fibril_owner_info_t oi; /**< Keep this the first thing. */ 94 int counter; 95 list_t waiters; 96 } fibril_mutex_t; 97 98 typedef struct { 99 fibril_owner_info_t oi; /**< Keep this the first thing. */ 100 unsigned int writers; 101 unsigned int readers; 102 list_t waiters; 103 } fibril_rwlock_t; 104 105 typedef struct { 106 list_t waiters; 107 } fibril_condvar_t; 92 108 93 109 typedef void (*fibril_timer_fun_t)(void *); … … 134 150 } fibril_semaphore_t; 135 151 136 #define FIBRIL_SEMAPHORE_INITIALIZER(name, cnt) \137 { \138 .count = (cnt), \139 .waiters = LIST_INITIALIZER((name).waiters), \140 }141 142 #define FIBRIL_SEMAPHORE_INITIALIZE(name, cnt) \143 fibril_semaphore_t name = FIBRIL_SEMAPHORE_INITIALIZER(name, cnt)144 145 152 extern void __fibril_synch_init(void); 146 153 extern void __fibril_synch_fini(void); … … 190 197 extern void mpsc_close(mpsc_t *); 191 198 199 __HELENOS_DECLS_END; 200 192 201 #endif 193 202 -
uspace/lib/c/include/malloc.h
r4d51c60 rbc56f30 37 37 38 38 #include <stddef.h> 39 #include <_bits/decls.h> 40 41 __C_DECLS_BEGIN; 39 42 40 43 extern void *malloc(size_t size) … … 42 45 extern void *calloc(size_t nmemb, size_t size) 43 46 __attribute__((malloc)); 44 extern void *memalign(size_t align, size_t size)45 __attribute__((malloc));46 47 extern void *realloc(void *addr, size_t size) 47 48 __attribute__((warn_unused_result)); 48 49 extern void free(void *addr); 50 51 __C_DECLS_END; 52 53 #ifdef _HELENOS_SOURCE 54 __HELENOS_DECLS_BEGIN; 55 56 extern void *memalign(size_t align, size_t size) 57 __attribute__((malloc)); 49 58 extern void *heap_check(void); 59 60 __HELENOS_DECLS_END; 61 #endif 50 62 51 63 #endif -
uspace/lib/c/include/mem.h
r4d51c60 rbc56f30 38 38 39 39 #include <stddef.h> 40 #include <_bits/decls.h> 41 42 __C_DECLS_BEGIN; 40 43 41 44 extern void *memset(void *, int, size_t) … … 50 53 __attribute__((nonnull(1))); 51 54 55 __C_DECLS_END; 56 52 57 #endif 53 58 -
uspace/lib/c/include/offset.h
r4d51c60 rbc56f30 36 36 #define _LIBC_OFFSET_H_ 37 37 38 #ifndef _HELENOS_SOURCE 39 #error This file should only be included from HelenOS sources 40 #endif 41 38 42 #include <stdint.h> 43 #include <_bits/decls.h> 44 #include <_bits/off64_t.h> 39 45 40 46 /* off64_t */ … … 52 58 #define PRIXOFF64 PRIX64 53 59 54 /** Relative offset */ 55 typedef int64_t off64_t; 60 __HELENOS_DECLS_BEGIN; 56 61 57 62 /** Absolute offset */ 58 63 typedef uint64_t aoff64_t; 64 65 __HELENOS_DECLS_END; 59 66 60 67 #endif -
uspace/lib/c/include/qsort.h
r4d51c60 rbc56f30 37 37 38 38 #include <stddef.h> 39 #include <_bits/decls.h> 39 40 41 __C_DECLS_BEGIN; 40 42 extern void qsort(void *, size_t, size_t, int (*)(const void *, 41 43 const void *)); 44 __C_DECLS_END; 45 46 #ifdef _HELENOS_SOURCE 47 __HELENOS_DECLS_BEGIN; 42 48 extern void qsort_r(void *, size_t, size_t, int (*)(const void *, 43 49 const void *, void *), void *); 50 __HELENOS_DECLS_END; 51 #endif 44 52 45 53 #endif -
uspace/lib/c/include/setjmp.h
r4d51c60 rbc56f30 34 34 #define _LIBC_SETJMP_H_ 35 35 36 #ifdef __cplusplus37 extern "C" {38 #endif39 40 36 #include <libarch/fibril_context.h> 41 37 #include <_bits/__noreturn.h> 38 #include <_bits/decls.h> 39 40 __C_DECLS_BEGIN; 42 41 43 42 typedef __context_t jmp_buf[1]; … … 46 45 extern __noreturn void __context_restore(__context_t *, int); 47 46 48 #define setjmp __context_save49 47 extern __noreturn void longjmp(jmp_buf, int); 50 48 51 #ifdef __cplusplus 52 } 53 # endif49 __C_DECLS_END; 50 51 #define setjmp __context_save 54 52 55 53 #endif -
uspace/lib/c/include/stdio.h
r4d51c60 rbc56f30 37 37 #define _LIBC_STDIO_H_ 38 38 39 #ifdef __cplusplus40 extern "C" {41 #endif42 43 #include <offset.h>44 39 #include <stdarg.h> 45 40 #include <io/verify.h> … … 48 43 #include <_bits/wchar_t.h> 49 44 #include <_bits/wint_t.h> 50 51 /** Forward declaration */ 52 struct _IO_FILE; 53 typedef struct _IO_FILE FILE; 54 55 /** File position */ 56 typedef struct { 57 off64_t pos; 58 } fpos_t; 45 #include <_bits/decls.h> 59 46 60 47 #ifndef _HELENOS_SOURCE … … 70 57 71 58 /** Max number of files that is guaranteed to be able to open at the same time */ 72 #define FOPEN_MAX VFS_MAX_OPEN_FILES59 #define FOPEN_MAX 16 73 60 74 61 /** Recommended size of fixed-size array for holding file names. */ … … 92 79 /** Minimum number of unique temporary file names */ 93 80 #define TMP_MAX 1000000 81 82 __C_DECLS_BEGIN; 83 84 /** Forward declaration */ 85 struct _IO_FILE; 86 typedef struct _IO_FILE FILE; 87 88 /** File position */ 89 typedef struct { 90 long long pos; 91 } fpos_t; 94 92 95 93 extern FILE *stdin; … … 98 96 99 97 /* Character and string input functions */ 100 #define getc fgetc101 98 extern int fgetc(FILE *); 102 99 extern char *fgets(char *, int, FILE *); 103 100 extern char *gets(char *, size_t) __attribute__((deprecated)); 104 101 102 static inline int getc(FILE *f) 103 { 104 return fgetc(f); 105 } 106 105 107 extern int getchar(void); 106 108 107 109 /* Character and string output functions */ 108 #define putc fputc109 110 extern int fputc(int, FILE *); 110 111 extern int fputs(const char *, FILE *); 112 113 static inline int putc(int i, FILE *f) 114 { 115 return fputc(i, f); 116 } 111 117 112 118 extern int putchar(int); … … 180 186 extern char *tmpnam(char *s); 181 187 188 __C_DECLS_END; 189 182 190 #ifdef _HELENOS_SOURCE 183 191 192 #include <_bits/off64_t.h> 193 194 __HELENOS_DECLS_BEGIN; 195 184 196 /* Nonstandard extensions. */ 185 197 186 enum _ buffer_type {198 enum __buffer_type { 187 199 /** No buffering */ 188 200 _IONBF, … … 193 205 }; 194 206 195 enum _buffer_state {196 /** Buffer is empty */197 _bs_empty,198 199 /** Buffer contains data to be written */200 _bs_write,201 202 /** Buffer contains prefetched data for reading */203 _bs_read204 };205 206 207 extern int vprintf_length(const char *, va_list); 207 208 extern int printf_length(const char *, ...) … … 210 211 extern int fileno(FILE *); 211 212 212 #include <offset.h>213 214 213 extern int fseek64(FILE *, off64_t, int); 215 214 extern off64_t ftell64(FILE *); 216 215 217 #endif 218 219 #ifdef __cplusplus 220 } 216 __HELENOS_DECLS_END; 221 217 #endif 222 218 -
uspace/lib/c/include/stdlib.h
r4d51c60 rbc56f30 36 36 #define _LIBC_STDLIB_H_ 37 37 38 #ifdef __cplusplus39 extern "C" {40 #endif41 42 38 #include <_bits/size_t.h> 43 39 #include <_bits/wchar_t.h> 40 #include <_bits/decls.h> 44 41 #include <bsearch.h> 45 42 #include <malloc.h> 46 43 #include <qsort.h> 44 45 #define EXIT_SUCCESS 0 46 #define EXIT_FAILURE 1 47 48 #define RAND_MAX 714025 49 50 #define MB_CUR_MAX 4 51 52 __C_DECLS_BEGIN; 47 53 48 54 /** Type returned by the div function */ … … 69 75 long long rem; 70 76 } lldiv_t; 71 72 #define EXIT_FAILURE 173 #define EXIT_SUCCESS 074 75 #define RAND_MAX 71402576 77 #define MB_CUR_MAX 478 77 79 78 extern long double strtold(const char *, char **); … … 109 108 extern lldiv_t lldiv(long long, long long); 110 109 111 #ifdef __cplusplus 112 } 113 #endif 110 __C_DECLS_END; 114 111 115 112 #endif -
uspace/lib/c/include/str.h
r4d51c60 rbc56f30 38 38 #define _LIBC_STR_H_ 39 39 40 #ifdef __cplusplus41 extern "C" {42 #endif43 44 40 #include <errno.h> 45 41 #include <stdbool.h> … … 48 44 49 45 #include <mem.h> 46 #include <_bits/decls.h> 47 48 #ifndef __cplusplus 50 49 51 50 /* Common Unicode characters */ … … 63 62 */ 64 63 #define SPASCII_STR_BUFSIZE(spa_size) ((spa_size) + 1) 64 65 #endif 66 67 __HELENOS_DECLS_BEGIN; 65 68 66 69 extern wchar_t str_decode(const char *str, size_t *offset, size_t sz); … … 147 150 extern unsigned long strtoul(const char *, char **, int); 148 151 149 #ifdef __cplusplus 150 } 151 #endif 152 __HELENOS_DECLS_END; 152 153 153 154 #endif -
uspace/lib/c/include/string.h
r4d51c60 rbc56f30 41 41 #endif 42 42 43 #include <_bits/decls.h> 43 44 #include <_bits/size_t.h> 44 45 #include <_bits/NULL.h> 45 46 #include <mem.h> 47 48 __C_DECLS_BEGIN; 46 49 47 50 extern char *strcpy(char *, const char *); … … 70 73 #endif 71 74 75 __C_DECLS_END; 76 72 77 #endif 73 78 -
uspace/lib/c/include/time.h
r4d51c60 rbc56f30 36 36 #define _LIBC_TIME_H_ 37 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 38 #include <_bits/decls.h> 41 39 42 40 /* ISO/IEC 9899:2011 7.27.1 (2) */ … … 51 49 52 50 #include <_bits/size_t.h> 51 52 __C_DECLS_BEGIN; 53 53 54 54 /* ISO/IEC 9899:2011 7.27.1 (3), (4) */ … … 106 106 const struct tm *__restrict__); 107 107 108 __C_DECLS_END; 109 108 110 #ifdef _HELENOS_SOURCE 109 111 … … 114 116 #include <stdbool.h> 115 117 #include <_bits/errno.h> 118 119 __HELENOS_DECLS_BEGIN; 116 120 117 121 typedef long long sec_t; … … 155 159 extern void udelay(sysarg_t); 156 160 161 __HELENOS_DECLS_END; 162 157 163 #endif /* _HELENOS_SOURCE */ 158 159 #ifdef __cplusplus160 }161 #endif162 164 163 165 #endif -
uspace/lib/c/include/vfs/vfs.h
r4d51c60 rbc56f30 44 44 #include <async.h> 45 45 #include <offset.h> 46 47 #define VFS_MAX_OPEN_FILES 12848 46 49 47 enum vfs_change_state_type {
Note:
See TracChangeset
for help on using the changeset viewer.