Changeset bc56f30 in mainline for uspace/lib/c/include/stdio.h


Ignore:
Timestamp:
2019-05-27T12:38:26Z (5 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:
0d14c25
Parents:
4d51c60
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-13 16:06:49)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-05-27 12:38:26)
Message:

Make some libc and libposix headers usable in C++

These headers either get included from standard C++ headers,
or are standard themselves, which means any unnamespaced nonstandard
identifiers are a problem. This commit attempts to fix those
issues, and removes hacks previously used in libcpp to work around it.

File:
1 edited

Legend:

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

    r4d51c60 rbc56f30  
    3737#define _LIBC_STDIO_H_
    3838
    39 #ifdef __cplusplus
    40 extern "C" {
    41 #endif
    42 
    43 #include <offset.h>
    4439#include <stdarg.h>
    4540#include <io/verify.h>
     
    4843#include <_bits/wchar_t.h>
    4944#include <_bits/wint_t.h>
    50 
    51 /** Forward declaration */
    52 struct _IO_FILE;
    53 typedef struct _IO_FILE FILE;
    54 
    55 /** File position */
    56 typedef struct {
    57         off64_t pos;
    58 } fpos_t;
     45#include <_bits/decls.h>
    5946
    6047#ifndef _HELENOS_SOURCE
     
    7057
    7158/** Max number of files that is guaranteed to be able to open at the same time */
    72 #define FOPEN_MAX VFS_MAX_OPEN_FILES
     59#define FOPEN_MAX 16
    7360
    7461/** Recommended size of fixed-size array for holding file names. */
     
    9279/** Minimum number of unique temporary file names */
    9380#define TMP_MAX 1000000
     81
     82__C_DECLS_BEGIN;
     83
     84/** Forward declaration */
     85struct _IO_FILE;
     86typedef struct _IO_FILE FILE;
     87
     88/** File position */
     89typedef struct {
     90        long long pos;
     91} fpos_t;
    9492
    9593extern FILE *stdin;
     
    9896
    9997/* Character and string input functions */
    100 #define getc fgetc
    10198extern int fgetc(FILE *);
    10299extern char *fgets(char *, int, FILE *);
    103100extern char *gets(char *, size_t) __attribute__((deprecated));
    104101
     102static inline int getc(FILE *f)
     103{
     104        return fgetc(f);
     105}
     106
    105107extern int getchar(void);
    106108
    107109/* Character and string output functions */
    108 #define putc fputc
    109110extern int fputc(int, FILE *);
    110111extern int fputs(const char *, FILE *);
     112
     113static inline int putc(int i, FILE *f)
     114{
     115        return fputc(i, f);
     116}
    111117
    112118extern int putchar(int);
     
    180186extern char *tmpnam(char *s);
    181187
     188__C_DECLS_END;
     189
    182190#ifdef _HELENOS_SOURCE
    183191
     192#include <_bits/off64_t.h>
     193
     194__HELENOS_DECLS_BEGIN;
     195
    184196/* Nonstandard extensions. */
    185197
    186 enum _buffer_type {
     198enum __buffer_type {
    187199        /** No buffering */
    188200        _IONBF,
     
    193205};
    194206
    195 enum _buffer_state {
    196         /** Buffer is empty */
    197         _bs_empty,
    198 
    199         /** Buffer contains data to be written */
    200         _bs_write,
    201 
    202         /** Buffer contains prefetched data for reading */
    203         _bs_read
    204 };
    205 
    206207extern int vprintf_length(const char *, va_list);
    207208extern int printf_length(const char *, ...)
     
    210211extern int fileno(FILE *);
    211212
    212 #include <offset.h>
    213 
    214213extern int fseek64(FILE *, off64_t, int);
    215214extern off64_t ftell64(FILE *);
    216215
    217 #endif
    218 
    219 #ifdef __cplusplus
    220 }
     216__HELENOS_DECLS_END;
    221217#endif
    222218
Note: See TracChangeset for help on using the changeset viewer.