Compile error and emulation errors for GFILE_NEED_STDIO

ugfx_release_2.6
inmarket 2015-02-21 09:23:33 +10:00
parent 5e0a0bfd9b
commit 07a63f7143
14 changed files with 56 additions and 16 deletions

View File

@ -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 ***

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 );

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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