Changeset ef84413 in mainline


Ignore:
Timestamp:
2018-09-25T18:33:23Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dc68f72
Parents:
5e6b76d
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-09-25 17:42:45)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-09-25 18:33:23)
Message:

libposix: Correctly disambiguate other uses of off_t

Location:
uspace/lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/io.c

    r5e6b76d ref84413  
    911911
    912912        /* The native position is too large for the C99-ish interface. */
    913         if (off > LONG_MAX)
    914                 return EOF;
     913        if (off > LONG_MAX) {
     914                errno = EOVERFLOW;
     915                return -1;
     916        }
    915917
    916918        return off;
  • uspace/lib/posix/include/posix/stdio.h

    r5e6b76d ref84413  
    6161    FILE *__restrict__ stream);
    6262
     63#ifdef _LARGEFILE64_SOURCE
     64extern int fseeko64(FILE *stream, off64_t offset, int whence);
     65extern off64_t ftello64(FILE *stream);
     66#endif
     67
     68#if _FILE_OFFSET_BITS == 64 && LONG_MAX == INT_MAX
     69#ifdef __GNUC__
     70extern int fseeko(FILE *stream, off_t offset, int whence) __asm__("fseeko64");
     71extern off_t ftello(FILE *stream) __asm__("ftello64");
     72#else
     73extern int fseeko64(FILE *stream, off_t offset, int whence);
     74extern off_t ftello64(FILE *stream);
     75#define fseeko fseeko64
     76#define ftello ftello64
     77#endif
     78#else
    6379extern int fseeko(FILE *stream, off_t offset, int whence);
    6480extern off_t ftello(FILE *stream);
     81#endif
    6582
    6683/* Formatted Output */
  • uspace/lib/posix/include/posix/unistd.h

    r5e6b76d ref84413  
    8181extern ssize_t write(int fildes, const void *buf, size_t nbyte);
    8282extern int fsync(int fildes);
    83 extern int ftruncate(int fildes, off_t length);
    8483extern int rmdir(const char *path);
    8584extern int unlink(const char *path);
     
    8988#ifdef _LARGEFILE64_SOURCE
    9089extern off64_t lseek64(int fildes, off64_t offset, int whence);
     90extern int ftruncate64(int fildes, off64_t length);
    9191#endif
    9292
    93 #if _FILE_OFFSET_BITS == 64
    94 static inline off_t lseek(int fildes, off_t offset, int whence)
    95 {
    96         /* Declarations visible in this function body only. */
    97         typedef int64_t off64_t;
    98         extern off64_t lseek64(int fildes, off64_t offset, int whence);
    99 
    100         /* With _FILE_OFFSET_BITS == 64, lseek is actually lseek64. */
    101         return lseek64(fildes, offset, whence);
    102 }
     93#if _FILE_OFFSET_BITS == 64 && LONG_MAX == INT_MAX
     94#ifdef __GNUC__
     95extern off_t lseek(int fildes, off_t offset, int whence) __asm__("lseek64");
     96extern int ftruncate(int fildes, off_t length) __asm__("ftruncate64");
     97#else
     98extern off_t lseek64(int fildes, off_t offset, int whence);
     99extern int ftruncate64(int fildes, off_t length);
     100#define lseek lseek64
     101#define ftruncate ftruncate64
     102#endif
    103103#else
    104104extern off_t lseek(int fildes, off_t offset, int whence);
     105extern int ftruncate(int fildes, off_t length);
    105106#endif
    106107
  • uspace/lib/posix/src/stdio.c

    r5e6b76d ref84413  
    3434/** @file Standard buffered input/output.
    3535 */
     36
     37#define _LARGEFILE64_SOURCE
     38#undef _FILE_OFFSET_BITS
    3639
    3740#include "internal/common.h"
     
    181184int fseeko(FILE *stream, off_t offset, int whence)
    182185{
    183         return fseek64(stream, offset, whence);
     186        return fseek(stream, offset, whence);
    184187}
    185188
     
    191194 */
    192195off_t ftello(FILE *stream)
     196{
     197        return ftell(stream);
     198}
     199
     200int fseeko64(FILE *stream, off64_t offset, int whence)
     201{
     202        return fseek64(stream, offset, whence);
     203}
     204
     205off64_t ftello64(FILE *stream)
    193206{
    194207        return ftell64(stream);
  • uspace/lib/posix/src/unistd.c

    r5e6b76d ref84413  
    302302off_t lseek(int fildes, off_t offset, int whence)
    303303{
    304 #if LONG_MAX == INT64_MAX
     304#if LONG_MAX == INT_MAX
     305        return _lseek(fildes, offset, LONG_MAX, whence);
     306#else
    305307        return _lseek64(fildes, offset, whence);
    306 #else
    307         return _lseek(fildes, offset, LONG_MAX, whence);
    308308#endif
    309309}
     
    331331 */
    332332int ftruncate(int fildes, off_t length)
     333{
     334        return ftruncate64(fildes, length);
     335}
     336
     337int ftruncate64(int fildes, off64_t length)
    333338{
    334339        if (failed(vfs_resize(fildes, (aoff64_t) length)))
Note: See TracChangeset for help on using the changeset viewer.