From 9c91f14547a5f41f15b11d8bd0875260c0b7d8a6 Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Fri, 5 Feb 2016 04:34:06 +0100 Subject: [PATCH] Fix NetBSD build: Retire unneeded PAL_fpos_t and fgetpos() fsetpos() These functions are unused. Linux version was unimplemented. Removal suggested by Jan Kotas (Microsoft) to get rid of these functions. The current code resulted with the following errors with the recent Clang/LLVM (3.9.0nb20160131 snapshot) on NetBSD-7.99.25: /tmp/pkgsrc-tmp/wip/coreclr-git/work/coreclr/src/pal/src/cruntime/file.cpp:858:20: error: no viable overloaded '=' native_pos = *pos; ~~~~~~~~~~ ^ ~~~~ /usr/include/stdio.h:67:16: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'PAL_fpos_t' (aka 'unsigned long') to 'const __sfpos' for 1st argument typedef struct __sfpos { ^ /usr/include/stdio.h:67:16: note: candidate function (the implicit move assignment operator) not viable: no known conversion from 'PAL_fpos_t' (aka 'unsigned long') to '__sfpos' for 1st argument /tmp/pkgsrc-tmp/wip/coreclr-git/work/coreclr/src/pal/src/cruntime/file.cpp:860:14: error: assigning to 'PAL_fpos_t' (aka 'unsigned long') from incompatible type 'fpos_t' (aka '__sfpos') *pos = native_pos; ^ ~~~~~~~~~~ /tmp/pkgsrc-tmp/wip/coreclr-git/work/coreclr/src/pal/src/cruntime/file.cpp:904:20: error: no viable overloaded '=' native_pos = *pos; ~~~~~~~~~~ ^ ~~~~ /usr/include/stdio.h:67:16: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'const PAL_fpos_t' (aka 'const unsigned long') to 'const __sfpos' for 1st argument typedef struct __sfpos { ^ /usr/include/stdio.h:67:16: note: candidate function (the implicit move assignment operator) not viable: no known conversion from 'const PAL_fpos_t' (aka 'const unsigned long') to '__sfpos' for 1st argument 3 errors generated. Possible implementation for NetBSD (attached here for historical references): +--- src/pal/src/cruntime/file.cpp.orig 2016-01-28 19:04:13.000000000 +0000 ++++ src/pal/src/cruntime/file.cpp +@@ -844,6 +844,15 @@ PAL_fgetpos ( + // TODO: implement for Linux if required + ASSERT(FALSE); + return -1; ++#elif defined(__NetBSD__) ++ off_t native_pos; ++ ++ if ((native_pos = ftello(f->bsdFilePtr)) == -1) ++ return -1; ++ ++ *pos = native_pos; ++ ++ return 0; + #else + int nRetVal = -1; + fpos_t native_pos; +@@ -890,6 +899,14 @@ PAL_fsetpos ( + // TODO: implement for Linux if required + ASSERT(FALSE); + return -1; ++#elif defined(__NetBSD__) ++ off_t native_pos; ++ ++ native_pos = *pos; ++ if (fseeko(f->bsdFilePtr, native_pos, SEEK_SET) == -1) ++ return -1; ++ ++ return 0; + #else + int nRetVal = -1; + fpos_t native_pos; We cannot go better on NetBSD. This implementation might still have issues with e.g. Unicode. This closes #3029 "PAL fpos_t clash with NetBSD libraries" Thanks Peter Jas (@jasonwilliams200OK) for hacking session on it. --- src/pal/inc/pal.h | 3 -- src/pal/src/cruntime/file.cpp | 92 ----------------------------------- src/pal/src/include/pal/palinternal.h | 2 - 3 files changed, 97 deletions(-) diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index 0fe30e4..cc4a695 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -393,7 +393,6 @@ PAL_IsDebuggerPresent(); #endif // defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus) #ifndef PAL_STDCPP_COMPAT -typedef ULONG64 fpos_t; #if _WIN64 || _MSC_VER >= 1400 typedef __int64 time_t; @@ -6433,8 +6432,6 @@ PALIMPORT int __cdecl PAL_putchar(int c); PALIMPORT int __cdecl PAL_fprintf(PAL_FILE *, const char *, ...); PALIMPORT int __cdecl PAL_vfprintf(PAL_FILE *, const char *, va_list); PALIMPORT int __cdecl PAL_fseek(PAL_FILE *, LONG, int); -PALIMPORT int __cdecl PAL_fgetpos(PAL_FILE *, fpos_t *); -PALIMPORT int __cdecl PAL_fsetpos(PAL_FILE *, const fpos_t *); PALIMPORT LONG __cdecl PAL_ftell(PAL_FILE *); PALIMPORT int __cdecl PAL_feof(PAL_FILE *); PALIMPORT int __cdecl PAL_ferror(PAL_FILE *); diff --git a/src/pal/src/cruntime/file.cpp b/src/pal/src/cruntime/file.cpp index 54d8e41..5fe2b67 100644 --- a/src/pal/src/cruntime/file.cpp +++ b/src/pal/src/cruntime/file.cpp @@ -825,98 +825,6 @@ PAL_ftell(PAL_FILE * f) } /*++ - -Function: - - fgetpos - -See msdn for more details. ---*/ - -int -__cdecl -PAL_fgetpos ( - PAL_FILE *f, - PAL_fpos_t *pos -) -{ -#ifdef __LINUX__ - // TODO: implement for Linux if required - ASSERT(FALSE); - return -1; -#else - int nRetVal = -1; - fpos_t native_pos; - - PERF_ENTRY(fgetpos); - ENTRY("fgetpos( f=%p, pos=%p )\n", f, pos); - - _ASSERTE(f != NULL); - _ASSERTE(pos != NULL); - - if (pos) { - native_pos = *pos; - nRetVal = fgetpos (f->bsdFilePtr, &native_pos); - *pos = native_pos; - } - else { - ERROR ("Error: NULL pos pointer\n"); - errno = EINVAL; - } - - LOGEXIT( "fgetpos returning error code %d, pos %d\n", nRetVal, pos ? *pos : 0); - PERF_EXIT(fgetpos); - return nRetVal; -#endif // __LINUX__ -} - -/*++ - -Function: - - fsetpos - -See msdn for more details. ---*/ - -int -__cdecl -PAL_fsetpos ( - PAL_FILE *f, - const PAL_fpos_t *pos -) -{ -#ifdef __LINUX__ - // TODO: implement for Linux if required - ASSERT(FALSE); - return -1; -#else - int nRetVal = -1; - fpos_t native_pos; - - PERF_ENTRY(fsetpos); - ENTRY("fsetpos( f=%p, pos=%p )\n", f, pos); - - _ASSERTE(f != NULL); - _ASSERTE(pos != NULL); - - if (pos) { - native_pos = *pos; - nRetVal = fsetpos (f->bsdFilePtr, &native_pos); - } - else { - ERROR ("Error: NULL pos pointer\n"); - errno = EINVAL; - } - - LOGEXIT( "fsetpos returning error code %d\n", nRetVal); - PERF_EXIT(fsetpos); - return nRetVal; -#endif // __LINUX__ -} - - -/*++ Function : feof diff --git a/src/pal/src/include/pal/palinternal.h b/src/pal/src/include/pal/palinternal.h index f7c841b..9dbbf1c 100644 --- a/src/pal/src/include/pal/palinternal.h +++ b/src/pal/src/include/pal/palinternal.h @@ -324,7 +324,6 @@ function_name() to call the system's implementation #define uintptr_t PAL_uintptr_t #define timeval PAL_timeval #define FILE PAL_FILE -#define fpos_t PAL_fpos_t #include "pal.h" @@ -478,7 +477,6 @@ function_name() to call the system's implementation #undef intptr_t #undef uintptr_t #undef timeval -#undef fpos_t #undef printf -- 2.7.4