Robert Dewar wrote: > > __gnat_ seems like it would be more consistent with the other > definitions in adaint.h, but it's not critical certainly.
Well, but they're macros rather than functions, and I personally don't like to hide the difference. I ended up doing this because it makes them look like a lot of the other type-independence macros we have in the code. Ah, and I see you also had an after-thought in a second reply. I'll respin this if you think it's horribly ugly, otherwise I'll send it to -patches with a changelog once the build has finished. cheers, DaveK
Index: adaint.c =================================================================== --- adaint.c (revision 149338) +++ adaint.c (working copy) @@ -520,7 +520,7 @@ __gnat_try_lock (char *dir, char *file) { char full_path[256]; char temp_file[256]; - STRUCT_STAT stat_result; + _GNAT_STRUCT_STAT_ stat_result; int fd; sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file); @@ -775,7 +775,7 @@ __gnat_fopen (char *path, char *mode, int encoding #elif defined (VMS) return decc$fopen (path, mode); #else - return FOPEN (path, mode); + return _GNAT_FOPEN_ (path, mode); #endif } @@ -1019,9 +1019,9 @@ long __gnat_file_length (int fd) { int ret; - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - ret = FSTAT (fd, &statbuf); + ret = _GNAT_FSTAT_ (fd, &statbuf); if (ret || !S_ISREG (statbuf.st_mode)) return 0; @@ -1038,7 +1038,7 @@ long __gnat_named_file_length (char *name) { int ret; - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; ret = __gnat_stat (name, &statbuf); if (ret || !S_ISREG (statbuf.st_mode)) @@ -1269,7 +1269,7 @@ __gnat_file_time_name (char *name) } return (OS_Time) ret; #else - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; if (__gnat_stat (name, &statbuf) != 0) { return (OS_Time)-1; } else { @@ -1361,9 +1361,9 @@ __gnat_file_time_fd (int fd) return (OS_Time) ret; #else - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - if (FSTAT (fd, &statbuf) != 0) { + if (_GNAT_FSTAT_ (fd, &statbuf) != 0) { return (OS_Time) -1; } else { #ifdef VMS @@ -1651,7 +1651,7 @@ __gnat_get_libraries_from_registry (void) } int -__gnat_stat (char *name, STRUCT_STAT *statbuf) +__gnat_stat (char *name, _GNAT_STRUCT_STAT_ *statbuf) { #ifdef __MINGW32__ /* Under Windows the directory name for the stat function must not be @@ -1683,7 +1683,7 @@ int return _tstat (wname, (struct _stat *)statbuf); #else - return STAT (name, statbuf); + return _GNAT_STAT_ (name, statbuf); #endif } @@ -1699,7 +1699,7 @@ __gnat_file_exists (char *name) S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2); return GetFileAttributes (wname) != INVALID_FILE_ATTRIBUTES; #else - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; return !__gnat_stat (name, &statbuf); #endif @@ -1744,7 +1744,7 @@ int __gnat_is_regular_file (char *name) { int ret; - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; ret = __gnat_stat (name, &statbuf); return (!ret && S_ISREG (statbuf.st_mode)); @@ -1754,7 +1754,7 @@ int __gnat_is_directory (char *name) { int ret; - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; ret = __gnat_stat (name, &statbuf); return (!ret && S_ISDIR (statbuf.st_mode)); @@ -1972,9 +1972,9 @@ __gnat_is_readable_file (char *name) #else int ret; int mode; - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - ret = STAT (name, &statbuf); + ret = _GNAT_STAT_ (name, &statbuf); mode = statbuf.st_mode & S_IRUSR; return (!ret && mode); #endif @@ -2004,9 +2004,9 @@ __gnat_is_writable_file (char *name) #else int ret; int mode; - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - ret = STAT (name, &statbuf); + ret = _GNAT_STAT_ (name, &statbuf); mode = statbuf.st_mode & S_IWUSR; return (!ret && mode); #endif @@ -2034,9 +2034,9 @@ __gnat_is_executable_file (char *name) #else int ret; int mode; - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - ret = STAT (name, &statbuf); + ret = _GNAT_STAT_ (name, &statbuf); mode = statbuf.st_mode & S_IXUSR; return (!ret && mode); #endif @@ -2056,9 +2056,9 @@ __gnat_set_writable (char *name) SetFileAttributes (wname, GetFileAttributes (wname) & ~FILE_ATTRIBUTE_READONLY); #elif ! defined (__vxworks) && ! defined(__nucleus__) - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - if (STAT (name, &statbuf) == 0) + if (_GNAT_STAT_ (name, &statbuf) == 0) { statbuf.st_mode = statbuf.st_mode | S_IWUSR; chmod (name, statbuf.st_mode); @@ -2078,9 +2078,9 @@ __gnat_set_executable (char *name) __gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_EXECUTE); #elif ! defined (__vxworks) && ! defined(__nucleus__) - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - if (STAT (name, &statbuf) == 0) + if (_GNAT_STAT_ (name, &statbuf) == 0) { statbuf.st_mode = statbuf.st_mode | S_IXUSR; chmod (name, statbuf.st_mode); @@ -2105,9 +2105,9 @@ __gnat_set_non_writable (char *name) SetFileAttributes (wname, GetFileAttributes (wname) | FILE_ATTRIBUTE_READONLY); #elif ! defined (__vxworks) && ! defined(__nucleus__) - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - if (STAT (name, &statbuf) == 0) + if (_GNAT_STAT_ (name, &statbuf) == 0) { statbuf.st_mode = statbuf.st_mode & 07577; chmod (name, statbuf.st_mode); @@ -2127,9 +2127,9 @@ __gnat_set_readable (char *name) __gnat_set_OWNER_ACL (wname, GRANT_ACCESS, FILE_GENERIC_READ); #elif ! defined (__vxworks) && ! defined(__nucleus__) - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - if (STAT (name, &statbuf) == 0) + if (_GNAT_STAT_ (name, &statbuf) == 0) { chmod (name, statbuf.st_mode | S_IREAD); } @@ -2148,9 +2148,9 @@ __gnat_set_non_readable (char *name) __gnat_set_OWNER_ACL (wname, DENY_ACCESS, FILE_GENERIC_READ); #elif ! defined (__vxworks) && ! defined(__nucleus__) - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - if (STAT (name, &statbuf) == 0) + if (_GNAT_STAT_ (name, &statbuf) == 0) { chmod (name, statbuf.st_mode & (~S_IREAD)); } @@ -2165,9 +2165,9 @@ __gnat_is_symbolic_link (char *name ATTRIBUTE_UNUS #elif defined (_AIX) || defined (__APPLE__) || defined (__unix__) int ret; - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; - ret = LSTAT (name, &statbuf); + ret = _GNAT_LSTAT_ (name, &statbuf); return (!ret && S_ISLNK (statbuf.st_mode)); #else @@ -3435,10 +3435,10 @@ __gnat_copy_attribs (char *from, char *to, int mod return 0; #else - STRUCT_STAT fbuf; + _GNAT_STRUCT_STAT_ fbuf; struct utimbuf tbuf; - if (STAT (from, &fbuf) == -1) + if (_GNAT_STAT_ (from, &fbuf) == -1) { return -1; } Index: adaint.h =================================================================== --- adaint.h (revision 149338) +++ adaint.h (working copy) @@ -49,17 +49,17 @@ tested. */ #if defined (__GLIBC__) || defined (sun) || defined (__sgi) -#define FOPEN fopen64 -#define STAT stat64 -#define FSTAT fstat64 -#define LSTAT lstat64 -#define STRUCT_STAT struct stat64 +#define _GNAT_FOPEN_ fopen64 +#define _GNAT_STAT_ stat64 +#define _GNAT_FSTAT_ fstat64 +#define _GNAT_LSTAT_ lstat64 +#define _GNAT_STRUCT_STAT_ struct stat64 #else -#define FOPEN fopen -#define STAT stat -#define FSTAT fstat -#define LSTAT lstat -#define STRUCT_STAT struct stat +#define _GNAT_FOPEN_ fopen +#define _GNAT_STAT_ stat +#define _GNAT_FSTAT_ fstat +#define _GNAT_LSTAT_ lstat +#define _GNAT_STRUCT_STAT_ struct stat #endif typedef long OS_Time; /* Type corresponding to GNAT.OS_Lib.OS_Time */ @@ -89,7 +89,7 @@ extern int __gnat_open_new extern int __gnat_open_new_temp (char *, int); extern int __gnat_mkdir (char *); extern int __gnat_stat (char *, - STRUCT_STAT *); + _GNAT_STRUCT_STAT_ *); extern int __gnat_unlink (char *); extern int __gnat_rename (char *, char *); extern int __gnat_chdir (char *); Index: cstreams.c =================================================================== --- cstreams.c (revision 149338) +++ cstreams.c (working copy) @@ -96,7 +96,7 @@ int __gnat_is_regular_file_fd (int fd) { int ret; - STRUCT_STAT statbuf; + _GNAT_STRUCT_STAT_ statbuf; #ifdef __EMX__ /* Programs using screen I/O may need to reset the FPU after @@ -107,7 +107,7 @@ __gnat_is_regular_file_fd (int fd) __gnat_init_float(); #endif - ret = FSTAT (fd, &statbuf); + ret = _GNAT_FSTAT_ (fd, &statbuf); return (!ret && S_ISREG (statbuf.st_mode)); }