From 07a63f714373859ace005c0686a7ac6982ba30f9 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 21 Feb 2015 09:23:33 +1000 Subject: [PATCH] Compile error and emulation errors for GFILE_NEED_STDIO --- docs/releases.txt | 2 ++ drivers/gaudio/Win32/gaudio_play_lld.c | 3 +++ drivers/gaudio/Win32/gaudio_record_lld.c | 3 +++ drivers/multiple/Win32/gdisp_lld_Win32.c | 3 +++ drivers/multiple/X/gdisp_lld_X.c | 3 +++ drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c | 3 +++ src/gfile/gfile.h | 25 +++++++++++--------- src/gfile/gfile_fs_native.c | 3 +++ src/gfile/gfile_stdio.c | 12 ++++++---- src/ginput/ginput_keyboard.c | 3 +++ src/gos/gos_linux.c | 3 +++ src/gos/gos_osx.c | 3 +++ src/gos/gos_raw32.c | 3 +++ src/gos/gos_win32.c | 3 +++ 14 files changed, 56 insertions(+), 16 deletions(-) diff --git a/docs/releases.txt b/docs/releases.txt index c7377d2c..77c21b4b 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -25,6 +25,8 @@ FEATURE: Add a number of UEXT connector board files for Olimex SAM7EX256 FIX: Fix for error rounding in gdispFillConvexPoly() FEATURE: Vastly improved gwin arrow button drawing FIX: GINPUT toggle fixes +FIX: GFILE_ALLOW_FLOAT compile error fixed +FIX: GFILE_NEED_STDIO compile and emulation errors fixed *** Release 2.2 *** diff --git a/drivers/gaudio/Win32/gaudio_play_lld.c b/drivers/gaudio/Win32/gaudio_play_lld.c index cdc9a62a..03d9acea 100644 --- a/drivers/gaudio/Win32/gaudio_play_lld.c +++ b/drivers/gaudio/Win32/gaudio_play_lld.c @@ -5,6 +5,9 @@ * http://ugfx.org/license.html */ +// We need to include stdio.h below. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_GAUDIO && GAUDIO_NEED_PLAY diff --git a/drivers/gaudio/Win32/gaudio_record_lld.c b/drivers/gaudio/Win32/gaudio_record_lld.c index cfe8edf5..dd1a201a 100644 --- a/drivers/gaudio/Win32/gaudio_record_lld.c +++ b/drivers/gaudio/Win32/gaudio_record_lld.c @@ -5,6 +5,9 @@ * http://ugfx.org/license.html */ +// We need to include stdio.h below. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_GAUDIO && GAUDIO_NEED_RECORD diff --git a/drivers/multiple/Win32/gdisp_lld_Win32.c b/drivers/multiple/Win32/gdisp_lld_Win32.c index 2067b8ad..f731d3b5 100644 --- a/drivers/multiple/Win32/gdisp_lld_Win32.c +++ b/drivers/multiple/Win32/gdisp_lld_Win32.c @@ -5,6 +5,9 @@ * http://ugfx.org/license.html */ +// We need to include stdio.h below. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_GDISP diff --git a/drivers/multiple/X/gdisp_lld_X.c b/drivers/multiple/X/gdisp_lld_X.c index 265d03ee..02091c8e 100644 --- a/drivers/multiple/X/gdisp_lld_X.c +++ b/drivers/multiple/X/gdisp_lld_X.c @@ -5,6 +5,9 @@ * http://ugfx.org/license.html */ +// We need to include stdio.h below. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_GDISP diff --git a/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c b/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c index fbc40916..d6279127 100644 --- a/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c +++ b/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c @@ -5,6 +5,9 @@ * http://ugfx.org/license.html */ +// We need to include stdio.h below. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_GDISP diff --git a/src/gfile/gfile.h b/src/gfile/gfile.h index 7d5c5c1a..cc1e9c4b 100644 --- a/src/gfile/gfile.h +++ b/src/gfile/gfile.h @@ -398,38 +398,40 @@ extern "C" { #endif #endif - #if GFILE_NEED_STDIO && !defined(GFILE_IMPLEMENTATION) + #if GFILE_NEED_STDIO && !defined(GFILE_NEED_STDIO_MUST_BE_OFF) + // Needed routines and definitions + size_t gstdioRead(void * ptr, size_t size, size_t count, GFILE *f); + size_t gstdioWrite(const void * ptr, size_t size, size_t count, GFILE *f); + int gstdioGetpos(GFILE *f, long int *pos); + int gstdioSeek(GFILE *f, size_t offset, int origin); + #define SEEK_SET 0 + #define SEEK_CUR 1 + #define SEEK_END 2 + + // Stdio emulation #define stdin gfileStdIn #define stdout gfileStdOut #define stderr gfileStdErr - #define FILENAME_MAX 256 // Use a relatively small number for an embedded platform - #define L_tmpnam FILENAME_MAX #define FOPEN_MAX GFILE_MAX_GFILES #define TMP_MAX GFILE_MAX_GFILES + #define FILENAME_MAX 256 // Use a relatively small number for an embedded platform + #define L_tmpnam FILENAME_MAX #define P_tmpdir "/tmp/" #define FILE GFILE #define fopen(n,m) gfileOpen(n,m) #define fclose(f) gfileClose(f) - size_t gstdioRead(void * ptr, size_t size, size_t count, FILE *f); - size_t gstdioWrite(const void * ptr, size_t size, size_t count, FILE *f); #define fread(p,sz,cnt,f) gstdioRead(p,sz,cnt,f) #define fwrite(p,sz,cnt,f) gstdioWrite(p,sz,cnt,f) - int gstdioSeek(FILE *f, size_t offset, int origin); #define fseek(f,ofs,org) gstdioSeek(f,ofs,org) - #define SEEK_SET 0 - #define SEEK_CUR 1 - #define SEEK_END 2 #define remove(n) (!gfileDelete(n)) #define rename(o,n) (!gfileRename(o,n)) #define fflush(f) (0) #define ftell(f) gfileGetPos(f) #define fpos_t long int - int gstdioGetpos(FILE *f, long int *pos); #define fgetpos(f,pos) gstdioGetpos(f,pos) #define fsetpos(f, pos) (!gfileSetPos(f, *pos)) #define rewind(f) gfileSetPos(f, 0); #define feof(f) gfileEOF(f) - #define vfprintf(f,m,a) vfnprintg(f,0,m,a) #define fprintf(f,m,...) fnprintg(f,0,m,__VA_ARGS__) #define vprintf(m,a) vfnprintg(gfileStdOut,0,m,a) @@ -438,6 +440,7 @@ extern "C" { #define snprintf(s,n,m,...) snprintg(s,n,m,__VA_ARGS__) #define vsprintf(s,m,a) vsnprintg(s,0,m,a) #define sprintf(s,m,...) snprintg(s,0,m,__VA_ARGS__) + //TODO //void clearerr ( FILE * stream ); //int ferror ( FILE * stream ); diff --git a/src/gfile/gfile_fs_native.c b/src/gfile/gfile_fs_native.c index 6a9fce94..db3cf02b 100644 --- a/src/gfile/gfile_fs_native.c +++ b/src/gfile/gfile_fs_native.c @@ -9,6 +9,9 @@ * The native file-system ********************************************************/ +// We need to include stdio.h below. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_GFILE && GFILE_NEED_NATIVEFS diff --git a/src/gfile/gfile_stdio.c b/src/gfile/gfile_stdio.c index 20169ef2..0528547d 100644 --- a/src/gfile/gfile_stdio.c +++ b/src/gfile/gfile_stdio.c @@ -11,17 +11,19 @@ #include "gfx.h" -#if GFX_USE_GFILE && GFILE_NEED_STDIO +#if GFX_USE_GFILE && GFILE_NEED_STDIO && !defined(GFILE_NEED_STDIO_MUST_BE_OFF) -size_t gstdioRead(void * ptr, size_t size, size_t count, FILE *f) { +#include "gfile_fs.h" + +size_t gstdioRead(void * ptr, size_t size, size_t count, GFILE *f) { return gfileRead(f, ptr, size*count)/size; } -size_t gstdioWrite(const void * ptr, size_t size, size_t count, FILE *f) { +size_t gstdioWrite(const void * ptr, size_t size, size_t count, GFILE *f) { return gfileWrite(f, ptr, size*count)/size; } -int gstdioSeek(FILE *f, size_t offset, int origin) { +int gstdioSeek(GFILE *f, size_t offset, int origin) { switch(origin) { case SEEK_SET: break; @@ -37,7 +39,7 @@ int gstdioSeek(FILE *f, size_t offset, int origin) { return gfileSetPos(f, offset) ? 0 : -1; } -int gstdioGetpos(FILE *f, long int *pos) { +int gstdioGetpos(GFILE *f, long int *pos) { if (!(f->flags & GFILEFLG_OPEN)) return -1; *pos = f->pos; diff --git a/src/ginput/ginput_keyboard.c b/src/ginput/ginput_keyboard.c index cdbe52a6..614cd525 100644 --- a/src/ginput/ginput_keyboard.c +++ b/src/ginput/ginput_keyboard.c @@ -10,6 +10,9 @@ * @brief GINPUT keyboard code. */ +// We need to include stdio.h below for MICROCODE_DEBUG. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD diff --git a/src/gos/gos_linux.c b/src/gos/gos_linux.c index e6fbe26c..52f983b2 100644 --- a/src/gos/gos_linux.c +++ b/src/gos/gos_linux.c @@ -5,6 +5,9 @@ * http://ugfx.org/license.html */ +// We need to include stdio.h below. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_OS_LINUX diff --git a/src/gos/gos_osx.c b/src/gos/gos_osx.c index f21b8a75..f0c2b4cd 100644 --- a/src/gos/gos_osx.c +++ b/src/gos/gos_osx.c @@ -5,6 +5,9 @@ * http://ugfx.org/license.html */ +// We need to include stdio.h below. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_OS_OSX diff --git a/src/gos/gos_raw32.c b/src/gos/gos_raw32.c index 22c753aa..d4072dc1 100644 --- a/src/gos/gos_raw32.c +++ b/src/gos/gos_raw32.c @@ -5,6 +5,9 @@ * http://ugfx.org/license.html */ +// We need to include stdio.h below for Win32 emulation. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_OS_RAW32 diff --git a/src/gos/gos_win32.c b/src/gos/gos_win32.c index a7e0943b..8e769aab 100644 --- a/src/gos/gos_win32.c +++ b/src/gos/gos_win32.c @@ -5,6 +5,9 @@ * http://ugfx.org/license.html */ +// We need to include stdio.h below. Turn off GFILE_NEED_STDIO just for this file to prevent conflicts +#define GFILE_NEED_STDIO_MUST_BE_OFF + #include "gfx.h" #if GFX_USE_OS_WIN32