summaryrefslogtreecommitdiffstats
path: root/nsprpub/pr/src/md
diff options
context:
space:
mode:
Diffstat (limited to 'nsprpub/pr/src/md')
-rw-r--r--nsprpub/pr/src/md/.cvsignore1
-rw-r--r--nsprpub/pr/src/md/beos/.cvsignore1
-rw-r--r--nsprpub/pr/src/md/os2/.cvsignore1
-rw-r--r--nsprpub/pr/src/md/unix/.cvsignore1
-rw-r--r--nsprpub/pr/src/md/unix/unix.c36
-rw-r--r--nsprpub/pr/src/md/unix/uxproces.c4
-rw-r--r--nsprpub/pr/src/md/windows/.cvsignore1
-rw-r--r--nsprpub/pr/src/md/windows/ntthread.c23
-rw-r--r--nsprpub/pr/src/md/windows/w95sock.c5
-rw-r--r--nsprpub/pr/src/md/windows/w95thred.c51
-rw-r--r--nsprpub/pr/src/md/windows/win32_errors.c8
11 files changed, 107 insertions, 25 deletions
diff --git a/nsprpub/pr/src/md/.cvsignore b/nsprpub/pr/src/md/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/nsprpub/pr/src/md/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/nsprpub/pr/src/md/beos/.cvsignore b/nsprpub/pr/src/md/beos/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/nsprpub/pr/src/md/beos/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/nsprpub/pr/src/md/os2/.cvsignore b/nsprpub/pr/src/md/os2/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/nsprpub/pr/src/md/os2/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/nsprpub/pr/src/md/unix/.cvsignore b/nsprpub/pr/src/md/unix/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/nsprpub/pr/src/md/unix/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/nsprpub/pr/src/md/unix/unix.c b/nsprpub/pr/src/md/unix/unix.c
index 662f561b6..7c90b5075 100644
--- a/nsprpub/pr/src/md/unix/unix.c
+++ b/nsprpub/pr/src/md/unix/unix.c
@@ -2713,8 +2713,13 @@ static void* _MD_Unix_mmap64(
} /* _MD_Unix_mmap64 */
#endif /* defined(_PR_NO_LARGE_FILES) || defined(SOLARIS2_5) */
-/* Android <= 19 doesn't have mmap64. */
-#if defined(ANDROID) && __ANDROID_API__ <= 19
+/* NDK non-unified headers for API < 21 don't have mmap64. However,
+ * NDK unified headers do provide mmap64 for all API versions when building
+ * with clang. Therefore, we should provide mmap64 here for API < 21 if we're
+ * not using clang or if we're using non-unified headers. We check for
+ * non-unified headers by the lack of __ANDROID_API_L__ macro. */
+#if defined(ANDROID) && __ANDROID_API__ < 21 && \
+ (!defined(__clang__) || !defined(__ANDROID_API_L__))
PR_IMPORT(void) *__mmap2(void *, size_t, int, int, int, size_t);
#define ANDROID_PAGE_SIZE 4096
@@ -2784,9 +2789,9 @@ static void _PR_InitIOV(void)
_md_iovector._stat64 = stat;
_md_iovector._lseek64 = _MD_Unix_lseek64;
#elif defined(_PR_HAVE_OFF64_T)
-#if defined(IRIX5_3) || defined(ANDROID)
+#if defined(IRIX5_3) || (defined(ANDROID) && __ANDROID_API__ < 21)
/*
- * Android doesn't have open64. We pass the O_LARGEFILE flag to open
+ * Android < 21 doesn't have open64. We pass the O_LARGEFILE flag to open
* in _MD_open.
*/
_md_iovector._open64 = open;
@@ -2794,8 +2799,14 @@ static void _PR_InitIOV(void)
_md_iovector._open64 = open64;
#endif
_md_iovector._mmap64 = mmap64;
+#if (defined(ANDROID) && __ANDROID_API__ < 21)
+ /* Same as the open64 case for Android. */
+ _md_iovector._fstat64 = fstat;
+ _md_iovector._stat64 = stat;
+#else
_md_iovector._fstat64 = fstat64;
_md_iovector._stat64 = stat64;
+#endif
_md_iovector._lseek64 = lseek64;
#elif defined(_PR_HAVE_LARGE_OFF_T)
_md_iovector._open64 = open;
@@ -2854,28 +2865,11 @@ void _PR_UnixInit(void)
#endif
#endif /* !defined(_PR_PTHREADS) */
- /*
- * Under HP-UX DCE threads, sigaction() installs a per-thread
- * handler, so we use sigvector() to install a process-wide
- * handler.
- */
-#if defined(HPUX) && defined(_PR_DCETHREADS)
- {
- struct sigvec vec;
-
- vec.sv_handler = SIG_IGN;
- vec.sv_mask = 0;
- vec.sv_flags = 0;
- rv = sigvector(SIGPIPE, &vec, NULL);
- PR_ASSERT(0 == rv);
- }
-#else
sigact.sa_handler = SIG_IGN;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
rv = sigaction(SIGPIPE, &sigact, 0);
PR_ASSERT(0 == rv);
-#endif /* HPUX && _PR_DCETHREADS */
_pr_rename_lock = PR_NewLock();
PR_ASSERT(NULL != _pr_rename_lock);
diff --git a/nsprpub/pr/src/md/unix/uxproces.c b/nsprpub/pr/src/md/unix/uxproces.c
index 5286b9e18..18f23fde8 100644
--- a/nsprpub/pr/src/md/unix/uxproces.c
+++ b/nsprpub/pr/src/md/unix/uxproces.c
@@ -685,10 +685,6 @@ static void pr_SigchldHandler(int sig)
static void pr_InstallSigchldHandler()
{
-#if defined(HPUX) && defined(_PR_DCETHREADS)
-#error "HP-UX DCE threads have their own SIGCHLD handler"
-#endif
-
struct sigaction act, oact;
int rv;
diff --git a/nsprpub/pr/src/md/windows/.cvsignore b/nsprpub/pr/src/md/windows/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/nsprpub/pr/src/md/windows/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/nsprpub/pr/src/md/windows/ntthread.c b/nsprpub/pr/src/md/windows/ntthread.c
index fead1236d..1fdf0e93b 100644
--- a/nsprpub/pr/src/md/windows/ntthread.c
+++ b/nsprpub/pr/src/md/windows/ntthread.c
@@ -27,6 +27,9 @@ PRUint32 _nt_idleCount;
extern __declspec(thread) PRThread *_pr_io_restarted_io;
extern DWORD _pr_io_restartedIOIndex;
+typedef HRESULT (WINAPI *SETTHREADDESCRIPTION)(HANDLE, PCWSTR);
+static SETTHREADDESCRIPTION sSetThreadDescription = NULL;
+
/* Must check the restarted_io *before* decrementing no_sched to 0 */
#define POST_SWITCH_WORK() \
PR_BEGIN_MACRO \
@@ -79,6 +82,8 @@ _nt_handle_restarted_io(PRThread *restarted_io)
void
_PR_MD_EARLY_INIT()
{
+ HMODULE hModule;
+
_MD_NEW_LOCK( &_nt_idleLock );
_nt_idleCount = 0;
PR_INIT_CLIST(&_nt_idleList);
@@ -98,6 +103,15 @@ _PR_MD_EARLY_INIT()
_pr_intsOffIndex = TlsAlloc();
_pr_io_restartedIOIndex = TlsAlloc();
}
+
+ // SetThreadDescription is Windows 10 build 1607+
+ hModule = GetModuleHandleW(L"kernel32.dll");
+ if (hModule) {
+ sSetThreadDescription =
+ (SETTHREADDESCRIPTION) GetProcAddress(
+ hModule,
+ "SetThreadDescription");
+ }
}
void _PR_MD_CLEANUP_BEFORE_EXIT(void)
@@ -293,7 +307,16 @@ _PR_MD_SET_CURRENT_THREAD_NAME(const char *name)
{
#ifdef _MSC_VER
THREADNAME_INFO info;
+#endif
+
+ if (sSetThreadDescription) {
+ WCHAR wideName[MAX_PATH];
+ if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {
+ sSetThreadDescription(GetCurrentThread(), wideName);
+ }
+ }
+#ifdef _MSC_VER
if (!IsDebuggerPresent())
return;
diff --git a/nsprpub/pr/src/md/windows/w95sock.c b/nsprpub/pr/src/md/windows/w95sock.c
index 0429c655a..c6a3ec111 100644
--- a/nsprpub/pr/src/md/windows/w95sock.c
+++ b/nsprpub/pr/src/md/windows/w95sock.c
@@ -382,6 +382,11 @@ PRInt32
_PR_MD_TCPSENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout)
{
+ if (!_fd_waiting_for_overlapped_done_lock) {
+ PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
+ return PR_FAILURE;
+ }
+
if (PR_CallOnce(&_pr_has_connectex_once, _pr_set_connectex) != PR_SUCCESS) {
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
return PR_FAILURE;
diff --git a/nsprpub/pr/src/md/windows/w95thred.c b/nsprpub/pr/src/md/windows/w95thred.c
index c27d982a7..a365411f5 100644
--- a/nsprpub/pr/src/md/windows/w95thred.c
+++ b/nsprpub/pr/src/md/windows/w95thred.c
@@ -1,3 +1,4 @@
+
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -27,14 +28,32 @@ DWORD _pr_currentCPUIndex;
int _pr_intsOff = 0;
_PRInterruptTable _pr_interruptTable[] = { { 0 } };
+typedef HRESULT (WINAPI *SETTHREADDESCRIPTION)(HANDLE, PCWSTR);
+static SETTHREADDESCRIPTION sSetThreadDescription = NULL;
+
void
_PR_MD_EARLY_INIT()
{
+ HMODULE hModule;
+
#ifndef _PR_USE_STATIC_TLS
_pr_currentThreadIndex = TlsAlloc();
_pr_lastThreadIndex = TlsAlloc();
_pr_currentCPUIndex = TlsAlloc();
#endif
+
+#if defined(_WIN64) && defined(WIN95)
+ _fd_waiting_for_overlapped_done_lock = PR_NewLock();
+#endif
+
+ // SetThreadDescription is Windows 10 build 1607+
+ hModule = GetModuleHandleW(L"kernel32.dll");
+ if (hModule) {
+ sSetThreadDescription =
+ (SETTHREADDESCRIPTION) GetProcAddress(
+ hModule,
+ "SetThreadDescription");
+ }
}
void _PR_MD_CLEANUP_BEFORE_EXIT(void)
@@ -50,6 +69,29 @@ void _PR_MD_CLEANUP_BEFORE_EXIT(void)
TlsFree(_pr_lastThreadIndex);
TlsFree(_pr_currentCPUIndex);
#endif
+
+#if defined(_WIN64) && defined(WIN95)
+ // For each iteration check if TFO overlapped IOs are down.
+ if (_fd_waiting_for_overlapped_done_lock) {
+ PRIntervalTime delay = PR_MillisecondsToInterval(1000);
+ PRFileDescList *cur;
+ do {
+ CheckOverlappedPendingSocketsAreDone();
+
+ PR_Lock(_fd_waiting_for_overlapped_done_lock);
+ cur = _fd_waiting_for_overlapped_done;
+ PR_Unlock(_fd_waiting_for_overlapped_done_lock);
+#if defined(DO_NOT_WAIT_FOR_CONNECT_OVERLAPPED_OPERATIONS)
+ cur = NULL;
+#endif
+ if (cur) {
+ PR_Sleep(delay); // wait another 1s.
+ }
+ } while (cur);
+
+ PR_DestroyLock(_fd_waiting_for_overlapped_done_lock);
+ }
+#endif
}
PRStatus
@@ -190,7 +232,16 @@ _PR_MD_SET_CURRENT_THREAD_NAME(const char *name)
{
#ifdef _MSC_VER
THREADNAME_INFO info;
+#endif
+
+ if (sSetThreadDescription) {
+ WCHAR wideName[MAX_PATH];
+ if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {
+ sSetThreadDescription(GetCurrentThread(), wideName);
+ }
+ }
+#ifdef _MSC_VER
if (!IsDebuggerPresent())
return;
diff --git a/nsprpub/pr/src/md/windows/win32_errors.c b/nsprpub/pr/src/md/windows/win32_errors.c
index d26820a7a..275792187 100644
--- a/nsprpub/pr/src/md/windows/win32_errors.c
+++ b/nsprpub/pr/src/md/windows/win32_errors.c
@@ -166,21 +166,26 @@ void _MD_win32_map_default_error(PRInt32 err)
prError = PR_ADDRESS_IN_USE_ERROR;
break;
case WSAEADDRNOTAVAIL:
+ case ERROR_INVALID_NETNAME:
prError = PR_ADDRESS_NOT_AVAILABLE_ERROR;
break;
case WSAEAFNOSUPPORT:
+ case ERROR_INCORRECT_ADDRESS:
prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
break;
case WSAEALREADY:
+ case ERROR_ALREADY_INITIALIZED:
prError = PR_ALREADY_INITIATED_ERROR;
break;
case WSAEBADF:
prError = PR_BAD_DESCRIPTOR_ERROR;
break;
case WSAECONNABORTED:
+ case ERROR_CONNECTION_ABORTED:
prError = PR_CONNECT_ABORTED_ERROR;
break;
case WSAECONNREFUSED:
+ case ERROR_CONNECTION_REFUSED:
prError = PR_CONNECT_REFUSED_ERROR;
break;
case WSAECONNRESET:
@@ -193,6 +198,7 @@ void _MD_win32_map_default_error(PRInt32 err)
prError = PR_ACCESS_FAULT_ERROR;
break;
case WSAEHOSTUNREACH:
+ case ERROR_HOST_UNREACHABLE:
prError = PR_HOST_UNREACHABLE_ERROR;
break;
case WSAEINVAL:
@@ -208,12 +214,14 @@ void _MD_win32_map_default_error(PRInt32 err)
prError = PR_BUFFER_OVERFLOW_ERROR;
break;
case WSAENETDOWN:
+ case ERROR_NO_NETWORK:
prError = PR_NETWORK_DOWN_ERROR;
break;
case WSAENETRESET:
prError = PR_CONNECT_ABORTED_ERROR;
break;
case WSAENETUNREACH:
+ case ERROR_NETWORK_UNREACHABLE:
prError = PR_NETWORK_UNREACHABLE_ERROR;
break;
case WSAENOBUFS: