Diff for /libaitio/src/bufio.c between versions 1.9 and 1.10

version 1.9, 2014/02/08 22:06:17 version 1.10, 2016/08/18 09:06:31
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004 - 2014Copyright 2004 - 2016
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 70  cf_(struct tagBufIO *buf) Line 70  cf_(struct tagBufIO *buf)
         return 0;          return 0;
 }  }
   
   #ifndef __linux__
 #ifdef __NetBSD__  #ifdef __NetBSD__
 static off_t  static off_t
 sf_lim(struct tagBufIO *buf, off_t pos, int w)  sf_lim(struct tagBufIO *buf, off_t pos, int w)
Line 77  sf_lim(struct tagBufIO *buf, off_t pos, int w) Line 78  sf_lim(struct tagBufIO *buf, off_t pos, int w)
 static fpos_t  static fpos_t
 sf_lim(struct tagBufIO *buf, fpos_t pos, int w)  sf_lim(struct tagBufIO *buf, fpos_t pos, int w)
 #endif  #endif
   #else
   static off_t
   sf_lim(struct tagBufIO *buf, off64_t *ppos, int w)
   #endif
 {  {
   #ifdef __linux__
           off_t pos = (off_t) *ppos;
   #endif
   
         if (!buf)          if (!buf)
                 goto err;                  goto err;
   
Line 139  wf_lim(struct tagBufIO *buf, const char *dat, int siz) Line 148  wf_lim(struct tagBufIO *buf, const char *dat, int siz)
         return siz;          return siz;
 }  }
   
   #ifndef __linux__
 #ifdef __NetBSD__  #ifdef __NetBSD__
 static off_t  static off_t
 sf_inf(struct tagBufIO *buf, off_t pos, int w)  sf_inf(struct tagBufIO *buf, off_t pos, int w)
