From 4d9c915d183f67c0c066996816524e863343c1d6 Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Sun, 25 Mar 2018 14:28:34 -0700 Subject: [PATCH] Replace off_t with file_offset_t Define as long for compatibility with stdio.h --- csrc/pf_inner.c | 25 +++++++++++-------------- csrc/pf_io.h | 7 ++++--- csrc/pf_types.h | 7 +++++++ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/csrc/pf_inner.c b/csrc/pf_inner.c index 2e5aac6..e435d49 100644 --- a/csrc/pf_inner.c +++ b/csrc/pf_inner.c @@ -26,12 +26,6 @@ ** ***************************************************************/ -#ifndef AMIGA -#include -#else -typedef long off_t; -#endif - #include "pf_all.h" #if defined(WIN32) && !defined(__MINGW32__) @@ -1043,13 +1037,14 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql )); /* Determine file size by seeking to end and returning position. */ FileID = (FileStream *) TOS; { - off_t endposition, offsetHi; - off_t original = sdTellFile( FileID ); + file_offset_t endposition, offsetHi; + file_offset_t original = sdTellFile( FileID ); sdSeekFile( FileID, 0, PF_SEEK_END ); endposition = sdTellFile( FileID ); M_PUSH(endposition); /* Just use a 0 if they are the same size. */ - offsetHi = (sizeof(off_t) > sizeof(cell_t)) ? (endposition >> (8*sizeof(cell_t))) : 0 ; + offsetHi = (sizeof(file_offset_t) > sizeof(cell_t)) + ? (endposition >> (8*sizeof(cell_t))) : 0 ; M_PUSH(offsetHi); sdSeekFile( FileID, original, PF_SEEK_SET ); TOS = (original < 0) ? -4 : 0 ; /* !!! err num */ @@ -1066,11 +1061,12 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql )); case ID_FILE_REPOSITION: /* ( ud fid -- ior ) */ { - off_t offset; + file_offset_t offset; FileID = (FileStream *) TOS; offset = M_POP; /* Avoid compiler warnings on Mac. */ - offset = (sizeof(off_t) > sizeof(cell_t)) ? (offset << 8*sizeof(cell_t)) : 0 ; + offset = (sizeof(file_offset_t) > sizeof(cell_t)) + ? (offset << 8*sizeof(cell_t)) : 0 ; offset += M_POP; TOS = sdSeekFile( FileID, offset, PF_SEEK_SET ); } @@ -1078,13 +1074,14 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql )); case ID_FILE_POSITION: /* ( fid -- ud ior ) */ { - off_t position; - off_t offsetHi; + file_offset_t position; + file_offset_t offsetHi; FileID = (FileStream *) TOS; position = sdTellFile( FileID ); M_PUSH(position); /* Just use a 0 if they are the same size. */ - offsetHi = (sizeof(off_t) > sizeof(cell_t)) ? (position >> (8*sizeof(cell_t))) : 0 ; + offsetHi = (sizeof(file_offset_t) > sizeof(cell_t)) + ? (position >> (8*sizeof(cell_t))) : 0 ; M_PUSH(offsetHi); TOS = (position < 0) ? -4 : 0 ; /* !!! err num */ } diff --git a/csrc/pf_io.h b/csrc/pf_io.h index 4576e4f..5217390 100644 --- a/csrc/pf_io.h +++ b/csrc/pf_io.h @@ -19,6 +19,8 @@ ** ***************************************************************/ +#include "pf_types.h" + #define PF_CHAR_XON (0x11) #define PF_CHAR_XOFF (0x13) @@ -33,7 +35,6 @@ void sdTerminalTerm( void ); void ioInit( void ); void ioTerm( void ); - #ifdef PF_NO_CHARIO void sdEnableInput( void ); void sdDisableInput( void ); @@ -84,11 +85,11 @@ void ioTerm( void ); cell_t sdFlushFile( FileStream * Stream ); cell_t sdReadFile( void *ptr, cell_t Size, int32_t nItems, FileStream * Stream ); cell_t sdWriteFile( void *ptr, cell_t Size, int32_t nItems, FileStream * Stream ); - cell_t sdSeekFile( FileStream * Stream, off_t Position, int32_t Mode ); + cell_t sdSeekFile( FileStream * Stream, file_offset_t Position, int32_t Mode ); cell_t sdRenameFile( const char *OldName, const char *NewName ); cell_t sdDeleteFile( const char *FileName ); ThrowCode sdResizeFile( FileStream *, uint64_t Size); - off_t sdTellFile( FileStream * Stream ); + file_offset_t sdTellFile( FileStream * Stream ); cell_t sdCloseFile( FileStream * Stream ); cell_t sdInputChar( FileStream *stream ); diff --git a/csrc/pf_types.h b/csrc/pf_types.h index ac4f33b..619a2c0 100644 --- a/csrc/pf_types.h +++ b/csrc/pf_types.h @@ -23,6 +23,13 @@ ** Type Declarations ***************************************************************/ +#ifndef AMIGA +#include +#endif + +/* file_offset_t is used in place of off_t */ +typedef long file_offset_t; + #ifndef Err typedef long Err; #endif -- 2.20.1