Skip to content

Commit 97da14c

Browse files
authored
Misc. illumous build fixes (prereq. for #105403) (#117023)
* Fix illumos compile error at minipal/debugger.c:127 dotnet/runtime/src/native/minipal/debugger.c:127:5: error: implicit declaration of function 'snprintf' [-Werror=implicit-function-declaration] 127 | snprintf(statusFilename, sizeof(statusFilename), "/proc/%d/status", getpid()); | ^~~~~~~~ * Fix illumos compile error in minipal/thread.h src/native/minipal/thread.h:73:23: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] 73 | tid = (size_t)(void*)pthread_self(); | ^~~~~~~~~~~~~~~~~~~~~ * Fix illumos compile error in native/libs/System.Native/pal_mount.c src/native/libs/System.Native/pal_mount.c:164:38: error: 'struct statvfs' has no member named 'f_type' 164 | *formatType = (int64_t)(stats.f_type); | ^ * Fix illumos compile error in coreclr/pal/src/thread/thread.cpp /home/gwr/dotnet/runtime/src/coreclr/pal/src/thread/thread.cpp:1367:5: error: 'cid' was not declared in this scope 1367 | cid = CLOCK_THREAD_CPUTIME_ID; | ^~~
1 parent b260561 commit 97da14c

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

src/coreclr/pal/src/thread/thread.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,10 +1330,9 @@ CorUnix::GetThreadTimesInternal(
13301330
CPalThread *pThread;
13311331
CPalThread *pTargetThread;
13321332
IPalObject *pobjThread = NULL;
1333+
clockid_t cid;
13331334
#ifdef __sun
13341335
int fd;
1335-
#else // __sun
1336-
clockid_t cid;
13371336
#endif // __sun
13381337

13391338
pThread = InternalGetCurrentThread();

src/native/libs/Common/pal_config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#cmakedefine01 HAVE_MNTINFO
3232
#cmakedefine01 HAVE_STATFS_FSTYPENAME
3333
#cmakedefine01 HAVE_STATVFS_FSTYPENAME
34+
#cmakedefine01 HAVE_STATVFS_BASETYPE
3435
#cmakedefine01 HAVE_NON_LEGACY_STATFS
3536
#cmakedefine01 HAVE_STRCPY_S
3637
#cmakedefine01 HAVE_STRLCPY

src/native/libs/System.Native/pal_mount.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ SystemNative_GetFileSystemTypeNameForMountPoint(const char* name, char* formatNa
159159
}
160160
SafeStringCopy(formatNameBuffer, Int32ToSizeT(bufferLength), stats.f_fstypename);
161161
*formatType = -1;
162+
#elif HAVE_STATVFS_BASETYPE
163+
if (bufferLength < _FSTYPSZ) // SunOS
164+
{
165+
errno = ERANGE;
166+
result = -1;
167+
}
168+
SafeStringCopy(formatNameBuffer, Int32ToSizeT(bufferLength), stats.f_basetype);
169+
*formatType = -1;
162170
#else
163171
SafeStringCopy(formatNameBuffer, Int32ToSizeT(bufferLength), "");
164172
*formatType = (int64_t)(stats.f_type);

src/native/libs/configure.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ check_struct_has_member(
324324
"sys/mount.h"
325325
HAVE_STATVFS_FSTYPENAME)
326326

327+
check_struct_has_member(
328+
"struct statvfs"
329+
f_basetype
330+
"sys/statvfs.h"
331+
HAVE_STATVFS_BASETYPE)
332+
327333
set(CMAKE_EXTRA_INCLUDE_FILES dirent.h)
328334

329335
# statfs: Find whether this struct exists

src/native/minipal/debugger.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <sys/proc.h>
3333
#define MINIPAL_DEBUGGER_PRESENT_CHECK
3434
#elif defined(__sun)
35+
#include <stdio.h>
3536
#include <fcntl.h>
3637
#include <procfs.h>
3738
#include <errno.h>

src/native/minipal/thread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ static inline size_t minipal_get_current_thread_id(void)
6969
tid = (size_t)_lwp_self();
7070
#elif defined(__HAIKU__)
7171
tid = (size_t)find_thread(NULL);
72+
#elif defined(__sun)
73+
tid = (size_t)pthread_self();
7274
#else
7375
tid = (size_t)(void*)pthread_self();
7476
#endif

0 commit comments

Comments
 (0)