From a8d98451409d647e922fa050736a78d77961c35e Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Thu, 7 Apr 2011 23:58:46 +1200 Subject: [PATCH] ICC: support 64-bit environments dirent definitions struct dirent is not consistently defined for 32-bit and 64-bit enabled environments. Provide a dirent_t type defined appropriate to the environment for use instead. --- compat/compat_shared.h | 12 ++++++++++-- src/fs/ufs/store_dir_ufs.cc | 2 +- src/fs/ufs/ufscommon.h | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compat/compat_shared.h b/compat/compat_shared.h index 1d2b89390f..7c09843a26 100644 --- a/compat/compat_shared.h +++ b/compat/compat_shared.h @@ -34,8 +34,7 @@ extern void (*failure_notify) (const char *); /* * DIRENT functionality can apparently come from many places. - * I believe these should really be done by OS-specific compat - * files, but for now its left here. + * With various complaints by different compilers */ #if HAVE_DIRENT_H #include @@ -54,6 +53,15 @@ extern void (*failure_notify) (const char *); #endif /* HAVE_NDIR_H */ #endif /* HAVE_DIRENT_H */ +/* The structure dirent also varies between 64-bit and 32-bit environments. + * Define our own dirent_t type for consistent simple internal use. + */ +#if defined(__USE_FILE_OFFSET64) +typedef struct dirent64 dirent_t; +#else +typedef struct dirent dirent_t; +#endif + /* * Filedescriptor limits in the different select loops diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 09101df3f9..cd706d7fdf 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -1063,7 +1063,6 @@ UFSSwapDir::DirClean(int swap_index) { DIR *dir_pointer = NULL; - struct dirent *de = NULL; LOCAL_ARRAY(char, p1, MAXPATHLEN + 1); LOCAL_ARRAY(char, p2, MAXPATHLEN + 1); @@ -1107,6 +1106,7 @@ UFSSwapDir::DirClean(int swap_index) return 0; } + dirent_t *de; while ((de = readdir(dir_pointer)) != NULL && k < 20) { if (sscanf(de->d_name, "%X", &swapfileno) != 1) continue; diff --git a/src/fs/ufs/ufscommon.h b/src/fs/ufs/ufscommon.h index bd3588c52d..4b58916fa2 100644 --- a/src/fs/ufs/ufscommon.h +++ b/src/fs/ufs/ufscommon.h @@ -399,7 +399,7 @@ public: int done; int fn; - struct dirent *entry; + dirent_t *entry; DIR *td; char fullpath[MAXPATHLEN]; char fullfilename[MAXPATHLEN]; -- 2.47.3