Changeset 7f9df7b9 in mainline


Ignore:
Timestamp:
2018-01-22T22:42:57Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7a08c70
Parents:
e0f47f5
Message:

Remove unnecessary symbol renaming from libposix.

Location:
uspace/lib/posix
Files:
1 deleted
50 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/Makefile

    re0f47f5 r7f9df7b9  
    3737LIBC_FILE = $(LIBC_PREFIX)/libc.a
    3838
    39 FIXED_POSIX_LIBRARY = libposixaslibc.a
    4039FIXED_C_LIBRARY = libc4posix.a
    4140MERGED_C_LIBRARY = libc.a
    4241MERGE_LIBRARIES = \
    4342        $(FIXED_C_LIBRARY) \
    44         $(FIXED_POSIX_LIBRARY) \
     43        $(LIBRARY).a \
    4544        $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a \
    4645        $(LIBSOFTINT_PREFIX)/libsoftint.a
    4746
    4847REDEFS_HIDE_LIBC = redefs-hide-libc-symbols.list
    49 REDEFS_SHOW_LIBPOSIX = redefs-show-posix-symbols.list
    50 COLLISIONS_LIST = collisions.list
    5148
    5249PRE_DEPEND = $(INCLUDE_LIBC)
     
    5451        $(INCLUDE_LIBC) \
    5552        $(REDEFS_HIDE_LIBC) \
    56         $(REDEFS_SHOW_LIBPOSIX) \
    57         $(COLLISIONS_LIST) \
    5853        libc.o
    5954
     
    6560        src/fcntl.c \
    6661        src/fnmatch.c \
    67         src/getopt.c \
    6862        src/locale.c \
    6963        src/pthread/condvar.c \
     
    9488        ln -s -f -n ../$^ $@
    9589
    96 $(FIXED_C_LIBRARY): $(LIBC_FILE) $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
     90$(FIXED_C_LIBRARY): $(LIBC_FILE) $(REDEFS_HIDE_LIBC)
    9791        $(OBJCOPY) --redefine-syms=$(REDEFS_HIDE_LIBC) $(LIBC_FILE) $@
    98         $(OBJCOPY) --redefine-syms=$(REDEFS_SHOW_LIBPOSIX) $@ $@
    99 
    100 $(FIXED_POSIX_LIBRARY): $(LIBRARY).a $(REDEFS_HIDE_LIBC) $(REDEFS_SHOW_LIBPOSIX)
    101         $(OBJCOPY) --redefine-syms=$(REDEFS_HIDE_LIBC) $(LIBRARY).a $@
    102         $(OBJCOPY) --redefine-syms=$(REDEFS_SHOW_LIBPOSIX) $@ $@
    10392
    10493$(MERGED_C_LIBRARY): $(MERGE_LIBRARIES)
     
    10695        $(AR) rc $@ libc.o
    10796
    108 $(REDEFS_HIDE_LIBC): $(COLLISIONS_LIST)
    109         sed 's/.*/& __helenos_libc_&/' <$(COLLISIONS_LIST) >$@
     97$(REDEFS_HIDE_LIBC): $(SOURCES)
     98        sed -n -e 's/_HIDE_LIBC_SYMBOL(\(.*\))/\1 __helenos_libc_\1/p' $(SOURCES) >$@
    11099
    111 $(REDEFS_SHOW_LIBPOSIX): $(COLLISIONS_LIST)
    112         sed 's/.*/posix_& &/' <$(COLLISIONS_LIST) >$@
    113 
    114 $(COLLISIONS_LIST): include/posix/*.h include/posix/*/*.h
    115         find ./include/posix -name '*.h' -exec \
    116                 sed -n -e '/^#/d' -e 's/__POSIX_DEF__/\n&/gp' {} \; | \
    117                 sed -n -e 's/__POSIX_DEF__(\([^)]*\)).*/\1/p' | \
    118                 sort -u >$@
  • uspace/lib/posix/include/posix/ctype.h

    re0f47f5 r7f9df7b9  
    3737#define POSIX_CTYPE_H_
    3838
    39 #ifndef __POSIX_DEF__
    40 #define __POSIX_DEF__(x) x
    41 #endif
    42 
    4339#include "libc/ctype.h"
    4440
  • uspace/lib/posix/include/posix/dirent.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_DIRENT_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include <libc/dirent.h>
    4339
  • uspace/lib/posix/include/posix/dlfcn.h

    re0f47f5 r7f9df7b9  
    3434#define POSIX_DLFCN_H_
    3535
    36 #ifndef __POSIX_DEF__
    37 #define __POSIX_DEF__(x) x
    38 #endif
     36#include "libc/dlfcn.h"
    3937
    4038#define RTLD_LAZY 1
     
    4341#define RTLD_LOCAL 0
    4442
    45 
    46 extern void *__POSIX_DEF__(dlopen)(const char *, int);
    47 extern void *__POSIX_DEF__(dlsym)(void *, const char *);
    48 extern int __POSIX_DEF__(dlclose)(void *);
    49 extern char *__POSIX_DEF__(dlerror)(void);
    50 
     43extern void *dlopen(const char *, int);
     44extern void *dlsym(void *, const char *);
     45extern int dlclose(void *);
     46extern char *dlerror(void);
    5147
    5248#endif
  • uspace/lib/posix/include/posix/fcntl.h

    re0f47f5 r7f9df7b9  
    3535#ifndef POSIX_FCNTL_H_
    3636#define POSIX_FCNTL_H_
    37 
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    4137
    4238#include "sys/types.h"
     
    9389#define FD_CLOEXEC         1 /* Close on exec. */
    9490
    95 extern int __POSIX_DEF__(open)(const char *pathname, int flags, ...);
    96 extern int __POSIX_DEF__(fcntl)(int fd, int cmd, ...);
    97 
     91extern int open(const char *pathname, int flags, ...);
     92extern int fcntl(int fd, int cmd, ...);
    9893
    9994#endif /* POSIX_FCNTL_H_ */
  • uspace/lib/posix/include/posix/fenv.h

    re0f47f5 r7f9df7b9  
    3737#define POSIX_FENV_H_
    3838
    39 
    4039#define FE_DIVBYZERO 1
    4140#define FE_INEXACT 2
  • uspace/lib/posix/include/posix/fnmatch.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_FNMATCH_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238/* Error Values */
    4339#undef FNM_NOMATCH
     
    6056#define FNM_CASEFOLD 16
    6157
    62 extern int __POSIX_DEF__(fnmatch)(const char *pattern, const char *string, int flags);
     58extern int fnmatch(const char *pattern, const char *string, int flags);
    6359
    6460
  • uspace/lib/posix/include/posix/getopt.h

    re0f47f5 r7f9df7b9  
    3535#define POSIX_GETOPT_H
    3636
    37 #ifndef __POSIX_DEF__
    38 #define __POSIX_DEF__(x) x
    39 #endif
    40 
    4137#include "unistd.h"
    4238
     
    5551#endif
    5652
    57 extern int __POSIX_DEF__(getopt_long)(int, char * const [], const char *, const struct option *, int *);
     53extern int getopt_long(int, char * const [], const char *, const struct option *, int *);
    5854
    5955
  • uspace/lib/posix/include/posix/inttypes.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_INTTYPES_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include "stdint.h"
    4339#include "libc/inttypes.h"
  • uspace/lib/posix/include/posix/locale.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_LOCALE_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include <_bits/NULL.h>
    4339
    4440#ifndef __locale_t_defined
    4541        #define __locale_t_defined
    46         typedef struct __posix_locale *__POSIX_DEF__(locale_t);
     42        typedef struct __posix_locale *locale_t;
    4743        #ifndef LIBPOSIX_INTERNAL
    48                 #define locale_t __POSIX_DEF__(locale_t)
     44                #define locale_t locale_t
    4945        #endif
    5046#endif
     
    8480#define LC_GLOBAL_LOCALE NULL
    8581
    86 struct __POSIX_DEF__(lconv) {
     82struct lconv {
    8783        char *currency_symbol;
    8884        char *decimal_point;
     
    111107};
    112108
    113 extern char *__POSIX_DEF__(setlocale)(int category, const char *locale);
    114 extern struct __POSIX_DEF__(lconv) *__POSIX_DEF__(localeconv)(void);
     109extern char *setlocale(int category, const char *locale);
     110extern struct lconv *localeconv(void);
    115111
    116112/* POSIX Extensions */
    117 extern __POSIX_DEF__(locale_t) __POSIX_DEF__(duplocale)(__POSIX_DEF__(locale_t) locobj);
    118 extern void __POSIX_DEF__(freelocale)(__POSIX_DEF__(locale_t) locobj);
    119 extern __POSIX_DEF__(locale_t) __POSIX_DEF__(newlocale)(int category_mask, const char *locale,
    120     __POSIX_DEF__(locale_t) base);
    121 extern __POSIX_DEF__(locale_t) __POSIX_DEF__(uselocale)(__POSIX_DEF__(locale_t) newloc);
     113extern locale_t duplocale(locale_t locobj);
     114extern void freelocale(locale_t locobj);
     115extern locale_t newlocale(int category_mask, const char *locale,
     116    locale_t base);
     117extern locale_t uselocale(locale_t newloc);
    122118
    123119
  • uspace/lib/posix/include/posix/pthread.h

    re0f47f5 r7f9df7b9  
    3232#ifndef POSIX_PTHREAD_H_
    3333#define POSIX_PTHREAD_H_
    34 
    35 #ifndef __POSIX_DEF__
    36 #define __POSIX_DEF__(x) x
    37 #endif
    3834
    3935#include "libc/thread.h"
     
    9995extern int pthread_cond_signal(pthread_cond_t *);
    10096extern int pthread_cond_timedwait(pthread_cond_t *__restrict__,
    101     pthread_mutex_t *__restrict__, const struct __POSIX_DEF__(timespec) *__restrict__);
     97    pthread_mutex_t *__restrict__, const struct timespec *__restrict__);
    10298extern int pthread_cond_wait(pthread_cond_t *__restrict__,
    10399    pthread_mutex_t *__restrict__);
  • uspace/lib/posix/include/posix/pwd.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_PWD_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include "sys/types.h"
    4339
    44 struct __POSIX_DEF__(passwd) {
     40struct passwd {
    4541        char *pw_name;
    46         __POSIX_DEF__(uid_t) pw_uid;
    47         __POSIX_DEF__(gid_t) pw_gid;
     42        uid_t pw_uid;
     43        gid_t pw_gid;
    4844        char *pw_dir;
    4945        char *pw_shell;
    5046};
    5147
    52 extern struct __POSIX_DEF__(passwd) *__POSIX_DEF__(getpwent)(void);
    53 extern void __POSIX_DEF__(setpwent)(void);
    54 extern void __POSIX_DEF__(endpwent)(void);
     48extern struct passwd *getpwent(void);
     49extern void setpwent(void);
     50extern void endpwent(void);
    5551
    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);
     52extern struct passwd *getpwnam(const char *name);
     53extern int getpwnam_r(const char *name, struct passwd *pwd,
     54    char *buffer, size_t bufsize, struct passwd **result);
    5955
    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);
     56extern struct passwd *getpwuid(uid_t uid);
     57extern int getpwuid_r(uid_t uid, struct passwd *pwd,
     58    char *buffer, size_t bufsize, struct passwd **result);
    6359
    6460
  • uspace/lib/posix/include/posix/signal.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_SIGNAL_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include "sys/types.h"
    4339#include <posix/ucontext.h>
     
    6359        int si_errno;
    6460
    65         __POSIX_DEF__(pid_t) si_pid;
    66         __POSIX_DEF__(uid_t) si_uid;
     61        pid_t si_pid;
     62        uid_t si_uid;
    6763        void *si_addr;
    6864        int si_status;
     
    7066        long si_band;
    7167
    72         union __POSIX_DEF__(sigval) si_value;
    73 } __POSIX_DEF__(siginfo_t);
    74 
    75 struct __POSIX_DEF__(sigaction) {
     68        union sigval si_value;
     69} siginfo_t;
     70
     71struct sigaction {
    7672        void (*sa_handler)(int);
    77         __POSIX_DEF__(sigset_t) sa_mask;
     73        sigset_t sa_mask;
    7874        int sa_flags;
    79         void (*sa_sigaction)(int, __POSIX_DEF__(siginfo_t) *, void *);
     75        void (*sa_sigaction)(int, siginfo_t *, void *);
    8076};
    8177
    8278
    83 /* Values of __POSIX_DEF__(sigevent)::sigev_notify */
     79/* Values of sigevent::sigev_notify */
    8480#undef SIGEV_NONE
    8581#undef SIGEV_SIGNAL
     
    229225};
    230226
    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);
     227extern int sigaction(int sig, const struct sigaction *__restrict__ act,
     228    struct sigaction *__restrict__ oact);
     229
     230extern void (*signal(int sig, void (*func)(int)))(int);
     231extern int raise(int sig);
     232extern int kill(pid_t pid, int sig);
     233extern int killpg(pid_t pid, int sig);
     234
     235extern void psiginfo(const siginfo_t *pinfo, const char *message);
     236extern void psignal(int signum, const char *message);
     237
     238extern int sigemptyset(sigset_t *set);
     239extern int sigfillset(sigset_t *set);
     240extern int sigaddset(sigset_t *set, int signo);
     241extern int sigdelset(sigset_t *set, int signo);
     242extern int sigismember(const sigset_t *set, int signo);
     243
     244extern int thread_sigmask(int how, const sigset_t *__restrict__ set,
     245    sigset_t *__restrict__ oset);
     246extern int sigprocmask(int how, const sigset_t *__restrict__ set,
     247    sigset_t *__restrict__ oset);
    252248
    253249
  • uspace/lib/posix/include/posix/stddef.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_STDDEF_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include "sys/types.h"
    4339
  • uspace/lib/posix/include/posix/stdint.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_STDINT_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include "libc/stdint.h"
    4339
  • uspace/lib/posix/include/posix/stdio.h

    re0f47f5 r7f9df7b9  
    3737#define POSIX_STDIO_H_
    3838
    39 #ifndef __POSIX_DEF__
    40 #define __POSIX_DEF__(x) x
    41 #endif
     39#include "libc/stdio.h"
    4240
    4341#include "stddef.h"
     
    6765typedef struct _IO_FILE FILE;
    6866
    69 #ifndef LIBPOSIX_INTERNAL
    70         enum _buffer_type {
    71                 /** No buffering */
    72                 _IONBF,
    73                 /** Line buffering */
    74                 _IOLBF,
    75                 /** Full buffering */
    76                 _IOFBF
    77         };
    78 #endif
    79 
    8067extern FILE *stdin;
    8168extern FILE *stdout;
     
    130117#undef L_ctermid
    131118#define L_ctermid PATH_MAX
    132 extern char *__POSIX_DEF__(ctermid)(char *s);
     119extern char *ctermid(char *s);
    133120
    134121/* Error Recovery */
    135 extern void __POSIX_DEF__(clearerr)(FILE *stream);
     122extern void clearerr(FILE *stream);
    136123
    137124/* Input/Output */
    138125#undef putc
    139126#define putc fputc
    140 extern int __POSIX_DEF__(fputs)(const char *__restrict__ s, FILE *__restrict__ stream);
     127extern int fputs(const char *__restrict__ s, FILE *__restrict__ stream);
    141128#undef getc
    142129#define getc fgetc
    143 extern int __POSIX_DEF__(ungetc)(int c, FILE *stream);
    144 extern ssize_t __POSIX_DEF__(getdelim)(char **__restrict__ lineptr, size_t *__restrict__ n,
     130extern int ungetc(int c, FILE *stream);
     131extern ssize_t getdelim(char **__restrict__ lineptr, size_t *__restrict__ n,
    145132    int delimiter, FILE *__restrict__ stream);
    146 extern ssize_t __POSIX_DEF__(getline)(char **__restrict__ lineptr, size_t *__restrict__ n,
     133extern ssize_t getline(char **__restrict__ lineptr, size_t *__restrict__ n,
    147134    FILE *__restrict__ stream);
    148135
    149136/* Opening Streams */
    150 extern FILE *__POSIX_DEF__(freopen)(const char *__restrict__ filename,
     137extern FILE *freopen(const char *__restrict__ filename,
    151138    const char *__restrict__ mode, FILE *__restrict__ stream);
    152139
    153140/* Error Messages */
    154 extern void __POSIX_DEF__(perror)(const char *s);
     141extern void perror(const char *s);
    155142
    156143/* File Positioning */
    157144typedef struct {
    158145        off64_t offset;
    159 } __POSIX_DEF__(fpos_t);
    160 
    161 extern int __POSIX_DEF__(fsetpos)(FILE *stream, const __POSIX_DEF__(fpos_t) *pos);
    162 extern int __POSIX_DEF__(fgetpos)(FILE *__restrict__ stream, __POSIX_DEF__(fpos_t) *__restrict__ pos);
    163 extern int __POSIX_DEF__(fseek)(FILE *stream, long offset, int whence);
    164 extern int __POSIX_DEF__(fseeko)(FILE *stream, __POSIX_DEF__(off_t) offset, int whence);
    165 extern long __POSIX_DEF__(ftell)(FILE *stream);
    166 extern __POSIX_DEF__(off_t) __POSIX_DEF__(ftello)(FILE *stream);
     146} fpos_t;
     147
     148extern int fsetpos(FILE *stream, const fpos_t *pos);
     149extern int fgetpos(FILE *__restrict__ stream, fpos_t *__restrict__ pos);
     150extern int fseek(FILE *stream, long offset, int whence);
     151extern int fseeko(FILE *stream, off_t offset, int whence);
     152extern long ftell(FILE *stream);
     153extern off_t ftello(FILE *stream);
    167154
    168155/* Flushing Buffers */
    169 extern int __POSIX_DEF__(fflush)(FILE *stream);
     156extern int fflush(FILE *stream);
    170157
    171158/* Formatted Output */
    172 extern int __POSIX_DEF__(dprintf)(int fildes, const char *__restrict__ format, ...)
     159extern int dprintf(int fildes, const char *__restrict__ format, ...)
    173160    _HELENOS_PRINTF_ATTRIBUTE(2, 3);
    174 extern int __POSIX_DEF__(vdprintf)(int fildes, const char *__restrict__ format, va_list ap);
    175 extern int __POSIX_DEF__(sprintf)(char *__restrict__ s, const char *__restrict__ format, ...)
     161extern int vdprintf(int fildes, const char *__restrict__ format, va_list ap);
     162extern int sprintf(char *__restrict__ s, const char *__restrict__ format, ...)
    176163    _HELENOS_PRINTF_ATTRIBUTE(2, 3);
    177 extern int __POSIX_DEF__(vsprintf)(char *__restrict__ s, const char *__restrict__ format, va_list ap);
     164extern int vsprintf(char *__restrict__ s, const char *__restrict__ format, va_list ap);
    178165
    179166/* Formatted Input */
    180 extern int __POSIX_DEF__(fscanf)(
     167extern int fscanf(
    181168    FILE *__restrict__ stream, const char *__restrict__ format, ...);
    182 extern int __POSIX_DEF__(vfscanf)(
     169extern int vfscanf(
    183170    FILE *__restrict__ stream, const char *__restrict__ format, va_list arg);
    184 extern int __POSIX_DEF__(scanf)(const char *__restrict__ format, ...);
    185 extern int __POSIX_DEF__(vscanf)(const char *__restrict__ format, va_list arg);
    186 extern int __POSIX_DEF__(sscanf)(
     171extern int scanf(const char *__restrict__ format, ...);
     172extern int vscanf(const char *__restrict__ format, va_list arg);
     173extern int sscanf(
    187174    const char *__restrict__ s, const char *__restrict__ format, ...);
    188 extern int __POSIX_DEF__(vsscanf)(
     175extern int vsscanf(
    189176    const char *__restrict__ s, const char *__restrict__ format, va_list arg);
    190177
    191178/* File Locking */
    192 extern void __POSIX_DEF__(flockfile)(FILE *file);
    193 extern int __POSIX_DEF__(ftrylockfile)(FILE *file);
    194 extern void __POSIX_DEF__(funlockfile)(FILE *file);
    195 extern int __POSIX_DEF__(getc_unlocked)(FILE *stream);
    196 extern int __POSIX_DEF__(getchar_unlocked)(void);
    197 extern int __POSIX_DEF__(putc_unlocked)(int c, FILE *stream);
    198 extern int __POSIX_DEF__(putchar_unlocked)(int c);
     179extern void flockfile(FILE *file);
     180extern int ftrylockfile(FILE *file);
     181extern void funlockfile(FILE *file);
     182extern int getc_unlocked(FILE *stream);
     183extern int getchar_unlocked(void);
     184extern int putc_unlocked(int c, FILE *stream);
     185extern int putchar_unlocked(int c);
    199186
    200187/* Deleting Files */
    201 extern int __POSIX_DEF__(remove)(const char *path);
     188extern int remove(const char *path);
    202189
    203190/* Renaming Files */
    204 extern int __POSIX_DEF__(rename)(const char *oldname, const char *newname);
     191extern int rename(const char *oldname, const char *newname);
    205192
    206193/* Temporary Files */
    207194#undef L_tmpnam
    208195#define L_tmpnam PATH_MAX
    209 extern char *__POSIX_DEF__(tmpnam)(char *s);
    210 extern char *__POSIX_DEF__(tempnam)(const char *dir, const char *pfx);
    211 extern FILE *__POSIX_DEF__(tmpfile)(void);
     196extern char *tmpnam(char *s);
     197extern char *tempnam(const char *dir, const char *pfx);
     198extern FILE *tmpfile(void);
    212199
    213200
  • uspace/lib/posix/include/posix/stdlib.h

    re0f47f5 r7f9df7b9  
    3737#define POSIX_STDLIB_H_
    3838
    39 #ifndef __POSIX_DEF__
    40 #define __POSIX_DEF__(x) x
    41 #endif
    42 
    4339#include "sys/types.h"
    4440
     
    5349#define EXIT_SUCCESS 0
    5450#define _Exit exit
    55 extern int __POSIX_DEF__(atexit)(void (*func)(void));
     51extern int atexit(void (*func)(void));
    5652extern void exit(int status) __attribute__((noreturn));
    5753extern void abort(void) __attribute__((noreturn));
    5854
    5955/* Absolute Value */
    60 extern int __POSIX_DEF__(abs)(int i);
    61 extern long __POSIX_DEF__(labs)(long i);
    62 extern long long __POSIX_DEF__(llabs)(long long i);
     56extern int abs(int i);
     57extern long labs(long i);
     58extern long long llabs(long long i);
    6359
    6460/* Integer Division */
     
    6662typedef struct {
    6763        int quot, rem;
    68 } __POSIX_DEF__(div_t);
     64} div_t;
    6965
    7066typedef struct {
    7167        long quot, rem;
    72 } __POSIX_DEF__(ldiv_t);
     68} ldiv_t;
    7369
    7470typedef struct {
    7571        long long quot, rem;
    76 } __POSIX_DEF__(lldiv_t);
     72} lldiv_t;
    7773
    78 extern __POSIX_DEF__(div_t) __POSIX_DEF__(div)(int numer, int denom);
    79 extern __POSIX_DEF__(ldiv_t) __POSIX_DEF__(ldiv)(long numer, long denom);
    80 extern __POSIX_DEF__(lldiv_t) __POSIX_DEF__(lldiv)(long long numer, long long denom);
     74extern div_t div(int numer, int denom);
     75extern ldiv_t ldiv(long numer, long denom);
     76extern lldiv_t lldiv(long long numer, long long denom);
    8177
    8278/* Array Functions */
    83 extern void __POSIX_DEF__(qsort)(void *array, size_t count, size_t size,
     79extern void qsort(void *array, size_t count, size_t size,
    8480    int (*compare)(const void *, const void *));
    85 extern void *__POSIX_DEF__(bsearch)(const void *key, const void *base,
     81extern void *bsearch(const void *key, const void *base,
    8682    size_t nmemb, size_t size, int (*compar)(const void *, const void *));
    8783
    8884/* Environment Access */
    89 extern char *__POSIX_DEF__(getenv)(const char *name);
    90 extern int __POSIX_DEF__(putenv)(char *string);
    91 extern int __POSIX_DEF__(system)(const char *string);
     85extern char *getenv(const char *name);
     86extern int putenv(char *string);
     87extern int system(const char *string);
    9288
    9389/* Symbolic Links */
    94 extern char *__POSIX_DEF__(realpath)(const char *__restrict__ name, char *__restrict__ resolved);
     90extern char *realpath(const char *__restrict__ name, char *__restrict__ resolved);
    9591
    9692/* Floating Point Conversion */
    97 extern double __POSIX_DEF__(atof)(const char *nptr);
    98 extern float __POSIX_DEF__(strtof)(const char *__restrict__ nptr, char **__restrict__ endptr);
    99 extern double __POSIX_DEF__(strtod)(const char *__restrict__ nptr, char **__restrict__ endptr);
    100 extern long double __POSIX_DEF__(strtold)(const char *__restrict__ nptr, char **__restrict__ endptr);
     93extern double atof(const char *nptr);
     94extern float strtof(const char *__restrict__ nptr, char **__restrict__ endptr);
     95extern double strtod(const char *__restrict__ nptr, char **__restrict__ endptr);
     96extern long double strtold(const char *__restrict__ nptr, char **__restrict__ endptr);
    10197
    10298/* Integer Conversion */
     
    114110
    115111/* Memory Allocation */
    116 extern void *__POSIX_DEF__(malloc)(size_t size)
     112extern void *malloc(size_t size)
    117113    __attribute__((malloc));
    118 extern void *__POSIX_DEF__(calloc)(size_t nelem, size_t elsize)
     114extern void *calloc(size_t nelem, size_t elsize)
    119115    __attribute__((malloc));
    120 extern void *__POSIX_DEF__(realloc)(void *ptr, size_t size)
     116extern void *realloc(void *ptr, size_t size)
    121117    __attribute__((warn_unused_result));
    122 extern void __POSIX_DEF__(free)(void *ptr);
     118extern void free(void *ptr);
    123119
    124120/* Temporary Files */
    125 extern int __POSIX_DEF__(mkstemp)(char *tmpl);
     121extern int mkstemp(char *tmpl);
    126122
    127123/* Pseudo-random number generator */
    128 extern int __POSIX_DEF__(rand)(void);
    129 extern void __POSIX_DEF__(srand)(unsigned int seed);
     124extern int rand(void);
     125extern void srand(unsigned int seed);
    130126
    131127/* Legacy Declarations */
    132 extern char *__POSIX_DEF__(mktemp)(char *tmpl);
     128extern char *mktemp(char *tmpl);
    133129extern int bsd_getloadavg(double loadavg[], int nelem);
    134130
  • uspace/lib/posix/include/posix/string.h

    re0f47f5 r7f9df7b9  
    3737#define POSIX_STRING_H_
    3838
    39 #ifndef __POSIX_DEF__
    40 #define __POSIX_DEF__(x) x
    41 #endif
    42 
    4339#include "sys/types.h"
    4440
     
    7470
    7571/* Copying and Concatenation */
    76 extern char *__POSIX_DEF__(strcpy)(char *__restrict__ dest, const char *__restrict__ src);
    77 extern char *__POSIX_DEF__(strncpy)(char *__restrict__ dest, const char *__restrict__ src, size_t n);
    78 extern char *__POSIX_DEF__(stpcpy)(char *__restrict__ dest, const char *__restrict__ src);
    79 extern char *__POSIX_DEF__(stpncpy)(char *__restrict__ dest, const char *__restrict__ src, size_t n);
    80 extern char *__POSIX_DEF__(strcat)(char *__restrict__ dest, const char *__restrict__ src);
    81 extern char *__POSIX_DEF__(strncat)(char *__restrict__ dest, const char *__restrict__ src, size_t n);
    82 extern void *__POSIX_DEF__(memccpy)(void *__restrict__ dest, const void *__restrict__ src, int c, size_t n);
    83 extern char *__POSIX_DEF__(strdup)(const char *s);
    84 extern char *__POSIX_DEF__(strndup)(const char *s, size_t n);
     72extern char *strcpy(char *__restrict__ dest, const char *__restrict__ src);
     73extern char *strncpy(char *__restrict__ dest, const char *__restrict__ src, size_t n);
     74extern char *stpcpy(char *__restrict__ dest, const char *__restrict__ src);
     75extern char *stpncpy(char *__restrict__ dest, const char *__restrict__ src, size_t n);
     76extern char *strcat(char *__restrict__ dest, const char *__restrict__ src);
     77extern char *strncat(char *__restrict__ dest, const char *__restrict__ src, size_t n);
     78extern void *memccpy(void *__restrict__ dest, const void *__restrict__ src, int c, size_t n);
     79extern char *strdup(const char *s);
     80extern char *strndup(const char *s, size_t n);
    8581
    8682/* String/Array Comparison */
    87 extern int __POSIX_DEF__(memcmp)(const void *mem1, const void *mem2, size_t n);
    88 extern int __POSIX_DEF__(strcmp)(const char *s1, const char *s2);
    89 extern int __POSIX_DEF__(strncmp)(const char *s1, const char *s2, size_t n);
     83extern int memcmp(const void *mem1, const void *mem2, size_t n);
     84extern int strcmp(const char *s1, const char *s2);
     85extern int strncmp(const char *s1, const char *s2, size_t n);
    9086
    9187/* Search Functions */
    92 extern void *__POSIX_DEF__(memchr)(const void *mem, int c, size_t n);
    93 extern char *__POSIX_DEF__(strchr)(const char *s, int c);
    94 extern char *__POSIX_DEF__(strrchr)(const char *s, int c);
     88extern void *memchr(const void *mem, int c, size_t n);
     89extern char *strchr(const char *s, int c);
     90extern char *strrchr(const char *s, int c);
    9591extern char *gnu_strchrnul(const char *s, int c);
    96 extern char *__POSIX_DEF__(strpbrk)(const char *s1, const char *s2);
    97 extern size_t __POSIX_DEF__(strcspn)(const char *s1, const char *s2);
    98 extern size_t __POSIX_DEF__(strspn)(const char *s1, const char *s2);
    99 extern char *__POSIX_DEF__(strstr)(const char *haystack, const char *needle);
     92extern char *strpbrk(const char *s1, const char *s2);
     93extern size_t strcspn(const char *s1, const char *s2);
     94extern size_t strspn(const char *s1, const char *s2);
     95extern char *strstr(const char *haystack, const char *needle);
    10096
    10197/* Tokenization functions. */
    102 extern char *__POSIX_DEF__(strtok_r)(char *, const char *, char **);
    103 extern char *__POSIX_DEF__(strtok)(char *, const char *);
     98extern char *strtok_r(char *, const char *, char **);
     99extern char *strtok(char *, const char *);
    104100
    105101
    106102/* Collation Functions */
    107 extern int __POSIX_DEF__(strcoll)(const char *s1, const char *s2);
    108 extern size_t __POSIX_DEF__(strxfrm)(char *__restrict__ s1, const char *__restrict__ s2, size_t n);
     103extern int strcoll(const char *s1, const char *s2);
     104extern size_t strxfrm(char *__restrict__ s1, const char *__restrict__ s2, size_t n);
    109105
    110106/* Error Messages */
    111 extern char *__POSIX_DEF__(strerror)(int errnum);
    112 extern int __POSIX_DEF__(strerror_r)(int errnum, char *buf, size_t bufsz);
     107extern char *strerror(int errnum);
     108extern int strerror_r(int errnum, char *buf, size_t bufsz);
    113109
    114110/* String Length */
    115 extern size_t __POSIX_DEF__(strlen)(const char *s);
    116 extern size_t __POSIX_DEF__(strnlen)(const char *s, size_t n);
     111extern size_t strlen(const char *s);
     112extern size_t strnlen(const char *s, size_t n);
    117113
    118114/* Signal Messages */
    119 extern char *__POSIX_DEF__(strsignal)(int signum);
     115extern char *strsignal(int signum);
    120116
    121117/* Legacy Declarations */
    122118#ifndef POSIX_STRINGS_H_
    123 extern int __POSIX_DEF__(ffs)(int i);
    124 extern int __POSIX_DEF__(strcasecmp)(const char *s1, const char *s2);
    125 extern int __POSIX_DEF__(strncasecmp)(const char *s1, const char *s2, size_t n);
     119extern int ffs(int i);
     120extern int strcasecmp(const char *s1, const char *s2);
     121extern int strncasecmp(const char *s1, const char *s2, size_t n);
    126122#endif
    127123
  • uspace/lib/posix/include/posix/strings.h

    re0f47f5 r7f9df7b9  
    3737#define POSIX_STRINGS_H_
    3838
    39 #ifndef __POSIX_DEF__
    40 #define __POSIX_DEF__(x) x
    41 #endif
    42 
    43 
    4439#include "libc/types/common.h"
    4540
    4641/* Search Functions */
    4742#ifndef POSIX_STRING_H_
    48 extern int __POSIX_DEF__(ffs)(int i);
     43extern int ffs(int i);
    4944#endif
    5045
    5146/* String/Array Comparison */
    5247#ifndef POSIX_STRING_H_
    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);
     48extern int strcasecmp(const char *s1, const char *s2);
     49extern int strncasecmp(const char *s1, const char *s2, size_t n);
    5550#endif
    5651
     
    6257
    6358/* Legacy Functions */
    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);
     59extern int bcmp(const void *mem1, const void *mem2, size_t n);
     60extern void bcopy(const void *src, void *dest, size_t n);
     61extern void bzero(void *mem, size_t n);
     62extern char *index(const char *s, int c);
     63extern char *rindex(const char *s, int c);
    6964
    7065
  • uspace/lib/posix/include/posix/sys/mman.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_SYS_MMAN_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include "types.h"
    4339#include <abi/mm/as.h>
     
    6157
    6258extern 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);
     59mmap(void *start, size_t length, int prot, int flags, int fd,
     60    off_t offset);
     61extern int munmap(void *start, size_t length);
    6662
    6763
  • uspace/lib/posix/include/posix/sys/stat.h

    re0f47f5 r7f9df7b9  
    3939#include "types.h"
    4040#include "../time.h"
    41 
    42 #ifndef __POSIX_DEF__
    43 #define __POSIX_DEF__(x) x
    44 #endif
    4541
    4642/* values are the same as on Linux */
     
    112108#define S_ISSOCK(m) ((m & S_IFSOCK) != 0) /* socket? (Not in POSIX.1-1996.) */
    113109
    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 */
    117         __POSIX_DEF__(mode_t)    st_mode;    /* protection */
    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 */
     110struct stat {
     111        dev_t     st_dev;     /* ID of device containing file */
     112        ino_t     st_ino;     /* inode number */
     113        mode_t    st_mode;    /* protection */
     114        nlink_t   st_nlink;   /* number of hard links */
     115        uid_t     st_uid;     /* user ID of owner */
     116        gid_t     st_gid;     /* group ID of owner */
     117        dev_t     st_rdev;    /* device ID (if special file) */
     118        off_t     st_size;    /* total size, in bytes */
     119        blksize_t st_blksize; /* blocksize for file system I/O */
     120        blkcnt_t  st_blocks;  /* number of 512B blocks allocated */
    125121        time_t          st_atime;   /* time of last access */
    126122        time_t          st_mtime;   /* time of last modification */
     
    128124};
    129125
    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, __POSIX_DEF__(mode_t) mode);
    134 extern __POSIX_DEF__(mode_t) __POSIX_DEF__(umask)(__POSIX_DEF__(mode_t) mask);
    135 extern int __POSIX_DEF__(mkdir)(const char *path, __POSIX_DEF__(mode_t) mode);
     126extern int fstat(int fd, struct stat *st);
     127extern int lstat(const char *__restrict__ path, struct stat *__restrict__ st);
     128extern int stat(const char *__restrict__ path, struct stat *__restrict__ st);
     129extern int chmod(const char *path, mode_t mode);
     130extern mode_t umask(mode_t mask);
     131extern int mkdir(const char *path, mode_t mode);
    136132
    137133
  • uspace/lib/posix/include/posix/sys/time.h

    re0f47f5 r7f9df7b9  
    3434#define POSIX_SYS_TIME_H_
    3535
    36 #ifndef __POSIX_DEF__
    37 #define __POSIX_DEF__(x) x
    38 #endif
    39 
    4036#include "libc/sys/time.h"
    4137
  • uspace/lib/posix/include/posix/sys/types.h

    re0f47f5 r7f9df7b9  
    3737#define POSIX_SYS_TYPES_H_
    3838
    39 #ifndef __POSIX_DEF__
    40 #define __POSIX_DEF__(x) x
    41 #endif
    42 
    4339#include "libc/offset.h"
    4440#include "libc/sys/time.h"
    4541#include "libc/types/common.h"
    4642
    47 typedef unsigned int __POSIX_DEF__(ino_t);
    48 typedef unsigned int __POSIX_DEF__(nlink_t);
    49 typedef unsigned int __POSIX_DEF__(uid_t);
    50 typedef unsigned int __POSIX_DEF__(gid_t);
    51 typedef off64_t __POSIX_DEF__(off_t);
    52 typedef long __POSIX_DEF__(blksize_t);
    53 typedef long __POSIX_DEF__(blkcnt_t);
    54 typedef int64_t __POSIX_DEF__(pid_t);
    55 typedef sysarg_t __POSIX_DEF__(dev_t);
    56 typedef unsigned int __POSIX_DEF__(mode_t);
     43typedef unsigned int ino_t;
     44typedef unsigned int nlink_t;
     45typedef unsigned int uid_t;
     46typedef unsigned int gid_t;
     47typedef off64_t off_t;
     48typedef long blksize_t;
     49typedef long blkcnt_t;
     50typedef int64_t pid_t;
     51typedef sysarg_t dev_t;
     52typedef unsigned int mode_t;
    5753
    5854/* PThread Types */
    59 typedef struct __POSIX_DEF__(thread_attr) __POSIX_DEF__(thread_attr_t);
     55typedef struct thread_attr thread_attr_t;
    6056
    6157/* Clock Types */
    62 typedef long __POSIX_DEF__(clock_t);
    63 typedef int __POSIX_DEF__(clockid_t);
     58typedef long clock_t;
     59typedef int clockid_t;
    6460
    6561
  • uspace/lib/posix/include/posix/sys/wait.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_SYS_WAIT_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include "types.h"
    4339
     
    5652extern int __posix_wtermsig(int status);
    5753
    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);
     54extern pid_t wait(int *stat_ptr);
     55extern pid_t waitpid(pid_t pid, int *stat_ptr, int options);
    6056
    6157
  • uspace/lib/posix/include/posix/time.h

    re0f47f5 r7f9df7b9  
    3737#define POSIX_TIME_H_
    3838
    39 #ifndef __POSIX_DEF__
    40 #define __POSIX_DEF__(x) x
    41 #endif
    42 
    4339#include "sys/types.h"
    4440
     
    5147#ifndef __locale_t_defined
    5248        #define __locale_t_defined
    53         typedef struct __posix_locale *__POSIX_DEF__(locale_t);
     49        typedef struct __posix_locale *locale_t;
    5450        #ifndef LIBPOSIX_INTERNAL
    55                 #define locale_t __POSIX_DEF__(locale_t)
     51                #define locale_t locale_t
    5652        #endif
    5753#endif
    5854
    5955#ifndef POSIX_SIGNAL_H_
    60         struct __POSIX_DEF__(sigevent);
     56        struct sigevent;
    6157        #ifndef LIBPOSIX_INTERNAL
    62                 #define sigevent __POSIX_DEF__(sigevent)
     58                #define sigevent sigevent
    6359        #endif
    6460#endif
    6561
    6662#undef CLOCK_REALTIME
    67 #define CLOCK_REALTIME ((__POSIX_DEF__(clockid_t)) 0)
     63#define CLOCK_REALTIME ((clockid_t) 0)
    6864
    69 struct __POSIX_DEF__(timespec) {
     65struct timespec {
    7066        time_t tv_sec; /* Seconds. */
    7167        long tv_nsec; /* Nanoseconds. */
    7268};
    7369
    74 struct __POSIX_DEF__(itimerspec) {
    75         struct __POSIX_DEF__(timespec) it_interval; /* Timer period. */
    76         struct __POSIX_DEF__(timespec) it_value; /* Timer expiration. */
     70struct itimerspec {
     71        struct timespec it_interval; /* Timer period. */
     72        struct timespec it_value; /* Timer expiration. */
    7773};
    7874
    79 typedef struct __posix_timer *__POSIX_DEF__(timer_t);
     75typedef struct __posix_timer *timer_t;
    8076
    8177/* Timezones */
    82 extern int __POSIX_DEF__(daylight);
    83 extern long __POSIX_DEF__(timezone);
    84 extern char *__POSIX_DEF__(tzname)[2];
    85 extern void __POSIX_DEF__(tzset)(void);
     78extern int daylight;
     79extern long timezone;
     80extern char *tzname[2];
     81extern void tzset(void);
    8682
    8783/* Time */
    88 extern time_t __POSIX_DEF__(time)(time_t *t);
     84extern time_t time(time_t *t);
    8985
    9086/* Broken-down Time */
    91 extern struct tm *__POSIX_DEF__(gmtime_r)(const time_t *__restrict__ timer,
     87extern struct tm *gmtime_r(const time_t *__restrict__ timer,
    9288    struct tm *__restrict__ result);
    93 extern struct tm *__POSIX_DEF__(gmtime)(const time_t *__restrict__ timep);
    94 extern struct tm *__POSIX_DEF__(localtime_r)(const time_t *__restrict__ timer,
     89extern struct tm *gmtime(const time_t *__restrict__ timep);
     90extern struct tm *localtime_r(const time_t *__restrict__ timer,
    9591    struct tm *__restrict__ result);
    96 extern struct tm *__POSIX_DEF__(localtime)(const time_t *__restrict__ timep);
     92extern struct tm *localtime(const time_t *__restrict__ timep);
    9793
    9894/* Formatting Calendar Time */
    99 extern char *__POSIX_DEF__(asctime_r)(const struct tm *__restrict__ timeptr,
     95extern char *asctime_r(const struct tm *__restrict__ timeptr,
    10096    char *__restrict__ buf);
    101 extern char *__POSIX_DEF__(asctime)(const struct tm *__restrict__ timeptr);
    102 extern char *__POSIX_DEF__(ctime_r)(const time_t *timer, char *buf);
    103 extern char *__POSIX_DEF__(ctime)(const time_t *timer);
     97extern char *asctime(const struct tm *__restrict__ timeptr);
     98extern char *ctime_r(const time_t *timer, char *buf);
     99extern char *ctime(const time_t *timer);
    104100extern time_t time(time_t *t);
    105101
    106102/* Clocks */
    107 extern int __POSIX_DEF__(clock_getres)(__POSIX_DEF__(clockid_t) clock_id,
    108     struct __POSIX_DEF__(timespec) *res);
    109 extern int __POSIX_DEF__(clock_gettime)(__POSIX_DEF__(clockid_t) clock_id,
    110     struct __POSIX_DEF__(timespec) *tp);
    111 extern int __POSIX_DEF__(clock_settime)(__POSIX_DEF__(clockid_t) clock_id,
    112     const struct __POSIX_DEF__(timespec) *tp);
    113 extern int __POSIX_DEF__(clock_nanosleep)(__POSIX_DEF__(clockid_t) clock_id, int flags,
    114     const struct __POSIX_DEF__(timespec) *rqtp, struct __POSIX_DEF__(timespec) *rmtp);
     103extern int clock_getres(clockid_t clock_id,
     104    struct timespec *res);
     105extern int clock_gettime(clockid_t clock_id,
     106    struct timespec *tp);
     107extern int clock_settime(clockid_t clock_id,
     108    const struct timespec *tp);
     109extern int clock_nanosleep(clockid_t clock_id, int flags,
     110    const struct timespec *rqtp, struct timespec *rmtp);
    115111
    116112/* CPU Time */
    117 extern __POSIX_DEF__(clock_t) __POSIX_DEF__(clock)(void);
     113extern clock_t clock(void);
    118114
    119115
  • uspace/lib/posix/include/posix/ucontext.h

    re0f47f5 r7f9df7b9  
    3636#define POSIX_UCONTEXT_H_
    3737
    38 #ifndef __POSIX_DEF__
    39 #define __POSIX_DEF__(x) x
    40 #endif
    41 
    4238#include "sys/types.h"
    4339
    44 typedef int __POSIX_DEF__(sig_atomic_t);
    45 typedef uint32_t __POSIX_DEF__(sigset_t);
    46 typedef struct __POSIX_DEF__(mcontext) {
     40typedef int sig_atomic_t;
     41typedef uint32_t sigset_t;
     42typedef struct mcontext {
    4743        /* must not be empty to avoid compiler warnings (-pedantic) */
    4844        int dummy;
    49 } __POSIX_DEF__(mcontext_t);
     45} mcontext_t;
    5046
    51 union __POSIX_DEF__(sigval) {
     47union sigval {
    5248        int sival_int;
    5349        void *sival_ptr;
    5450};
    5551
    56 struct __POSIX_DEF__(sigevent) {
     52struct sigevent {
    5753        int sigev_notify; /* Notification type. */
    5854        int sigev_signo; /* Signal number. */
    59         union __POSIX_DEF__(sigval) sigev_value; /* Signal value. */
    60         void (*sigev_notify_function)(union __POSIX_DEF__(sigval)); /* Notification function. */
    61         __POSIX_DEF__(thread_attr_t) *sigev_notify_attributes; /* Notification attributes. */
     55        union sigval sigev_value; /* Signal value. */
     56        void (*sigev_notify_function)(union sigval); /* Notification function. */
     57        thread_attr_t *sigev_notify_attributes; /* Notification attributes. */
    6258};
    6359
     
    6662        size_t ss_size;
    6763        int ss_flags;
    68 } __POSIX_DEF__(stack_t);
     64} stack_t;
    6965
    70 typedef struct __POSIX_DEF__(ucontext) {
    71         struct __POSIX_DEF__(ucontext) *uc_link;
    72         __POSIX_DEF__(sigset_t) uc_sigmask;
    73         __POSIX_DEF__(stack_t) uc_stack;
    74         __POSIX_DEF__(mcontext_t) uc_mcontext;
    75 } __POSIX_DEF__(ucontext_t);
     66typedef struct ucontext {
     67        struct ucontext *uc_link;
     68        sigset_t uc_sigmask;
     69        stack_t uc_stack;
     70        mcontext_t uc_mcontext;
     71} ucontext_t;
    7672
    7773
  • uspace/lib/posix/include/posix/unistd.h

    re0f47f5 r7f9df7b9  
    3737#define POSIX_UNISTD_H_
    3838
    39 #ifndef __POSIX_DEF__
    40 #define __POSIX_DEF__(x) x
    41 #endif
    42 
    4339#include "sys/types.h"
    4440#include "stddef.h"
     
    5147#define _exit exit
    5248
    53 extern char *__POSIX_DEF__(optarg);
     49extern char *optarg;
    5450extern int optind, opterr, optopt;
    55 extern int __POSIX_DEF__(getopt)(int, char * const [], const char *);
     51extern int getopt(int, char * const [], const char *);
    5652
    5753/* Environment */
    58 extern char **__POSIX_DEF__(environ);
     54extern char **environ;
    5955
    6056/* Sleeping */
    61 extern unsigned int __POSIX_DEF__(sleep)(unsigned int);
     57extern unsigned int sleep(unsigned int);
    6258
    6359/* Login Information */
    64 extern char *__POSIX_DEF__(getlogin)(void);
    65 extern int __POSIX_DEF__(getlogin_r)(char *name, size_t namesize);
     60extern char *getlogin(void);
     61extern int getlogin_r(char *name, size_t namesize);
    6662
    6763/* Identifying Terminals */
    68 extern int __POSIX_DEF__(isatty)(int fd);
     64extern int isatty(int fd);
    6965
    7066/* Working Directory */
    71 extern char *__POSIX_DEF__(getcwd)(char *buf, size_t size);
    72 extern int __POSIX_DEF__(chdir)(const char *path);
     67extern char *getcwd(char *buf, size_t size);
     68extern int chdir(const char *path);
    7369
    7470/* Query Memory Parameters */
    75 extern int __POSIX_DEF__(getpagesize)(void);
     71extern int getpagesize(void);
    7672
    7773/* Process Identification */
    78 extern __POSIX_DEF__(pid_t) __POSIX_DEF__(getpid)(void);
    79 extern __POSIX_DEF__(uid_t) __POSIX_DEF__(getuid)(void);
    80 extern __POSIX_DEF__(gid_t) __POSIX_DEF__(getgid)(void);
     74extern pid_t getpid(void);
     75extern uid_t getuid(void);
     76extern gid_t getgid(void);
    8177
    8278/* File Manipulation */
    83 extern int __POSIX_DEF__(close)(int fildes);
    84 extern ssize_t __POSIX_DEF__(read)(int fildes, void *buf, size_t nbyte);
    85 extern ssize_t __POSIX_DEF__(write)(int fildes, const void *buf, size_t nbyte);
    86 extern __POSIX_DEF__(off_t) __POSIX_DEF__(lseek)(int fildes,
    87     __POSIX_DEF__(off_t) offset, int whence);
    88 extern int __POSIX_DEF__(fsync)(int fildes);
    89 extern int __POSIX_DEF__(ftruncate)(int fildes, __POSIX_DEF__(off_t) length);
    90 extern int __POSIX_DEF__(rmdir)(const char *path);
    91 extern int __POSIX_DEF__(unlink)(const char *path);
    92 extern int __POSIX_DEF__(dup)(int fildes);
    93 extern int __POSIX_DEF__(dup2)(int fildes, int fildes2);
     79extern int close(int fildes);
     80extern ssize_t read(int fildes, void *buf, size_t nbyte);
     81extern ssize_t write(int fildes, const void *buf, size_t nbyte);
     82extern off_t lseek(int fildes,
     83    off_t offset, int whence);
     84extern int fsync(int fildes);
     85extern int ftruncate(int fildes, off_t length);
     86extern int rmdir(const char *path);
     87extern int unlink(const char *path);
     88extern int dup(int fildes);
     89extern int dup2(int fildes, int fildes2);
    9490
    9591/* Standard Streams */
     
    110106#define W_OK 2 /* Test for write permission. */
    111107#define R_OK 4 /* Test for read permission. */
    112 extern int __POSIX_DEF__(access)(const char *path, int amode);
     108extern int access(const char *path, int amode);
    113109
    114110/* System Parameters */
     
    119115        _SC_CLK_TCK
    120116};
    121 extern long __POSIX_DEF__(sysconf)(int name);
     117extern long sysconf(int name);
    122118
    123119/* Path Configuration Parameters */
     
    143139        _PC_VDISABLE
    144140};
    145 extern long __POSIX_DEF__(pathconf)(const char *path, int name);
     141extern long pathconf(const char *path, int name);
    146142
    147143/* Creating a Process */
    148 extern __POSIX_DEF__(pid_t) __POSIX_DEF__(fork)(void);
     144extern pid_t fork(void);
    149145
    150146/* Executing a File */
    151 extern int __POSIX_DEF__(execv)(const char *path, char *const argv[]);
    152 extern int __POSIX_DEF__(execvp)(const char *file, char *const argv[]);
     147extern int execv(const char *path, char *const argv[]);
     148extern int execvp(const char *file, char *const argv[]);
    153149
    154150/* Creating a Pipe */
    155 extern int __POSIX_DEF__(pipe)(int fildes[2]);
     151extern int pipe(int fildes[2]);
    156152
    157153/* Issue alarm signal. */
    158 extern unsigned int __POSIX_DEF__(alarm)(unsigned int);
     154extern unsigned int alarm(unsigned int);
    159155
    160156#endif /* POSIX_UNISTD_H_ */
  • uspace/lib/posix/src/dlfcn.c

    re0f47f5 r7f9df7b9  
    3131 */
    3232
    33 #define LIBPOSIX_INTERNAL
    34 #define __POSIX_DEF__(x) posix_##x
    35 
    3633#include "internal/common.h"
    3734#include "posix/dlfcn.h"
    3835
    39 #include "libc/dlfcn.h"
     36_HIDE_LIBC_SYMBOL(dlopen)
     37extern void *__helenos_libc_dlopen(const char *filename, int flags);
    4038
    41 void *posix_dlopen(const char *filename, int flags)
     39void *dlopen(const char *filename, int flags)
    4240{
    4341        if (flags != 0) {
     
    4543        }
    4644       
    47         return dlopen(filename, 0);
     45        return __helenos_libc_dlopen(filename, 0);
    4846}
    4947
    50 void *posix_dlsym(void *handle, const char *symbol)
    51 {
    52         return dlsym(handle, symbol);
    53 }
    54 
    55 int posix_dlclose(void *handle)
     48int dlclose(void *handle)
    5649{
    5750        not_implemented();
     
    5952}
    6053
    61 char *posix_dlerror(void)
     54char *dlerror(void)
    6255{
    6356        not_implemented();
  • uspace/lib/posix/src/fcntl.c

    re0f47f5 r7f9df7b9  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include "internal/common.h"
    3936#include "posix/fcntl.h"
     
    5148 *     to the requested operation.
    5249 */
    53 int posix_fcntl(int fd, int cmd, ...)
     50int fcntl(int fd, int cmd, ...)
    5451{
    5552        int flags;
     
    10299 * @param posix_flags Access mode flags.
    103100 */
    104 int posix_open(const char *pathname, int posix_flags, ...)
     101int open(const char *pathname, int posix_flags, ...)
    105102{
    106         posix_mode_t posix_mode = 0;
     103        mode_t posix_mode = 0;
    107104        if (posix_flags & O_CREAT) {
    108105                va_list args;
    109106                va_start(args, posix_flags);
    110                 posix_mode = va_arg(args, posix_mode_t);
     107                posix_mode = va_arg(args, mode_t);
    111108                va_end(args);
    112109                (void) posix_mode;
  • uspace/lib/posix/src/fnmatch.c

    re0f47f5 r7f9df7b9  
    4141 * will be fairly straightforward.
    4242 */
    43 
    44 #define LIBPOSIX_INTERNAL
    45 #define __POSIX_DEF__(x) posix_##x
    4643
    4744#include "libc/stdbool.h"
     
    205202{
    206203        const struct _char_class *class = elem;
    207         return posix_strcmp((const char *) key, class->name);
     204        return strcmp((const char *) key, class->name);
    208205}
    209206
     
    218215{
    219216        /* Search for class in the array of supported character classes. */
    220         const struct _char_class *class = posix_bsearch(cname, _char_classes,
     217        const struct _char_class *class = bsearch(cname, _char_classes,
    221218            sizeof(_char_classes) / sizeof(struct _char_class),
    222219            sizeof(struct _char_class), _class_compare);
     
    582579{
    583580        assert(s != NULL);
    584         char *result = posix_strdup(s);
     581        char *result = strdup(s);
    585582        for (char *i = result; *i != '\0'; ++i) {
    586583                *i = tolower(*i);
     
    598595 * @return Zero if the string matches the pattern, FNM_NOMATCH otherwise.
    599596 */
    600 int posix_fnmatch(const char *pattern, const char *string, int flags)
     597int fnmatch(const char *pattern, const char *string, int flags)
    601598{
    602599        assert(pattern != NULL);
     
    637634        #undef assert
    638635        #define assert(x) { if (x) printf("SUCCESS: "#x"\n"); else { printf("FAILED: "#x"\n"); fail++; } }
    639         #define match(s1, s2, flags) assert(posix_fnmatch(s1, s2, flags) == 0)
    640         #define nomatch(s1, s2, flags) assert(posix_fnmatch(s1, s2, flags) == FNM_NOMATCH)
     636        #define match(s1, s2, flags) assert(fnmatch(s1, s2, flags) == 0)
     637        #define nomatch(s1, s2, flags) assert(fnmatch(s1, s2, flags) == FNM_NOMATCH)
    641638
    642639        static_assert(FNM_PATHNAME == FNM_FILE_NAME);
  • uspace/lib/posix/src/internal/common.h

    re0f47f5 r7f9df7b9  
    5050        } while (0)
    5151
     52// Just a marker for external tools.
     53#define _HIDE_LIBC_SYMBOL(symbol)
     54
    5255/* Checks if the value is a failing error code.
    5356 * If so, writes the error code to errno and returns true.
  • uspace/lib/posix/src/locale.c

    re0f47f5 r7f9df7b9  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include "internal/common.h"
    3936#include "posix/locale.h"
     
    5451};
    5552
    56 const struct posix_lconv C_LOCALE = {
     53const struct lconv C_LOCALE = {
    5754        .currency_symbol = (char *) "",
    5855        .decimal_point = (char *) ".",
     
    8885 * @return Original locale name on success, NULL on failure.
    8986 */
    90 char *posix_setlocale(int category, const char *locale)
     87char *setlocale(int category, const char *locale)
    9188{
    9289        // TODO
    9390        if (locale == NULL || *locale == '\0' ||
    94             posix_strcmp(locale, "C") == 0) {
     91            strcmp(locale, "C") == 0) {
    9592                return (char *) "C";
    9693        }
     
    103100 * @return Information about the current locale.
    104101 */
    105 struct posix_lconv *posix_localeconv(void)
     102struct lconv *localeconv(void)
    106103{
    107104        // TODO
    108         return (struct posix_lconv *) &C_LOCALE;
     105        return (struct lconv *) &C_LOCALE;
    109106}
    110107
     
    115112 * @return Duplicated object.
    116113 */
    117 posix_locale_t posix_duplocale(posix_locale_t locobj)
     114locale_t duplocale(locale_t locobj)
    118115{
    119116        if (locobj == NULL) {
     
    121118                return NULL;
    122119        }
    123         posix_locale_t copy = malloc(sizeof(struct __posix_locale));
     120        locale_t copy = malloc(sizeof(struct __posix_locale));
    124121        if (copy == NULL) {
    125122                errno = ENOMEM;
     
    135132 * @param locobj Object to free.
    136133 */
    137 void posix_freelocale(posix_locale_t locobj)
     134void freelocale(locale_t locobj)
    138135{
    139136        if (locobj) {
     
    150147 * @return The new/modified locale object.
    151148 */
    152 posix_locale_t posix_newlocale(int category_mask, const char *locale,
    153     posix_locale_t base)
     149locale_t newlocale(int category_mask, const char *locale,
     150    locale_t base)
    154151{
    155152        if (locale == NULL ||
     
    159156        }
    160157        // TODO
    161         posix_locale_t new = malloc(sizeof(struct __posix_locale));
     158        locale_t new = malloc(sizeof(struct __posix_locale));
    162159        if (new == NULL) {
    163160                errno = ENOMEM;
     
    165162        }
    166163        if (base != NULL) {
    167                 posix_freelocale(base);
     164                freelocale(base);
    168165        }
    169166        return new;
     
    176173 * @return The previously set locale or LC_GLOBAL_LOCALE
    177174 */
    178 posix_locale_t posix_uselocale(posix_locale_t newloc)
     175locale_t uselocale(locale_t newloc)
    179176{
    180177        // TODO
  • uspace/lib/posix/src/pthread/condvar.c

    re0f47f5 r7f9df7b9  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include "posix/pthread.h"
    3936#include "errno.h"
     
    6663
    6764int pthread_cond_timedwait(pthread_cond_t *restrict condvar,
    68     pthread_mutex_t *restrict mutex, const struct __POSIX_DEF__(timespec) *restrict timeout)
     65    pthread_mutex_t *restrict mutex, const struct timespec *restrict timeout)
    6966{
    7067        not_implemented();
  • uspace/lib/posix/src/pthread/keys.c

    re0f47f5 r7f9df7b9  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include "posix/stdlib.h"
    3936#include "posix/pthread.h"
  • uspace/lib/posix/src/pthread/mutex.c

    re0f47f5 r7f9df7b9  
    3232/** @file Pthread: mutexes.
    3333 */
    34 
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    3734
    3835#include "posix/pthread.h"
  • uspace/lib/posix/src/pthread/threads.c

    re0f47f5 r7f9df7b9  
    3232/** @file Pthread: thread management.
    3333 */
    34 
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    3734
    3835#include "posix/pthread.h"
  • uspace/lib/posix/src/pwd.c

    re0f47f5 r7f9df7b9  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include "libc/stdbool.h"
    3936#include "posix/pwd.h"
     
    4542
    4643/* dummy user account */
    47 static const struct posix_passwd dummy_pwd = {
     44static const struct passwd dummy_pwd = {
    4845        .pw_name = (char *) "user",
    4946        .pw_uid = 0,
     
    6259 *     doesn't have user accounts, this always returns the same made-up entry.
    6360 */
    64 struct posix_passwd *posix_getpwent(void)
     61struct passwd *getpwent(void)
    6562{
    6663        if (entry_read) {
     
    6966
    7067        entry_read = true;
    71         return (struct posix_passwd *) &dummy_pwd;
     68        return (struct passwd *) &dummy_pwd;
    7269}
    7370
     
    7572 * Rewind the user list.
    7673 */
    77 void posix_setpwent(void)
     74void setpwent(void)
    7875{
    7976        entry_read = false;
     
    8380 * Ends enumerating and releases all resources. (Noop)
    8481 */
    85 void posix_endpwent(void)
     82void endpwent(void)
    8683{
    8784        /* noop */
     
    9491 * @return Either found entry or NULL if no such entry exists.
    9592 */
    96 struct posix_passwd *posix_getpwnam(const char *name)
     93struct passwd *getpwnam(const char *name)
    9794{
    9895        assert(name != NULL);
    9996
    100         if (posix_strcmp(name, "user") != 0) {
     97        if (strcmp(name, "user") != 0) {
    10198                return NULL;
    10299        }
    103100
    104         return (struct posix_passwd *) &dummy_pwd;
     101        return (struct passwd *) &dummy_pwd;
    105102}
    106103
     
    116113 *     non-zero error number if error occured.
    117114 */
    118 int posix_getpwnam_r(const char *name, struct posix_passwd *pwd,
    119     char *buffer, size_t bufsize, struct posix_passwd **result)
     115int getpwnam_r(const char *name, struct passwd *pwd,
     116    char *buffer, size_t bufsize, struct passwd **result)
    120117{
    121118        assert(name != NULL);
     
    124121        assert(result != NULL);
    125122       
    126         if (posix_strcmp(name, "user") != 0) {
     123        if (strcmp(name, "user") != 0) {
    127124                *result = NULL;
    128125                return 0;
    129126        }
    130127       
    131         return posix_getpwuid_r(0, pwd, buffer, bufsize, result);
     128        return getpwuid_r(0, pwd, buffer, bufsize, result);
    132129}
    133130
     
    138135 * @return Either found entry or NULL if no such entry exists.
    139136 */
    140 struct posix_passwd *posix_getpwuid(posix_uid_t uid)
     137struct passwd *getpwuid(uid_t uid)
    141138{
    142139        if (uid != 0) {
     
    144141        }
    145142
    146         return (struct posix_passwd *) &dummy_pwd;
     143        return (struct passwd *) &dummy_pwd;
    147144}
    148145
     
    158155 *     non-zero error number if error occured.
    159156 */
    160 int posix_getpwuid_r(posix_uid_t uid, struct posix_passwd *pwd,
    161     char *buffer, size_t bufsize, struct posix_passwd **result)
     157int getpwuid_r(uid_t uid, struct passwd *pwd,
     158    char *buffer, size_t bufsize, struct passwd **result)
    162159{
    163160        assert(pwd != NULL);
     
    184181        pwd->pw_dir = (char *) bf + 5;
    185182        pwd->pw_shell = (char *) bf + 7;
    186         *result = (struct posix_passwd *) pwd;
     183        *result = (struct passwd *) pwd;
    187184
    188185        return 0;
  • uspace/lib/posix/src/signal.c

    re0f47f5 r7f9df7b9  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include "posix/signal.h"
    3936#include "internal/common.h"
     
    6158static LIST_INITIALIZE(_signal_queue);
    6259
    63 static posix_sigset_t _signal_mask = 0;
     60static sigset_t _signal_mask = 0;
    6461
    6562#define DEFAULT_HANDLER { .sa_handler = SIG_DFL, \
     
    6764
    6865/* Actions associated with each signal number. */
    69 static struct posix_sigaction _signal_actions[_TOP_SIGNAL + 1] = {
     66static struct sigaction _signal_actions[_TOP_SIGNAL + 1] = {
    7067        DEFAULT_HANDLER, DEFAULT_HANDLER, DEFAULT_HANDLER, DEFAULT_HANDLER,
    7168        DEFAULT_HANDLER, DEFAULT_HANDLER, DEFAULT_HANDLER, DEFAULT_HANDLER,
     
    111108        case SIGILL:
    112109        case SIGSEGV:
    113                 posix_psignal(signo, "Hardware exception raised by user code");
     110                psignal(signo, "Hardware exception raised by user code");
    114111                abort();
    115112        case SIGSYS:
     
    124121        case SIGTTIN:
    125122        case SIGTTOU:
    126                 posix_psignal(signo, "Unsupported signal caught");
     123                psignal(signo, "Unsupported signal caught");
    127124                abort();
    128125        case SIGCHLD:
     
    164161 * @return Always returns zero.
    165162 */
    166 int posix_sigemptyset(posix_sigset_t *set)
     163int sigemptyset(sigset_t *set)
    167164{
    168165        assert(set != NULL);
     
    178175 * @return Always returns zero.
    179176 */
    180 int posix_sigfillset(posix_sigset_t *set)
     177int sigfillset(sigset_t *set)
    181178{
    182179        assert(set != NULL);
     
    193190 * @return Always returns zero.
    194191 */
    195 int posix_sigaddset(posix_sigset_t *set, int signo)
     192int sigaddset(sigset_t *set, int signo)
    196193{
    197194        assert(set != NULL);
     
    208205 * @return Always returns zero.
    209206 */
    210 int posix_sigdelset(posix_sigset_t *set, int signo)
     207int sigdelset(sigset_t *set, int signo)
    211208{
    212209        assert(set != NULL);
     
    223220 * @return 1 if the signal is in the set, 0 otherwise.
    224221 */
    225 int posix_sigismember(const posix_sigset_t *set, int signo)
     222int sigismember(const sigset_t *set, int signo)
    226223{
    227224        assert(set != NULL);
     
    239236 * @param oact
    240237 */
    241 static void _sigaction_unsafe(int sig, const struct posix_sigaction *restrict act,
    242     struct posix_sigaction *restrict oact)
     238static void _sigaction_unsafe(int sig, const struct sigaction *restrict act,
     239    struct sigaction *restrict oact)
    243240{
    244241        if (oact != NULL) {
    245242                memcpy(oact, &_signal_actions[sig],
    246                     sizeof(struct posix_sigaction));
     243                    sizeof(struct sigaction));
    247244        }
    248245
    249246        if (act != NULL) {
    250247                memcpy(&_signal_actions[sig], act,
    251                     sizeof(struct posix_sigaction));
     248                    sizeof(struct sigaction));
    252249        }
    253250}
     
    263260 * @return -1 with errno set on failure, 0 on success.
    264261 */
    265 int posix_sigaction(int sig, const struct posix_sigaction *restrict act,
    266     struct posix_sigaction *restrict oact)
     262int sigaction(int sig, const struct sigaction *restrict act,
     263    struct sigaction *restrict oact)
    267264{
    268265        if (sig > _TOP_SIGNAL || (act != NULL &&
     
    273270
    274271        if (sig > _TOP_CATCHABLE_SIGNAL) {
    275                 posix_psignal(sig,
     272                psignal(sig,
    276273                    "WARNING: registering handler for a partially"
    277274                    " or fully unsupported signal. This handler may only be"
     
    294291 * @return SIG_ERR on failure, original handler on success.
    295292 */
    296 void (*posix_signal(int sig, void (*func)(int)))(int)
    297 {
    298         struct posix_sigaction new = {
     293void (*signal(int sig, void (*func)(int)))(int)
     294{
     295        struct sigaction new = {
    299296                .sa_handler = func,
    300297                .sa_mask = 0,
     
    302299                .sa_sigaction = NULL
    303300        };
    304         struct posix_sigaction old;
    305         if (posix_sigaction(sig, func == NULL ? NULL : &new, &old) == 0) {
     301        struct sigaction old;
     302        if (sigaction(sig, func == NULL ? NULL : &new, &old) == 0) {
    306303                return old.sa_handler;
    307304        } else {
     
    313310        link_t link;
    314311        int signo;
    315         posix_siginfo_t siginfo;
     312        siginfo_t siginfo;
    316313} signal_queue_item;
    317314
     
    322319 * @param siginfo Additional information about the signal.
    323320 */
    324 static void _queue_signal(int signo, posix_siginfo_t *siginfo)
     321static void _queue_signal(int signo, siginfo_t *siginfo)
    325322{
    326323        assert(signo >= 0 && signo <= _TOP_SIGNAL);
     
    330327        link_initialize(&(item->link));
    331328        item->signo = signo;
    332         memcpy(&item->siginfo, siginfo, sizeof(posix_siginfo_t));
     329        memcpy(&item->siginfo, siginfo, sizeof(siginfo_t));
    333330        list_append(&(item->link), &_signal_queue);
    334331}
     
    343340 *     blocked.
    344341 */
    345 static int _raise_sigaction(int signo, posix_siginfo_t *siginfo)
     342static int _raise_sigaction(int signo, siginfo_t *siginfo)
    346343{
    347344        assert(signo >= 0 && signo <= _TOP_SIGNAL);
     
    350347        fibril_mutex_lock(&_signal_mutex);
    351348
    352         struct posix_sigaction action = _signal_actions[signo];
    353 
    354         if (posix_sigismember(&_signal_mask, signo) ||
     349        struct sigaction action = _signal_actions[signo];
     350
     351        if (sigismember(&_signal_mask, signo) ||
    355352            action.sa_handler == SIG_HOLD) {
    356353                _queue_signal(signo, siginfo);
     
    364361
    365362        if ((action.sa_flags & SA_RESETHAND) && signo != SIGILL && signo != SIGTRAP) {
    366                 _signal_actions[signo] = (struct posix_sigaction) DEFAULT_HANDLER;
     363                _signal_actions[signo] = (struct sigaction) DEFAULT_HANDLER;
    367364        }
    368365
     
    394391                    list_get_instance(iterator, signal_queue_item, link);
    395392               
    396                 if (!posix_sigismember(&_signal_mask, item->signo) &&
     393                if (!sigismember(&_signal_mask, item->signo) &&
    397394                    _signal_actions[item->signo].sa_handler != SIG_HOLD) {
    398395                        list_remove(&(item->link));
     
    411408 * @return -1 with errno set on failure, 0 on success.
    412409 */
    413 int posix_raise(int sig)
     410int raise(int sig)
    414411{
    415412        if (sig >= 0 && sig <= _TOP_SIGNAL) {
    416                 posix_siginfo_t siginfo = {
     413                siginfo_t siginfo = {
    417414                        .si_signo = sig,
    418415                        .si_code = SI_USER
     
    433430 *     action, invalid signal number, lack of permissions, etc.), 0 on success.
    434431 */
    435 int posix_kill(posix_pid_t pid, int signo)
     432int kill(pid_t pid, int signo)
    436433{
    437434        if (pid < 1) {
     
    446443        }
    447444
    448         if (pid == (posix_pid_t) task_get_id()) {
    449                 return posix_raise(signo);
     445        if (pid == (pid_t) task_get_id()) {
     446                return raise(signo);
    450447        }
    451448
     
    471468 * @return -1 on failure, 0 on success (see kill()).
    472469 */
    473 int posix_killpg(posix_pid_t pid, int sig)
     470int killpg(pid_t pid, int sig)
    474471{
    475472        assert(pid > 1);
    476         return posix_kill(-pid, sig);
     473        return kill(-pid, sig);
    477474}
    478475
     
    483480 * @param message String to output alongside human-readable signal description.
    484481 */
    485 void posix_psiginfo(const posix_siginfo_t *pinfo, const char *message)
     482void psiginfo(const siginfo_t *pinfo, const char *message)
    486483{
    487484        assert(pinfo != NULL);
    488         posix_psignal(pinfo->si_signo, message);
     485        psignal(pinfo->si_signo, message);
    489486        // TODO: print si_code
    490487}
     
    496493 * @param message String to output alongside human-readable signal description.
    497494 */
    498 void posix_psignal(int signum, const char *message)
    499 {
    500         char *sigmsg = posix_strsignal(signum);
     495void psignal(int signum, const char *message)
     496{
     497        char *sigmsg = strsignal(signum);
    501498        if (message == NULL || *message == '\0') {
    502499                fprintf(stderr, "%s\n", sigmsg);
     
    514511 * @return 0 success, errorcode on failure.
    515512 */
    516 int posix_thread_sigmask(int how, const posix_sigset_t *restrict set,
    517     posix_sigset_t *restrict oset)
     513int thread_sigmask(int how, const sigset_t *restrict set,
     514    sigset_t *restrict oset)
    518515{
    519516        fibril_mutex_lock(&_signal_mutex);
     
    554551 * @return 0 on success, -1 with errno set on failure.
    555552 */
    556 int posix_sigprocmask(int how, const posix_sigset_t *restrict set,
    557     posix_sigset_t *restrict oset)
    558 {
    559         int result = posix_thread_sigmask(how, set, oset);
     553int sigprocmask(int how, const sigset_t *restrict set,
     554    sigset_t *restrict oset)
     555{
     556        int result = thread_sigmask(how, set, oset);
    560557        if (result != 0) {
    561558                errno = result;
  • uspace/lib/posix/src/stdio.c

    re0f47f5 r7f9df7b9  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "internal/common.h"
    4037#include "posix/stdio.h"
     
    5552#include "libc/adt/list.h"
    5653
    57 /** Clears the stream's error and end-of-file indicators.
    58  *
    59  * @param stream Stream whose indicators shall be cleared.
    60  */
    61 void posix_clearerr(FILE *stream)
    62 {
    63         clearerr(stream);
    64 }
    65 
    6654/**
    6755 * Generate a pathname for the controlling terminal.
     
    7058 * @return Either s or static location filled with the requested pathname.
    7159 */
    72 char *posix_ctermid(char *s)
     60char *ctermid(char *s)
    7361{
    7462        /* Currently always returns an error value (empty string). */
     
    8371        s[0] = '\0';
    8472        return s;
    85 }
    86 
    87 /**
    88  * Put a string on the stream.
    89  *
    90  * @param s String to be written.
    91  * @param stream Output stream.
    92  * @return Non-negative on success, EOF on failure.
    93  */
    94 int posix_fputs(const char *restrict s, FILE *restrict stream)
    95 {
    96         return fputs(s, stream);
    97 }
    98 
    99 /**
    100  * Push byte back into input stream.
    101  *
    102  * @param c Byte to be pushed back.
    103  * @param stream Stream to where the byte shall be pushed.
    104  * @return Provided byte on success or EOF if not possible.
    105  */
    106 int posix_ungetc(int c, FILE *stream)
    107 {
    108         return ungetc(c, stream);
    10973}
    11074
     
    12286 *     or -1 on error (set in errno).
    12387 */
    124 ssize_t posix_getdelim(char **restrict lineptr, size_t *restrict n,
     88ssize_t getdelim(char **restrict lineptr, size_t *restrict n,
    12589    int delimiter, FILE *restrict stream)
    12690{
     
    194158 *     or -1 on error (set in errno).
    195159 */
    196 ssize_t posix_getline(char **restrict lineptr, size_t *restrict n,
     160ssize_t getline(char **restrict lineptr, size_t *restrict n,
    197161    FILE *restrict stream)
    198162{
    199         return posix_getdelim(lineptr, n, '\n', stream);
    200 }
    201 
    202 /**
    203  * Reopen a file stream.
    204  *
    205  * @param filename Pathname of a file to be reopened or NULL for changing
    206  *     the mode of the stream.
    207  * @param mode Mode to be used for reopening the file or changing current
    208  *     mode of the stream.
    209  * @param stream Current stream associated with the opened file.
    210  * @return On success, either a stream of the reopened file or the provided
    211  *     stream with a changed mode. NULL otherwise.
    212  */
    213 FILE *posix_freopen(const char *restrict filename,
    214     const char *restrict mode, FILE *restrict stream)
    215 {
    216         return freopen(filename, mode, stream);
     163        return getdelim(lineptr, n, '\n', stream);
    217164}
    218165
     
    222169 * @param s Error message.
    223170 */
    224 void posix_perror(const char *s)
     171void perror(const char *s)
    225172{
    226173        if (s == NULL || s[0] == '\0') {
    227                 fprintf(stderr, "%s\n", posix_strerror(errno));
     174                fprintf(stderr, "%s\n", strerror(errno));
    228175        } else {
    229                 fprintf(stderr, "%s: %s\n", s, posix_strerror(errno));
     176                fprintf(stderr, "%s: %s\n", s, strerror(errno));
    230177        }
    231178}
     
    237184 * @return Zero on success, non-zero (with errno set) on failure
    238185 */
    239 int posix_fsetpos(FILE *stream, const posix_fpos_t *pos)
     186int fsetpos(FILE *stream, const fpos_t *pos)
    240187{
    241188        return fseek64(stream, pos->offset, SEEK_SET);
     
    248195 * @return Zero on success, non-zero (with errno set) on failure
    249196 */
    250 int posix_fgetpos(FILE *restrict stream, posix_fpos_t *restrict pos)
     197int fgetpos(FILE *restrict stream, fpos_t *restrict pos)
    251198{
    252199        off64_t ret = ftell64(stream);
     
    267214 * @return Zero on success, -1 otherwise.
    268215 */
    269 int posix_fseek(FILE *stream, long offset, int whence)
    270 {
    271         return fseek(stream, offset, whence);
    272 }
    273 
    274 /**
    275  * Reposition a file-position indicator in a stream.
    276  *
    277  * @param stream Stream to seek in.
    278  * @param offset Direction and amount of bytes to seek.
    279  * @param whence From where to seek.
    280  * @return Zero on success, -1 otherwise.
    281  */
    282 int posix_fseeko(FILE *stream, posix_off_t offset, int whence)
     216int fseeko(FILE *stream, off_t offset, int whence)
    283217{
    284218        return fseek64(stream, offset, whence);
     
    291225 * @return Current offset or -1 if not possible.
    292226 */
    293 long posix_ftell(FILE *stream)
    294 {
    295         return ftell(stream);
    296 }
    297 
    298 /**
    299  * Discover current file offset in a stream.
    300  *
    301  * @param stream Stream for which the offset shall be retrieved.
    302  * @return Current offset or -1 if not possible.
    303  */
    304 posix_off_t posix_ftello(FILE *stream)
     227off_t ftello(FILE *stream)
    305228{
    306229        return ftell64(stream);
     
    308231
    309232/**
    310  * Discard prefetched data or write unwritten data.
    311  *
    312  * @param stream Stream that shall be flushed.
    313  * @return Zero on success, EOF on failure.
    314  */
    315 int posix_fflush(FILE *stream)
    316 {
    317         return fflush(stream);
    318 }
    319 
    320 /**
    321233 * Print formatted output to the opened file.
    322234 *
     
    325237 * @return Either the number of printed characters or negative value on error.
    326238 */
    327 int posix_dprintf(int fildes, const char *restrict format, ...)
     239int dprintf(int fildes, const char *restrict format, ...)
    328240{
    329241        va_list list;
    330242        va_start(list, format);
    331         int result = posix_vdprintf(fildes, format, list);
     243        int result = vdprintf(fildes, format, list);
    332244        va_end(list);
    333245        return result;
     
    392304 * @return Either the number of printed characters or negative value on error.
    393305 */
    394 int posix_vdprintf(int fildes, const char *restrict format, va_list ap)
     306int vdprintf(int fildes, const char *restrict format, va_list ap)
    395307{
    396308        printf_spec_t spec = {
     
    411323 *     negative value on error.
    412324 */
    413 int posix_sprintf(char *s, const char *restrict format, ...)
     325int sprintf(char *s, const char *restrict format, ...)
    414326{
    415327        va_list list;
    416328        va_start(list, format);
    417         int result = posix_vsprintf(s, format, list);
     329        int result = vsprintf(s, format, list);
    418330        va_end(list);
    419331        return result;
     
    429341 *     negative value on error.
    430342 */
    431 int posix_vsprintf(char *s, const char *restrict format, va_list ap)
     343int vsprintf(char *s, const char *restrict format, va_list ap)
    432344{
    433345        return vsnprintf(s, STR_NO_LIMIT, format, ap);
     
    441353 * @return The number of converted output items or EOF on failure.
    442354 */
    443 int posix_fscanf(FILE *restrict stream, const char *restrict format, ...)
     355int fscanf(FILE *restrict stream, const char *restrict format, ...)
    444356{
    445357        va_list list;
    446358        va_start(list, format);
    447         int result = posix_vfscanf(stream, format, list);
     359        int result = vfscanf(stream, format, list);
    448360        va_end(list);
    449361        return result;
     
    456368 * @return The number of converted output items or EOF on failure.
    457369 */
    458 int posix_scanf(const char *restrict format, ...)
     370int scanf(const char *restrict format, ...)
    459371{
    460372        va_list list;
    461373        va_start(list, format);
    462         int result = posix_vscanf(format, list);
     374        int result = vscanf(format, list);
    463375        va_end(list);
    464376        return result;
     
    472384 * @return The number of converted output items or EOF on failure.
    473385 */
    474 int posix_vscanf(const char *restrict format, va_list arg)
    475 {
    476         return posix_vfscanf(stdin, format, arg);
     386int vscanf(const char *restrict format, va_list arg)
     387{
     388        return vfscanf(stdin, format, arg);
    477389}
    478390
     
    484396 * @return The number of converted output items or EOF on failure.
    485397 */
    486 int posix_sscanf(const char *restrict s, const char *restrict format, ...)
     398int sscanf(const char *restrict s, const char *restrict format, ...)
    487399{
    488400        va_list list;
    489401        va_start(list, format);
    490         int result = posix_vsscanf(s, format, list);
     402        int result = vsscanf(s, format, list);
    491403        va_end(list);
    492404        return result;
     
    498410 * @param file File stream to lock.
    499411 */
    500 void posix_flockfile(FILE *file)
     412void flockfile(FILE *file)
    501413{
    502414        /* dummy */
     
    509421 * @return Zero for success and non-zero if the lock cannot be acquired.
    510422 */
    511 int posix_ftrylockfile(FILE *file)
     423int ftrylockfile(FILE *file)
    512424{
    513425        /* dummy */
     
    520432 * @param file File stream to unlock.
    521433 */
    522 void posix_funlockfile(FILE *file)
     434void funlockfile(FILE *file)
    523435{
    524436        /* dummy */
     
    531443 * @return Either read byte or EOF.
    532444 */
    533 int posix_getc_unlocked(FILE *stream)
     445int getc_unlocked(FILE *stream)
    534446{
    535447        return getc(stream);
     
    541453 * @return Either read byte or EOF.
    542454 */
    543 int posix_getchar_unlocked(void)
     455int getchar_unlocked(void)
    544456{
    545457        return getchar();
     
    553465 * @return Either written byte or EOF.
    554466 */
    555 int posix_putc_unlocked(int c, FILE *stream)
     467int putc_unlocked(int c, FILE *stream)
    556468{
    557469        return putc(c, stream);
     
    564476 * @return Either written byte or EOF.
    565477 */
    566 int posix_putchar_unlocked(int c)
     478int putchar_unlocked(int c)
    567479{
    568480        return putchar(c);
    569 }
    570 
    571 /**
    572  * Remove a file or directory.
    573  *
    574  * @param path Pathname of the file that shall be removed.
    575  * @return Zero on success, -1 (with errno set) otherwise.
    576  */
    577 int posix_remove(const char *path)
    578 {
    579         if (failed(vfs_unlink_path(path)))
    580                 return -1;
    581         else
    582                 return 0;
    583 }
    584 
    585 /**
    586  * Rename a file or directory.
    587  *
    588  * @param old Old pathname.
    589  * @param new New pathname.
    590  * @return Zero on success, -1 (with errno set) otherwise.
    591  */
    592 int posix_rename(const char *old, const char *new)
    593 {
    594         if (failed(vfs_rename_path(old, new)))
    595                 return -1;
    596         else
    597                 return 0;
    598481}
    599482
     
    604487 * @return The value of s on success, NULL on failure.
    605488 */
    606 char *posix_tmpnam(char *s)
    607 {
    608         assert(L_tmpnam >= posix_strlen("/tmp/tnXXXXXX"));
     489char *tmpnam(char *s)
     490{
     491        assert(L_tmpnam >= strlen("/tmp/tnXXXXXX"));
    609492       
    610493        static char buffer[L_tmpnam + 1];
     
    613496        }
    614497       
    615         posix_strcpy(s, "/tmp/tnXXXXXX");
    616         posix_mktemp(s);
     498        strcpy(s, "/tmp/tnXXXXXX");
     499        mktemp(s);
    617500       
    618501        if (*s == '\0') {
     
    631514 * @return Newly allocated unique path for temporary file. NULL on failure.
    632515 */
    633 char *posix_tempnam(const char *dir, const char *pfx)
     516char *tempnam(const char *dir, const char *pfx)
    634517{
    635518        /* Sequence number of the filename. */
    636519        static int seq = 0;
    637520       
    638         size_t dir_len = posix_strlen(dir);
     521        size_t dir_len = strlen(dir);
    639522        if (dir[dir_len - 1] == '/') {
    640523                dir_len--;
    641524        }
    642525       
    643         size_t pfx_len = posix_strlen(pfx);
     526        size_t pfx_len = strlen(pfx);
    644527        if (pfx_len > 5) {
    645528                pfx_len = 5;
     
    655538       
    656539        char *res_ptr = result;
    657         posix_strncpy(res_ptr, dir, dir_len);
     540        strncpy(res_ptr, dir, dir_len);
    658541        res_ptr += dir_len;
    659         posix_strncpy(res_ptr, pfx, pfx_len);
     542        strncpy(res_ptr, pfx, pfx_len);
    660543        res_ptr += pfx_len;
    661544       
     
    666549                errno = EOK;
    667550                /* Check if the file exists. */
    668                 if (posix_access(result, F_OK) == -1) {
     551                if (access(result, F_OK) == -1) {
    669552                        if (errno == ENOENT) {
    670553                                errno = orig_errno;
     
    694577 * @return Newly allocated unique path for temporary file. NULL on failure.
    695578 */
    696 FILE *posix_tmpfile(void)
     579FILE *tmpfile(void)
    697580{
    698581        char filename[] = "/tmp/tfXXXXXX";
    699         int fd = posix_mkstemp(filename);
     582        int fd = mkstemp(filename);
    700583        if (fd == -1) {
    701584                /* errno set by mkstemp(). */
     
    704587       
    705588        /* Unlink the created file, so that it's removed on close(). */
    706         posix_unlink(filename);
     589        unlink(filename);
    707590        return fdopen(fd, "w+");
    708591}
  • uspace/lib/posix/src/stdio/scanf.c

    re0f47f5 r7f9df7b9  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include <assert.h>
    3936
     
    119116        /* Initialize internal structures. */
    120117        self->consumed = 0;
    121         ssize_t fetched = posix_getline(
     118        ssize_t fetched = getline(
    122119            &self->window, &self->window_size, self->source.stream);
    123120        if (fetched != -1) {
     
    140137        /* Initialize internal structures. */
    141138        self->consumed = 0;
    142         self->fetched = posix_strlen(self->source.string);
     139        self->fetched = strlen(self->source.string);
    143140        self->window = (char *) self->source.string;
    144141        self->window_size = self->fetched + 1;
     
    158155                /* Do we need to fetch a new line from the source? */
    159156                if (*self->cursor == '\0') {
    160                         ssize_t fetched = posix_getline(&self->window,
     157                        ssize_t fetched = getline(&self->window,
    161158                            &self->window_size, self->source.stream);
    162159                        if (fetched != -1) {
     
    208205                 * containing newline, while at the same time newline is the character
    209206                 * that breaks the matching process. */
    210                 int rc = posix_fseek(
    211                     self->source.stream, -1, SEEK_CUR);
     207                int rc = fseek(self->source.stream, -1, SEEK_CUR);
    212208                if (rc == -1) {
    213209                        /* Seek failed.  */
    214210                        return 0;
    215211                }
    216                 ssize_t fetched = posix_getline(&self->window,
     212                ssize_t fetched = getline(&self->window,
    217213                    &self->window_size, self->source.stream);
    218214                if (fetched != -1) {
     
    266262        if (*self->cursor == '\0') {
    267263                /* Window was completely consumed, fetch new data. */
    268                 ssize_t fetched = posix_getline(&self->window,
     264                ssize_t fetched = getline(&self->window,
    269265                    &self->window_size, self->source.stream);
    270266                if (fetched != -1) {
     
    298294        /* Try to correct the difference between the stream position and what was
    299295         * actually consumed. If it is not possible, continue anyway. */
    300         posix_fseek(self->source.stream, self->consumed - self->fetched, SEEK_CUR);
     296        fseek(self->source.stream, self->consumed - self->fetched, SEEK_CUR);
    301297
    302298        /* Destruct internal structures. */
     
    638634                                 * than allowed by width. */
    639635                                if (width != -1) {
    640                                         cur_duplicated = posix_strndup(cur_borrowed, width);
     636                                        cur_duplicated = strndup(cur_borrowed, width);
    641637                                        cur_limited = cur_duplicated;
    642638                                } else {
     
    812808                                 * than allowed by width. */
    813809                                if (width != -1) {
    814                                         cur_duplicated = posix_strndup(cur_borrowed, width);
     810                                        cur_duplicated = strndup(cur_borrowed, width);
    815811                                        cur_limited = cur_duplicated;
    816812                                } else {
     
    826822                                switch (length_mod) {
    827823                                case LMOD_NONE:
    828                                         fres = posix_strtof(cur_limited, (char **) &cur_updated);
     824                                        fres = strtof(cur_limited, (char **) &cur_updated);
    829825                                        break;
    830826                                case LMOD_l:
    831                                         dres = posix_strtod(cur_limited, (char **) &cur_updated);
     827                                        dres = strtod(cur_limited, (char **) &cur_updated);
    832828                                        break;
    833829                                case LMOD_L:
    834                                         ldres = posix_strtold(cur_limited, (char **) &cur_updated);
     830                                        ldres = strtold(cur_limited, (char **) &cur_updated);
    835831                                        break;
    836832                                default:
     
    11941190 * @return The number of converted output items or EOF on failure.
    11951191 */
    1196 int posix_vfscanf(
     1192int vfscanf(
    11971193    FILE *restrict stream, const char *restrict format, va_list arg)
    11981194{
     
    12141210 * @return The number of converted output items or EOF on failure.
    12151211 */
    1216 int posix_vsscanf(
     1212int vsscanf(
    12171213    const char *restrict s, const char *restrict format, va_list arg)
    12181214{
  • uspace/lib/posix/src/stdlib.c

    re0f47f5 r7f9df7b9  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "internal/common.h"
    4037#include "posix/stdlib.h"
     
    6057 * @param compare
    6158 */
    62 int posix_atexit(void (*func)(void))
     59int atexit(void (*func)(void))
    6360{
    6461        // TODO: low priority, just a compile-time dependency of binutils
     
    7370 * @return Absolute value of the parameter.
    7471 */
    75 int posix_abs(int i)
     72int abs(int i)
    7673{
    7774        return i < 0 ? -i : i;
     
    8481 * @return Absolute value of the parameter.
    8582 */
    86 long posix_labs(long i)
     83long labs(long i)
    8784{
    8885        return i < 0 ? -i : i;
     
    9592 * @return Absolute value of the parameter.
    9693 */
    97 long long posix_llabs(long long i)
     94long long llabs(long long i)
    9895{
    9996        return i < 0 ? -i : i;
     
    107104 * @return Quotient and remainder packed into structure.
    108105 */
    109 posix_div_t posix_div(int numer, int denom)
    110 {
    111         return (posix_div_t) { .quot = numer / denom, .rem = numer % denom };
     106div_t div(int numer, int denom)
     107{
     108        return (div_t) { .quot = numer / denom, .rem = numer % denom };
    112109}
    113110
     
    119116 * @return Quotient and remainder packed into structure.
    120117 */
    121 posix_ldiv_t posix_ldiv(long numer, long denom)
    122 {
    123         return (posix_ldiv_t) { .quot = numer / denom, .rem = numer % denom };
     118ldiv_t ldiv(long numer, long denom)
     119{
     120        return (ldiv_t) { .quot = numer / denom, .rem = numer % denom };
    124121}
    125122
     
    131128 * @return Quotient and remainder packed into structure.
    132129 */
    133 posix_lldiv_t posix_lldiv(long long numer, long long denom)
    134 {
    135         return (posix_lldiv_t) { .quot = numer / denom, .rem = numer % denom };
    136 }
    137 
    138 /**
    139  * Array sorting utilizing the quicksort algorithm.
    140  *
    141  * @param array Array of elements to sort.
    142  * @param count Number of elements in the array.
    143  * @param size Width of each element.
    144  * @param compare Decides relative ordering of two elements.
    145  */
    146 void posix_qsort(void *array, size_t count, size_t size,
    147     int (*compare)(const void *, const void *))
    148 {
    149         qsort(array, count, size, compare);
     130lldiv_t lldiv(long long numer, long long denom)
     131{
     132        return (lldiv_t) { .quot = numer / denom, .rem = numer % denom };
    150133}
    151134
     
    160143 * @return Pointer to a matching element, or NULL if none can be found.
    161144 */
    162 void *posix_bsearch(const void *key, const void *base,
     145void *bsearch(const void *key, const void *base,
    163146    size_t nmemb, size_t size, int (*compar)(const void *, const void *))
    164147{
     
    195178 * @return Value of the variable or NULL if such variable does not exist.
    196179 */
    197 char *posix_getenv(const char *name)
     180char *getenv(const char *name)
    198181{
    199182        return NULL;
     
    206189 * @return
    207190 */
    208 int posix_putenv(char *string)
     191int putenv(char *string)
    209192{
    210193        // TODO: low priority, just a compile-time dependency of binutils
     
    221204 *     or not (zero).
    222205 */
    223 int posix_system(const char *string) {
     206int system(const char *string) {
    224207        // TODO: does nothing at the moment
    225208        not_implemented();
     
    237220 *
    238221 */
    239 char *posix_realpath(const char *restrict name, char *restrict resolved)
     222char *realpath(const char *restrict name, char *restrict resolved)
    240223{
    241224        #ifndef PATH_MAX
     
    279262/**
    280263 * Converts a string representation of a floating-point number to
    281  * its native representation. See posix_strtold().
     264 * its native representation. See strtold().
    282265 *
    283266 * @param nptr String representation of a floating-point number.
    284267 * @return Double-precision number resulting from the string conversion.
    285268 */
    286 double posix_atof(const char *nptr)
    287 {
    288         return posix_strtod(nptr, NULL);
     269double atof(const char *nptr)
     270{
     271        return strtod(nptr, NULL);
    289272}
    290273
    291274/**
    292275 * Converts a string representation of a floating-point number to
    293  * its native representation. See posix_strtold().
     276 * its native representation. See strtold().
    294277 *
    295278 * @param nptr String representation of a floating-point number.
     
    298281 * @return Single-precision number resulting from the string conversion.
    299282 */
    300 float posix_strtof(const char *restrict nptr, char **restrict endptr)
    301 {
    302         return (float) posix_strtold(nptr, endptr);
     283float strtof(const char *restrict nptr, char **restrict endptr)
     284{
     285        return (float) strtold(nptr, endptr);
    303286}
    304287
    305288/**
    306289 * Converts a string representation of a floating-point number to
    307  * its native representation. See posix_strtold().
     290 * its native representation. See strtold().
    308291 *
    309292 * @param nptr String representation of a floating-point number.
     
    312295 * @return Double-precision number resulting from the string conversion.
    313296 */
    314 double posix_strtod(const char *restrict nptr, char **restrict endptr)
    315 {
    316         return (double) posix_strtold(nptr, endptr);
    317 }
    318 
    319 /**
    320  * Allocate memory chunk.
    321  *
    322  * @param size Size of the chunk to allocate.
    323  * @return Either pointer to the allocated chunk or NULL if not possible.
    324  */
    325 void *posix_malloc(size_t size)
    326 {
    327         return malloc(size);
    328 }
    329 
    330 /**
    331  * Allocate memory for an array of elements.
    332  *
    333  * @param nelem Number of elements in the array.
    334  * @param elsize Size of each element.
    335  * @return Either pointer to the allocated array or NULL if not possible.
    336  */
    337 void *posix_calloc(size_t nelem, size_t elsize)
    338 {
    339         return calloc(nelem, elsize);
    340 }
    341 
    342 /**
    343  * Reallocate memory chunk to a new size.
    344  *
    345  * @param ptr Memory chunk to reallocate. Might be NULL.
    346  * @param size Size of the reallocated chunk. Might be zero.
    347  * @return Either NULL or the pointer to the newly reallocated chunk.
    348  */
    349 void *posix_realloc(void *ptr, size_t size)
    350 {
    351         if (ptr != NULL && size == 0) {
    352                 /* Native realloc does not handle this special case. */
    353                 free(ptr);
    354                 return NULL;
    355         } else {
    356                 return realloc(ptr, size);
    357         }
    358 }
    359 
    360 /**
    361  * Free allocated memory chunk.
    362  *
    363  * @param ptr Memory chunk to be freed.
    364  */
    365 void posix_free(void *ptr)
    366 {
    367         if (ptr) {
    368                 free(ptr);
    369         }
    370 }
    371 
    372 /**
    373  * Generate a pseudo random integer in the range 0 to RAND_MAX inclusive.
    374  *
    375  * @return The pseudo random integer.
    376  */
    377 int posix_rand(void)
    378 {
    379         return (int) rand();
    380 }
    381 
    382 /**
    383  * Initialize a new sequence of pseudo-random integers.
    384  *
    385  * @param seed The seed of the new sequence.
    386  */
    387 void posix_srand(unsigned int seed)
    388 {
    389         srand(seed);
     297double strtod(const char *restrict nptr, char **restrict endptr)
     298{
     299        return (double) strtold(nptr, endptr);
    390300}
    391301
     
    396306 * @return The opened file descriptor or -1 on error.
    397307 */
    398 int posix_mkstemp(char *tmpl)
     308int mkstemp(char *tmpl)
    399309{
    400310        int fd = -1;
    401311       
    402         char *tptr = tmpl + posix_strlen(tmpl) - 6;
     312        char *tptr = tmpl + strlen(tmpl) - 6;
    403313       
    404314        while (fd < 0) {
    405                 if (*posix_mktemp(tmpl) == '\0') {
     315                if (*mktemp(tmpl) == '\0') {
    406316                        /* Errno set by mktemp(). */
    407317                        return -1;
    408318                }
    409319               
    410                 fd = posix_open(tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
     320                fd = open(tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
    411321               
    412322                if (fd == -1) {
     
    427337 *    reduced to an empty string.
    428338 */
    429 char *posix_mktemp(char *tmpl)
    430 {
    431         int tmpl_len = posix_strlen(tmpl);
     339char *mktemp(char *tmpl)
     340{
     341        int tmpl_len = strlen(tmpl);
    432342        if (tmpl_len < 6) {
    433343                errno = EINVAL;
     
    437347       
    438348        char *tptr = tmpl + tmpl_len - 6;
    439         if (posix_strcmp(tptr, "XXXXXX") != 0) {
     349        if (strcmp(tptr, "XXXXXX") != 0) {
    440350                errno = EINVAL;
    441351                *tmpl = '\0';
     
    451361                errno = 0;
    452362                /* Check if the file exists. */
    453                 if (posix_access(tmpl, F_OK) == -1) {
     363                if (access(tmpl, F_OK) == -1) {
    454364                        if (errno == ENOENT) {
    455365                                errno = orig_errno;
  • uspace/lib/posix/src/stdlib/strtold.c

    re0f47f5 r7f9df7b9  
    3232/** @file Backend for floating point conversions.
    3333 */
    34 
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    3734
    3835#include "../internal/common.h"
     
    407404 * @return An approximate representation of the input floating-point number.
    408405 */
    409 long double posix_strtold(const char *restrict nptr, char **restrict endptr)
     406long double strtold(const char *restrict nptr, char **restrict endptr)
    410407{
    411408        assert(nptr != NULL);
     
    433430       
    434431        /* check for NaN */
    435         if (posix_strncasecmp(&nptr[i], "nan", 3) == 0) {
     432        if (strncasecmp(&nptr[i], "nan", 3) == 0) {
    436433                // FIXME: return NaN
    437434                // TODO: handle the parenthesised case
     
    445442       
    446443        /* check for Infinity */
    447         if (posix_strncasecmp(&nptr[i], "inf", 3) == 0) {
     444        if (strncasecmp(&nptr[i], "inf", 3) == 0) {
    448445                i += 3;
    449                 if (posix_strncasecmp(&nptr[i], "inity", 5) == 0) {
     446                if (strncasecmp(&nptr[i], "inity", 5) == 0) {
    450447                        i += 5;
    451448                }
  • uspace/lib/posix/src/string.c

    re0f47f5 r7f9df7b9  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "internal/common.h"
    4037#include "posix/string.h"
     
    6259static char *strpbrk_null(const char *s1, const char *s2)
    6360{
    64         while (!posix_strchr(s2, *s1)) {
     61        while (!strchr(s2, *s1)) {
    6562                ++s1;
    6663        }
     
    7673 * @return Pointer to the destination buffer.
    7774 */
    78 char *posix_strcpy(char *restrict dest, const char *restrict src)
    79 {
    80         posix_stpcpy(dest, src);
     75char *strcpy(char *restrict dest, const char *restrict src)
     76{
     77        stpcpy(dest, src);
    8178        return dest;
    8279}
     
    9087 * @return Pointer to the destination buffer.
    9188 */
    92 char *posix_strncpy(char *restrict dest, const char *restrict src, size_t n)
    93 {
    94         posix_stpncpy(dest, src, n);
     89char *strncpy(char *restrict dest, const char *restrict src, size_t n)
     90{
     91        stpncpy(dest, src, n);
    9592        return dest;
    9693}
     
    103100 * @return Pointer to the nul character in the destination string.
    104101 */
    105 char *posix_stpcpy(char *restrict dest, const char *restrict src)
     102char *stpcpy(char *restrict dest, const char *restrict src)
    106103{
    107104        assert(dest != NULL);
     
    129126 * @return Pointer to the first written nul character or &dest[n].
    130127 */
    131 char *posix_stpncpy(char *restrict dest, const char *restrict src, size_t n)
     128char *stpncpy(char *restrict dest, const char *restrict src, size_t n)
    132129{
    133130        assert(dest != NULL);
     
    159156 * @return Pointer to destination buffer.
    160157 */
    161 char *posix_strcat(char *restrict dest, const char *restrict src)
     158char *strcat(char *restrict dest, const char *restrict src)
    162159{
    163160        assert(dest != NULL);
    164161        assert(src != NULL);
    165162
    166         posix_strcpy(posix_strchr(dest, '\0'), src);
     163        strcpy(strchr(dest, '\0'), src);
    167164        return dest;
    168165}
     
    176173 * @return Pointer to destination buffer.
    177174 */
    178 char *posix_strncat(char *restrict dest, const char *restrict src, size_t n)
     175char *strncat(char *restrict dest, const char *restrict src, size_t n)
    179176{
    180177        assert(dest != NULL);
    181178        assert(src != NULL);
    182179
    183         char *zeroptr = posix_strncpy(posix_strchr(dest, '\0'), src, n);
     180        char *zeroptr = strncpy(strchr(dest, '\0'), src, n);
    184181        /* strncpy doesn't append the nul terminator, so we do it here */
    185182        zeroptr[n] = '\0';
     
    196193 * @return Pointer to the first byte after c in dest if found, NULL otherwise.
    197194 */
    198 void *posix_memccpy(void *restrict dest, const void *restrict src, int c, size_t n)
     195void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n)
    199196{
    200197        assert(dest != NULL);
     
    222219 * @return Newly allocated copy of the string.
    223220 */
    224 char *posix_strdup(const char *s)
    225 {
    226         return posix_strndup(s, SIZE_MAX);
     221char *strdup(const char *s)
     222{
     223        return strndup(s, SIZE_MAX);
    227224}
    228225
     
    234231 * @return Newly allocated string copy of length at most n.
    235232 */
    236 char *posix_strndup(const char *s, size_t n)
     233char *strndup(const char *s, size_t n)
    237234{
    238235        assert(s != NULL);
    239236
    240         size_t len = posix_strnlen(s, n);
     237        size_t len = strnlen(s, n);
    241238        char *dup = malloc(len + 1);
    242239        if (dup == NULL) {
     
    248245
    249246        return dup;
    250 }
    251 
    252 /**
    253  * Compare bytes in memory.
    254  *
    255  * @param mem1 First area of memory to be compared.
    256  * @param mem2 Second area of memory to be compared.
    257  * @param n Maximum number of bytes to be compared.
    258  * @return Difference of the first pair of inequal bytes,
    259  *     or 0 if areas have the same content.
    260  */
    261 int posix_memcmp(const void *mem1, const void *mem2, size_t n)
    262 {
    263         assert(mem1 != NULL);
    264         assert(mem2 != NULL);
    265 
    266         const unsigned char *s1 = mem1;
    267         const unsigned char *s2 = mem2;
    268        
    269         for (size_t i = 0; i < n; ++i) {
    270                 if (s1[i] != s2[i]) {
    271                         return s1[i] - s2[i];
    272                 }
    273         }
    274        
    275         return 0;
    276247}
    277248
     
    284255 *     or 0 if strings have the same content.
    285256 */
    286 int posix_strcmp(const char *s1, const char *s2)
     257int strcmp(const char *s1, const char *s2)
    287258{
    288259        assert(s1 != NULL);
    289260        assert(s2 != NULL);
    290261
    291         return posix_strncmp(s1, s2, STR_NO_LIMIT);
     262        return strncmp(s1, s2, STR_NO_LIMIT);
    292263}
    293264
     
    301272 *     or 0 if strings have the same content.
    302273 */
    303 int posix_strncmp(const char *s1, const char *s2, size_t n)
     274int strncmp(const char *s1, const char *s2, size_t n)
    304275{
    305276        assert(s1 != NULL);
     
    327298 *     NULL pointer otherwise.
    328299 */
    329 void *posix_memchr(const void *mem, int c, size_t n)
     300void *memchr(const void *mem, int c, size_t n)
    330301{
    331302        assert(mem != NULL);
     
    349320 *     NULL pointer otherwise.
    350321 */
    351 char *posix_strchr(const char *s, int c)
     322char *strchr(const char *s, int c)
    352323{
    353324        assert(s != NULL);
     
    365336 *     NULL pointer otherwise.
    366337 */
    367 char *posix_strrchr(const char *s, int c)
     338char *strrchr(const char *s, int c)
    368339{
    369340        assert(s != NULL);
    370341       
    371         const char *ptr = posix_strchr(s, '\0');
     342        const char *ptr = strchr(s, '\0');
    372343       
    373344        /* the same as in strchr, except it loops in reverse direction */
     
    410381 *     NULL pointer otherwise.
    411382 */
    412 char *posix_strpbrk(const char *s1, const char *s2)
     383char *strpbrk(const char *s1, const char *s2)
    413384{
    414385        assert(s1 != NULL);
     
    426397 * @return Length of the prefix.
    427398 */
    428 size_t posix_strcspn(const char *s1, const char *s2)
     399size_t strcspn(const char *s1, const char *s2)
    429400{
    430401        assert(s1 != NULL);
     
    442413 * @return Length of the prefix.
    443414 */
    444 size_t posix_strspn(const char *s1, const char *s2)
     415size_t strspn(const char *s1, const char *s2)
    445416{
    446417        assert(s1 != NULL);
     
    449420        const char *ptr;
    450421        for (ptr = s1; *ptr != '\0'; ++ptr) {
    451                 if (!posix_strchr(s2, *ptr)) {
     422                if (!strchr(s2, *ptr)) {
    452423                        break;
    453424                }
     
    464435 *     not found.
    465436 */
    466 char *posix_strstr(const char *haystack, const char *needle)
     437char *strstr(const char *haystack, const char *needle)
    467438{
    468439        assert(haystack != NULL);
     
    475446       
    476447        /* Preprocess needle. */
    477         size_t nlen = posix_strlen(needle);
     448        size_t nlen = strlen(needle);
    478449        size_t prefix_table[nlen + 1];
    479450       
     
    521492 *                      exists.
    522493 */
    523 char *posix_strtok(char *s, const char *delim)
     494char *strtok(char *s, const char *delim)
    524495{
    525496        static char *next;
    526497
    527         return posix_strtok_r(s, delim, &next);
     498        return strtok_r(s, delim, &next);
    528499}
    529500
     
    541512 *                      exists.
    542513 */
    543 char *posix_strtok_r(char *s, const char *delim, char **next)
     514char *strtok_r(char *s, const char *delim, char **next)
    544515{
    545516        char *start, *end;
     
    549520
    550521        /* Skip over leading delimiters. */
    551         while (*s && (posix_strchr(delim, *s) != NULL)) ++s;
     522        while (*s && (strchr(delim, *s) != NULL)) ++s;
    552523        start = s;
    553524
    554525        /* Skip over token characters. */
    555         while (*s && (posix_strchr(delim, *s) == NULL)) ++s;
     526        while (*s && (strchr(delim, *s) == NULL)) ++s;
    556527        end = s;
    557528        *next = (*s ? s + 1 : s);
     
    576547 *     or 0 if strings have the same content.
    577548 */
    578 int posix_strcoll(const char *s1, const char *s2)
     549int strcoll(const char *s1, const char *s2)
    579550{
    580551        assert(s1 != NULL);
    581552        assert(s2 != NULL);
    582553
    583         return posix_strcmp(s1, s2);
     554        return strcmp(s1, s2);
    584555}
    585556
     
    596567 * @return Length of the transformed string.
    597568 */
    598 size_t posix_strxfrm(char *restrict s1, const char *restrict s2, size_t n)
     569size_t strxfrm(char *restrict s1, const char *restrict s2, size_t n)
    599570{
    600571        assert(s1 != NULL || n == 0);
    601572        assert(s2 != NULL);
    602573
    603         size_t len = posix_strlen(s2);
     574        size_t len = strlen(s2);
    604575
    605576        if (n > len) {
    606                 posix_strcpy(s1, s2);
     577                strcpy(s1, s2);
    607578        }
    608579
     
    616587 * @return Error message.
    617588 */
    618 char *posix_strerror(int errnum)
     589char *strerror(int errnum)
    619590{
    620591        // FIXME: move strerror() and strerror_r() to libc.
     
    630601 * @return Zero on success, errno otherwise.
    631602 */
    632 int posix_strerror_r(int errnum, char *buf, size_t bufsz)
     603int strerror_r(int errnum, char *buf, size_t bufsz)
    633604{
    634605        assert(buf != NULL);
    635606       
    636         char *errstr = posix_strerror(errnum);
    637        
    638         if (posix_strlen(errstr) + 1 > bufsz) {
     607        char *errstr = strerror(errnum);
     608       
     609        if (strlen(errstr) + 1 > bufsz) {
    639610                return ERANGE;
    640611        } else {
    641                 posix_strcpy(buf, errstr);
     612                strcpy(buf, errstr);
    642613        }
    643614
     
    651622 * @return Length of the string.
    652623 */
    653 size_t posix_strlen(const char *s)
     624size_t strlen(const char *s)
    654625{
    655626        assert(s != NULL);
    656627       
    657         return (size_t) (posix_strchr(s, '\0') - s);
     628        return (size_t) (strchr(s, '\0') - s);
    658629}
    659630
     
    665636 * @return The lower of either string length or n limit.
    666637 */
    667 size_t posix_strnlen(const char *s, size_t n)
     638size_t strnlen(const char *s, size_t n)
    668639{
    669640        assert(s != NULL);
     
    685656 * @return Human readable signal description.
    686657 */
    687 char *posix_strsignal(int signum)
     658char *strsignal(int signum)
    688659{
    689660        static const char *const sigstrings[] = {
  • uspace/lib/posix/src/strings.c

    re0f47f5 r7f9df7b9  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "internal/common.h"
    4037#include "posix/strings.h"
     
    5249 * @return Index of first set bit. Bits are numbered starting at one.
    5350 */
    54 int posix_ffs(int i)
     51int ffs(int i)
    5552{
    5653        if (i == 0) {
     
    9289 *     or 0 if strings have the same content.
    9390 */
    94 int posix_strcasecmp(const char *s1, const char *s2)
     91int strcasecmp(const char *s1, const char *s2)
    9592{
    96         return posix_strncasecmp(s1, s2, STR_NO_LIMIT);
     93        return strncasecmp(s1, s2, STR_NO_LIMIT);
    9794}
    9895
     
    106103 *     or 0 if strings have the same content.
    107104 */
    108 int posix_strncasecmp(const char *s1, const char *s2, size_t n)
     105int strncasecmp(const char *s1, const char *s2, size_t n)
    109106{
    110107        for (size_t i = 0; i < n; ++i) {
     
    131128 *     zero. Otherwise return non-zero.
    132129 */
    133 int posix_bcmp(const void *mem1, const void *mem2, size_t n)
     130int bcmp(const void *mem1, const void *mem2, size_t n)
    134131{
    135132        return memcmp(mem1, mem2, n);
     
    143140 * @param n Number of bytes to copy.
    144141 */
    145 void posix_bcopy(const void *src, void *dest, size_t n)
     142void bcopy(const void *src, void *dest, size_t n)
    146143{
    147144        /* Note that memmove has different order of arguments. */
     
    155152 * @param n Number of bytes to reset.
    156153 */
    157 void posix_bzero(void *mem, size_t n)
     154void bzero(void *mem, size_t n)
    158155{
    159156        memset(mem, 0, n);
     
    168165 *     NULL pointer otherwise.
    169166 */
    170 char *posix_index(const char *s, int c)
     167char *index(const char *s, int c)
    171168{
    172         return posix_strchr(s, c);
     169        return strchr(s, c);
    173170}
    174171
     
    181178 *     NULL pointer otherwise.
    182179 */
    183 char *posix_rindex(const char *s, int c)
     180char *rindex(const char *s, int c)
    184181{
    185         return posix_strrchr(s, c);
     182        return strrchr(s, c);
    186183}
    187184
  • uspace/lib/posix/src/sys/mman.c

    re0f47f5 r7f9df7b9  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include "../internal/common.h"
    3936#include <posix/sys/mman.h>
     
    4239#include <posix/unistd.h>
    4340
    44 void *posix_mmap(void *start, size_t length, int prot, int flags, int fd,
    45     __POSIX_DEF__(off_t) offset)
     41void *mmap(void *start, size_t length, int prot, int flags, int fd,
     42    off_t offset)
    4643{
    4744        if (!start)
     
    5754}
    5855
    59 int posix_munmap(void *start, size_t length)
     56int munmap(void *start, size_t length)
    6057{
    6158        int rc = as_area_destroy(start);
  • uspace/lib/posix/src/sys/stat.c

    re0f47f5 r7f9df7b9  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "../internal/common.h"
    4037#include "posix/sys/stat.h"
     
    5249 * @return 0 on success, -1 on error.
    5350 */
    54 static int stat_to_posix(struct posix_stat *dest, vfs_stat_t *src)
     51static int stat_to_posix(struct stat *dest, vfs_stat_t *src)
    5552{
    56         memset(dest, 0, sizeof(struct posix_stat));
     53        memset(dest, 0, sizeof(struct stat));
    5754       
    5855        dest->st_dev = src->service;
     
    8683 * @return Zero on success, -1 otherwise.
    8784 */
    88 int posix_fstat(int fd, struct posix_stat *st)
     85int fstat(int fd, struct stat *st)
    8986{
    9087        vfs_stat_t hst;
     
    10198 * @return Zero on success, -1 otherwise.
    10299 */
    103 int posix_lstat(const char *restrict path, struct posix_stat *restrict st)
     100int lstat(const char *restrict path, struct stat *restrict st)
    104101{
    105102        /* There are currently no symbolic links in HelenOS. */
    106         return posix_stat(path, st);
     103        return stat(path, st);
    107104}
    108105
     
    114111 * @return Zero on success, -1 otherwise.
    115112 */
    116 int posix_stat(const char *restrict path, struct posix_stat *restrict st)
     113int stat(const char *restrict path, struct stat *restrict st)
    117114{
    118115        vfs_stat_t hst;
     
    129126 * @return Zero on success, -1 otherwise.
    130127 */
    131 int posix_chmod(const char *path, posix_mode_t mode)
     128int chmod(const char *path, mode_t mode)
    132129{
    133130        /* HelenOS doesn't support permissions, return success. */
     
    142139 * @return Previous file mode creation mask.
    143140 */
    144 posix_mode_t posix_umask(posix_mode_t mask)
     141mode_t umask(mode_t mask)
    145142{
    146143        /* HelenOS doesn't support permissions, return empty mask. */
     
    155152 * @return Zero on success, -1 otherwise.
    156153 */
    157 int posix_mkdir(const char *path, posix_mode_t mode)
     154int mkdir(const char *path, mode_t mode)
    158155{
    159156        if (failed(vfs_link_path(path, KIND_DIRECTORY, NULL)))
  • uspace/lib/posix/src/sys/wait.c

    re0f47f5 r7f9df7b9  
    3333/** @file Support for waiting.
    3434 */
    35 
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    3835
    3936#include "../internal/common.h"
     
    7673 *     -1 on signal interrupt, (pid_t)-1 otherwise.
    7774 */
    78 posix_pid_t posix_wait(int *stat_ptr)
     75pid_t wait(int *stat_ptr)
    7976{
    8077        /* HelenOS does not support this. */
    8178        errno = ENOSYS;
    82         return (posix_pid_t) -1;
     79        return (pid_t) -1;
    8380}
    8481
     
    9491 *     no child process whose status can be reported, (pid_t)-1 otherwise.
    9592 */
    96 posix_pid_t posix_waitpid(posix_pid_t pid, int *stat_ptr, int options)
     93pid_t waitpid(pid_t pid, int *stat_ptr, int options)
    9794{
    9895        assert(stat_ptr != NULL);
     
    104101        if (failed(task_wait_task_id((task_id_t) pid, &texit, &retval))) {
    105102                /* Unable to retrieve status. */
    106                 return (posix_pid_t) -1;
     103                return (pid_t) -1;
    107104        }
    108105       
  • uspace/lib/posix/src/time.c

    re0f47f5 r7f9df7b9  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "internal/common.h"
    4037#include "posix/time.h"
     
    7067 * Set timezone conversion information.
    7168 */
    72 void posix_tzset(void)
     69void tzset(void)
    7370{
    7471        // TODO: read environment
     
    8077
    8178/**
    82  * Get the time in seconds
    83  *
    84  * @param t If t is non-NULL, the return value is also stored in the memory
    85  *          pointed to by t.
    86  * @return  On success, the value of time in seconds since the Epoch
    87  *          is returned. On error, (time_t)-1 is returned.
    88  */
    89 time_t posix_time(time_t *t)
    90 {
    91         return time(t);
    92 }
    93 
    94 /**
    9579 * Converts a time value to a broken-down UTC time.
    9680 *
     
    9983 * @return Value of result on success, NULL on overflow.
    10084 */
    101 struct tm *posix_gmtime_r(const time_t *restrict timer,
     85struct tm *gmtime_r(const time_t *restrict timer,
    10286    struct tm *restrict result)
    10387{
     
    117101 *               the result, NULL in case of error.
    118102 */
    119 struct tm *posix_gmtime(const time_t *restrict timep)
     103struct tm *gmtime(const time_t *restrict timep)
    120104{
    121105        static struct tm result;
    122106
    123         return posix_gmtime_r(timep, &result);
     107        return gmtime_r(timep, &result);
    124108}
    125109
     
    131115 * @return Value of result on success, NULL on overflow.
    132116 */
    133 struct tm *posix_localtime_r(const time_t *restrict timer,
     117struct tm *localtime_r(const time_t *restrict timer,
    134118    struct tm *restrict result)
    135119{
    136120        // TODO: deal with timezone
    137121        // currently assumes system and all times are in GMT
    138         return posix_gmtime_r(timer, result);
     122        return gmtime_r(timer, result);
    139123}
    140124
     
    147131 *                 the result, NULL in case of error.
    148132 */
    149 struct tm *posix_localtime(const time_t *restrict timep)
     133struct tm *localtime(const time_t *restrict timep)
    150134{
    151135        static struct tm result;
    152136
    153         return posix_localtime_r(timep, &result);
     137        return localtime_r(timep, &result);
    154138}
    155139
     
    163147 * @return Value of buf.
    164148 */
    165 char *posix_asctime_r(const struct tm *restrict timeptr,
     149char *asctime_r(const struct tm *restrict timeptr,
    166150    char *restrict buf)
    167151{
     
    179163 *                   the result, NULL in case of error.
    180164 */
    181 char *posix_asctime(const struct tm *restrict timeptr)
     165char *asctime(const struct tm *restrict timeptr)
    182166{
    183167        static char buf[ASCTIME_BUF_LEN];
    184168
    185         return posix_asctime_r(timeptr, buf);
     169        return asctime_r(timeptr, buf);
    186170}
    187171
     
    195179 * @return Pointer to buf on success, NULL on failure.
    196180 */
    197 char *posix_ctime_r(const time_t *timer, char *buf)
     181char *ctime_r(const time_t *timer, char *buf)
    198182{
    199183        if (failed(time_local2str(*timer, buf))) {
     
    213197 *                 the result, NULL in case of error.
    214198 */
    215 char *posix_ctime(const time_t *timep)
     199char *ctime(const time_t *timep)
    216200{
    217201        static char buf[ASCTIME_BUF_LEN];
    218202
    219         return posix_ctime_r(timep, buf);
     203        return ctime_r(timep, buf);
    220204}
    221205
     
    227211 * @return 0 on success, -1 with errno set on failure.
    228212 */
    229 int posix_clock_getres(posix_clockid_t clock_id, struct posix_timespec *res)
     213int clock_getres(clockid_t clock_id, struct timespec *res)
    230214{
    231215        assert(res != NULL);
     
    249233 * @return 0 on success, -1 with errno on failure.
    250234 */
    251 int posix_clock_gettime(posix_clockid_t clock_id, struct posix_timespec *tp)
     235int clock_gettime(clockid_t clock_id, struct timespec *tp)
    252236{
    253237        assert(tp != NULL);
     
    275259 * @return 0 on success, -1 with errno on failure.
    276260 */
    277 int posix_clock_settime(posix_clockid_t clock_id,
    278     const struct posix_timespec *tp)
     261int clock_settime(clockid_t clock_id,
     262    const struct timespec *tp)
    279263{
    280264        assert(tp != NULL);
     
    302286 * @return 0 on success, -1 with errno set on failure.
    303287 */
    304 int posix_clock_nanosleep(posix_clockid_t clock_id, int flags,
    305     const struct posix_timespec *rqtp, struct posix_timespec *rmtp)
     288int clock_nanosleep(clockid_t clock_id, int flags,
     289    const struct timespec *rqtp, struct timespec *rmtp)
    306290{
    307291        assert(rqtp != NULL);
     
    329313 * @return Consumed CPU cycles by this process or -1 if not available.
    330314 */
    331 posix_clock_t posix_clock(void)
    332 {
    333         posix_clock_t total_cycles = -1;
     315clock_t clock(void)
     316{
     317        clock_t total_cycles = -1;
    334318        stats_task_t *task_stats = stats_get_task(task_get_id());
    335319        if (task_stats) {
    336                 total_cycles = (posix_clock_t) (task_stats->kcycles +
     320                total_cycles = (clock_t) (task_stats->kcycles +
    337321                    task_stats->ucycles);
    338322                free(task_stats);
  • uspace/lib/posix/src/unistd.c

    re0f47f5 r7f9df7b9  
    3434 */
    3535
    36 #define LIBPOSIX_INTERNAL
    37 #define __POSIX_DEF__(x) posix_##x
    38 
    3936#include "internal/common.h"
    4037#include "posix/unistd.h"
     
    7067 * @return Always 0 on HelenOS.
    7168 */
    72 unsigned int posix_sleep(unsigned int seconds)
     69unsigned int sleep(unsigned int seconds)
    7370{
    7471        return thread_sleep(seconds);
     
    8077 * @return User name (static) string or NULL if not found.
    8178 */
    82 char *posix_getlogin(void)
     79char *getlogin(void)
    8380{
    8481        /* There is currently no support for user accounts in HelenOS. */
     
    9390 * @return Zero on success, error code otherwise.
    9491 */
    95 int posix_getlogin_r(char *name, size_t namesize)
     92int getlogin_r(char *name, size_t namesize)
    9693{
    9794        /* There is currently no support for user accounts in HelenOS. */
    9895        if (namesize >= 5) {
    99                 posix_strcpy(name, (char *) "user");
     96                strcpy(name, (char *) "user");
    10097                return 0;
    10198        } else {
     
    111108 * @return Boolean result of the test.
    112109 */
    113 int posix_isatty(int fd)
     110int isatty(int fd)
    114111{
    115112        // TODO
     
    126123 * @return Buffer pointer on success, NULL on failure.
    127124 */
    128 char *posix_getcwd(char *buf, size_t size)
     125char *getcwd(char *buf, size_t size)
    129126{
    130127        if (failed(vfs_cwd_get(buf, size)))
     
    138135 * @param path New working directory.
    139136 */
    140 int posix_chdir(const char *path)
     137int chdir(const char *path)
    141138{
    142139        if (failed(vfs_cwd_set(path)))
     
    150147 * @return Page size of the process.
    151148 */
    152 int posix_getpagesize(void)
     149int getpagesize(void)
    153150{
    154151        return PAGE_SIZE;
     
    160157 * @return Process ID.
    161158 */
    162 posix_pid_t posix_getpid(void)
     159pid_t getpid(void)
    163160{
    164161        return task_get_id();
     
    170167 * @return User ID.
    171168 */
    172 posix_uid_t posix_getuid(void)
     169uid_t getuid(void)
    173170{
    174171        /* There is currently no support for user accounts in HelenOS. */
     
    181178 * @return Group ID.
    182179 */
    183 posix_gid_t posix_getgid(void)
     180gid_t getgid(void)
    184181{
    185182        /* There is currently no support for user accounts in HelenOS. */
     
    193190 * @return 0 on success, -1 on error.
    194191 */
    195 int posix_close(int fildes)
     192int close(int fildes)
    196193{
    197194        posix_pos[fildes] = 0;
     
    210207 * @return Number of read bytes on success, -1 otherwise.
    211208 */
    212 ssize_t posix_read(int fildes, void *buf, size_t nbyte)
     209ssize_t read(int fildes, void *buf, size_t nbyte)
    213210{
    214211        size_t nread;
     
    226223 * @return Number of written bytes on success, -1 otherwise.
    227224 */
    228 ssize_t posix_write(int fildes, const void *buf, size_t nbyte)
     225ssize_t write(int fildes, const void *buf, size_t nbyte)
    229226{
    230227        size_t nwr;
     
    243240 *         as measured in bytes from the beginning of the file, -1 otherwise.
    244241 */
    245 posix_off_t posix_lseek(int fildes, posix_off_t offset, int whence)
     242off_t lseek(int fildes, off_t offset, int whence)
    246243{
    247244        vfs_stat_t st;
     
    274271 * @return Zero on success, -1 otherwise.
    275272 */
    276 int posix_fsync(int fildes)
     273int fsync(int fildes)
    277274{
    278275        if (failed(vfs_sync(fildes)))
     
    289286 * @return Zero on success, -1 otherwise.
    290287 */
    291 int posix_ftruncate(int fildes, posix_off_t length)
     288int ftruncate(int fildes, off_t length)
    292289{
    293290        if (failed(vfs_resize(fildes, (aoff64_t) length)))
     
    303300 * @return Zero on success, -1 otherwise.
    304301 */
    305 int posix_rmdir(const char *path)
     302int rmdir(const char *path)
    306303{
    307304        if (failed(vfs_unlink_path(path)))
     
    317314 * @return Zero on success, -1 otherwise.
    318315 */
    319 int posix_unlink(const char *path)
     316int unlink(const char *path)
    320317{
    321318        if (failed(vfs_unlink_path(path)))
     
    331328 * @return On success, new file descriptor for the same file, otherwise -1.
    332329 */
    333 int posix_dup(int fildes)
    334 {
    335         return posix_fcntl(fildes, F_DUPFD, 0);
     330int dup(int fildes)
     331{
     332        return fcntl(fildes, F_DUPFD, 0);
    336333}
    337334
     
    344341 * @return fildes2 on success, -1 otherwise.
    345342 */
    346 int posix_dup2(int fildes, int fildes2)
     343int dup2(int fildes, int fildes2)
    347344{
    348345        int file;
     
    360357 * @return Zero on success, -1 otherwise.
    361358 */
    362 int posix_access(const char *path, int amode)
     359int access(const char *path, int amode)
    363360{
    364361        if (amode == F_OK || (amode & (X_OK | W_OK | R_OK))) {
     
    368365                 * Check file existence by attempting to open it.
    369366                 */
    370                 int fd = posix_open(path, O_RDONLY);
     367                int fd = open(path, O_RDONLY);
    371368                if (fd < 0)
    372369                        return -1;
    373                 posix_close(fd);
     370                close(fd);
    374371                return 0;
    375372        } else {
     
    386383 * @return Variable value.
    387384 */
    388 long posix_sysconf(int name)
     385long sysconf(int name)
    389386{
    390387        long clk_tck = 0;
     
    403400        stats_physmem_t *mem_stats = stats_get_physmem();
    404401        if (mem_stats) {
    405                 phys_pages = (long) (mem_stats->total / posix_getpagesize());
    406                 avphys_pages = (long) (mem_stats->free / posix_getpagesize());
     402                phys_pages = (long) (mem_stats->total / getpagesize());
     403                avphys_pages = (long) (mem_stats->free / getpagesize());
    407404                free(mem_stats);
    408405                mem_stats = 0;
     
    415412                return avphys_pages;
    416413        case _SC_PAGESIZE:
    417                 return posix_getpagesize();
     414                return getpagesize();
    418415        case _SC_CLK_TCK:
    419416                return clk_tck;
     
    430427 * @return
    431428 */
    432 long posix_pathconf(const char *path, int name)
     429long pathconf(const char *path, int name)
    433430{
    434431        // TODO: low priority, just a compile-time dependency of binutils
     
    441438 * @return
    442439 */
    443 posix_pid_t posix_fork(void)
     440pid_t fork(void)
    444441{
    445442        // TODO: low priority, just a compile-time dependency of binutils
     
    454451 * @return
    455452 */
    456 int posix_execv(const char *path, char *const argv[])
     453int execv(const char *path, char *const argv[])
    457454{
    458455        // TODO: low priority, just a compile-time dependency of binutils
     
    467464 * @return
    468465 */
    469 int posix_execvp(const char *file, char *const argv[])
     466int execvp(const char *file, char *const argv[])
    470467{
    471468        // TODO: low priority, just a compile-time dependency of binutils
     
    479476 * @return
    480477 */
    481 int posix_pipe(int fildes[2])
     478int pipe(int fildes[2])
    482479{
    483480        // TODO: low priority, just a compile-time dependency of binutils
     
    486483}
    487484
    488 unsigned int posix_alarm(unsigned int seconds)
     485unsigned int alarm(unsigned int seconds)
    489486{
    490487        not_implemented();
  • uspace/lib/posix/test/scanf.c

    re0f47f5 r7f9df7b9  
    2727 */
    2828
    29 #define LIBPOSIX_INTERNAL
    30 #define __POSIX_DEF__(x) posix_##x
     29
    3130
    3231#include <errno.h>
     
    5251PCUT_TEST(int_decimal) {
    5352        int number;
    54         int rc = posix_sscanf("4242", "%d", &number);
     53        int rc = sscanf("4242", "%d", &number);
    5554        PCUT_ASSERT_INT_EQUALS(1, rc);
    5655        PCUT_ASSERT_INT_EQUALS(4242, number);
     
    5958PCUT_TEST(int_negative_decimal) {
    6059        int number;
    61         int rc = posix_sscanf("-53", "%d", &number);
     60        int rc = sscanf("-53", "%d", &number);
    6261        PCUT_ASSERT_INT_EQUALS(1, rc);
    6362        PCUT_ASSERT_INT_EQUALS(-53, number);
     
    8382        void *p;
    8483
    85         int rc = posix_sscanf(
     84        int rc = sscanf(
    8685                "\n j tt % \t -121314 98765 aqw 0765 0x77 0xABCDEF88 -99 884",
    8786                " j tt %%%3hhd%1hhu%3hd %3hu%u aqw%n %lo%llx %p %li %lld",
     
    108107        long double ld;
    109108
    110         int rc = posix_sscanf(
     109        int rc = sscanf(
    111110                "\n \t\t1.0 -0x555.AP10 1234.5678e12",
    112111                "%f %lf %Lf",
     
    124123        char *pstr;
    125124
    126         int rc = posix_sscanf(
     125        int rc = sscanf(
    127126                "\n\n\thello world    \n",
    128127                "%5s %ms",
     
    141140        char *pscanset;
    142141
    143         int rc = posix_sscanf(
     142        int rc = sscanf(
    144143                "\n\n\th-e-l-l-o world-]    \n",
    145144                " %9[-eh-o] %m[^]-]",
     
    158157        char *pseq;
    159158
    160         int rc = posix_sscanf(
     159        int rc = sscanf(
    161160                "\n\n\thello world    \n",
    162161                " %5c %mc",
Note: See TracChangeset for help on using the changeset viewer.