CS318 - Pintos
Pintos source browser for JHU CS318 course
stdio.h
Go to the documentation of this file.
1 #ifndef __LIB_STDIO_H
2 #define __LIB_STDIO_H
3 
4 #include <debug.h>
5 #include <stdarg.h>
6 #include <stdbool.h>
7 #include <stddef.h>
8 #include <stdint.h>
9 
10 /** Include lib/user/stdio.h or lib/kernel/stdio.h, as
11  appropriate. */
12 #include_next <stdio.h>
13 
14 /** Predefined file handles. */
15 #define STDIN_FILENO 0
16 #define STDOUT_FILENO 1
17 
18 /** Standard functions. */
19 int printf (const char *, ...) PRINTF_FORMAT (1, 2);
20 int snprintf (char *, size_t, const char *, ...) PRINTF_FORMAT (3, 4);
21 int vprintf (const char *, va_list) PRINTF_FORMAT (1, 0);
22 int vsnprintf (char *, size_t, const char *, va_list) PRINTF_FORMAT (3, 0);
23 int putchar (int);
24 int puts (const char *);
25 
26 /** Nonstandard functions. */
27 void hex_dump (uintptr_t ofs, const void *, size_t size, bool ascii);
29 
30 /** Internal functions. */
31 void __vprintf (const char *format, va_list args,
32  void (*output) (char, void *), void *aux);
33 void __printf (const char *format,
34  void (*output) (char, void *), void *aux, ...);
35 
36 /** Try to be helpful. */
37 #define sprintf dont_use_sprintf_use_snprintf
38 #define vsprintf dont_use_vsprintf_use_vsnprintf
39 
40 #endif /**< lib/stdio.h */
uint64_t
unsigned long long int uint64_t
Definition: stdint.h:29
print_human_readable_size
void print_human_readable_size(uint64_t sz)
Prints SIZE, which represents a number of bytes, in a human-readable format, e.g.
Definition: stdio.c:642
stdbool.h
vsnprintf
int int int int vsnprintf(char *, size_t, const char *, va_list) PRINTF_FORMAT(3
vprintf
int int int vprintf(const char *, va_list) PRINTF_FORMAT(1
putchar
int int int int int putchar(int)
Writes C to the vga display and serial port.
Definition: console.c:163
__printf
void __printf(const char *format, void(*output)(char, void *), void *aux,...)
Wrapper for __vprintf() that converts varargs into a va_list.
Definition: stdio.c:577
hex_dump
void hex_dump(uintptr_t ofs, const void *, size_t size, bool ascii)
Nonstandard functions.
Definition: stdio.c:593
stdarg.h
snprintf
int int snprintf(char *, size_t, const char *,...) PRINTF_FORMAT(3
printf
int printf(const char *,...) PRINTF_FORMAT(1
Standard functions.
stdint.h
va_list
__builtin_va_list va_list
GCC has <stdarg.h> functionality as built-ins, so all we need is to use it.
Definition: stdarg.h:7
__vprintf
void __vprintf(const char *format, va_list args, void(*output)(char, void *), void *aux)
Internal functions.
Definition: stdio.c:157
puts
int puts(const char *)
Writes string S to the console, followed by a new-line character.
Definition: console.c:140
uintptr_t
uint32_t uintptr_t
Definition: stdint.h:36
stddef.h
debug.h
PRINTF_FORMAT
#define PRINTF_FORMAT(FMT, FIRST)
Definition: debug.h:10