Changeset 55092672 in mainline


Ignore:
Timestamp:
2018-06-15T13:06:18Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8338a81
Parents:
1ae9c07
git-author:
Jiri Svoboda <jiri@…> (2018-06-14 22:05:23)
git-committer:
Jiri Svoboda <jiri@…> (2018-06-15 13:06:18)
Message:

Clean up libposix stdio.h and stdlib.h a bit.

Location:
uspace
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/scli.h

    r1ae9c07 r55092672  
    3131
    3232#include "config.h"
     33#include <errno.h>
    3334#include <stdint.h>
    3435#include <stdio.h>
  • uspace/app/sbi/src/os/os.h

    r1ae9c07 r55092672  
    3030#define OS_H_
    3131
     32#include <errno.h>
     33
    3234char *os_str_acat(const char *a, const char *b);
    3335char *os_str_aslice(const char *str, size_t start, size_t length);
  • uspace/app/untar/main.c

    r1ae9c07 r55092672  
    3333 */
    3434
     35#include <errno.h>
    3536#include <stdio.h>
    3637#include <stdarg.h>
  • uspace/lib/bithenge/include/bithenge/os.h

    r1ae9c07 r55092672  
    3333
    3434#ifdef __HELENOS__
     35#include <stdint.h>
    3536typedef int64_t bithenge_int_t;
    3637#define BITHENGE_PRId PRId64
  • uspace/lib/c/generic/elf/elf.c

    r1ae9c07 r55092672  
    2727 */
    2828
     29#include <assert.h>
    2930#include <elf/elf.h>
    30 
    31 #include <assert.h>
     31#include <stdbool.h>
    3232#include <stdlib.h>
    3333
  • uspace/lib/c/generic/strtol.c

    r1ae9c07 r55092672  
    3737 */
    3838
     39#include <assert.h>
     40#include <ctype.h>
     41#include <errno.h>
    3942#include <inttypes.h>
     43#include <limits.h>
     44#include <stdbool.h>
    4045#include <stdlib.h>
    41 #include <limits.h>
    42 #include <ctype.h>
    43 #include <assert.h>
    4446
    4547// TODO: unit tests
  • uspace/lib/c/include/stdio.h

    r1ae9c07 r55092672  
    5959#define BUFSIZ  4096
    6060
     61/** Recommended size of fixed-size array for holding file names. */
     62#define FILENAME_MAX 4096
     63
    6164/** Forward declaration */
    6265struct _IO_FILE;
     
    6871
    6972/* Character and string input functions */
     73#define getc fgetc
    7074extern int fgetc(FILE *);
    7175extern char *fgets(char *, int, FILE *);
     
    7478
    7579/* Character and string output functions */
     80#define putc fputc
    7681extern int fputc(int, FILE *);
    7782extern int fputs(const char *, FILE *);
     
    96101extern int snprintf(char *, size_t, const char *, ...)
    97102    _HELENOS_PRINTF_ATTRIBUTE(3, 4);
     103#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
    98104extern int vasprintf(char **, const char *, va_list);
    99105extern int asprintf(char **, const char *, ...)
     106#endif
    100107    _HELENOS_PRINTF_ATTRIBUTE(2, 3);
    101108extern int vsnprintf(char *, size_t, const char *, va_list);
     
    137144#define _IOLBF 1
    138145#define _IOFBF 2
     146
     147extern char *gets(char *, size_t);
     148
    139149#endif
    140150
     
    168178extern FILE *fdopen(int, const char *);
    169179extern int fileno(FILE *);
    170 extern char *gets(char *, size_t);
    171180
    172181#include <offset.h>
  • uspace/lib/c/include/stdlib.h

    r1ae9c07 r55092672  
    3838#include <malloc.h>
    3939#include <qsort.h>
    40 #include <stacktrace.h>
    4140
    4241#define RAND_MAX  714025
     42
     43#define EXIT_FAILURE 1
     44#define EXIT_SUCCESS 0
    4345
    4446extern int rand(void);
  • uspace/lib/posix/include/posix/stdio.h

    r1ae9c07 r55092672  
    4040
    4141#include "stddef.h"
    42 #include "unistd.h"
    4342#include "libc/io/verify.h"
    4443#include "sys/types.h"
     
    4645#include "limits.h"
    4746
    48 /*
    49  * These are the same as in HelenOS libc.
    50  * It would be possible to directly include <stdio.h> but
    51  * it is better not to pollute POSIX namespace with other functions
    52  * defined in that header.
    53  *
    54  * Because libposix is always linked with libc, providing only these
    55  * forward declarations ought to be enough.
    56  */
    57 #define EOF (-1)
    58 
    59 /** Size of buffers used in stdio header. */
    60 #define BUFSIZ  4096
    61 
    62 /** Maximum size in bytes of the longest filename. */
    63 #define FILENAME_MAX 4096
    64 
    65 typedef struct _IO_FILE FILE;
    66 
    67 extern FILE *stdin;
    68 extern FILE *stdout;
    69 extern FILE *stderr;
    70 
    71 extern int fgetc(FILE *);
    72 extern char *fgets(char *, int, FILE *);
    73 
    74 extern int getchar(void);
    75 extern char *gets(char *, size_t);
    76 
    77 extern int fputc(int, FILE *);
    78 extern int fputs(const char *, FILE *);
    79 
    80 extern int putchar(int);
    81 extern int puts(const char *);
    82 
    83 extern int fprintf(FILE *, const char *, ...) _HELENOS_PRINTF_ATTRIBUTE(2, 3);
    84 extern int vfprintf(FILE *, const char *, va_list);
    85 
    86 extern int printf(const char *, ...) _HELENOS_PRINTF_ATTRIBUTE(1, 2);
    87 extern int vprintf(const char *, va_list);
    88 
    89 extern int snprintf(char *, size_t, const char *, ...) _HELENOS_PRINTF_ATTRIBUTE(3, 4);
    90 #ifdef _GNU_SOURCE
    91 extern int vasprintf(char **, const char *, va_list);
    92 extern int asprintf(char **, const char *, ...) _HELENOS_PRINTF_ATTRIBUTE(2, 3);
    93 #endif
    94 extern int vsnprintf(char *, size_t, const char *, va_list);
    95 
    96 extern FILE *fopen(const char *, const char *);
    9747extern FILE *fdopen(int, const char *);
    98 extern int fclose(FILE *);
    99 
    100 extern size_t fread(void *, size_t, size_t, FILE *);
    101 extern size_t fwrite(const void *, size_t, size_t, FILE *);
    102 
    103 extern void rewind(FILE *);
    104 extern int feof(FILE *);
    10548extern int fileno(FILE *);
    106 
    107 extern int fflush(FILE *);
    108 extern int ferror(FILE *);
    109 extern void clearerr(FILE *);
    110 
    111 extern void setvbuf(FILE *, void *, int, size_t);
    112 extern void setbuf(FILE *, void *);
    113 
    114 /* POSIX specific stuff. */
    11549
    11650/* Identifying the Terminal */
     
    11953extern char *ctermid(char *s);
    12054
    121 /* Error Recovery */
    122 extern void clearerr(FILE *stream);
    123 
    12455/* Input/Output */
    125 #undef putc
    126 #define putc fputc
    127 extern int fputs(const char *__restrict__ s, FILE *__restrict__ stream);
    128 #undef getc
    129 #define getc fgetc
    130 extern int ungetc(int c, FILE *stream);
    13156extern ssize_t getdelim(char **__restrict__ lineptr, size_t *__restrict__ n,
    13257    int delimiter, FILE *__restrict__ stream);
    13358extern ssize_t getline(char **__restrict__ lineptr, size_t *__restrict__ n,
    13459    FILE *__restrict__ stream);
    135 
    136 /* Opening Streams */
    137 extern FILE *freopen(const char *__restrict__ filename,
    138     const char *__restrict__ mode, FILE *__restrict__ stream);
    13960
    14061/* Error Messages */
     
    14869extern int fsetpos(FILE *stream, const fpos_t *pos);
    14970extern int fgetpos(FILE *__restrict__ stream, fpos_t *__restrict__ pos);
    150 extern int fseek(FILE *stream, long offset, int whence);
    15171extern int fseeko(FILE *stream, off_t offset, int whence);
    152 extern long ftell(FILE *stream);
    15372extern off_t ftello(FILE *stream);
    154 
    155 /* Flushing Buffers */
    156 extern int fflush(FILE *stream);
    15773
    15874/* Formatted Output */
     
    17389extern int putchar_unlocked(int c);
    17490
    175 /* Deleting Files */
    176 extern int remove(const char *path);
    177 
    178 /* Renaming Files */
    179 extern int rename(const char *oldname, const char *newname);
    180 
    18191/* Temporary Files */
    18292#undef L_tmpnam
     
    18696extern FILE *tmpfile(void);
    18797
    188 
    18998#endif /* POSIX_STDIO_H_ */
    19099
  • uspace/lib/posix/include/posix/stdlib.h

    r1ae9c07 r55092672  
    3737#define POSIX_STDLIB_H_
    3838
     39#include "libc/stdlib.h"
    3940#include "sys/types.h"
    4041
    4142#include <_bits/NULL.h>
    4243
    43 #define RAND_MAX  714025
     44/* Process Termination */
     45#define _Exit exit
    4446
    45 /* Process Termination */
    46 #undef EXIT_FAILURE
    47 #define EXIT_FAILURE 1
    48 #undef EXIT_SUCCESS
    49 #define EXIT_SUCCESS 0
    50 #define _Exit exit
    5147extern int atexit(void (*func)(void));
    52 extern void exit(int status) __attribute__((noreturn));
    53 extern void abort(void) __attribute__((noreturn));
    5448
    5549/* Absolute Value */
     
    7771
    7872/* Array Functions */
    79 extern void qsort(void *array, size_t count, size_t size,
    80     int (*compare)(const void *, const void *));
    8173extern void *bsearch(const void *key, const void *base,
    8274    size_t nmemb, size_t size, int (*compar)(const void *, const void *));
     
    9688extern long double strtold(const char *__restrict__ nptr, char **__restrict__ endptr);
    9789
    98 /* Integer Conversion */
    99 extern int atoi(const char *nptr);
    100 extern long int atol(const char *nptr);
    101 extern long long int atoll(const char *nptr);
    102 extern long int strtol(const char *__restrict__ nptr,
    103     char **__restrict__ endptr, int base);
    104 extern long long int strtoll(const char *__restrict__ nptr,
    105     char **__restrict__ endptr, int base);
    106 extern unsigned long int strtoul(const char *__restrict__ nptr,
    107     char **__restrict__ endptr, int base);
    108 extern unsigned long long int strtoull(
    109     const char *__restrict__ nptr, char **__restrict__ endptr, int base);
    110 
    111 /* Memory Allocation */
    112 extern void *malloc(size_t size)
    113     __attribute__((malloc));
    114 extern void *calloc(size_t nelem, size_t elsize)
    115     __attribute__((malloc));
    116 extern void *realloc(void *ptr, size_t size)
    117     __attribute__((warn_unused_result));
    118 extern void free(void *ptr);
    119 
    12090/* Temporary Files */
    12191extern int mkstemp(char *tmpl);
    122 
    123 /* Pseudo-random number generator */
    124 extern int rand(void);
    125 extern void srand(unsigned int seed);
    12692
    12793/* Legacy Declarations */
Note: See TracChangeset for help on using the changeset viewer.