/*************************************************************** SYS-LSEEK.C This file contains Linux/i386/ILP32 implementation of __cpu_sys_lseek(). PART OF : CPU - library . USAGE : Internal only . Copyright (C) 2026 by Andrew V.Kosteltsev. All Rights Reserved. ***************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include __mpu_int64_t __cpu_sys_lseek( int fd, __mpu_int64_t offset, __mpu_uint64_t whence ) { off_t host_offset; off_t ret; int host_whence; switch( whence ) { case __CPU_SEEK_SET: host_whence = SEEK_SET; break; case __CPU_SEEK_CUR: host_whence = SEEK_CUR; break; case __CPU_SEEK_END: host_whence = SEEK_END; break; default: return( -(__mpu_int64_t)__MCPU_EINVAL ); } host_offset = (off_t)offset; if( (__mpu_int64_t)host_offset != offset ) return( -(__mpu_int64_t)__MCPU_EOVERFLOW ); ret = lseek( fd, host_offset, host_whence ); if( ret == (off_t)-1 ) return( -(__mpu_int64_t)__cpu_errno_from_host( errno ) ); if( (off_t)(__mpu_int64_t)ret != ret ) return( -(__mpu_int64_t)__MCPU_EOVERFLOW ); return( (__mpu_int64_t)ret ); }