Ignore:
Timestamp:
2013-07-10T08:58:49Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3908355, 4c53333
Parents:
30c1b75 (diff), 98abd40 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Extending POSIX library

Merge from lp:~vojtech-horky/helenos/gcc-port.

This is work-in-progress merge from branch aimed at bringing GCC to run
inside HelenOS.

The most notable change is dealing with the name clashes in libposix and
libc. For ported applications, the libposix headers looks as normal
POSIX headers and there is no need to do preprocessor-based renaming inside
the ported application. The renaming is done inside object files instead.
See revision 1745 in lp:~vojtech-horky/helenos/gcc-port [1] for more
detailed explanation.
The solution is definitely not perfect but shall deal with the naming
conflicts in much safer manner than using the redefines.

There were some other changes as well, mostly small ones.

  • Add some functions, some as ToDo ones (i.e. empty implementation).
  • Add more POSIX headers, split some existing.

[1] http://bazaar.launchpad.net/~vojtech-horky/helenos/gcc-port/revision/1745

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/include/posix/stdio.h

    r30c1b75 rc8bb1633  
    3737#define POSIX_STDIO_H_
    3838
     39#ifndef __POSIX_DEF__
     40#define __POSIX_DEF__(x) x
     41/* DEBUG macro does not belong to POSIX stdio.h. Its unconditional
     42 * definition in the native stdio.h causes unexpected behaviour of
     43 * applications which uses their own DEBUG macro (e.g. debugging
     44 * output is printed even if not desirable). */
     45#undef DEBUG
     46#endif
     47
    3948#include "stddef.h"
    4049#include "unistd.h"
     
    108117extern size_t fwrite(const void *, size_t, size_t, FILE *);
    109118
    110 extern int fseek(FILE *, off64_t, int);
    111119extern void rewind(FILE *);
    112 extern off64_t ftell(FILE *);
    113120extern int feof(FILE *);
    114121extern int fileno(FILE *);
     
    126133#undef L_ctermid
    127134#define L_ctermid PATH_MAX
    128 extern char *posix_ctermid(char *s);
     135extern char *__POSIX_DEF__(ctermid)(char *s);
    129136
    130137/* Error Recovery */
    131 extern void posix_clearerr(FILE *stream);
     138extern void __POSIX_DEF__(clearerr)(FILE *stream);
    132139
    133140/* Input/Output */
    134141#undef putc
    135142#define putc fputc
    136 extern int posix_fputs(const char *restrict s, FILE *restrict stream);
     143extern int __POSIX_DEF__(fputs)(const char *restrict s, FILE *restrict stream);
    137144#undef getc
    138145#define getc fgetc
    139 extern int posix_ungetc(int c, FILE *stream);
    140 extern ssize_t posix_getdelim(char **restrict lineptr, size_t *restrict n,
     146extern int __POSIX_DEF__(ungetc)(int c, FILE *stream);
     147extern ssize_t __POSIX_DEF__(getdelim)(char **restrict lineptr, size_t *restrict n,
    141148    int delimiter, FILE *restrict stream);
    142 extern ssize_t posix_getline(char **restrict lineptr, size_t *restrict n,
     149extern ssize_t __POSIX_DEF__(getline)(char **restrict lineptr, size_t *restrict n,
    143150    FILE *restrict stream);
    144151
    145152/* Opening Streams */
    146 extern FILE *posix_freopen(const char *restrict filename,
     153extern FILE *__POSIX_DEF__(freopen)(const char *restrict filename,
    147154    const char *restrict mode, FILE *restrict stream);
    148155
    149156/* Error Messages */
    150 extern void posix_perror(const char *s);
     157extern void __POSIX_DEF__(perror)(const char *s);
    151158
    152159/* File Positioning */
    153 typedef struct _posix_fpos posix_fpos_t;
    154 extern int posix_fsetpos(FILE *stream, const posix_fpos_t *pos);
    155 extern int posix_fgetpos(FILE *restrict stream, posix_fpos_t *restrict pos);
    156 extern int posix_fseek(FILE *stream, long offset, int whence);
    157 extern int posix_fseeko(FILE *stream, posix_off_t offset, int whence);
    158 extern long posix_ftell(FILE *stream);
    159 extern posix_off_t posix_ftello(FILE *stream);
     160typedef struct _posix_fpos __POSIX_DEF__(fpos_t);
     161extern int __POSIX_DEF__(fsetpos)(FILE *stream, const __POSIX_DEF__(fpos_t) *pos);
     162extern int __POSIX_DEF__(fgetpos)(FILE *restrict stream, __POSIX_DEF__(fpos_t) *restrict pos);
     163extern int __POSIX_DEF__(fseek)(FILE *stream, long offset, int whence);
     164extern int __POSIX_DEF__(fseeko)(FILE *stream, __POSIX_DEF__(off_t) offset, int whence);
     165extern long __POSIX_DEF__(ftell)(FILE *stream);
     166extern __POSIX_DEF__(off_t) __POSIX_DEF__(ftello)(FILE *stream);
    160167
    161168/* Flushing Buffers */
    162 extern int posix_fflush(FILE *stream);
     169extern int __POSIX_DEF__(fflush)(FILE *stream);
    163170
    164171/* Formatted Output */
    165 extern int posix_dprintf(int fildes, const char *restrict format, ...)
     172extern int __POSIX_DEF__(dprintf)(int fildes, const char *restrict format, ...)
    166173    PRINTF_ATTRIBUTE(2, 3);
    167 extern int posix_vdprintf(int fildes, const char *restrict format, va_list ap);
    168 extern int posix_sprintf(char *restrict s, const char *restrict format, ...)
     174extern int __POSIX_DEF__(vdprintf)(int fildes, const char *restrict format, va_list ap);
     175extern int __POSIX_DEF__(sprintf)(char *restrict s, const char *restrict format, ...)
    169176    PRINTF_ATTRIBUTE(2, 3);
    170 extern int posix_vsprintf(char *restrict s, const char *restrict format, va_list ap);
     177extern int __POSIX_DEF__(vsprintf)(char *restrict s, const char *restrict format, va_list ap);
    171178
    172179/* Formatted Input */
    173 extern int posix_fscanf(
     180extern int __POSIX_DEF__(fscanf)(
    174181    FILE *restrict stream, const char *restrict format, ...);
    175 extern int posix_vfscanf(
     182extern int __POSIX_DEF__(vfscanf)(
    176183    FILE *restrict stream, const char *restrict format, va_list arg);
    177 extern int posix_scanf(const char *restrict format, ...);
    178 extern int posix_vscanf(const char *restrict format, va_list arg);
    179 extern int posix_sscanf(
     184extern int __POSIX_DEF__(scanf)(const char *restrict format, ...);
     185extern int __POSIX_DEF__(vscanf)(const char *restrict format, va_list arg);
     186extern int __POSIX_DEF__(sscanf)(
    180187    const char *restrict s, const char *restrict format, ...);
    181 extern int posix_vsscanf(
     188extern int __POSIX_DEF__(vsscanf)(
    182189    const char *restrict s, const char *restrict format, va_list arg);
    183190
    184191/* File Locking */
    185 extern void posix_flockfile(FILE *file);
    186 extern int posix_ftrylockfile(FILE *file);
    187 extern void posix_funlockfile(FILE *file);
    188 extern int posix_getc_unlocked(FILE *stream);
    189 extern int posix_getchar_unlocked(void);
    190 extern int posix_putc_unlocked(int c, FILE *stream);
    191 extern int posix_putchar_unlocked(int c);
     192extern void __POSIX_DEF__(flockfile)(FILE *file);
     193extern int __POSIX_DEF__(ftrylockfile)(FILE *file);
     194extern void __POSIX_DEF__(funlockfile)(FILE *file);
     195extern int __POSIX_DEF__(getc_unlocked)(FILE *stream);
     196extern int __POSIX_DEF__(getchar_unlocked)(void);
     197extern int __POSIX_DEF__(putc_unlocked)(int c, FILE *stream);
     198extern int __POSIX_DEF__(putchar_unlocked)(int c);
    192199
    193200/* Deleting Files */
    194 extern int posix_remove(const char *path);
     201extern int __POSIX_DEF__(remove)(const char *path);
    195202
    196203/* Renaming Files */
    197 extern int posix_rename(const char *old, const char *new);
     204extern int __POSIX_DEF__(rename)(const char *oldname, const char *newname);
    198205
    199206/* Temporary Files */
    200207#undef L_tmpnam
    201208#define L_tmpnam PATH_MAX
    202 extern char *posix_tmpnam(char *s);
    203 extern char *posix_tempnam(const char *dir, const char *pfx);
    204 extern FILE *posix_tmpfile(void);
    205 
    206 #ifndef LIBPOSIX_INTERNAL
    207         /* DEBUG macro does not belong to POSIX stdio.h. Its unconditional
    208          * definition in the native stdio.h causes unexpected behaviour of
    209          * applications which uses their own DEBUG macro (e.g. debugging
    210          * output is printed even if not desirable). */
    211         #undef DEBUG
    212 
    213         #define ctermid posix_ctermid
    214 
    215         #define clearerr posix_clearerr
    216 
    217         #define fputs posix_fputs
    218         #define ungetc posix_ungetc
    219         #define getdelim posix_getdelim
    220         #define getline posix_getline
    221 
    222         #define freopen posix_freopen
    223 
    224         #define perror posix_perror
    225 
    226         #define fpos_t posix_fpos_t
    227         #define fsetpos posix_fsetpos
    228         #define fgetpos posix_fgetpos
    229         #define fseek posix_fseek
    230         #define fseeko posix_fseeko
    231         #define ftell posix_ftell
    232         #define ftello posix_ftello
    233 
    234         #define fflush posix_fflush
    235 
    236         #define dprintf posix_dprintf
    237         #define vdprintf posix_vdprintf
    238         #define sprintf posix_sprintf
    239         #define vsprintf posix_vsprintf
    240 
    241         #define fscanf posix_fscanf
    242         #define vfscanf posix_vfscanf
    243         #define vscanf posix_vscanf
    244         #define scanf posix_scanf
    245         #define sscanf posix_sscanf
    246         #define vsscanf posix_vsscanf
    247 
    248         #define flockfile posix_flockfile
    249         #define ftrylockfile posix_ftrylockfile
    250         #define funlockfile posix_funlockfile
    251 
    252         #define getc_unlocked posix_getc_unlocked
    253         #define getchar_unlocked posix_getchar_unlocked
    254         #define putc_unlocked posix_putc_unlocked
    255         #define putchar_unlocked posix_putchar_unlocked
    256 
    257         #define remove posix_remove
    258 
    259         #define rename posix_rename
    260 
    261         #define tmpnam posix_tmpnam
    262         #define tempnam posix_tempnam
    263         #define tmpfile posix_tmpfile
    264 #endif
     209extern char *__POSIX_DEF__(tmpnam)(char *s);
     210extern char *__POSIX_DEF__(tempnam)(const char *dir, const char *pfx);
     211extern FILE *__POSIX_DEF__(tmpfile)(void);
     212
    265213
    266214#endif /* POSIX_STDIO_H_ */
Note: See TracChangeset for help on using the changeset viewer.