Line 146  sf_inf(struct tagBufIO *buf, off_t pos, int w) Line 156  sf_inf(struct tagBufIO *buf, off_t pos, int w)
 static fpos_t  static fpos_t
 sf_inf(struct tagBufIO *buf, fpos_t pos, int w)  sf_inf(struct tagBufIO *buf, fpos_t pos, int w)
 #endif  #endif
   #else
   static off_t
   sf_inf(struct tagBufIO *buf, off64_t *ppos, int w)
   #endif
 {  {
         void *b;          void *b;
   #ifdef __linux__
           off_t pos = (off_t) *ppos;
   #endif
   
         if (!buf)          if (!buf)
                 goto err;                  goto err;
Line 254  io_fmemopen(void ** __restrict base, off_t basesize) Line 271  io_fmemopen(void ** __restrict base, off_t basesize)
 {  {
         FILE *f = NULL;          FILE *f = NULL;
         struct tagBufIO *buf;          struct tagBufIO *buf;
   #ifdef __linux__
           cookie_io_functions_t cookie;
   #endif
   
         if (!base) {          if (!base) {
                 io_SetErr(EINVAL, "Invalid base argument ...");                  io_SetErr(EINVAL, "Invalid base argument ...");
Line 283  io_fmemopen(void ** __restrict base, off_t basesize) Line 303  io_fmemopen(void ** __restrict base, off_t basesize)
         buf->buf_base = *base;          buf->buf_base = *base;
         buf->buf_size = basesize;          buf->buf_size = basesize;
   
   #ifndef __linux__
 #ifdef __NetBSD__  #ifdef __NetBSD__
         if (buf->buf_mode == BUFIO_MODE_INFINIT)          if (buf->buf_mode == BUFIO_MODE_INFINIT)
                 f = funopen(buf, (int (*)(void *, char *, int)) rf_lim,                   f = funopen(buf, (int (*)(void *, char *, int)) rf_lim, 
Line 306  io_fmemopen(void ** __restrict base, off_t basesize) Line 327  io_fmemopen(void ** __restrict base, off_t basesize)
                                 (fpos_t (*)(void *, fpos_t, int)) sf_lim,                                   (fpos_t (*)(void *, fpos_t, int)) sf_lim, 
                                 (int (*)(void *)) cf_);                                  (int (*)(void *)) cf_);
 #endif  #endif
   #else
           if (buf->buf_mode == BUFIO_MODE_INFINIT) {
                   cookie.read = (cookie_read_function_t*) rf_lim;
                   cookie.write = (cookie_write_function_t*) wf_inf;
                   cookie.seek = (cookie_seek_function_t*) sf_inf;
                   cookie.close = (cookie_close_function_t*) cf_;
           } else {
                   cookie.read = (cookie_read_function_t*) rf_lim;
                   cookie.write = (cookie_write_function_t*) wf_lim;
                   cookie.seek = (cookie_seek_function_t*) sf_lim;
                   cookie.close = (cookie_close_function_t*) cf_;
           }
   
           f = fopencookie(buf, "r+", cookie);
   #endif
         if (!f) {          if (!f) {
                 LOGERR;                  LOGERR;
                 if (buf->buf_mode == BUFIO_MODE_INFINIT) {                  if (buf->buf_mode == BUFIO_MODE_INFINIT) {
Line 338  io_fmapopen(const char *csFile, int mode, int perm, in Line 374  io_fmapopen(const char *csFile, int mode, int perm, in
         void *base;          void *base;
         off_t basesize;          off_t basesize;
         int fd = -1;          int fd = -1;
   #ifdef __linux__
           cookie_io_functions_t cookie = {
                   .read = (cookie_read_function_t*) rf_lim, 
                   .write = (cookie_write_function_t*) wf_lim, 
                   .seek = (cookie_seek_function_t*) sf_lim, 
                   .close = (cookie_close_function_t*) cf_
           };
   #endif
   
         if (csFile) {          if (csFile) {
                 fd = open(csFile, mode, perm);                  fd = open(csFile, mode, perm);
Line 362  io_fmapopen(const char *csFile, int mode, int perm, in Line 406  io_fmapopen(const char *csFile, int mode, int perm, in
                         close(fd);                          close(fd);
         } else if (offset) {          } else if (offset) {
                 basesize = offset;                  basesize = offset;
                base = mmap(NULL, basesize, prot, MAP_ANON, -1, 0);                base = mmap(NULL, basesize, prot, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
                 if (base == MAP_FAILED) {                  if (base == MAP_FAILED) {
                         LOGERR;                          LOGERR;
                         return NULL;                          return NULL;
Line 386  io_fmapopen(const char *csFile, int mode, int perm, in Line 430  io_fmapopen(const char *csFile, int mode, int perm, in
         buf->buf_size = basesize;          buf->buf_size = basesize;
         buf->buf_unmap = unmap_cf;          buf->buf_unmap = unmap_cf;
   
   #ifndef __linux__
 #ifdef __NetBSD__  #ifdef __NetBSD__
         f = funopen(buf, (int (*)(void *, char *, int)) rf_lim,           f = funopen(buf, (int (*)(void *, char *, int)) rf_lim, 
                         (int (*)(void *, char const *, int)) wf_lim,                           (int (*)(void *, char const *, int)) wf_lim, 
Line 396  io_fmapopen(const char *csFile, int mode, int perm, in Line 441  io_fmapopen(const char *csFile, int mode, int perm, in
                         (int (*)(void *, char const *, int)) wf_lim,                           (int (*)(void *, char const *, int)) wf_lim, 
                         (fpos_t (*)(void *, fpos_t, int)) sf_lim,                           (fpos_t (*)(void *, fpos_t, int)) sf_lim, 
                         (int (*)(void *)) cf_);                          (int (*)(void *)) cf_);
   #endif
   #else
           f = fopencookie(buf, "r+", cookie);
 #endif  #endif
         if (!f) {          if (!f) {
                 LOGERR;                  LOGERR;

Removed from v.1.9  
changed lines
  Added in v.1.10


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>