Skip to content

Commit bb0cde3

Browse files
committed
Fix tvOS build
1 parent 337751b commit bb0cde3

File tree

10 files changed

+38
-13
lines changed

10 files changed

+38
-13
lines changed

src/coreclr/pal/src/configure.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ check_function_exists(statvfs HAVE_STATVFS)
134134
check_function_exists(thread_self HAVE_THREAD_SELF)
135135
check_function_exists(_lwp_self HAVE__LWP_SELF)
136136
check_function_exists(pthread_mach_thread_np HAVE_MACH_THREADS)
137-
check_function_exists(thread_set_exception_ports HAVE_MACH_EXCEPTIONS)
137+
if(CLR_CMAKE_TARGET_TVOS)
138+
set(HAVE_MACH_EXCEPTIONS 0)
139+
else()
140+
check_function_exists(thread_set_exception_ports HAVE_MACH_EXCEPTIONS)
141+
endif()
138142
check_function_exists(vm_allocate HAVE_VM_ALLOCATE)
139143
check_function_exists(vm_read HAVE_VM_READ)
140144
check_function_exists(directio HAVE_DIRECTIO)

src/coreclr/pal/src/exception/seh.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ PAL_ERROR SEHEnable(CPalThread *pthrCurrent)
305305
{
306306
#if HAVE_MACH_EXCEPTIONS
307307
return pthrCurrent->EnableMachExceptions();
308-
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun)
308+
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(TARGET_TVOS)
309309
return NO_ERROR;
310310
#else// HAVE_MACH_EXCEPTIONS
311311
#error not yet implemented
@@ -330,7 +330,7 @@ PAL_ERROR SEHDisable(CPalThread *pthrCurrent)
330330
{
331331
#if HAVE_MACH_EXCEPTIONS
332332
return pthrCurrent->DisableMachExceptions();
333-
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun)
333+
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(TARGET_TVOS)
334334
return NO_ERROR;
335335
#else // HAVE_MACH_EXCEPTIONS
336336
#error not yet implemented

src/coreclr/pal/src/exception/signal.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ BOOL SEHInitializeSignals(CorUnix::CPalThread *pthrCurrent, DWORD flags)
182182
handle_signal(SIGINT, sigint_handler, &g_previous_sigint, 0 /* additionalFlags */, true /* skipIgnored */);
183183
handle_signal(SIGQUIT, sigquit_handler, &g_previous_sigquit, 0 /* additionalFlags */, true /* skipIgnored */);
184184

185-
#if HAVE_MACH_EXCEPTIONS
185+
#if HAVE_MACH_EXCEPTIONS || defined(TARGET_TVOS)
186186
handle_signal(SIGSEGV, sigsegv_handler, &g_previous_sigsegv);
187187
#else
188188
handle_signal(SIGTRAP, sigtrap_handler, &g_previous_sigtrap);
@@ -471,7 +471,15 @@ static void sigfpe_handler(int code, siginfo_t *siginfo, void *context)
471471
invoke_previous_action(&g_previous_sigfpe, code, siginfo, context);
472472
}
473473

474-
#if !HAVE_MACH_EXCEPTIONS
474+
#if defined(TARGET_TVOS)
475+
476+
static bool SwitchStackAndExecuteHandler(int code, siginfo_t *siginfo, void *context, size_t sp)
477+
{
478+
// Not yet implemented
479+
_exit(0xdead);
480+
}
481+
482+
#elif !HAVE_MACH_EXCEPTIONS
475483

