Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/misoc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f5cc6fb72d8e
Choose a base ref
...
head repository: m-labs/misoc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: eef1aa77efbd
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jul 26, 2015

  1. Add support for fprintf(stderr, ...).

    whitequark committed Jul 26, 2015
    Copy the full SHA
    10f719a View commit details
  2. Mark abort() as __attribute__((noreturn)).

    whitequark committed Jul 26, 2015
    Copy the full SHA
    eef1aa7 View commit details
Showing with 21 additions and 2 deletions.
  1. +1 −1 software/include/base/stdlib.h
  2. +20 −1 software/libbase/console.c
2 changes: 1 addition & 1 deletion software/include/base/stdlib.h
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ char *number(char *buf, char *end, unsigned long num, int base, int size, int pr

unsigned int rand(void);
void srand(unsigned int seed);
void abort(void);
void abort(void) __attribute__((noreturn));

void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));

21 changes: 20 additions & 1 deletion software/libbase/console.c
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@
#include <stdio.h>
#include <stdarg.h>

FILE *stdin, *stdout, *stderr;

static console_write_hook write_hook;
static console_read_hook read_hook;
static console_read_nonblock_hook read_nonblock_hook;
@@ -60,11 +62,28 @@ void putsnonl(const char *s)
}
}

#define PRINTF_BUFFER_SIZE 256

int printf(const char *fmt, ...)
{
va_list args;
int len;
char outbuf[256];
char outbuf[PRINTF_BUFFER_SIZE];

va_start(args, fmt);
len = vscnprintf(outbuf, sizeof(outbuf), fmt, args);
va_end(args);
outbuf[len] = 0;
putsnonl(outbuf);

return len;
}

int fprintf(FILE *stream, const char *fmt, ...)
{
va_list args;
int len;
char outbuf[PRINTF_BUFFER_SIZE];

va_start(args, fmt);
len = vscnprintf(outbuf, sizeof(outbuf), fmt, args);