Changeset 12811


Ignore:
Timestamp:
Sep 11, 2009, 10:51:22 AM (10 years ago)
Author:
gb
Message:

#include <limits.h>, so that we can refer to INT_MAX (largest signed 'int').
In load_image_section(), mem_size needs to be a natural, not an int.
In writebuf(), don't try to write more than INT_MAX bytes at a time, since
The World's Most Powerful Operating System can't do so.
(These changes are intended to support loading/saving images larger than
2GB.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/image.c

    r11623 r12811  
    2626#endif
    2727#include <stdio.h>
     28#include <limits.h>
    2829
    2930
     
    175176  off_t
    176177    pos = seek_to_next_page(fd), advance;
    177   int
     178  natural
    178179    mem_size = sect->memory_size;
    179180  void *addr;
     
    379380writebuf(int fd, char *bytes, natural n)
    380381{
    381   natural remain = n;
    382   int result;
     382  natural remain = n, this_size;
     383  signed_natural result;
    383384
    384385  while (remain) {
    385     result = write(fd, bytes, remain);
     386    this_size = remain;
     387    if (this_size > INT_MAX) {
     388      this_size = INT_MAX;
     389    }
     390    result = write(fd, bytes, this_size);
    386391    if (result < 0) {
    387392      return errno;
    388393    }
    389394    bytes += result;
     395
    390396    remain -= result;
    391397  }
Note: See TracChangeset for help on using the changeset viewer.