Changeset 8b863a62 in mainline for uspace/lib/posix
- Timestamp:
- 2014-04-16T17:14:06Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f857e8b
- Parents:
- dba3e2c (diff), 70b570c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/posix
- Files:
-
- 7 added
- 1 deleted
- 43 edited
- 3 moved
-
Makefile (modified) (4 diffs)
-
include/posix/ctype.h (modified) (2 diffs)
-
include/posix/dirent.h (added)
-
include/posix/fcntl.h (modified) (2 diffs)
-
include/posix/fenv.h (moved) (moved from uspace/lib/c/generic/device/graph_dev.c ) (2 diffs)
-
include/posix/float.h (modified) (1 diff)
-
include/posix/fnmatch.h (modified) (2 diffs)
-
include/posix/getopt.h (modified) (2 diffs)
-
include/posix/inttypes.h (modified) (1 diff)
-
include/posix/locale.h (modified) (4 diffs)
-
include/posix/math.h (modified) (2 diffs)
-
include/posix/pthread.h (added)
-
include/posix/pwd.h (modified) (1 diff)
-
include/posix/setjmp.h (moved) (moved from uspace/lib/softfloat/other.c ) (2 diffs)
-
include/posix/signal.h (modified) (5 diffs)
-
include/posix/stddef.h (modified) (2 diffs)
-
include/posix/stdint.h (modified) (2 diffs)
-
include/posix/stdio.h (modified) (5 diffs)
-
include/posix/stdlib.h (modified) (4 diffs)
-
include/posix/string.h (modified) (3 diffs)
-
include/posix/strings.h (modified) (2 diffs)
-
include/posix/sys/mman.h (modified) (3 diffs)
-
include/posix/sys/stat.h (modified) (3 diffs)
-
include/posix/sys/types.h (modified) (1 diff)
-
include/posix/sys/wait.h (modified) (2 diffs)
-
include/posix/time.h (modified) (2 diffs)
-
include/posix/ucontext.h (added)
-
include/posix/unistd.h (modified) (4 diffs)
-
source/ctype.c (modified) (1 diff)
-
source/errno.c (modified) (2 diffs)
-
source/fcntl.c (modified) (1 diff)
-
source/fnmatch.c (modified) (1 diff)
-
source/getopt.c (modified) (1 diff)
-
source/internal/common.h (modified) (1 diff)
-
source/locale.c (modified) (1 diff)
-
source/math.c (deleted)
-
source/pthread/condvar.c (added)
-
source/pthread/keys.c (added)
-
source/pthread/mutex.c (added)
-
source/pthread/threads.c (added)
-
source/pwd.c (modified) (1 diff)
-
source/signal.c (modified) (1 diff)
-
source/stdio.c (modified) (2 diffs)
-
source/stdio/scanf.c (modified) (1 diff)
-
source/stdlib.c (modified) (5 diffs)
-
source/stdlib/strtol.c (modified) (1 diff)
-
source/stdlib/strtold.c (modified) (1 diff)
-
source/string.c (modified) (1 diff)
-
source/strings.c (modified) (1 diff)
-
source/sys/mman.c (moved) (moved from uspace/lib/c/generic/mman.c ) (3 diffs)
-
source/sys/stat.c (modified) (1 diff)
-
source/sys/wait.c (modified) (1 diff)
-
source/time.c (modified) (2 diffs)
-
source/unistd.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/Makefile
rdba3e2c r8b863a62 37 37 INCLUDE_LIBC = ./include/libc 38 38 39 LIBC_FILE = $(LIBC_PREFIX)/libc.a 40 41 FIXED_POSIX_LIBRARY = libposixaslibc.a 42 FIXED_C_LIBRARY = libc4posix.a 43 44 REDEFS_HIDE_LIBC = redefs-hide-libc-symbols.list 45 REDEFS_SHOW_LIBPOSIX = redefs-show-posix-symbols.list 46 COLLISIONS_LIST = collisions.list 47 39 48 PRE_DEPEND = $(INCLUDE_LIBC) 40 EXTRA_CLEAN = $(INCLUDE_LIBC) 49 EXTRA_CLEAN = \ 50 $(INCLUDE_LIBC) \ 51 $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX) \ 52 $(COLLISIONS_LIST) 53 EXTRA_OUTPUT = $(FIXED_C_LIBRARY) $(FIXED_POSIX_LIBRARY) 41 54 42 55 SOURCES = \ … … 47 60 source/getopt.c \ 48 61 source/locale.c \ 49 source/math.c \ 62 source/pthread/condvar.c \ 63 source/pthread/keys.c \ 64 source/pthread/mutex.c \ 65 source/pthread/threads.c \ 50 66 source/pwd.c \ 51 67 source/signal.c \ … … 57 73 source/string.c \ 58 74 source/strings.c \ 75 source/sys/mman.c \ 59 76 source/sys/stat.c \ 60 77 source/sys/wait.c \ … … 66 83 $(INCLUDE_LIBC): ../c/include 67 84 ln -s -f -n ../$^ $@ 85 86 $(FIXED_C_LIBRARY): $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX) 87 $(OBJCOPY) --redefine-syms=$(REDEFS_HIDE_LIBC) $(LIBC_FILE) $@ 88 $(OBJCOPY) --redefine-syms=$(REDEFS_SHOW_LIBPOSIX) $@ $@ 89 90 $(FIXED_POSIX_LIBRARY): $(LIBRARY).a $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX) 91 $(OBJCOPY) --redefine-syms=$(REDEFS_HIDE_LIBC) $(LIBRARY).a $@ 92 $(OBJCOPY) --redefine-syms=$(REDEFS_SHOW_LIBPOSIX) $@ $@ 93 94 $(REDEFS_HIDE_LIBC): $(COLLISIONS_LIST) 95 sed 's/.*/& __helenos_libc_&/' <$(COLLISIONS_LIST) >$@ 96 97 $(REDEFS_SHOW_LIBPOSIX): $(COLLISIONS_LIST) 98 sed 's/.*/posix_& &/' <$(COLLISIONS_LIST) >$@ 99 100 $(COLLISIONS_LIST): 101 find ./include/posix -name '*.h' -exec \ 102 sed -n -e '/^#/d' -e 's/__POSIX_DEF__/\n&/gp' {} \; | \ 103 sed -n -e 's/__POSIX_DEF__(\([^)]*\)).*/\1/p' | \ 104 sort -u >$@ -
uspace/lib/posix/include/posix/ctype.h
rdba3e2c r8b863a62 37 37 #define POSIX_CTYPE_H_ 38 38 39 #ifndef __POSIX_DEF__ 40 #define __POSIX_DEF__(x) x 41 #endif 42 39 43 #include "libc/ctype.h" 40 44 41 45 /* 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);46 extern int __POSIX_DEF__(isxdigit)(int c); 47 extern int __POSIX_DEF__(isblank)(int c); 48 extern int __POSIX_DEF__(iscntrl)(int c); 49 extern int __POSIX_DEF__(isgraph)(int c); 50 extern int __POSIX_DEF__(isprint)(int c); 51 extern int __POSIX_DEF__(ispunct)(int c); 48 52 49 53 /* Obsolete Functions and Macros */ 50 extern int posix_isascii(int c);51 extern int posix_toascii(int c);54 extern int __POSIX_DEF__(isascii)(int c); 55 extern int __POSIX_DEF__(toascii)(int c); 52 56 #undef _tolower 53 57 #define _tolower(c) ((c) - 'A' + 'a') … … 56 60 57 61 58 #ifndef LIBPOSIX_INTERNAL59 #define isxdigit posix_isxdigit60 #define isblank posix_isblank61 #define iscntrl posix_iscntrl62 #define isgraph posix_isgraph63 #define isprint posix_isprint64 #define ispunct posix_ispunct65 66 #define isascii posix_isascii67 #define toascii posix_toascii68 #endif69 62 70 63 #endif /* POSIX_CTYPE_H_ */ -
uspace/lib/posix/include/posix/fcntl.h
rdba3e2c r8b863a62 35 35 #ifndef POSIX_FCNTL_H_ 36 36 #define POSIX_FCNTL_H_ 37 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 37 41 38 42 #include "sys/types.h" … … 76 80 #define FD_CLOEXEC 1 /* Close on exec. */ 77 81 78 extern int posix_open(const char *pathname, int flags, ...);79 extern int posix_fcntl(int fd, int cmd, ...);82 extern int __POSIX_DEF__(open)(const char *pathname, int flags, ...); 83 extern int __POSIX_DEF__(fcntl)(int fd, int cmd, ...); 80 84 81 #ifndef LIBPOSIX_INTERNAL82 #define fcntl posix_fcntl83 #define open posix_open84 #endif85 85 86 86 #endif /* POSIX_FCNTL_H_ */ -
uspace/lib/posix/include/posix/fenv.h
rdba3e2c r8b863a62 1 1 /* 2 * Copyright (c) 201 1 Petr Koupy2 * Copyright (c) 2013 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc 29 /** @addtogroup libposix 30 30 * @{ 31 31 */ 32 32 /** @file 33 * Floating point related constants. 33 34 */ 34 35 35 #include <errno.h> 36 #include <ipc/dev_iface.h> 37 #include <device/graph_dev.h> 36 #ifndef POSIX_FENV_H_ 37 #define POSIX_FENV_H_ 38 38 39 int graph_dev_connect(async_sess_t *sess)40 {41 async_exch_t *exch = async_exchange_begin(sess);42 int ret = async_req_1_0(exch, DEV_IFACE_ID(GRAPH_DEV_IFACE), GRAPH_DEV_CONNECT);43 async_exchange_end(exch);44 39 45 return ret; 46 } 40 #define FE_DIVBYZERO 1 41 #define FE_INEXACT 2 42 #define FE_INVALID 4 43 #define FE_OVERFLOW 8 44 #define FE_UNDERFLOW 16 45 #define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) 46 47 #endif 47 48 48 49 /** @} -
uspace/lib/posix/include/posix/float.h
rdba3e2c r8b863a62 59 59 #undef DBL_EPSILON 60 60 #define DBL_EPSILON __DBL_EPSILON__ 61 #undef LDBL_EPSILON 62 #define LDBL_EPSILON __LDBL_EPSILON__ 61 63 #undef FLT_RADIX 62 64 #define FLT_RADIX __FLT_RADIX__ 65 #undef FLT_MIN 66 #define FLT_MIN __FLT_MIN__ 67 #undef FLT_MAX 68 #define FLT_MAX __FLT_MAX__ 69 #undef FLT_EPSILON 70 #define FLT_EPSILON __FLT_EPSILON__ 71 #undef FLT_MANT_DIG 72 #define FLT_MANT_DIG __FLT_MANT_DIG__ 73 #undef LDBL_MIN 74 #define LDBL_MIN __LDBL_MIN__ 75 #undef LDBL_MAX 76 #define LDBL_MAX __LDBL_MAX__ 77 #undef LDBL_MANT_DIG 78 #define LDBL_MANT_DIG __LDBL_MANT_DIG__ 79 #else 80 /* For something else than GCC, following definitions are provided. 81 * They are intentionally guarded by the given macro to ensure that anyone 82 * who wants them states this explicitly. 83 * 84 * The values are the ones GCC prints when compiled on i686 Linux. 85 * 86 * WARNING: the values are not accurate (especially the long double ones)! 87 * 88 */ 89 #ifdef FLOAT_H_YES_I_REALLY_WANT_LIMITS 90 /* float limits */ 91 #define FLT_MIN 1.1754943508222875079687365372222456778186655567720875215087517062784172594547271728515625e-38 92 #define FLT_MAX 340282346638528859811704183484516925440 93 94 /* double limits */ 95 #define DBL_MIN 2.2250738585072013830902327173324040642192159804623318305533274168872044348139181958542831590125110205640673397310358110051524341615534601088560123853777188211307779935320023304796101474425836360719216e-308 96 #define DBL_MAX 1.7976931348623157081452742373170435679807056752584499659891747680315726078002853876058955863276687817154045895351438246423432132688946418276846754670353751698604991057655128207624549009038932894407587e+308 97 98 /* long double limits */ 99 #define LDBL_MIN 3.3621031431120935062626778173217526025980793448464712401088272298087426993907289670430927063650562228625019066688234732270901114717276781407474941951906317291667263914849985862188944930687409323125832e-4932L 100 #define LDBL_MAX 1.1897314953572317650212638530309702051690633222946242004403237338917370055229707226164102903365288828535456978074955773144274431536702884341981255738537436786735932007069732632019159182829615243655295e+4932L 101 102 /* epsilons */ 103 #define FLT_EPSILON 1.1920928955078125e-07 104 #define DBL_EPSILON 2.220446049250313080847263336181640625e-16 105 #define LDBL_EPSILON 1.08420217248550443400745280086994171142578125e-19L 106 107 /* float radix */ 108 #define FLT_RADIX 2 109 110 /* mantisa */ 111 #define FLT_MANT_DIG 24 112 #define DBL_MANT_DIG 53 113 #define LDBL_MANT_DIG 64 114 115 /* exponents */ 116 #define DBL_MIN_EXP -1021 117 #define DBL_MAX_EXP 1024 118 63 119 #endif 120 121 #endif /* __GNUC__ */ 64 122 65 123 #endif /* POSIX_FLOAT_H_ */ -
uspace/lib/posix/include/posix/fnmatch.h
rdba3e2c r8b863a62 36 36 #define POSIX_FNMATCH_H_ 37 37 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 41 38 42 /* Error Values */ 39 43 #undef FNM_NOMATCH … … 56 60 #define FNM_CASEFOLD 16 57 61 58 extern int posix_fnmatch(const char *pattern, const char *string, int flags);62 extern int __POSIX_DEF__(fnmatch)(const char *pattern, const char *string, int flags); 59 63 60 #ifndef LIBPOSIX_INTERNAL61 #define fnmatch posix_fnmatch62 #endif63 64 64 65 #endif /* POSIX_FNMATCH_H_ */ -
uspace/lib/posix/include/posix/getopt.h
rdba3e2c r8b863a62 35 35 #define POSIX_GETOPT_H 36 36 37 #ifndef __POSIX_DEF__ 38 #define __POSIX_DEF__(x) x 39 #endif 40 37 41 #include "unistd.h" 38 42 … … 51 55 #endif 52 56 53 extern int posix_getopt_long(int, char * const [], const char *, const struct option *, int *); 54 55 56 #ifndef LIBPOSIX_INTERNAL 57 #define getopt_long posix_getopt_long 58 #endif 57 extern int __POSIX_DEF__(getopt_long)(int, char * const [], const char *, const struct option *, int *); 59 58 60 59 -
uspace/lib/posix/include/posix/inttypes.h
rdba3e2c r8b863a62 36 36 #define POSIX_INTTYPES_H_ 37 37 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 41 38 42 #include "stdint.h" 39 43 #include "libc/inttypes.h" 40 44 41 extern posix_intmax_t posix_strtoimax(const char *restrict nptr,45 extern __POSIX_DEF__(intmax_t) __POSIX_DEF__(strtoimax)(const char *restrict nptr, 42 46 char **restrict endptr, int base); 43 extern posix_uintmax_t posix_strtoumax(const char *restrict nptr,47 extern __POSIX_DEF__(uintmax_t) __POSIX_DEF__(strtoumax)(const char *restrict nptr, 44 48 char **restrict endptr, int base); 45 49 46 #ifndef LIBPOSIX_INTERNAL47 #define strtoimax posix_strtoimax48 #define strtoumax posix_strtoumax49 #endif50 50 51 51 #endif /* POSIX_INTTYPES_H_ */ -
uspace/lib/posix/include/posix/locale.h
rdba3e2c r8b863a62 36 36 #define POSIX_LOCALE_H_ 37 37 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 41 38 42 #ifndef NULL 39 43 #define NULL ((void *) 0) … … 42 46 #ifndef __locale_t_defined 43 47 #define __locale_t_defined 44 typedef struct __posix_locale * posix_locale_t;48 typedef struct __posix_locale *__POSIX_DEF__(locale_t); 45 49 #ifndef LIBPOSIX_INTERNAL 46 #define locale_t posix_locale_t50 #define locale_t __POSIX_DEF__(locale_t) 47 51 #endif 48 52 #endif … … 82 86 #define LC_GLOBAL_LOCALE NULL 83 87 84 struct posix_lconv{88 struct __POSIX_DEF__(lconv) { 85 89 char *currency_symbol; 86 90 char *decimal_point; … … 109 113 }; 110 114 111 extern char * posix_setlocale(int category, const char *locale);112 extern struct posix_lconv *posix_localeconv(void);115 extern char *__POSIX_DEF__(setlocale)(int category, const char *locale); 116 extern struct __POSIX_DEF__(lconv) *__POSIX_DEF__(localeconv)(void); 113 117 114 118 /* POSIX Extensions */ 115 extern posix_locale_t posix_duplocale(posix_locale_tlocobj);116 extern void posix_freelocale(posix_locale_tlocobj);117 extern posix_locale_t posix_newlocale(int category_mask, const char *locale,118 posix_locale_tbase);119 extern posix_locale_t posix_uselocale(posix_locale_tnewloc);119 extern __POSIX_DEF__(locale_t) __POSIX_DEF__(duplocale)(__POSIX_DEF__(locale_t) locobj); 120 extern void __POSIX_DEF__(freelocale)(__POSIX_DEF__(locale_t) locobj); 121 extern __POSIX_DEF__(locale_t) __POSIX_DEF__(newlocale)(int category_mask, const char *locale, 122 __POSIX_DEF__(locale_t) base); 123 extern __POSIX_DEF__(locale_t) __POSIX_DEF__(uselocale)(__POSIX_DEF__(locale_t) newloc); 120 124 121 #ifndef LIBPOSIX_INTERNAL122 #define lconv posix_lconv123 124 #define setlocale posix_setlocale125 #define localeconv posix_localeconv126 127 #define newlocale posix_newlocale128 #define uselocale posix_uselocale129 #define duplocale posix_duplocale130 #define freelocale posix_freelocale131 #endif132 125 133 126 #endif /* POSIX_LOCALE_H_ */ -
uspace/lib/posix/include/posix/math.h
rdba3e2c r8b863a62 31 31 */ 32 32 /** @file Mathematical operations. 33 * 34 * The purpose of this file is only to provide prototypes of mathematical 35 * functions defined by C standard and by POSIX. 36 * 37 * It is up to the application to correctly link with either libmath 38 * (provided by HelenOS) or by some other math library (such as fdlibm). 33 39 */ 34 40 … … 40 46 #endif 41 47 42 /* Normalization Functions */ 43 extern double posix_ldexp(double x, int exp); 44 extern double posix_frexp(double num, int *exp); 48 extern double ldexp(double, int); 49 extern double frexp(double, int *); 45 50 46 double posix_fabs(double x); 47 double posix_floor(double x); 48 double posix_modf(double x, double *iptr); 49 double posix_fmod(double x, double y); 50 double posix_pow(double x, double y); 51 double posix_exp(double x); 52 double posix_sqrt(double x); 53 double posix_log(double x); 54 double posix_sin(double x); 55 double posix_cos(double x); 56 double posix_atan2(double y, double x); 57 58 #ifndef LIBPOSIX_INTERNAL 59 #define ldexp posix_ldexp 60 #define frexp posix_frexp 61 62 #define fabs posix_fabs 63 #define floor posix_floor 64 #define modf posix_modf 65 #define fmod posix_fmod 66 #define pow posix_pow 67 #define exp posix_exp 68 #define sqrt posix_sqrt 69 #define log posix_log 70 #define sin posix_sin 71 #define cos posix_cos 72 #define atan2 posix_atan2 73 #endif 51 extern double fabs(double); 52 extern double floor(double); 53 extern double ceil(double); 54 extern double modf(double, double *); 55 extern double fmod(double, double); 56 extern double pow(double, double); 57 extern double exp(double); 58 extern double frexp(double, int *); 59 extern double expm1(double); 60 extern double sqrt(double); 61 extern double log(double); 62 extern double log10(double); 63 extern double sin(double); 64 extern double sinh(double); 65 extern double asin(double); 66 extern double asinh(double); 67 extern double cos(double); 68 extern double cosh(double); 69 extern double acos(double); 70 extern double acosh(double); 71 extern double tan(double); 72 extern double tanh(double); 73 extern double atan(double); 74 extern double atanh(double); 75 extern double atan2(double, double); 76 extern double copysign(double, double); 74 77 75 78 #endif /* POSIX_MATH_H_ */ -
uspace/lib/posix/include/posix/pwd.h
rdba3e2c r8b863a62 36 36 #define POSIX_PWD_H_ 37 37 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 41 38 42 #include "sys/types.h" 39 43 40 struct posix_passwd{44 struct __POSIX_DEF__(passwd) { 41 45 char *pw_name; 42 posix_uid_tpw_uid;43 posix_gid_tpw_gid;46 __POSIX_DEF__(uid_t) pw_uid; 47 __POSIX_DEF__(gid_t) pw_gid; 44 48 char *pw_dir; 45 49 char *pw_shell; 46 50 }; 47 51 48 extern struct posix_passwd *posix_getpwent(void);49 extern void posix_setpwent(void);50 extern void posix_endpwent(void);52 extern struct __POSIX_DEF__(passwd) *__POSIX_DEF__(getpwent)(void); 53 extern void __POSIX_DEF__(setpwent)(void); 54 extern void __POSIX_DEF__(endpwent)(void); 51 55 52 extern struct posix_passwd *posix_getpwnam(const char *name);53 extern int posix_getpwnam_r(const char *name, struct posix_passwd*pwd,54 char *buffer, size_t bufsize, struct posix_passwd**result);56 extern struct __POSIX_DEF__(passwd) *__POSIX_DEF__(getpwnam)(const char *name); 57 extern int __POSIX_DEF__(getpwnam_r)(const char *name, struct __POSIX_DEF__(passwd) *pwd, 58 char *buffer, size_t bufsize, struct __POSIX_DEF__(passwd) **result); 55 59 56 extern struct posix_passwd *posix_getpwuid(posix_uid_tuid);57 extern int posix_getpwuid_r(posix_uid_t uid, struct posix_passwd*pwd,58 char *buffer, size_t bufsize, struct posix_passwd**result);60 extern struct __POSIX_DEF__(passwd) *__POSIX_DEF__(getpwuid)(__POSIX_DEF__(uid_t) uid); 61 extern int __POSIX_DEF__(getpwuid_r)(__POSIX_DEF__(uid_t) uid, struct __POSIX_DEF__(passwd) *pwd, 62 char *buffer, size_t bufsize, struct __POSIX_DEF__(passwd) **result); 59 63 60 #ifndef LIBPOSIX_INTERNAL61 #define passwd posix_passwd62 63 #define getpwent posix_getpwent64 #define setpwent posix_setpwent65 #define endpwent posix_endpwent66 67 #define getpwnam posix_getpwnam68 #define getpwnam_r posix_getpwnam_r69 70 #define getpwuid posix_getpwuid71 #define getpwuid_r posix_getpwuid_r72 #endif73 64 74 65 #endif /* POSIX_PWD_H_ */ -
uspace/lib/posix/include/posix/setjmp.h
rdba3e2c r8b863a62 1 1 /* 2 * Copyright (c) 20 05 Josef Cejka2 * Copyright (c) 2013 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup softfloat29 /** @addtogroup libposix 30 30 * @{ 31 31 */ 32 /** @file Other functions (power, complex). 32 33 /* 34 * Just a pass-through to libc setjmp. 33 35 */ 34 36 #include "libc/setjmp.h" 35 37 36 38 /** @} -
uspace/lib/posix/include/posix/signal.h
rdba3e2c r8b863a62 36 36 #define POSIX_SIGNAL_H_ 37 37 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 41 38 42 #include "sys/types.h" 43 #include <posix/ucontext.h> 39 44 40 45 extern void __posix_default_signal_handler(int signo); … … 51 56 #define SIG_IGN ((void (*)(int)) __posix_ignore_signal_handler) 52 57 53 typedef int posix_sig_atomic_t;54 typedef uint32_t posix_sigset_t;55 typedef struct posix_mcontext {56 /* must not be empty to avoid compiler warnings (-pedantic) */57 int dummy;58 } posix_mcontext_t;59 60 union posix_sigval {61 int sival_int;62 void *sival_ptr;63 };64 65 struct posix_sigevent {66 int sigev_notify; /* Notification type. */67 int sigev_signo; /* Signal number. */68 union posix_sigval sigev_value; /* Signal value. */69 void (*sigev_notify_function)(union posix_sigval); /* Notification function. */70 posix_thread_attr_t *sigev_notify_attributes; /* Notification attributes. */71 };72 58 73 59 typedef struct { … … 77 63 int si_errno; 78 64 79 posix_pid_tsi_pid;80 posix_uid_tsi_uid;65 __POSIX_DEF__(pid_t) si_pid; 66 __POSIX_DEF__(uid_t) si_uid; 81 67 void *si_addr; 82 68 int si_status; … … 84 70 long si_band; 85 71 86 union posix_sigvalsi_value;87 } posix_siginfo_t;88 89 struct posix_sigaction{72 union __POSIX_DEF__(sigval) si_value; 73 } __POSIX_DEF__(siginfo_t); 74 75 struct __POSIX_DEF__(sigaction) { 90 76 void (*sa_handler)(int); 91 posix_sigset_tsa_mask;77 __POSIX_DEF__(sigset_t) sa_mask; 92 78 int sa_flags; 93 void (*sa_sigaction)(int, posix_siginfo_t*, void *);79 void (*sa_sigaction)(int, __POSIX_DEF__(siginfo_t) *, void *); 94 80 }; 95 81 96 typedef struct { 97 void *ss_sp; 98 size_t ss_size; 99 int ss_flags; 100 } posix_stack_t; 101 102 typedef struct posix_ucontext { 103 struct posix_ucontext *uc_link; 104 posix_sigset_t uc_sigmask; 105 posix_stack_t uc_stack; 106 posix_mcontext_t uc_mcontext; 107 } posix_ucontext_t; 108 109 /* Values of posix_sigevent::sigev_notify */ 82 83 /* Values of __POSIX_DEF__(sigevent)::sigev_notify */ 110 84 #undef SIGEV_NONE 111 85 #undef SIGEV_SIGNAL … … 255 229 }; 256 230 257 extern int posix_sigaction(int sig, const struct posix_sigaction *restrict act, 258 struct posix_sigaction *restrict oact); 259 260 extern void (*posix_signal(int sig, void (*func)(int)))(int); 261 extern int posix_raise(int sig); 262 extern int posix_kill(posix_pid_t pid, int sig); 263 extern int posix_killpg(posix_pid_t pid, int sig); 264 265 extern void posix_psiginfo(const posix_siginfo_t *pinfo, const char *message); 266 extern void posix_psignal(int signum, const char *message); 267 268 extern int posix_sigemptyset(posix_sigset_t *set); 269 extern int posix_sigfillset(posix_sigset_t *set); 270 extern int posix_sigaddset(posix_sigset_t *set, int signo); 271 extern int posix_sigdelset(posix_sigset_t *set, int signo); 272 extern int posix_sigismember(const posix_sigset_t *set, int signo); 273 274 extern int posix_thread_sigmask(int how, const posix_sigset_t *restrict set, 275 posix_sigset_t *restrict oset); 276 extern int posix_sigprocmask(int how, const posix_sigset_t *restrict set, 277 posix_sigset_t *restrict oset); 278 279 #ifndef LIBPOSIX_INTERNAL 280 #define sig_atomic_t posix_sig_atomic_t 281 #define sigset_t posix_sigset_t 282 #define sigval posix_sigval 283 #ifndef sigevent 284 #define sigevent posix_sigevent 285 #endif 286 #define mcontext_t posix_mcontext_t 287 #define ucontext_t posix_ucontext_t 288 #define stack_t posix_stack_t 289 #define siginfo_t posix_siginfo_t 290 291 #define sigaction posix_sigaction 292 293 #define signal posix_signal 294 #define raise posix_raise 295 #define kill posix_kill 296 #define killpg posix_killpg 297 298 #define psiginfo posix_psiginfo 299 #define psignal posix_psignal 300 301 #define sigemptyset posix_sigemptyset 302 #define sigfillset posix_sigfillset 303 #define sigaddset posix_sigaddset 304 #define sigdelset posix_sigdelset 305 #define sigismember posix_sigismember 306 307 #define pthread_sigmask posix_thread_sigmask 308 #define sigprocmask posix_sigprocmask 309 #endif 231 extern int __POSIX_DEF__(sigaction)(int sig, const struct __POSIX_DEF__(sigaction) *restrict act, 232 struct __POSIX_DEF__(sigaction) *restrict oact); 233 234 extern void (*__POSIX_DEF__(signal)(int sig, void (*func)(int)))(int); 235 extern int __POSIX_DEF__(raise)(int sig); 236 extern int __POSIX_DEF__(kill)(__POSIX_DEF__(pid_t) pid, int sig); 237 extern int __POSIX_DEF__(killpg)(__POSIX_DEF__(pid_t) pid, int sig); 238 239 extern void __POSIX_DEF__(psiginfo)(const __POSIX_DEF__(siginfo_t) *pinfo, const char *message); 240 extern void __POSIX_DEF__(psignal)(int signum, const char *message); 241 242 extern int __POSIX_DEF__(sigemptyset)(__POSIX_DEF__(sigset_t) *set); 243 extern int __POSIX_DEF__(sigfillset)(__POSIX_DEF__(sigset_t) *set); 244 extern int __POSIX_DEF__(sigaddset)(__POSIX_DEF__(sigset_t) *set, int signo); 245 extern int __POSIX_DEF__(sigdelset)(__POSIX_DEF__(sigset_t) *set, int signo); 246 extern int __POSIX_DEF__(sigismember)(const __POSIX_DEF__(sigset_t) *set, int signo); 247 248 extern int __POSIX_DEF__(thread_sigmask)(int how, const __POSIX_DEF__(sigset_t) *restrict set, 249 __POSIX_DEF__(sigset_t) *restrict oset); 250 extern int __POSIX_DEF__(sigprocmask)(int how, const __POSIX_DEF__(sigset_t) *restrict set, 251 __POSIX_DEF__(sigset_t) *restrict oset); 252 310 253 311 254 #endif /* POSIX_SIGNAL_H_ */ -
uspace/lib/posix/include/posix/stddef.h
rdba3e2c r8b863a62 36 36 #define POSIX_STDDEF_H_ 37 37 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 41 38 42 #include "sys/types.h" 39 43 … … 44 48 #define offsetof(type,member) ((size_t) &(((type *) 0)->member)) 45 49 46 typedef ssize_t posix_ptrdiff_t;50 typedef ssize_t __POSIX_DEF__(ptrdiff_t); 47 51 48 #ifndef LIBPOSIX_INTERNAL49 #define ptrdiff_t posix_ptrdiff_t50 #endif51 52 52 53 #endif /* POSIX_STDDEF_H_ */ -
uspace/lib/posix/include/posix/stdint.h
rdba3e2c r8b863a62 35 35 #ifndef POSIX_STDINT_H_ 36 36 #define POSIX_STDINT_H_ 37 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 37 41 38 42 #include "libc/stdint.h" … … 100 104 #include "libc/sys/types.h" 101 105 102 typedef int64_t posix_intmax_t;103 typedef uint64_t posix_uintmax_t;106 typedef int64_t __POSIX_DEF__(intmax_t); 107 typedef uint64_t __POSIX_DEF__(uintmax_t); 104 108 105 #ifndef LIBPOSIX_INTERNAL 106 #define intmax_t posix_intmax_t 107 #define uintmax_t posix_uintmax_t 108 #endif 109 110 /* 111 * Fast* and least* integer types. 112 * 113 * The definitions below are definitely safe if not the best. 114 */ 115 typedef uint8_t uint_least8_t; 116 typedef uint16_t uint_least16_t; 117 typedef uint32_t uint_least32_t; 118 typedef uint64_t uint_least64_t; 119 120 typedef int8_t int_least8_t; 121 typedef int16_t int_least16_t; 122 typedef int32_t int_least32_t; 123 typedef int64_t int_least64_t; 124 125 typedef uint8_t uint_fast8_t; 126 typedef uint16_t uint_fast16_t; 127 typedef uint32_t uint_fast32_t; 128 typedef uint64_t uint_fast64_t; 129 130 typedef int8_t int_fast8_t; 131 typedef int16_t int_fast16_t; 132 typedef int32_t int_fast32_t; 133 typedef int64_t int_fast64_t; 109 134 110 135 #endif /* POSIX_STDINT_H_ */ -
uspace/lib/posix/include/posix/stdio.h
rdba3e2c r8b863a62 37 37 #define POSIX_STDIO_H_ 38 38 39 #ifndef __POSIX_DEF__ 40 #define __POSIX_DEF__(x) x 41 /* DEBUG macro does not belong to POSIX stdio.h. Its unconditional 42 * definition in the native stdio.h causes unexpected behaviour of 43 * applications which uses their own DEBUG macro (e.g. debugging 44 * output is printed even if not desirable). */ 45 #undef DEBUG 46 #endif 47 39 48 #include "stddef.h" 40 49 #include "unistd.h" … … 55 64 #define EOF (-1) 56 65 66 /** Size of buffers used in stdio header. */ 57 67 #define BUFSIZ 4096 58 #define SEEK_SET 0 59 #define SEEK_CUR 1 60 #define SEEK_END 268 69 /** Maximum size in bytes of the longest filename. */ 70 #define FILENAME_MAX 4096 61 71 62 72 typedef struct _IO_FILE FILE; … … 108 118 extern size_t fwrite(const void *, size_t, size_t, FILE *); 109 119 110 extern int fseek(FILE *, off64_t, int);111 120 extern void rewind(FILE *); 112 extern off64_t ftell(FILE *);113 121 extern int feof(FILE *); 114 122 extern int fileno(FILE *); … … 119 127 120 128 extern void setvbuf(FILE *, void *, int, size_t); 121 129 extern void setbuf(FILE *, void *); 122 130 123 131 /* POSIX specific stuff. */ … … 126 134 #undef L_ctermid 127 135 #define L_ctermid PATH_MAX 128 extern char * posix_ctermid(char *s);136 extern char *__POSIX_DEF__(ctermid)(char *s); 129 137 130 138 /* Error Recovery */ 131 extern void posix_clearerr(FILE *stream);139 extern void __POSIX_DEF__(clearerr)(FILE *stream); 132 140 133 141 /* Input/Output */ 134 142 #undef putc 135 143 #define putc fputc 136 extern int posix_fputs(const char *restrict s, FILE *restrict stream);144 extern int __POSIX_DEF__(fputs)(const char *restrict s, FILE *restrict stream); 137 145 #undef getc 138 146 #define getc fgetc 139 extern int posix_ungetc(int c, FILE *stream);140 extern ssize_t posix_getdelim(char **restrict lineptr, size_t *restrict n,147 extern int __POSIX_DEF__(ungetc)(int c, FILE *stream); 148 extern ssize_t __POSIX_DEF__(getdelim)(char **restrict lineptr, size_t *restrict n, 141 149 int delimiter, FILE *restrict stream); 142 extern ssize_t posix_getline(char **restrict lineptr, size_t *restrict n,150 extern ssize_t __POSIX_DEF__(getline)(char **restrict lineptr, size_t *restrict n, 143 151 FILE *restrict stream); 144 152 145 153 /* Opening Streams */ 146 extern FILE * posix_freopen(const char *restrict filename,154 extern FILE *__POSIX_DEF__(freopen)(const char *restrict filename, 147 155 const char *restrict mode, FILE *restrict stream); 148 156 149 157 /* Error Messages */ 150 extern void posix_perror(const char *s);158 extern void __POSIX_DEF__(perror)(const char *s); 151 159 152 160 /* File Positioning */ 153 typedef struct _posix_fpos posix_fpos_t; 154 extern int posix_fsetpos(FILE *stream, const posix_fpos_t *pos); 155 extern int posix_fgetpos(FILE *restrict stream, posix_fpos_t *restrict pos); 156 extern int posix_fseek(FILE *stream, long offset, int whence); 157 extern int posix_fseeko(FILE *stream, posix_off_t offset, int whence); 158 extern long posix_ftell(FILE *stream); 159 extern posix_off_t posix_ftello(FILE *stream); 161 typedef struct { 162 off64_t offset; 163 } __POSIX_DEF__(fpos_t); 164 165 extern int __POSIX_DEF__(fsetpos)(FILE *stream, const __POSIX_DEF__(fpos_t) *pos); 166 extern int __POSIX_DEF__(fgetpos)(FILE *restrict stream, __POSIX_DEF__(fpos_t) *restrict pos); 167 extern int __POSIX_DEF__(fseek)(FILE *stream, long offset, int whence); 168 extern int __POSIX_DEF__(fseeko)(FILE *stream, __POSIX_DEF__(off_t) offset, int whence); 169 extern long __POSIX_DEF__(ftell)(FILE *stream); 170 extern __POSIX_DEF__(off_t) __POSIX_DEF__(ftello)(FILE *stream); 160 171 161 172 /* Flushing Buffers */ 162 extern int posix_fflush(FILE *stream);173 extern int __POSIX_DEF__(fflush)(FILE *stream); 163 174 164 175 /* Formatted Output */ 165 extern int posix_dprintf(int fildes, const char *restrict format, ...)176 extern int __POSIX_DEF__(dprintf)(int fildes, const char *restrict format, ...) 166 177 PRINTF_ATTRIBUTE(2, 3); 167 extern int posix_vdprintf(int fildes, const char *restrict format, va_list ap);168 extern int posix_sprintf(char *restrict s, const char *restrict format, ...)178 extern int __POSIX_DEF__(vdprintf)(int fildes, const char *restrict format, va_list ap); 179 extern int __POSIX_DEF__(sprintf)(char *restrict s, const char *restrict format, ...) 169 180 PRINTF_ATTRIBUTE(2, 3); 170 extern int posix_vsprintf(char *restrict s, const char *restrict format, va_list ap);181 extern int __POSIX_DEF__(vsprintf)(char *restrict s, const char *restrict format, va_list ap); 171 182 172 183 /* Formatted Input */ 173 extern int posix_fscanf(184 extern int __POSIX_DEF__(fscanf)( 174 185 FILE *restrict stream, const char *restrict format, ...); 175 extern int posix_vfscanf(186 extern int __POSIX_DEF__(vfscanf)( 176 187 FILE *restrict stream, const char *restrict format, va_list arg); 177 extern int posix_scanf(const char *restrict format, ...);178 extern int posix_vscanf(const char *restrict format, va_list arg);179 extern int posix_sscanf(188 extern int __POSIX_DEF__(scanf)(const char *restrict format, ...); 189 extern int __POSIX_DEF__(vscanf)(const char *restrict format, va_list arg); 190 extern int __POSIX_DEF__(sscanf)( 180 191 const char *restrict s, const char *restrict format, ...); 181 extern int posix_vsscanf(192 extern int __POSIX_DEF__(vsscanf)( 182 193 const char *restrict s, const char *restrict format, va_list arg); 183 194 184 195 /* File Locking */ 185 extern void posix_flockfile(FILE *file);186 extern int posix_ftrylockfile(FILE *file);187 extern void posix_funlockfile(FILE *file);188 extern int posix_getc_unlocked(FILE *stream);189 extern int posix_getchar_unlocked(void);190 extern int posix_putc_unlocked(int c, FILE *stream);191 extern int posix_putchar_unlocked(int c);196 extern void __POSIX_DEF__(flockfile)(FILE *file); 197 extern int __POSIX_DEF__(ftrylockfile)(FILE *file); 198 extern void __POSIX_DEF__(funlockfile)(FILE *file); 199 extern int __POSIX_DEF__(getc_unlocked)(FILE *stream); 200 extern int __POSIX_DEF__(getchar_unlocked)(void); 201 extern int __POSIX_DEF__(putc_unlocked)(int c, FILE *stream); 202 extern int __POSIX_DEF__(putchar_unlocked)(int c); 192 203 193 204 /* Deleting Files */ 194 extern int posix_remove(const char *path);205 extern int __POSIX_DEF__(remove)(const char *path); 195 206 196 207 /* Renaming Files */ 197 extern int posix_rename(const char *old, const char *new);208 extern int __POSIX_DEF__(rename)(const char *oldname, const char *newname); 198 209 199 210 /* Temporary Files */ 200 211 #undef L_tmpnam 201 212 #define L_tmpnam PATH_MAX 202 extern char *posix_tmpnam(char *s); 203 extern char *posix_tempnam(const char *dir, const char *pfx); 204 extern FILE *posix_tmpfile(void); 205 206 #ifndef LIBPOSIX_INTERNAL 207 /* DEBUG macro does not belong to POSIX stdio.h. Its unconditional 208 * definition in the native stdio.h causes unexpected behaviour of 209 * applications which uses their own DEBUG macro (e.g. debugging 210 * output is printed even if not desirable). */ 211 #undef DEBUG 212 213 #define ctermid posix_ctermid 214 215 #define clearerr posix_clearerr 216 217 #define fputs posix_fputs 218 #define ungetc posix_ungetc 219 #define getdelim posix_getdelim 220 #define getline posix_getline 221 222 #define freopen posix_freopen 223 224 #define perror posix_perror 225 226 #define fpos_t posix_fpos_t 227 #define fsetpos posix_fsetpos 228 #define fgetpos posix_fgetpos 229 #define fseek posix_fseek 230 #define fseeko posix_fseeko 231 #define ftell posix_ftell 232 #define ftello posix_ftello 233 234 #define fflush posix_fflush 235 236 #define dprintf posix_dprintf 237 #define vdprintf posix_vdprintf 238 #define sprintf posix_sprintf 239 #define vsprintf posix_vsprintf 240 241 #define fscanf posix_fscanf 242 #define vfscanf posix_vfscanf 243 #define vscanf posix_vscanf 244 #define scanf posix_scanf 245 #define sscanf posix_sscanf 246 #define vsscanf posix_vsscanf 247 248 #define flockfile posix_flockfile 249 #define ftrylockfile posix_ftrylockfile 250 #define funlockfile posix_funlockfile 251 252 #define getc_unlocked posix_getc_unlocked 253 #define getchar_unlocked posix_getchar_unlocked 254 #define putc_unlocked posix_putc_unlocked 255 #define putchar_unlocked posix_putchar_unlocked 256 257 #define remove posix_remove 258 259 #define rename posix_rename 260 261 #define tmpnam posix_tmpnam 262 #define tempnam posix_tempnam 263 #define tmpfile posix_tmpfile 264 #endif 213 extern char *__POSIX_DEF__(tmpnam)(char *s); 214 extern char *__POSIX_DEF__(tempnam)(const char *dir, const char *pfx); 215 extern FILE *__POSIX_DEF__(tmpfile)(void); 216 265 217 266 218 #endif /* POSIX_STDIO_H_ */ -
uspace/lib/posix/include/posix/stdlib.h
rdba3e2c r8b863a62 37 37 #define POSIX_STDLIB_H_ 38 38 39 #ifndef __POSIX_DEF__ 40 #define __POSIX_DEF__(x) x 41 #endif 42 39 43 #include "sys/types.h" 40 44 … … 42 46 #define NULL ((void *) 0) 43 47 #endif 48 49 #define RAND_MAX 714025 44 50 45 51 /* Process Termination */ … … 49 55 #define EXIT_SUCCESS 0 50 56 #define _Exit exit 51 extern int posix_atexit(void (*func)(void));52 extern void exit(int status) ;57 extern int __POSIX_DEF__(atexit)(void (*func)(void)); 58 extern void exit(int status) __attribute__((noreturn)); 53 59 extern void abort(void) __attribute__((noreturn)); 54 60 55 61 /* Absolute Value */ 56 extern int posix_abs(int i);57 extern long posix_labs(long i);58 extern long long posix_llabs(long long i);62 extern int __POSIX_DEF__(abs)(int i); 63 extern long __POSIX_DEF__(labs)(long i); 64 extern long long __POSIX_DEF__(llabs)(long long i); 59 65 60 66 /* Integer Division */ … … 62 68 typedef struct { 63 69 int quot, rem; 64 } posix_div_t;70 } __POSIX_DEF__(div_t); 65 71 66 72 typedef struct { 67 73 long quot, rem; 68 } posix_ldiv_t;74 } __POSIX_DEF__(ldiv_t); 69 75 70 76 typedef struct { 71 77 long long quot, rem; 72 } posix_lldiv_t;78 } __POSIX_DEF__(lldiv_t); 73 79 74 extern posix_div_t posix_div(int numer, int denom);75 extern posix_ldiv_t posix_ldiv(long numer, long denom);76 extern posix_lldiv_t posix_lldiv(long long numer, long long denom);80 extern __POSIX_DEF__(div_t) __POSIX_DEF__(div)(int numer, int denom); 81 extern __POSIX_DEF__(ldiv_t) __POSIX_DEF__(ldiv)(long numer, long denom); 82 extern __POSIX_DEF__(lldiv_t) __POSIX_DEF__(lldiv)(long long numer, long long denom); 77 83 78 84 /* Array Functions */ 79 extern void posix_qsort(void *array, size_t count, size_t size,85 extern void __POSIX_DEF__(qsort)(void *array, size_t count, size_t size, 80 86 int (*compare)(const void *, const void *)); 81 extern void * posix_bsearch(const void *key, const void *base,87 extern void *__POSIX_DEF__(bsearch)(const void *key, const void *base, 82 88 size_t nmemb, size_t size, int (*compar)(const void *, const void *)); 83 89 84 90 /* Environment Access */ 85 extern char * posix_getenv(const char *name);86 extern int posix_putenv(char *string);87 extern int posix_system(const char *string);91 extern char *__POSIX_DEF__(getenv)(const char *name); 92 extern int __POSIX_DEF__(putenv)(char *string); 93 extern int __POSIX_DEF__(system)(const char *string); 88 94 89 95 /* Symbolic Links */ 90 extern char * posix_realpath(const char *restrict name, char *restrict resolved);96 extern char *__POSIX_DEF__(realpath)(const char *restrict name, char *restrict resolved); 91 97 92 98 /* Floating Point Conversion */ 93 extern double posix_atof(const char *nptr);94 extern float posix_strtof(const char *restrict nptr, char **restrict endptr);95 extern double posix_strtod(const char *restrict nptr, char **restrict endptr);96 extern long double posix_strtold(const char *restrict nptr, char **restrict endptr);99 extern double __POSIX_DEF__(atof)(const char *nptr); 100 extern float __POSIX_DEF__(strtof)(const char *restrict nptr, char **restrict endptr); 101 extern double __POSIX_DEF__(strtod)(const char *restrict nptr, char **restrict endptr); 102 extern long double __POSIX_DEF__(strtold)(const char *restrict nptr, char **restrict endptr); 97 103 98 104 /* Integer Conversion */ 99 extern int posix_atoi(const char *nptr);100 extern long int posix_atol(const char *nptr);101 extern long long int posix_atoll(const char *nptr);102 extern long int posix_strtol(const char *restrict nptr,105 extern int __POSIX_DEF__(atoi)(const char *nptr); 106 extern long int __POSIX_DEF__(atol)(const char *nptr); 107 extern long long int __POSIX_DEF__(atoll)(const char *nptr); 108 extern long int __POSIX_DEF__(strtol)(const char *restrict nptr, 103 109 char **restrict endptr, int base); 104 extern long long int posix_strtoll(const char *restrict nptr,110 extern long long int __POSIX_DEF__(strtoll)(const char *restrict nptr, 105 111 char **restrict endptr, int base); 106 extern unsigned long int posix_strtoul(const char *restrict nptr,112 extern unsigned long int __POSIX_DEF__(strtoul)(const char *restrict nptr, 107 113 char **restrict endptr, int base); 108 extern unsigned long long int posix_strtoull(114 extern unsigned long long int __POSIX_DEF__(strtoull)( 109 115 const char *restrict nptr, char **restrict endptr, int base); 110 116 111 117 /* Memory Allocation */ 112 extern void * posix_malloc(size_t size);113 extern void * posix_calloc(size_t nelem, size_t elsize);114 extern void * posix_realloc(void *ptr, size_t size);115 extern void posix_free(void *ptr);118 extern void *__POSIX_DEF__(malloc)(size_t size); 119 extern void *__POSIX_DEF__(calloc)(size_t nelem, size_t elsize); 120 extern void *__POSIX_DEF__(realloc)(void *ptr, size_t size); 121 extern void __POSIX_DEF__(free)(void *ptr); 116 122 117 123 /* Temporary Files */ 118 extern int posix_mkstemp(char *tmpl); 124 extern int __POSIX_DEF__(mkstemp)(char *tmpl); 125 126 /* Pseudo-random number generator */ 127 extern int __POSIX_DEF__(rand)(void); 128 extern void __POSIX_DEF__(srand)(unsigned int seed); 119 129 120 130 /* Legacy Declarations */ 121 extern char * posix_mktemp(char *tmpl);131 extern char *__POSIX_DEF__(mktemp)(char *tmpl); 122 132 extern int bsd_getloadavg(double loadavg[], int nelem); 123 124 #ifndef LIBPOSIX_INTERNAL125 #define atexit posix_atexit126 127 #define abs posix_abs128 #define labs posix_labs129 #define llabs posix_llabs130 131 #define div_t posix_div_t132 #define ldiv_t posix_ldiv_t133 #define lldiv_t posix_lldiv_t134 #define div posix_div135 #define ldiv posix_ldiv136 #define lldiv posix_lldiv137 138 #define qsort posix_qsort139 #define bsearch posix_bsearch140 141 #define getenv posix_getenv142 #define putenv posix_putenv143 #define system posix_system144 145 #define realpath posix_realpath146 147 #define atof posix_atof148 #define strtof posix_strtof149 #define strtod posix_strtod150 #define strtold posix_strtold151 152 #define atoi posix_atoi153 #define atol posix_atol154 #define atoll posix_atoll155 #define strtol posix_strtol156 #define strtoll posix_strtoll157 #define strtoul posix_strtoul158 #define strtoull posix_strtoull159 160 #define malloc posix_malloc161 #define calloc posix_calloc162 #define realloc posix_realloc163 #define free posix_free164 165 #define mkstemp posix_mkstemp166 167 #define mktemp posix_mktemp168 #define getloadavg bsd_getloadavg169 #endif170 133 171 134 #endif // POSIX_STDLIB_H_ -
uspace/lib/posix/include/posix/string.h
rdba3e2c r8b863a62 37 37 #define POSIX_STRING_H_ 38 38 39 #ifndef __POSIX_DEF__ 40 #define __POSIX_DEF__(x) x 41 #endif 42 39 43 #include "sys/types.h" 40 44 … … 65 69 66 70 /* From mem.h */ 67 #define bzero(ptr, len) memset((ptr), 0, (len))71 // #define bzero(ptr, len) memset((ptr), 0, (len)) 68 72 extern void *memset(void *, int, size_t); 69 73 extern void *memcpy(void *, const void *, size_t); … … 72 76 73 77 /* Copying and Concatenation */ 74 extern char * posix_strcpy(char *restrict dest, const char *restrict src);75 extern char * posix_strncpy(char *restrict dest, const char *restrict src, size_t n);76 extern char * posix_stpcpy(char *restrict dest, const char *restrict src);77 extern char * posix_stpncpy(char *restrict dest, const char *restrict src, size_t n);78 extern char * posix_strcat(char *restrict dest, const char *restrict src);79 extern char * posix_strncat(char *restrict dest, const char *restrict src, size_t n);80 extern void * posix_memccpy(void *restrict dest, const void *restrict src, int c, size_t n);81 extern char * posix_strdup(const char *s);82 extern char * posix_strndup(const char *s, size_t n);78 extern char *__POSIX_DEF__(strcpy)(char *restrict dest, const char *restrict src); 79 extern char *__POSIX_DEF__(strncpy)(char *restrict dest, const char *restrict src, size_t n); 80 extern char *__POSIX_DEF__(stpcpy)(char *restrict dest, const char *restrict src); 81 extern char *__POSIX_DEF__(stpncpy)(char *restrict dest, const char *restrict src, size_t n); 82 extern char *__POSIX_DEF__(strcat)(char *restrict dest, const char *restrict src); 83 extern char *__POSIX_DEF__(strncat)(char *restrict dest, const char *restrict src, size_t n); 84 extern void *__POSIX_DEF__(memccpy)(void *restrict dest, const void *restrict src, int c, size_t n); 85 extern char *__POSIX_DEF__(strdup)(const char *s); 86 extern char *__POSIX_DEF__(strndup)(const char *s, size_t n); 83 87 84 88 /* String/Array Comparison */ 85 extern int posix_memcmp(const void *mem1, const void *mem2, size_t n);86 extern int posix_strcmp(const char *s1, const char *s2);87 extern int posix_strncmp(const char *s1, const char *s2, size_t n);89 extern int __POSIX_DEF__(memcmp)(const void *mem1, const void *mem2, size_t n); 90 extern int __POSIX_DEF__(strcmp)(const char *s1, const char *s2); 91 extern int __POSIX_DEF__(strncmp)(const char *s1, const char *s2, size_t n); 88 92 89 93 /* Search Functions */ 90 extern void * posix_memchr(const void *mem, int c, size_t n);91 extern char * posix_strchr(const char *s, int c);92 extern char * posix_strrchr(const char *s, int c);94 extern void *__POSIX_DEF__(memchr)(const void *mem, int c, size_t n); 95 extern char *__POSIX_DEF__(strchr)(const char *s, int c); 96 extern char *__POSIX_DEF__(strrchr)(const char *s, int c); 93 97 extern char *gnu_strchrnul(const char *s, int c); 94 extern char * posix_strpbrk(const char *s1, const char *s2);95 extern size_t posix_strcspn(const char *s1, const char *s2);96 extern size_t posix_strspn(const char *s1, const char *s2);97 extern char * posix_strstr(const char *haystack, const char *needle);98 extern char *__POSIX_DEF__(strpbrk)(const char *s1, const char *s2); 99 extern size_t __POSIX_DEF__(strcspn)(const char *s1, const char *s2); 100 extern size_t __POSIX_DEF__(strspn)(const char *s1, const char *s2); 101 extern char *__POSIX_DEF__(strstr)(const char *haystack, const char *needle); 98 102 99 103 /* Collation Functions */ 100 extern int posix_strcoll(const char *s1, const char *s2);101 extern size_t posix_strxfrm(char *restrict s1, const char *restrict s2, size_t n);104 extern int __POSIX_DEF__(strcoll)(const char *s1, const char *s2); 105 extern size_t __POSIX_DEF__(strxfrm)(char *restrict s1, const char *restrict s2, size_t n); 102 106 103 107 /* Error Messages */ 104 extern char * posix_strerror(int errnum);105 extern int posix_strerror_r(int errnum, char *buf, size_t bufsz);108 extern char *__POSIX_DEF__(strerror)(int errnum); 109 extern int __POSIX_DEF__(strerror_r)(int errnum, char *buf, size_t bufsz); 106 110 107 111 /* String Length */ 108 extern size_t posix_strlen(const char *s);109 extern size_t posix_strnlen(const char *s, size_t n);112 extern size_t __POSIX_DEF__(strlen)(const char *s); 113 extern size_t __POSIX_DEF__(strnlen)(const char *s, size_t n); 110 114 111 115 /* Signal Messages */ 112 extern char * posix_strsignal(int signum);116 extern char *__POSIX_DEF__(strsignal)(int signum); 113 117 114 118 /* Legacy Declarations */ 115 119 #ifndef POSIX_STRINGS_H_ 116 extern int posix_ffs(int i);117 extern int posix_strcasecmp(const char *s1, const char *s2);118 extern int posix_strncasecmp(const char *s1, const char *s2, size_t n);120 extern int __POSIX_DEF__(ffs)(int i); 121 extern int __POSIX_DEF__(strcasecmp)(const char *s1, const char *s2); 122 extern int __POSIX_DEF__(strncasecmp)(const char *s1, const char *s2, size_t n); 119 123 #endif 120 124 121 #ifndef LIBPOSIX_INTERNAL122 #define strcpy posix_strcpy123 #define strncpy posix_strncpy124 #define stpcpy posix_stpcpy125 #define stpncpy posix_stpncpy126 #define strcat posix_strcat127 #define strncat posix_strncat128 #define memccpy posix_memccpy129 #define strdup posix_strdup130 #define strndup posix_strndup131 132 #define memcmp posix_memcmp133 #define strcmp posix_strcmp134 #define strncmp posix_strncmp135 136 #define memchr posix_memchr137 #define strchr posix_strchr138 #define strrchr posix_strrchr139 #define strchrnul gnu_strchrnul140 #define strpbrk posix_strpbrk141 #define strcspn posix_strcspn142 #define strspn posix_strspn143 #define strstr posix_strstr144 145 #define strcoll posix_strcoll146 #define strxfrm posix_strxfrm147 148 #define strerror posix_strerror149 #define strerror_r posix_strerror_r150 151 #define strlen posix_strlen152 #define strnlen posix_strnlen153 154 #define strsignal posix_strsignal155 156 #define ffs posix_ffs157 #define strcasecmp posix_strcasecmp158 #define strncasecmp posix_strncasecmp159 #endif160 125 161 126 #endif // POSIX_STRING_H_ -
uspace/lib/posix/include/posix/strings.h
rdba3e2c r8b863a62 37 37 #define POSIX_STRINGS_H_ 38 38 39 #ifndef __POSIX_DEF__ 40 #define __POSIX_DEF__(x) x 41 #endif 42 43 44 #include <libarch/types.h> 45 39 46 /* Search Functions */ 40 47 #ifndef POSIX_STRING_H_ 41 extern int posix_ffs(int i);48 extern int __POSIX_DEF__(ffs)(int i); 42 49 #endif 43 50 44 51 /* String/Array Comparison */ 45 52 #ifndef POSIX_STRING_H_ 46 extern int posix_strcasecmp(const char *s1, const char *s2);47 extern int posix_strncasecmp(const char *s1, const char *s2, size_t n);53 extern int __POSIX_DEF__(strcasecmp)(const char *s1, const char *s2); 54 extern int __POSIX_DEF__(strncasecmp)(const char *s1, const char *s2, size_t n); 48 55 #endif 49 56 … … 55 62 56 63 /* Legacy Functions */ 57 extern int posix_bcmp(const void *mem1, const void *mem2, size_t n);58 extern void posix_bcopy(const void *src, void *dest, size_t n);59 extern void posix_bzero(void *mem, size_t n);60 extern char * posix_index(const char *s, int c);61 extern char * posix_rindex(const char *s, int c);64 extern int __POSIX_DEF__(bcmp)(const void *mem1, const void *mem2, size_t n); 65 extern void __POSIX_DEF__(bcopy)(const void *src, void *dest, size_t n); 66 extern void __POSIX_DEF__(bzero)(void *mem, size_t n); 67 extern char *__POSIX_DEF__(index)(const char *s, int c); 68 extern char *__POSIX_DEF__(rindex)(const char *s, int c); 62 69 63 #ifndef LIBPOSIX_INTERNAL64 #define ffs posix_ffs65 66 #define strcasecmp posix_strcasecmp67 #define strncasecmp posix_strncasecmp68 69 #define bcmp posix_bcmp70 #define bcopy posix_bcopy71 #undef bzero72 #define bzero posix_bzero73 #define index posix_index74 #define rindex posix_rindex75 #endif76 70 77 71 #endif // POSIX_STRINGS_H_ -
uspace/lib/posix/include/posix/sys/mman.h
rdba3e2c r8b863a62 36 36 #define POSIX_SYS_MMAN_H_ 37 37 38 #include "sys/types.h" 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 41 42 #include "types.h" 39 43 #include <abi/mm/as.h> 40 44 … … 45 49 #define MAP_FIXED (1 << 2) 46 50 #define MAP_ANONYMOUS (1 << 3) 51 #define MAP_ANON MAP_ANONYMOUS 47 52 48 53 #undef PROT_NONE … … 55 60 #define PROT_EXEC AS_AREA_EXEC 56 61 57 extern void *mmap(void *start, size_t length, int prot, int flags, int fd, 58 posix_off_t offset); 59 extern int munmap(void *start, size_t length); 62 extern void * 63 __POSIX_DEF__(mmap)(void *start, size_t length, int prot, int flags, int fd, 64 __POSIX_DEF__(off_t) offset); 65 extern int __POSIX_DEF__(munmap)(void *start, size_t length); 66 60 67 61 68 #endif /* POSIX_SYS_MMAN_H_ */ -
uspace/lib/posix/include/posix/sys/stat.h
rdba3e2c r8b863a62 39 39 #include "types.h" 40 40 #include "../time.h" 41 42 #ifndef __POSIX_DEF__ 43 #define __POSIX_DEF__(x) x 44 #endif 41 45 42 46 /* values are the same as on Linux */ … … 108 112 #define S_ISSOCK(m) ((m & S_IFSOCK) != 0) /* socket? (Not in POSIX.1-1996.) */ 109 113 110 struct posix_stat{111 posix_dev_tst_dev; /* ID of device containing file */112 posix_ino_tst_ino; /* inode number */114 struct __POSIX_DEF__(stat) { 115 __POSIX_DEF__(dev_t) st_dev; /* ID of device containing file */ 116 __POSIX_DEF__(ino_t) st_ino; /* inode number */ 113 117 mode_t st_mode; /* protection */ 114 posix_nlink_tst_nlink; /* number of hard links */115 posix_uid_tst_uid; /* user ID of owner */116 posix_gid_tst_gid; /* group ID of owner */117 posix_dev_tst_rdev; /* device ID (if special file) */118 posix_off_tst_size; /* total size, in bytes */119 posix_blksize_tst_blksize; /* blocksize for file system I/O */120 posix_blkcnt_tst_blocks; /* number of 512B blocks allocated */118 __POSIX_DEF__(nlink_t) st_nlink; /* number of hard links */ 119 __POSIX_DEF__(uid_t) st_uid; /* user ID of owner */ 120 __POSIX_DEF__(gid_t) st_gid; /* group ID of owner */ 121 __POSIX_DEF__(dev_t) st_rdev; /* device ID (if special file) */ 122 __POSIX_DEF__(off_t) st_size; /* total size, in bytes */ 123 __POSIX_DEF__(blksize_t) st_blksize; /* blocksize for file system I/O */ 124 __POSIX_DEF__(blkcnt_t) st_blocks; /* number of 512B blocks allocated */ 121 125 time_t st_atime; /* time of last access */ 122 126 time_t st_mtime; /* time of last modification */ … … 124 128 }; 125 129 126 extern int posix_fstat(int fd, struct posix_stat*st);127 extern int posix_lstat(const char *restrict path, struct posix_stat*restrict st);128 extern int posix_stat(const char *restrict path, struct posix_stat*restrict st);129 extern int posix_chmod(const char *path, mode_t mode);130 extern mode_t posix_umask(mode_t mask);130 extern int __POSIX_DEF__(fstat)(int fd, struct __POSIX_DEF__(stat) *st); 131 extern int __POSIX_DEF__(lstat)(const char *restrict path, struct __POSIX_DEF__(stat) *restrict st); 132 extern int __POSIX_DEF__(stat)(const char *restrict path, struct __POSIX_DEF__(stat) *restrict st); 133 extern int __POSIX_DEF__(chmod)(const char *path, mode_t mode); 134 extern mode_t __POSIX_DEF__(umask)(mode_t mask); 131 135 extern int mkdir(const char *, mode_t); 132 136 133 #ifndef LIBPOSIX_INTERNAL134 #define fstat posix_fstat135 #define lstat posix_lstat136 #define stat posix_stat137 #define chmod posix_chmod138 #define umask posix_umask139 #endif140 137 141 138 #endif /* POSIX_SYS_STAT_H */ -
uspace/lib/posix/include/posix/sys/types.h
rdba3e2c r8b863a62 37 37 #define POSIX_SYS_TYPES_H_ 38 38 39 #ifndef __POSIX_DEF__ 40 #define __POSIX_DEF__(x) x 41 #endif 42 39 43 #include "libc/sys/types.h" 40 44 #include "libc/sys/time.h" 41 45 42 typedef unsigned int posix_ino_t;43 typedef unsigned int posix_nlink_t;44 typedef unsigned int posix_uid_t;45 typedef unsigned int posix_gid_t;46 typedef off64_t posix_off_t;47 typedef long posix_blksize_t;48 typedef long posix_blkcnt_t;49 typedef int64_t posix_pid_t;50 typedef sysarg_t posix_dev_t;46 typedef unsigned int __POSIX_DEF__(ino_t); 47 typedef unsigned int __POSIX_DEF__(nlink_t); 48 typedef unsigned int __POSIX_DEF__(uid_t); 49 typedef unsigned int __POSIX_DEF__(gid_t); 50 typedef off64_t __POSIX_DEF__(off_t); 51 typedef long __POSIX_DEF__(blksize_t); 52 typedef long __POSIX_DEF__(blkcnt_t); 53 typedef int64_t __POSIX_DEF__(pid_t); 54 typedef sysarg_t __POSIX_DEF__(dev_t); 51 55 52 56 /* PThread Types */ 53 typedef struct posix_thread_attr posix_thread_attr_t;57 typedef struct __POSIX_DEF__(thread_attr) __POSIX_DEF__(thread_attr_t); 54 58 55 59 /* Clock Types */ 56 typedef long posix_clock_t;57 typedef int posix_clockid_t;60 typedef long __POSIX_DEF__(clock_t); 61 typedef int __POSIX_DEF__(clockid_t); 58 62 59 #ifndef LIBPOSIX_INTERNAL60 #define ino_t posix_ino_t61 #define nlink_t posix_nlink_t62 #define uid_t posix_uid_t63 #define gid_t posix_gid_t64 #define off_t posix_off_t65 #define blksize_t posix_blksize_t66 #define blkcnt_t posix_blkcnt_t67 #define pid_t posix_pid_t68 #define dev_t posix_dev_t69 70 #define pthread_attr_t posix_thread_attr_t71 72 #define clock_t posix_clock_t73 #define clockid_t posix_clockid_t74 #endif75 63 76 64 #endif /* POSIX_SYS_TYPES_H_ */ -
uspace/lib/posix/include/posix/sys/wait.h
rdba3e2c r8b863a62 36 36 #define POSIX_SYS_WAIT_H_ 37 37 38 #ifndef __POSIX_DEF__ 39 #define __POSIX_DEF__(x) x 40 #endif 41 38 42 #include "types.h" 39 43 … … 52 56 extern int __posix_wtermsig(int status); 53 57 54 extern posix_pid_t posix_wait(int *stat_ptr);55 extern posix_pid_t posix_waitpid(posix_pid_tpid, int *stat_ptr, int options);58 extern __POSIX_DEF__(pid_t) __POSIX_DEF__(wait)(int *stat_ptr); 59 extern __POSIX_DEF__(pid_t) __POSIX_DEF__(waitpid)(__POSIX_DEF__(pid_t) pid, int *stat_ptr, int options); 56 60 57 #ifndef LIBPOSIX_INTERNAL58 #define wait posix_wait59 #define waitpid posix_waitpid60 #endif61 61 62 62 #endif /* POSIX_SYS_WAIT_H_ */ -
uspace/lib/posix/include/posix/time.h
rdba3e2c r8b863a62 37 37 #define POSIX_TIME_H_ 38 38 39 #ifndef __POSIX_DEF__ 40 #define __POSIX_DEF__(x) x 41 #endif 42 39 43 #include "sys/types.h" 40 44 … … 49 53 #ifndef __locale_t_defined 50 54 #define __locale_t_defined 51 typedef struct __posix_locale * posix_locale_t;55 typedef struct __posix_locale *__POSIX_DEF__(locale_t); 52 56 #ifndef LIBPOSIX_INTERNAL 53 #define locale_t posix_locale_t57 #define locale_t __POSIX_DEF__(locale_t) 54 58 #endif 55 59 #endif 56 60 57 61 #ifndef POSIX_SIGNAL_H_ 58 struct posix_sigevent;62 struct __POSIX_DEF__(sigevent); 59 63 #ifndef LIBPOSIX_INTERNAL 60 #define sigevent posix_sigevent64 #define sigevent __POSIX_DEF__(sigevent) 61 65 #endif 62 66 #endif 63 67 64 68 #undef CLOCK_REALTIME 65 #define CLOCK_REALTIME (( posix_clockid_t) 0)69 #define CLOCK_REALTIME ((__POSIX_DEF__(clockid_t)) 0) 66 70 67 struct posix_timespec{71 struct __POSIX_DEF__(timespec) { 68 72 time_t tv_sec; /* Seconds. */ 69 73 long tv_nsec; /* Nanoseconds. */ 70 74 }; 71 75 72 struct posix_itimerspec{73 struct posix_timespecit_interval; /* Timer period. */74 struct posix_timespecit_value; /* Timer expiration. */76 struct __POSIX_DEF__(itimerspec) { 77 struct __POSIX_DEF__(timespec) it_interval; /* Timer period. */ 78 struct __POSIX_DEF__(timespec) it_value; /* Timer expiration. */ 75 79 }; 76 80 77 typedef struct __posix_timer * posix_timer_t;81 typedef struct __posix_timer *__POSIX_DEF__(timer_t); 78 82 79 83 /* Timezones */ 80 extern int posix_daylight; 81 extern long posix_timezone; 82 extern char *posix_tzname[2]; 83 extern void posix_tzset(void); 84 extern int __POSIX_DEF__(daylight); 85 extern long __POSIX_DEF__(timezone); 86 extern char *__POSIX_DEF__(tzname)[2]; 87 extern void __POSIX_DEF__(tzset)(void); 88 89 /* Time */ 90 extern time_t __POSIX_DEF__(time)(time_t *t); 84 91 85 92 /* Broken-down Time */ 86 extern struct tm * posix_gmtime_r(const time_t *restrict timer,93 extern struct tm *__POSIX_DEF__(gmtime_r)(const time_t *restrict timer, 87 94 struct tm *restrict result); 88 extern struct tm * posix_gmtime(const time_t *restrict timep);89 extern struct tm * posix_localtime_r(const time_t *restrict timer,95 extern struct tm *__POSIX_DEF__(gmtime)(const time_t *restrict timep); 96 extern struct tm *__POSIX_DEF__(localtime_r)(const time_t *restrict timer, 90 97 struct tm *restrict result); 91 extern struct tm * posix_localtime(const time_t *restrict timep);98 extern struct tm *__POSIX_DEF__(localtime)(const time_t *restrict timep); 92 99 93 100 /* Formatting Calendar Time */ 94 extern char * posix_asctime_r(const struct tm *restrict timeptr,101 extern char *__POSIX_DEF__(asctime_r)(const struct tm *restrict timeptr, 95 102 char *restrict buf); 96 extern char *posix_asctime(const struct tm *restrict timeptr); 97 extern char *posix_ctime_r(const time_t *timer, char *buf); 98 extern char *posix_ctime(const time_t *timer); 103 extern char *__POSIX_DEF__(asctime)(const struct tm *restrict timeptr); 104 extern char *__POSIX_DEF__(ctime_r)(const time_t *timer, char *buf); 105 extern char *__POSIX_DEF__(ctime)(const time_t *timer); 106 extern time_t time(time_t *t); 99 107 100 108 /* Clocks */ 101 extern int posix_clock_getres(posix_clockid_tclock_id,102 struct posix_timespec*res);103 extern int posix_clock_gettime(posix_clockid_tclock_id,104 struct posix_timespec*tp);105 extern int posix_clock_settime(posix_clockid_tclock_id,106 const struct posix_timespec*tp);107 extern int posix_clock_nanosleep(posix_clockid_tclock_id, int flags,108 const struct posix_timespec *rqtp, struct posix_timespec*rmtp);109 extern int __POSIX_DEF__(clock_getres)(__POSIX_DEF__(clockid_t) clock_id, 110 struct __POSIX_DEF__(timespec) *res); 111 extern int __POSIX_DEF__(clock_gettime)(__POSIX_DEF__(clockid_t) clock_id, 112 struct __POSIX_DEF__(timespec) *tp); 113 extern int __POSIX_DEF__(clock_settime)(__POSIX_DEF__(clockid_t) clock_id, 114 const struct __POSIX_DEF__(timespec) *tp); 115 extern int __POSIX_DEF__(clock_nanosleep)(__POSIX_DEF__(clockid_t) clock_id, int flags, 116 const struct __POSIX_DEF__(timespec) *rqtp, struct __POSIX_DEF__(timespec) *rmtp); 109 117 110 118 /* CPU Time */ 111 extern posix_clock_t posix_clock(void);119 extern __POSIX_DEF__(clock_t) __POSIX_DEF__(clock)(void); 112 120 113 #ifndef LIBPOSIX_INTERNAL114 #define timespec posix_timespec115 #define itimerspec posix_itimerspec116 #define timer_t posix_timer_t117 118 #define daylight posix_daylight119 #define timezone posix_timezone120 #define tzname posix_tzname121 #define tzset posix_tzset122 123 #define gmtime_r posix_gmtime_r124 #define gmtime posix_gmtime125 #define localtime_r posix_localtime_r126 #define localtime posix_localtime127 128 #define asctime_r posix_asctime_r129 #define asctime posix_asctime130 #define ctime_r posix_ctime_r131 #define ctime posix_ctime132 133 #define clock_getres posix_clock_getres134 #define clock_gettime posix_clock_gettime135 #define clock_settime posix_clock_settime136 #define clock_nanosleep posix_clock_nanosleep137 138 #define clock posix_clock139 #endif140 121 141 122 #endif // POSIX_TIME_H_ -
uspace/lib/posix/include/posix/unistd.h
rdba3e2c r8b863a62 37 37 #define POSIX_UNISTD_H_ 38 38 39 #ifndef __POSIX_DEF__ 40 #define __POSIX_DEF__(x) x 41 #endif 42 39 43 #include "sys/types.h" 40 44 #include "stddef.h" 45 46 #define SEEK_SET 0 47 #define SEEK_CUR 1 48 #define SEEK_END 2 41 49 42 50 /* Process Termination */ 43 51 #define _exit exit 44 52 45 extern char * posix_optarg;53 extern char *__POSIX_DEF__(optarg); 46 54 extern int optind, opterr, optopt; 47 extern int posix_getopt(int, char * const [], const char *);55 extern int __POSIX_DEF__(getopt)(int, char * const [], const char *); 48 56 49 57 /* Environment */ 50 extern char ** posix_environ;58 extern char **__POSIX_DEF__(environ); 51 59 52 60 /* Login Information */ 53 extern char * posix_getlogin(void);54 extern int posix_getlogin_r(char *name, size_t namesize);61 extern char *__POSIX_DEF__(getlogin)(void); 62 extern int __POSIX_DEF__(getlogin_r)(char *name, size_t namesize); 55 63 56 64 /* Identifying Terminals */ 57 extern int posix_isatty(int fd);65 extern int __POSIX_DEF__(isatty)(int fd); 58 66 59 67 /* Working Directory */ 60 extern char * posix_getcwd(char *buf, size_t size);61 extern int posix_chdir(const char *path);68 extern char *__POSIX_DEF__(getcwd)(char *buf, size_t size); 69 extern int __POSIX_DEF__(chdir)(const char *path); 62 70 63 71 /* Query Memory Parameters */ 64 extern int posix_getpagesize(void);72 extern int __POSIX_DEF__(getpagesize)(void); 65 73 66 74 /* Process Identification */ 67 extern posix_pid_t posix_getpid(void);68 extern posix_uid_t posix_getuid(void);69 extern posix_gid_t posix_getgid(void);75 extern __POSIX_DEF__(pid_t) __POSIX_DEF__(getpid)(void); 76 extern __POSIX_DEF__(uid_t) __POSIX_DEF__(getuid)(void); 77 extern __POSIX_DEF__(gid_t) __POSIX_DEF__(getgid)(void); 70 78 71 79 /* File Manipulation */ 72 extern int posix_close(int fildes); 73 extern ssize_t posix_read(int fildes, void *buf, size_t nbyte); 74 extern ssize_t posix_write(int fildes, const void *buf, size_t nbyte); 75 extern int posix_fsync(int fildes); 76 extern int posix_ftruncate(int fildes, posix_off_t length); 77 extern int posix_rmdir(const char *path); 78 extern int posix_unlink(const char *path); 79 extern int posix_dup(int fildes); 80 extern int posix_dup2(int fildes, int fildes2); 80 extern int __POSIX_DEF__(close)(int fildes); 81 extern ssize_t __POSIX_DEF__(read)(int fildes, void *buf, size_t nbyte); 82 extern ssize_t __POSIX_DEF__(write)(int fildes, const void *buf, size_t nbyte); 83 extern __POSIX_DEF__(off_t) __POSIX_DEF__(lseek)(int fildes, 84 __POSIX_DEF__(off_t) offset, int whence); 85 extern int __POSIX_DEF__(fsync)(int fildes); 86 extern int __POSIX_DEF__(ftruncate)(int fildes, __POSIX_DEF__(off_t) length); 87 extern int __POSIX_DEF__(rmdir)(const char *path); 88 extern int __POSIX_DEF__(unlink)(const char *path); 89 extern int __POSIX_DEF__(dup)(int fildes); 90 extern int __POSIX_DEF__(dup2)(int fildes, int fildes2); 81 91 82 92 /* Standard Streams */ … … 97 107 #define W_OK 2 /* Test for write permission. */ 98 108 #define R_OK 4 /* Test for read permission. */ 99 extern int posix_access(const char *path, int amode);109 extern int __POSIX_DEF__(access)(const char *path, int amode); 100 110 101 111 /* System Parameters */ … … 106 116 _SC_CLK_TCK 107 117 }; 108 extern long posix_sysconf(int name);118 extern long __POSIX_DEF__(sysconf)(int name); 109 119 110 120 /* Path Configuration Parameters */ … … 130 140 _PC_VDISABLE 131 141 }; 132 extern long posix_pathconf(const char *path, int name);142 extern long __POSIX_DEF__(pathconf)(const char *path, int name); 133 143 134 144 /* Creating a Process */ 135 extern posix_pid_t posix_fork(void);145 extern __POSIX_DEF__(pid_t) __POSIX_DEF__(fork)(void); 136 146 137 147 /* Executing a File */ 138 extern int posix_execv(const char *path, char *const argv[]);139 extern int posix_execvp(const char *file, char *const argv[]);148 extern int __POSIX_DEF__(execv)(const char *path, char *const argv[]); 149 extern int __POSIX_DEF__(execvp)(const char *file, char *const argv[]); 140 150 141 151 /* Creating a Pipe */ 142 extern int posix_pipe(int fildes[2]);152 extern int __POSIX_DEF__(pipe)(int fildes[2]); 143 153 144 #ifndef LIBPOSIX_INTERNAL 145 #define getopt posix_getopt 146 #define optarg posix_optarg 147 148 #define environ posix_environ 149 150 #define getlogin posix_getlogin 151 #define getlogin_r posix_getlogin_r 152 153 #define getcwd posix_getcwd 154 #define chdir posix_chdir 155 156 #define isatty posix_isatty 157 158 #undef getpagesize 159 #define getpagesize posix_getpagesize 160 161 #define getpid posix_getpid 162 #define getuid posix_getuid 163 #define getgid posix_getgid 164 165 #define close posix_close 166 #define read posix_read 167 #define write posix_write 168 #define fsync posix_fsync 169 #define ftruncate posix_ftruncate 170 #define rmdir posix_rmdir 171 #define unlink posix_unlink 172 #define dup posix_dup 173 #define dup2 posix_dup2 174 175 #define access posix_access 176 177 #define sysconf posix_sysconf 178 179 #define pathconf posix_pathconf 180 181 #define fork posix_fork 182 183 #define execv posix_execv 184 #define execvp posix_execvp 185 186 #define pipe posix_pipe 187 #endif 154 /* Issue alarm signal. */ 155 extern unsigned int __POSIX_DEF__(alarm)(unsigned int); 188 156 189 157 #endif /* POSIX_UNISTD_H_ */ -
uspace/lib/posix/source/ctype.c
rdba3e2c r8b863a62 35 35 36 36 #define LIBPOSIX_INTERNAL 37 #define __POSIX_DEF__(x) posix_##x 37 38 38 39 #include "posix/ctype.h" -
uspace/lib/posix/source/errno.c
rdba3e2c r8b863a62 32 32 /** @file System error numbers. 33 33 */ 34 #define LIBPOSIX_INTERNAL 35 #define __POSIX_DEF__(x) posix_##x 34 36 35 37 #include "posix/errno.h" … … 43 45 { 44 46 if (*__errno() != 0) { 45 _posix_errno = abs(*__errno());47 _posix_errno = posix_abs(*__errno()); 46 48 *__errno() = 0; 47 49 } -
uspace/lib/posix/source/fcntl.c
rdba3e2c r8b863a62 34 34 35 35 #define LIBPOSIX_INTERNAL 36 #define __POSIX_DEF__(x) posix_##x 36 37 37 38 #include "internal/common.h" -
uspace/lib/posix/source/fnmatch.c
rdba3e2c r8b863a62 43 43 44 44 #define LIBPOSIX_INTERNAL 45 #define __POSIX_DEF__(x) posix_##x 45 46 46 47 #include "libc/stdbool.h" -
uspace/lib/posix/source/getopt.c
rdba3e2c r8b863a62 33 33 */ 34 34 #define LIBPOSIX_INTERNAL 35 #define __POSIX_DEF__(x) posix_##x 35 36 36 37 #include "internal/common.h" -
uspace/lib/posix/source/internal/common.h
rdba3e2c r8b863a62 39 39 #include <stdlib.h> 40 40 41 #define not_implemented() (fprintf(stderr, \ 42 "Function %s() in file %s at line %d is not implemented\n", \ 43 __func__, __FILE__, __LINE__), abort()) 41 #define not_implemented() do { \ 42 static int __not_implemented_counter = 0; \ 43 if (__not_implemented_counter == 0) { \ 44 fprintf(stderr, "%s() not implemented in %s:%d, something will NOT work.\n", \ 45 __func__, __FILE__, __LINE__); \ 46 } \ 47 __not_implemented_counter++; \ 48 } while (0) 44 49 45 50 /* A little helper macro to avoid typing this over and over. */ -
uspace/lib/posix/source/locale.c
rdba3e2c r8b863a62 34 34 35 35 #define LIBPOSIX_INTERNAL 36 #define __POSIX_DEF__(x) posix_##x 36 37 37 38 #include "internal/common.h" -
uspace/lib/posix/source/pwd.c
rdba3e2c r8b863a62 34 34 35 35 #define LIBPOSIX_INTERNAL 36 #define __POSIX_DEF__(x) posix_##x 36 37 37 38 #include "libc/stdbool.h" -
uspace/lib/posix/source/signal.c
rdba3e2c r8b863a62 34 34 35 35 #define LIBPOSIX_INTERNAL 36 #define __POSIX_DEF__(x) posix_##x 36 37 37 38 #include "posix/signal.h" -
uspace/lib/posix/source/stdio.c
rdba3e2c r8b863a62 35 35 36 36 #define LIBPOSIX_INTERNAL 37 #define __POSIX_DEF__(x) posix_##x 37 38 38 39 #include "internal/common.h" … … 308 309 } 309 310 310 struct _posix_fpos {311 off64_t offset;312 };313 314 311 /** Restores stream a to position previously saved with fgetpos(). 315 312 * -
uspace/lib/posix/source/stdio/scanf.c
rdba3e2c r8b863a62 34 34 35 35 #define LIBPOSIX_INTERNAL 36 #define __POSIX_DEF__(x) posix_##x 36 37 37 38 #include "posix/assert.h" -
uspace/lib/posix/source/stdlib.c
rdba3e2c r8b863a62 35 35 36 36 #define LIBPOSIX_INTERNAL 37 #define __POSIX_DEF__(x) posix_##x 37 38 38 39 #include "internal/common.h" … … 62 63 // TODO: low priority, just a compile-time dependency of binutils 63 64 not_implemented(); 65 return 0; 64 66 } 65 67 … … 231 233 // TODO: low priority, just a compile-time dependency of binutils 232 234 not_implemented(); 235 return 0; 233 236 } 234 237 … … 243 246 int posix_system(const char *string) { 244 247 // TODO: does nothing at the moment 248 not_implemented(); 245 249 return 0; 246 250 } … … 387 391 free(ptr); 388 392 } 393 } 394 395 /** 396 * Generate a pseudo random integer in the range 0 to RAND_MAX inclusive. 397 * 398 * @return The pseudo random integer. 399 */ 400 int posix_rand(void) 401 { 402 return (int) random(); 403 } 404 405 /** 406 * Initialize a new sequence of pseudo-random integers. 407 * 408 * @param seed The seed of the new sequence. 409 */ 410 void posix_srand(unsigned int seed) 411 { 412 srandom(seed); 389 413 } 390 414 -
uspace/lib/posix/source/stdlib/strtol.c
rdba3e2c r8b863a62 34 34 35 35 #define LIBPOSIX_INTERNAL 36 #define __POSIX_DEF__(x) posix_##x 36 37 37 38 #include "../internal/common.h" -
uspace/lib/posix/source/stdlib/strtold.c
rdba3e2c r8b863a62 34 34 35 35 #define LIBPOSIX_INTERNAL 36 #define __POSIX_DEF__(x) posix_##x 36 37 37 38 #include "../internal/common.h" -
uspace/lib/posix/source/string.c
rdba3e2c r8b863a62 35 35 36 36 #define LIBPOSIX_INTERNAL 37 #define __POSIX_DEF__(x) posix_##x 37 38 38 39 #include "internal/common.h" -
uspace/lib/posix/source/strings.c
rdba3e2c r8b863a62 35 35 36 36 #define LIBPOSIX_INTERNAL 37 #define __POSIX_DEF__(x) posix_##x 37 38 38 39 #include "internal/common.h" -
uspace/lib/posix/source/sys/mman.c
rdba3e2c r8b863a62 27 27 */ 28 28 29 /** @addtogroup lib c29 /** @addtogroup libposix 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #include <sys/mman.h> 36 #include <sys/types.h> 37 #include <as.h> 38 #include <unistd.h> 35 #define LIBPOSIX_INTERNAL 36 #define __POSIX_DEF__(x) posix_##x 39 37 40 void *mmap(void *start, size_t length, int prot, int flags, int fd, 41 aoff64_t offset) 38 #include "../internal/common.h" 39 #include <posix/sys/mman.h> 40 #include <posix/sys/types.h> 41 #include <libc/as.h> 42 #include <posix/unistd.h> 43 44 void *posix_mmap(void *start, size_t length, int prot, int flags, int fd, 45 __POSIX_DEF__(off_t) offset) 42 46 { 43 47 if (!start) … … 53 57 } 54 58 55 int munmap(void *start, size_t length)59 int posix_munmap(void *start, size_t length) 56 60 { 57 61 return as_area_destroy(start); -
uspace/lib/posix/source/sys/stat.c
rdba3e2c r8b863a62 35 35 36 36 #define LIBPOSIX_INTERNAL 37 #define __POSIX_DEF__(x) posix_##x 37 38 38 39 #include "../internal/common.h" -
uspace/lib/posix/source/sys/wait.c
rdba3e2c r8b863a62 35 35 36 36 #define LIBPOSIX_INTERNAL 37 #define __POSIX_DEF__(x) posix_##x 37 38 38 39 #include "../internal/common.h" -
uspace/lib/posix/source/time.c
rdba3e2c r8b863a62 35 35 36 36 #define LIBPOSIX_INTERNAL 37 #define __POSIX_DEF__(x) posix_##x 37 38 38 39 #include "internal/common.h" … … 73 74 posix_daylight = 0; 74 75 posix_timezone = 0; 76 } 77 78 /** 79 * Get the time in seconds 80 * 81 * @param t If t is non-NULL, the return value is also stored in the memory 82 * pointed to by t. 83 * @return On success, the value of time in seconds since the Epoch 84 * is returned. On error, (time_t)-1 is returned. 85 */ 86 time_t posix_time(time_t *t) 87 { 88 return time(t); 75 89 } 76 90 -
uspace/lib/posix/source/unistd.c
rdba3e2c r8b863a62 35 35 36 36 #define LIBPOSIX_INTERNAL 37 #define __POSIX_DEF__(x) posix_##x 37 38 38 39 #include "internal/common.h" … … 220 221 { 221 222 return errnify(write, fildes, buf, nbyte); 223 } 224 225 /** 226 * Reposition read/write file offset 227 * 228 * @param fildes File descriptor of the opened file. 229 * @param offset New offset in the file. 230 * @param whence The position from which the offset argument is specified. 231 * @return Upon successful completion, returns the resulting offset 232 * as measured in bytes from the beginning of the file, -1 otherwise. 233 */ 234 posix_off_t posix_lseek(int fildes, posix_off_t offset, int whence) 235 { 236 return errnify(lseek, fildes, offset, whence); 222 237 } 223 238 … … 374 389 // TODO: low priority, just a compile-time dependency of binutils 375 390 not_implemented(); 391 return -1; 376 392 } 377 393 … … 384 400 // TODO: low priority, just a compile-time dependency of binutils 385 401 not_implemented(); 402 return -1; 386 403 } 387 404 … … 396 413 // TODO: low priority, just a compile-time dependency of binutils 397 414 not_implemented(); 415 return -1; 398 416 } 399 417 … … 408 426 // TODO: low priority, just a compile-time dependency of binutils 409 427 not_implemented(); 428 return -1; 410 429 } 411 430 … … 419 438 // TODO: low priority, just a compile-time dependency of binutils 420 439 not_implemented(); 440 return -1; 441 } 442 443 unsigned int posix_alarm(unsigned int seconds) 444 { 445 not_implemented(); 446 return 0; 421 447 } 422 448
Note:
See TracChangeset
for help on using the changeset viewer.
