Ver código fonte

Merge pull request #1 from xxxajk/master

Add missing _P versions of printf family
main
Paul Stoffregen 11 anos atrás
pai
commit
b5591e75ae
2 arquivos alterados com 16 adições e 0 exclusões
  1. +6
    -0
      teensy3/avr/pgmspace.h
  2. +10
    -0
      teensy3/mk20dx128.c

+ 6
- 0
teensy3/avr/pgmspace.h Ver arquivo

@@ -45,6 +45,12 @@ typedef uint32_t prog_uint32_t;
#define strspn_P(str, chrs) strspn((str), (chrs))
#define strstr_P(a, b) strstr((a), (b))
#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
#define vfprintf_P(s, f, ...) vfprintf((s), (f), __VA_ARGS__)
#define printf_P(f, ...) printf((f), __VA_ARGS__)
#define snprintf_P(s, n, f, ...) ((s), (n), (f), __VA_ARGS__)
#define vsprintf_P(s, f, ...) ((s), (f),__VA_ARGS__)
#define vsnprintf_P(s, n, f, ...) ((s), (n), (f),__VA_ARGS__)
#define fprintf_P(s, f, ...) ((s), (f),__VA_ARGS__)

#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) (*(const unsigned short *)(addr))

+ 10
- 0
teensy3/mk20dx128.c Ver arquivo

@@ -341,16 +341,19 @@ void * _sbrk(int incr)
return prev;
}

__attribute__((weak))
int _read(int file, char *ptr, int len)
{
return 0;
}

__attribute__((weak))
int _write(int file, char *ptr, int len)
{
return 0;
}

__attribute__((weak))
int _close(int fd)
{
return -1;
@@ -358,37 +361,44 @@ int _close(int fd)

#include <sys/stat.h>

__attribute__((weak))
int _fstat(int fd, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}

__attribute__((weak))
int _isatty(int fd)
{
return 1;
}

__attribute__((weak))
int _lseek(int fd, long long offset, int whence)
{
return -1;
}

__attribute__((weak))
void _exit(int status)
{
while (1);
}

__attribute__((weak))
void __cxa_pure_virtual()
{
while (1);
}

__attribute__((weak))
int __cxa_guard_acquire (int *g)
{
return 1;
}

__attribute__((weak))
void __cxa_guard_release(int *g)
{
}

Carregando…
Cancelar
Salvar