Portability: Support platforms that lack (struct stat).st_blksize or SSIZE_MAX

Of course, FreeBSD has both.
This commit is contained in:
Tim Kientzle 2008-09-12 04:03:34 +00:00
parent 6d35d9a6e9
commit 220265229d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182954
3 changed files with 11 additions and 0 deletions

View File

@ -78,6 +78,9 @@
#if !HAVE_DECL_SIZE_MAX
#define SIZE_MAX (~(size_t)0)
#endif
#if !HAVE_DECL_SSIZE_MAX
#define SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1))
#endif
#if !HAVE_DECL_UINT32_MAX
#define UINT32_MAX (~(uint32_t)0)
#endif

View File

@ -514,9 +514,15 @@ write_data_block(struct archive_write_disk *a,
}
if (a->flags & ARCHIVE_EXTRACT_SPARSE) {
#if HAVE_STRUCT_STAT_ST_BLKSIZE
if ((r = _archive_write_disk_lazy_stat(a)) != ARCHIVE_OK)
return (r);
block_size = a->pst->st_blksize;
#else
/* XXX TODO XXX Is there a more appropriate choice here ? */
/* This needn't match the filesystem allocation size. */
block_size = 16*1024;
#endif
}
if (a->filesize >= 0 && (off_t)(offset + size) > a->filesize)

View File

@ -41,6 +41,7 @@
#define HAVE_DECL_INT64_MAX 1
#define HAVE_DECL_INT64_MIN 1
#define HAVE_DECL_SIZE_MAX 1
#define HAVE_DECL_SSIZE_MAX 1
#define HAVE_DECL_STRERROR_R 1
#define HAVE_DECL_UINT32_MAX 1
#define HAVE_DECL_UINT64_MAX 1
@ -86,6 +87,7 @@
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_STRRCHR 1
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
#define HAVE_SYS_ACL_H 1
#define HAVE_SYS_IOCTL_H 1