476484
/*++
477485
Function :

src/coreclr/pal/src/include/pal/thread.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ namespace CorUnix
588588
m_pNext = pNext;
589589
};
590590

591-
#if !HAVE_MACH_EXCEPTIONS
591+
#if !HAVE_MACH_EXCEPTIONS && !defined(TARGET_TVOS)
592592
BOOL
593593
EnsureSignalAlternateStack(
594594
void

src/coreclr/pal/src/init/sxs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ AllocatePalThread(CPalThread **ppThread)
6464
goto exit;
6565
}
6666

67-
#if !HAVE_MACH_EXCEPTIONS
67+
#if !HAVE_MACH_EXCEPTIONS && !defined(TARGET_TVOS)
6868
// Ensure alternate stack for SIGSEGV handling. Our SIGSEGV handler is set to
6969
// run on an alternate stack and the stack needs to be allocated per thread.
7070
if (!pThread->EnsureSignalAlternateStack())

src/coreclr/pal/src/misc/sysinfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Revision History:
6565
#include <mach/mach_host.h>
6666
#endif // defined(TARGET_APPLE)
6767

68-
#if !defined(TARGET_IOS)
68+
#if !defined(TARGET_IOS) && !defined(TARGET_TVOS)
6969
// On some platforms sys/user.h ends up defining _DEBUG; if so
7070
// remove the definition before including the header and put
7171
// back our definition afterwards
@@ -79,7 +79,7 @@ Revision History:
7979
#define _DEBUG OLD_DEBUG
8080
#undef OLD_DEBUG
8181
#endif
82-
#endif // !TARGET_IOS
82+
#endif // !TARGET_IOS && !TARGET_TVOS
8383

8484
#include "pal/dbgmsg.h"
8585
#include "pal/process.h"

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ CorUnix::InternalCreateProcess(
545545
LPPROCESS_INFORMATION lpProcessInformation
546546
)
547547
{
548+
#ifdef TARGET_TVOS
549+
return ERROR_NOT_SUPPORTED;
550+
#else
548551
PAL_ERROR palError = NO_ERROR;
549552
IPalObject *pobjProcess = NULL;
550553
IPalObject *pobjProcessRegistered = NULL;
@@ -1081,6 +1084,7 @@ CorUnix::InternalCreateProcess(
10811084
}
10821085

10831086
return palError;
1087+
#endif // !TARGET_TVOS
10841088
}
10851089

10861090

@@ -2195,6 +2199,9 @@ PROCCreateCrashDump(
21952199
INT cbErrorMessageBuffer,
21962200
bool serialize)
21972201
{
2202+
#if defined(TARGET_IOS) || defined(TARGET_TVOS)
2203+
return FALSE;
2204+
#else
21982205
_ASSERTE(argv.size() > 0);
21992206
_ASSERTE(errorMessageBuffer == nullptr || cbErrorMessageBuffer > 0);
22002207

@@ -2319,6 +2326,7 @@ PROCCreateCrashDump(
23192326
}
23202327
}
23212328
return true;
2329+
#endif // !TARGET_IOS && !TARGET_TVOS
23222330
}
23232331

23242332
/*++

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static void InternalEndCurrentThreadWrapper(void *arg)
173173
will lock its own critical section */
174174
LOADCallDllMain(DLL_THREAD_DETACH, NULL);
175175

176-
#if !HAVE_MACH_EXCEPTIONS
176+
#if !HAVE_MACH_EXCEPTIONS && !defined(TARGET_TVOS)
177177
pThread->FreeSignalAlternateStack();
178178
#endif // !HAVE_MACH_EXCEPTIONS
179179

@@ -1683,7 +1683,7 @@ CPalThread::ThreadEntry(
16831683
}
16841684
#endif // HAVE_SCHED_GETAFFINITY && HAVE_SCHED_SETAFFINITY
16851685

1686-
#if !HAVE_MACH_EXCEPTIONS
1686+
#if !HAVE_MACH_EXCEPTIONS && !defined(TARGET_TVOS)
16871687
if (!pThread->EnsureSignalAlternateStack())
16881688
{
16891689
ASSERT("Cannot allocate alternate stack for SIGSEGV!\n");
@@ -2406,7 +2406,7 @@ CPalThread::WaitForStartStatus(
24062406
return m_fStartStatus;
24072407
}
24082408

2409-
#if !HAVE_MACH_EXCEPTIONS
2409+
#if !HAVE_MACH_EXCEPTIONS && !defined(TARGET_TVOS)
24102410
/*++
24112411
Function :
24122412
EnsureSignalAlternateStack

src/native/corehost/apphost/static/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ else()
144144

145145
System.Globalization.Native-Static
146146
System.IO.Compression.Native-Static
147-
System.Net.Security.Native-Static
148147
System.Native-Static
149148

150149
palrt
@@ -155,6 +154,10 @@ else()
155154
nativeresourcestring
156155
)
157156

157+
if(NOT CLR_CMAKE_TARGET_TVOS)
158+
LIST(APPEND NATIVE_LIBS System.Net.Security.Native-Static)
159+
endif()
160+
158161
if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_HOST_ANDROID)
159162
LIST(APPEND NATIVE_LIBS System.Security.Cryptography.Native.OpenSsl-Static)
160163
endif()

src/native/corehost/hostpolicy/hostpolicy_context.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ namespace
6060
// This function is only called with the library name specified for a p/invoke, not any variations.
6161
// It must handle exact matches to the names specified. See Interop.Libraries.cs for each platform.
6262
#if !defined(_WIN32)
63+
#if !defined(TARGET_TVOS)
6364
if (strcmp(library_name, LIB_NAME("System.Net.Security.Native")) == 0)
6465
{
6566
return SecurityResolveDllImport(entry_point_name);
6667
}
68+
#endif
6769

6870
if (strcmp(library_name, LIB_NAME("System.Native")) == 0)
6971
{

0 commit comments

Comments
 (0)