diff options
author | Steve Bennett <steveb@workware.net.au> | 2012-09-05 10:57:35 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2012-09-06 07:24:51 +1000 |
commit | 1bde066fbbf55d881f5bc75316c12a762cf39608 (patch) | |
tree | fc570e69ac4035a49af29c31e0dfc3568361dff9 | |
parent | 49036996bce7bc28c695455caa5cef84932e7ac4 (diff) | |
download | jimtcl-1bde066fbbf55d881f5bc75316c12a762cf39608.zip jimtcl-1bde066fbbf55d881f5bc75316c12a762cf39608.tar.gz jimtcl-1bde066fbbf55d881f5bc75316c12a762cf39608.tar.bz2 |
aio seek and tell should allow for 64 bit offsets
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | auto.def | 7 | ||||
-rw-r--r-- | jim-aio.c | 18 |
2 files changed, 18 insertions, 7 deletions
@@ -2,7 +2,7 @@ # # Note: modules which support options *must* be included before 'options' -use cc cc-shared cc-db +use cc cc-shared cc-db cc-lib use local options { @@ -90,6 +90,9 @@ if {[cc-check-functions sysinfo]} { } } +cc-check-lfs +cc-check-functions fseeko ftello + define TCL_LIBRARY [get-define prefix]/lib/jim lassign [split [get-define host] -] host_cpu host_vendor host_os @@ -329,7 +332,7 @@ define TCL_EXTS [suffix .tcl $extinfo(module-tcl)] define EXTRA_OBJS $extra_objs make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -none * -make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_*} +make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*} make-template Makefile.in make-template build-jim-ext.in @@ -38,13 +38,14 @@ * official policies, either expressed or implied, of the Jim Tcl Project. **/ +#include "jimautoconf.h" + #include <stdio.h> #include <string.h> #include <errno.h> #include <fcntl.h> #include "jim.h" -#include "jimautoconf.h" #if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_SELECT) && defined(HAVE_NETINET_IN_H) && defined(HAVE_NETDB_H) && defined(HAVE_ARPA_INET_H) #include <sys/socket.h> @@ -65,6 +66,13 @@ #define AIO_CMD_LEN 32 /* e.g. aio.handleXXXXXX */ #define AIO_BUF_LEN 256 /* Can keep this small and rely on stdio buffering */ +#ifndef HAVE_FTELLO + #define ftello ftell +#endif +#ifndef HAVE_FSEEKO + #define fseeko fseek +#endif + #define AIO_KEEPOPEN 1 #if defined(JIM_IPV6) @@ -671,7 +679,7 @@ static int aio_cmd_seek(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { AioFile *af = Jim_CmdPrivData(interp); int orig = SEEK_SET; - long offset; + jim_wide offset; if (argc == 2) { if (Jim_CompareStringImmediate(interp, argv[1], "start")) @@ -684,10 +692,10 @@ static int aio_cmd_seek(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return -1; } } - if (Jim_GetLong(interp, argv[0], &offset) != JIM_OK) { + if (Jim_GetWide(interp, argv[0], &offset) != JIM_OK) { return JIM_ERR; } - if (fseek(af->fp, offset, orig) == -1) { + if (fseeko(af->fp, offset, orig) == -1) { JimAioSetError(interp, af->filename); return JIM_ERR; } @@ -698,7 +706,7 @@ static int aio_cmd_tell(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { AioFile *af = Jim_CmdPrivData(interp); - Jim_SetResultInt(interp, ftell(af->fp)); + Jim_SetResultInt(interp, ftello(af->fp)); return JIM_OK; } |