From b08f5441725d6e1232acbcb7dfd970da2d113b39 Mon Sep 17 00:00:00 2001 From: wuggy Date: Wed, 9 Sep 2026 12:00:04 -0700 Subject: [PATCH 1/3] Simplify class selector result collection --- dom/base/nsINode.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 740c18417f..abfa901d80 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -2927,12 +2927,11 @@ FindMatchingElementsWithId(const nsAString& aId, nsINode* aRoot, // Actually find elements matching aSelectorList (which must not be // null) and which are descendants of aRoot and put them in aList. If // onlyFirstMatch, then stop once the first one is found. -template +template static void FindMatchingElementsWithClass(nsINode* aRoot, nsIAtom* aClass, nsCaseTreatment aCaseTreatment, T& aList) { - Collector results; for (nsIContent* cur = aRoot->GetFirstChild(); cur; cur = cur->GetNextNode(aRoot)) { if (!cur->IsElement()) { @@ -2944,14 +2943,7 @@ FindMatchingElementsWithClass(nsINode* aRoot, nsIAtom* aClass, aList.AppendElement(cur->AsElement()); return; } - results.AppendElement(cur->AsElement()); - } - } - const uint32_t len = results.Length(); - if (len) { - aList.SetCapacity(len); - for (uint32_t i = 0; i < len; ++i) { - aList.AppendElement(results.ElementAt(i)); + aList.AppendElement(cur->AsElement()); } } } @@ -2975,7 +2967,7 @@ FindMatchingElements(nsINode* aRoot, nsCSSSelectorList* aSelectorList, T &aList, nsCaseTreatment caseTreatment = doc->GetCompatibilityMode() == eCompatibility_NavQuirks ? eIgnoreCase : eCaseMatters; - FindMatchingElementsWithClass( + FindMatchingElementsWithClass( aRoot, selector->mClassList->mAtom, caseTreatment, aList); return; } From 1d44f05fba7fe7ca6133701afaa9801706318b3b Mon Sep 17 00:00:00 2001 From: wuggy Date: Thu, 10 Sep 2026 08:32:59 -0700 Subject: [PATCH 2/3] clang on windows support --- config/external/lgpllibs/moz.build | 6 ++ config/external/nss/Makefile.in | 8 ++- db/sqlite3/src/sqlite3.c | 5 ++ dom/plugins/ipc/PluginInstanceChild.cpp | 4 +- dom/workers/ServiceWorkerPrivate.cpp | 2 +- gfx/cairo/cairo/src/cairo-d2d-surface.cpp | 6 +- media/ffvpx/libavcodec/moz.build | 7 ++ media/ffvpx/libavutil/atomic_win32.h | 3 +- media/libdav1d/src/src/cpu.c | 20 +++++- media/libdav1d/src/src/thread.h | 56 ++++++++------- media/libdav1d/src/src/win32/thread.c | 72 +++++++++++++++++-- media/libsoundtouch/src/moz.build | 3 + media/libstagefright/moz.build | 3 +- .../system/core/liblog/logprint.c | 10 +++ modules/zlib/src/moz.build | 9 +++ modules/zlib/src/x86.c | 6 +- mozconfigs/windows/uxp-win64-clang | 7 +- nsprpub/pr/src/io/prsocket.c | 8 +-- nsprpub/pr/src/md/windows/ntmisc.c | 11 +-- nsprpub/pr/src/md/windows/w95io.c | 4 +- nsprpub/pr/src/md/windows/w95sock.c | 10 +-- old-configure.in | 15 +++- 22 files changed, 209 insertions(+), 66 deletions(-) diff --git a/config/external/lgpllibs/moz.build b/config/external/lgpllibs/moz.build index be913e933e..f8df7687d7 100644 --- a/config/external/lgpllibs/moz.build +++ b/config/external/lgpllibs/moz.build @@ -11,3 +11,9 @@ GeckoSharedLibrary('lgpllibs', linkage=None) SHARED_LIBRARY_NAME = 'lgpllibs' + +if CONFIG['CLANG_CL']: + # SoundTouch uses clang's OpenMP runtime. Link its import library into the + # containing LGPL DLL and place the runtime beside the browser binaries. + OS_LIBS += ['C:/clang/lib/libomp'] + FINAL_TARGET_FILES += ['C:/clang/bin/libomp.dll'] diff --git a/config/external/nss/Makefile.in b/config/external/nss/Makefile.in index 7289e57f4c..1b3b51ccd2 100644 --- a/config/external/nss/Makefile.in +++ b/config/external/nss/Makefile.in @@ -262,6 +262,13 @@ ifeq (WINNT,$(OS_TARGET)) NSS_XCFLAGS += $(filter -arch:%,$(CFLAGS)) endif +# freebl's x86 AES/GCM sources use AES-NI and PCLMUL intrinsics. The nested +# NSS build's per-object flags are not propagated through this wrapper when +# using clang-cl, so pass them explicitly. +ifeq (1,$(CLANG_CL)) +NSS_XCFLAGS += -maes -mpclmul +endif + # Enable short header experiment. Firefox only. NSS_XCFLAGS += -DNSS_ENABLE_TLS13_SHORT_HEADERS @@ -466,4 +473,3 @@ endif # MOZ_FOLD_LIBS # Work around NSS build system race condition creating certdata.c in # security/nss/lib/ckfw/builtins. See bug #836220. libs-nss/lib$(if $(MOZ_FOLD_LIBS),/ckfw): $(call mkdir_deps,$(DEPTH)/security/nss/lib/ckfw/builtins) - diff --git a/db/sqlite3/src/sqlite3.c b/db/sqlite3/src/sqlite3.c index 49a4256b0c..c92130c251 100644 --- a/db/sqlite3/src/sqlite3.c +++ b/db/sqlite3/src/sqlite3.c @@ -27219,6 +27219,11 @@ static malloc_zone_t* _sqliteZone_; #if HAVE_MALLOC_H && HAVE_MALLOC_USABLE_SIZE # define SQLITE_USE_MALLOC_H 1 # define SQLITE_USE_MALLOC_USABLE_SIZE 1 +# if defined(_WIN32) + /* Mozilla's jemalloc wrapper provides this symbol, but the Windows + * malloc.h does not declare it for clang-cl. */ + extern size_t malloc_usable_size(void *); +# endif /* ** The MSVCRT has malloc_usable_size(), but it is called _msize(). The ** use of _msize() is automatic, but can be disabled by compiling with diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index cdb27508e9..a262dbc98b 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -3694,12 +3694,12 @@ PluginInstanceChild::UpdateWindowAttributes(bool aForceSetWindow) WINDOWPOS winpos = { 0, 0, mWindow.x, mWindow.y, - mWindow.width, mWindow.height, + static_cast(mWindow.width), static_cast(mWindow.height), 0 }; NPEvent pluginEvent = { WM_WINDOWPOSCHANGED, 0, - (LPARAM) &winpos + reinterpret_cast(&winpos) }; mPluginIface->event(&mData, &pluginEvent); } diff --git a/dom/workers/ServiceWorkerPrivate.cpp b/dom/workers/ServiceWorkerPrivate.cpp index 9e7b855efc..26fb6da024 100644 --- a/dom/workers/ServiceWorkerPrivate.cpp +++ b/dom/workers/ServiceWorkerPrivate.cpp @@ -1355,7 +1355,7 @@ public: rv = httpChannel->GetReferrerPolicy(&referrerPolicy); NS_ENSURE_SUCCESS(rv, rv); switch (referrerPolicy) { - case nsIHttpChannel::REFERRER_POLICY_UNSET: + case static_cast(nsIHttpChannel::REFERRER_POLICY_UNSET): mReferrerPolicy = ReferrerPolicy::_empty; break; case nsIHttpChannel::REFERRER_POLICY_NO_REFERRER: diff --git a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp index 6aa8a3503c..d5e4365494 100644 --- a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp +++ b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp @@ -2774,7 +2774,7 @@ _cairo_d2d_copy_surface(cairo_d2d_surface_t *dst, cairo_rectangle_int_t transformed_rect = { area_to_copy.x + translation->x, area_to_copy.y + translation->y, area_to_copy.width, area_to_copy.height }; - cairo_rectangle_int_t surface_rect = { 0, 0, srcDesc.Width, srcDesc.Height }; + cairo_rectangle_int_t surface_rect = { 0, 0, static_cast(srcDesc.Width), static_cast(srcDesc.Height) }; if (!_cairo_rectangle_contains(&surface_rect, &transformed_rect)) { @@ -2989,8 +2989,8 @@ _cairo_d2d_try_fastblit(cairo_d2d_surface_t *dst, // Areas outside of the surface do not matter. cairo_rectangle_int_t surface_rect = { 0, 0, - dst->rt->GetPixelSize().width, - dst->rt->GetPixelSize().height }; + static_cast(dst->rt->GetPixelSize().width), + static_cast(dst->rt->GetPixelSize().height) }; cairo_region_intersect_rectangle(region, &surface_rect); } diff --git a/media/ffvpx/libavcodec/moz.build b/media/ffvpx/libavcodec/moz.build index 5d85b64cf2..6c63745d35 100644 --- a/media/ffvpx/libavcodec/moz.build +++ b/media/ffvpx/libavcodec/moz.build @@ -162,6 +162,13 @@ SOURCES += [ 'xiph.c' ] +# dummy_funcs.c intentionally provides tentative definitions for FFmpeg +# objects that are disabled by the generated configuration. Clang's default +# -fno-common turns those placeholders into duplicate definitions when an +# enabled codec supplies the real object. +if CONFIG['CLANG_CL']: + SOURCES['dummy_funcs.c'].flags += ['-fcommon'] + SYMBOLS_FILE = 'avcodec.symbols' NO_VISIBILITY_FLAGS = True diff --git a/media/ffvpx/libavutil/atomic_win32.h b/media/ffvpx/libavutil/atomic_win32.h index f7299336f6..d702b7e454 100644 --- a/media/ffvpx/libavutil/atomic_win32.h +++ b/media/ffvpx/libavutil/atomic_win32.h @@ -41,7 +41,8 @@ static inline void atomic_int_set_win32(volatile int *ptr, int val) #define avpriv_atomic_int_add_and_fetch atomic_int_add_and_fetch_win32 static inline int atomic_int_add_and_fetch_win32(volatile int *ptr, int inc) { - return inc + InterlockedExchangeAdd(ptr, inc); + /* Windows int and LONG are both 32-bit, but have distinct C types. */ + return inc + InterlockedExchangeAdd((volatile LONG *)ptr, inc); } #define avpriv_atomic_ptr_cas atomic_ptr_cas_win32 diff --git a/media/libdav1d/src/src/cpu.c b/media/libdav1d/src/src/cpu.c index 6b57fe4a97..d41fe5d84e 100644 --- a/media/libdav1d/src/src/cpu.c +++ b/media/libdav1d/src/src/cpu.c @@ -85,10 +85,24 @@ COLD int dav1d_num_logical_processors(Dav1dContext *const c) { #ifdef _WIN32 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) GROUP_AFFINITY affinity; - if (GetThreadGroupAffinity(GetCurrentThread(), &affinity)) { - int num_processors = 1; - while (affinity.Mask &= affinity.Mask - 1) + DWORD_PTR mask = 0, system_mask; + HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll"); + typedef BOOL (WINAPI *get_thread_group_affinity_fn)(HANDLE, PGROUP_AFFINITY); + get_thread_group_affinity_fn get_thread_group_affinity = kernel32 ? + (get_thread_group_affinity_fn)GetProcAddress(kernel32, "GetThreadGroupAffinity") : NULL; + + /* Processor groups are only available on Windows 7 and later. */ + if (get_thread_group_affinity && + get_thread_group_affinity(GetCurrentThread(), &affinity)) + mask = affinity.Mask; + else if (!GetProcessAffinityMask(GetCurrentProcess(), &mask, &system_mask)) + mask = 0; + + if (mask) { + int num_processors = 0; + do { num_processors++; + } while (mask &= mask - 1); return num_processors; } #else diff --git a/media/libdav1d/src/src/thread.h b/media/libdav1d/src/src/thread.h index 459aaced66..fb5eeed31a 100644 --- a/media/libdav1d/src/src/thread.h +++ b/media/libdav1d/src/src/thread.h @@ -33,8 +33,8 @@ #include #include -#define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT -#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT +#define PTHREAD_MUTEX_INITIALIZER { 0 } +#define PTHREAD_ONCE_INIT 0 typedef struct { HANDLE h; @@ -46,9 +46,16 @@ typedef struct { unsigned stack_size; } pthread_attr_t; -typedef SRWLOCK pthread_mutex_t; -typedef CONDITION_VARIABLE pthread_cond_t; -typedef INIT_ONCE pthread_once_t; +typedef struct { + volatile LONG state; + CRITICAL_SECTION cs; +} pthread_mutex_t; +struct dav1d_cond_waiter; +typedef struct { + CRITICAL_SECTION cs; + struct dav1d_cond_waiter *head; +} pthread_cond_t; +typedef volatile LONG pthread_once_t; void dav1d_init_thread(void); void dav1d_set_thread_name(const wchar_t *name); @@ -84,50 +91,51 @@ static inline int pthread_attr_setstacksize(pthread_attr_t *const attr, static inline int pthread_mutex_init(pthread_mutex_t *const mutex, const void *const attr) { - InitializeSRWLock(mutex); + mutex->state = 0; return 0; } static inline int pthread_mutex_destroy(pthread_mutex_t *const mutex) { + if (mutex->state == 2) DeleteCriticalSection(&mutex->cs); return 0; } static inline int pthread_mutex_lock(pthread_mutex_t *const mutex) { - AcquireSRWLockExclusive(mutex); + if (InterlockedCompareExchange(&mutex->state, 1, 0) == 0) { + InitializeCriticalSection(&mutex->cs); + InterlockedExchange(&mutex->state, 2); + } else { + while (InterlockedCompareExchange(&mutex->state, 2, 2) != 2) + Sleep(1); + } + EnterCriticalSection(&mutex->cs); return 0; } static inline int pthread_mutex_unlock(pthread_mutex_t *const mutex) { - ReleaseSRWLockExclusive(mutex); + LeaveCriticalSection(&mutex->cs); return 0; } static inline int pthread_cond_init(pthread_cond_t *const cond, const void *const attr) { - InitializeConditionVariable(cond); + InitializeCriticalSection(&cond->cs); + cond->head = NULL; return 0; } static inline int pthread_cond_destroy(pthread_cond_t *const cond) { + DeleteCriticalSection(&cond->cs); return 0; } -static inline int pthread_cond_wait(pthread_cond_t *const cond, - pthread_mutex_t *const mutex) -{ - return !SleepConditionVariableSRW(cond, mutex, INFINITE, 0); -} - -static inline int pthread_cond_signal(pthread_cond_t *const cond) { - WakeConditionVariable(cond); - return 0; -} - -static inline int pthread_cond_broadcast(pthread_cond_t *const cond) { - WakeAllConditionVariable(cond); - return 0; -} +#define pthread_cond_wait dav1d_pthread_cond_wait +#define pthread_cond_signal dav1d_pthread_cond_signal +#define pthread_cond_broadcast dav1d_pthread_cond_broadcast +int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); +int pthread_cond_signal(pthread_cond_t *cond); +int pthread_cond_broadcast(pthread_cond_t *cond); #else diff --git a/media/libdav1d/src/src/win32/thread.c b/media/libdav1d/src/src/win32/thread.c index b89bd6b165..18b112ee36 100644 --- a/media/libdav1d/src/src/win32/thread.c +++ b/media/libdav1d/src/src/win32/thread.c @@ -85,15 +85,73 @@ COLD int dav1d_pthread_join(pthread_t *const thread, void **const res) { COLD int dav1d_pthread_once(pthread_once_t *const once_control, void (*const init_routine)(void)) { - BOOL pending = FALSE; - - if (InitOnceBeginInitialize(once_control, 0, &pending, NULL) != TRUE) - return 1; - - if (pending == TRUE) + if (InterlockedCompareExchange(once_control, 1, 0) == 0) { init_routine(); + InterlockedExchange(once_control, 2); + } else { + while (InterlockedCompareExchange(once_control, 2, 2) != 2) + Sleep(1); + } + return 0; +} - return !InitOnceComplete(once_control, 0, NULL); +/* Each waiter owns an event. Queue operations and signalling share a lock, + * so a new waiter cannot consume an earlier waiter's notification. */ +struct dav1d_cond_waiter { + HANDLE event; + struct dav1d_cond_waiter *next; +}; + +int dav1d_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { + struct dav1d_cond_waiter waiter, **link; + DWORD result; + waiter.event = CreateEventW(NULL, FALSE, FALSE, NULL); + if (!waiter.event) return 1; + EnterCriticalSection(&cond->cs); + waiter.next = NULL; + for (link = &cond->head; *link; link = &(*link)->next) {} + *link = &waiter; + pthread_mutex_unlock(mutex); + LeaveCriticalSection(&cond->cs); + + result = WaitForSingleObject(waiter.event, INFINITE); + EnterCriticalSection(&cond->cs); + /* Also unlink on wait failure before the stack record goes away. */ + for (link = &cond->head; *link; link = &(*link)->next) { + if (*link == &waiter) { + *link = waiter.next; + break; + } + } + CloseHandle(waiter.event); + LeaveCriticalSection(&cond->cs); + pthread_mutex_lock(mutex); + return result != WAIT_OBJECT_0; +} + +int dav1d_pthread_cond_signal(pthread_cond_t *cond) { + int result = 0; + EnterCriticalSection(&cond->cs); + if (cond->head) { + if (SetEvent(cond->head->event)) cond->head = cond->head->next; + else result = 1; + } + LeaveCriticalSection(&cond->cs); + return result; +} + +int dav1d_pthread_cond_broadcast(pthread_cond_t *cond) { + int result = 0; + EnterCriticalSection(&cond->cs); + while (cond->head) { + if (!SetEvent(cond->head->event)) { + result = 1; + break; + } + cond->head = cond->head->next; + } + LeaveCriticalSection(&cond->cs); + return result; } #endif diff --git a/media/libsoundtouch/src/moz.build b/media/libsoundtouch/src/moz.build index b24e88eb0b..ab0fd227ce 100644 --- a/media/libsoundtouch/src/moz.build +++ b/media/libsoundtouch/src/moz.build @@ -47,6 +47,9 @@ if CONFIG['CC_TYPE'] == 'gcc': OS_LIBS += ['gomp'] if CONFIG['OS_ARCH'] == 'WINNT': OS_LIBS += ['dl'] +elif CONFIG['CLANG_CL']: + # clang-cl lowers OpenMP pragmas to the LLVM OpenMP runtime. + CXXFLAGS += ['-fopenmp'] DEFINES['BUILDING_SOUNDTOUCH'] = 1 diff --git a/media/libstagefright/moz.build b/media/libstagefright/moz.build index a8876638aa..e010ca2a48 100644 --- a/media/libstagefright/moz.build +++ b/media/libstagefright/moz.build @@ -39,11 +39,12 @@ if CONFIG['OS_TARGET'] != 'Android': DEFINES['FAKE_LOG_DEVICE'] = True SOURCES += [ 'system/core/liblog/fake_log_device.c', + # io.h conflicts with the access stub in logd_write.c on Windows. + 'system/core/liblog/logprint.c', ] UNIFIED_SOURCES += [ 'system/core/libcutils/strdup16to8.c', 'system/core/liblog/logd_write.c', - 'system/core/liblog/logprint.c', ] EXPORTS.mp4_demuxer += [ diff --git a/media/libstagefright/system/core/liblog/logprint.c b/media/libstagefright/system/core/liblog/logprint.c index 6bdd8e0b38..8798c9e323 100644 --- a/media/libstagefright/system/core/liblog/logprint.c +++ b/media/libstagefright/system/core/liblog/logprint.c @@ -26,6 +26,12 @@ #include #include +#ifdef _WIN32 +#include +#else +#include +#endif + #include #include @@ -945,7 +951,11 @@ int android_log_printLogLine( return -1; do { +#ifdef _WIN32 + ret = _write(fd, outBuffer, totalLen); +#else ret = write(fd, outBuffer, totalLen); +#endif } while (ret < 0 && errno == EINTR); if (ret < 0) { diff --git a/modules/zlib/src/moz.build b/modules/zlib/src/moz.build index df181cb0d4..c9e8c1f7f8 100644 --- a/modules/zlib/src/moz.build +++ b/modules/zlib/src/moz.build @@ -31,6 +31,15 @@ if CONFIG['INTEL_ARCHITECTURE']: 'inflate_simd.c', 'x86.c', ] + # Clang (including clang-cl) and GCC require explicit ISA flags for + # intrinsics. MSVC accepts these intrinsics without additional flags. + # Keep advanced instructions confined to the runtime-dispatched sources. + if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']: + SOURCES['adler32_simd.c'].flags += ['-mssse3'] + for source in ['crc32_simd.c', 'crc_folding.c']: + SOURCES[source].flags += ['-msse4.2', '-mpclmul'] + for source in ['fill_window_sse.c', 'inffast_chunk.c', 'inflate_simd.c']: + SOURCES[source].flags += ['-msse2'] else: SOURCES += [ 'simd_stub.c', diff --git a/modules/zlib/src/x86.c b/modules/zlib/src/x86.c index 714dfdc420..baee488f11 100644 --- a/modules/zlib/src/x86.c +++ b/modules/zlib/src/x86.c @@ -65,8 +65,8 @@ static void _x86_check_features(void) #include #include -static volatile int32_t once_control = 0; -static int fake_pthread_once(volatile int32_t *once_control, +static volatile LONG once_control = 0; +static int fake_pthread_once(volatile LONG *once_control, void (*init_routine)(void)); void x86_check_features(void) @@ -75,7 +75,7 @@ void x86_check_features(void) } /* Copied from "perftools_pthread_once" in tcmalloc */ -static int fake_pthread_once(volatile int32_t *once_control, +static int fake_pthread_once(volatile LONG *once_control, void (*init_routine)(void)) { // Try for a fast path first. Note: this should be an acquire semantics read // It is on x86 and x64, where Windows runs. diff --git a/mozconfigs/windows/uxp-win64-clang b/mozconfigs/windows/uxp-win64-clang index d452f8d2a5..e39707f500 100644 --- a/mozconfigs/windows/uxp-win64-clang +++ b/mozconfigs/windows/uxp-win64-clang @@ -10,7 +10,6 @@ export CLANG=/c/clang/bin export CC="clang-cl.exe" export MT="llvm-mt.exe" export LD="lld-link.exe" -export LIB="lib.exe" # Force PATH so UXP thinks only Clang is there export PATH="$CLANG:$PATH" @@ -24,8 +23,8 @@ mk_add_options MOZ_MAKE_FLAGS="-j6" ac_add_options --host=x86_64-pc-mingw32 ac_add_options --target=x86_64-pc-mingw32 -# Build only Hydra -ac_add_options --enable-application=basilisk +# Build only Dactyloidae +ac_add_options --enable-application=browser ac_add_options --disable-artifact-builds # Updater stuffs @@ -43,7 +42,7 @@ ac_add_options --enable-devtools #ac_add_options --enable-install-strip ac_add_options --enable-jemalloc ac_add_options --enable-js-lto -ac_add_options --enable-optimize="-O2 -Ob2ity -openmp -arch:AVX -w0 -w" +ac_add_options --enable-optimize="-O2 -Ob2ity -arch:SSE2 -w0 -w" ac_add_options --enable-phoenix-extensions ac_add_options --enable-release ac_add_options --enable-shared-js diff --git a/nsprpub/pr/src/io/prsocket.c b/nsprpub/pr/src/io/prsocket.c index e0f917c16a..08a1fc693e 100644 --- a/nsprpub/pr/src/io/prsocket.c +++ b/nsprpub/pr/src/io/prsocket.c @@ -321,8 +321,8 @@ static PRStatus PR_CALLBACK SocketConnectContinue( } else { #if defined(_WIN64) if (fd->secret->overlappedActive) { - PRInt32 rvSent; - if (GetOverlappedResult(osfd, &fd->secret->ol, &rvSent, FALSE) == FALSE) { + DWORD rvSent; + if (GetOverlappedResult((HANDLE)osfd, &fd->secret->ol, &rvSent, FALSE) == FALSE) { err = WSAGetLastError(); PR_LOG(_pr_io_lm, PR_LOG_MIN, ("SocketConnectContinue GetOverlappedResult failed %d\n", err)); @@ -353,8 +353,8 @@ static PRStatus PR_CALLBACK SocketConnectContinue( * To get result we need to use GetOverlappedResult. */ if (fd->secret->overlappedActive) { PR_ASSERT(fd->secret->nonblocking); - PRInt32 rvSent; - if (GetOverlappedResult(osfd, &fd->secret->ol, &rvSent, FALSE) == TRUE) { + DWORD rvSent; + if (GetOverlappedResult((HANDLE)osfd, &fd->secret->ol, &rvSent, FALSE) == TRUE) { fd->secret->overlappedActive = PR_FALSE; PR_LOG(_pr_io_lm, PR_LOG_MIN, ("SocketConnectContinue GetOverlappedResult succeeded\n")); diff --git a/nsprpub/pr/src/md/windows/ntmisc.c b/nsprpub/pr/src/md/windows/ntmisc.c index 1ec6c2a5e5..f07b3c136e 100644 --- a/nsprpub/pr/src/md/windows/ntmisc.c +++ b/nsprpub/pr/src/md/windows/ntmisc.c @@ -769,10 +769,13 @@ PRStatus _PR_WaitWindowsProcess(PRProcess *process, return PR_FAILURE; } PR_ASSERT(dwRetVal == WAIT_OBJECT_0); - if (exitCode != NULL && - GetExitCodeProcess(process->md.handle, exitCode) == FALSE) { - PR_SetError(PR_UNKNOWN_ERROR, GetLastError()); - return PR_FAILURE; + if (exitCode != NULL) { + DWORD dwExitCode; + if (GetExitCodeProcess(process->md.handle, &dwExitCode) == FALSE) { + PR_SetError(PR_UNKNOWN_ERROR, GetLastError()); + return PR_FAILURE; + } + *exitCode = (PRInt32)dwExitCode; } CloseHandle(process->md.handle); PR_DELETE(process); diff --git a/nsprpub/pr/src/md/windows/w95io.c b/nsprpub/pr/src/md/windows/w95io.c index 2ad52e19ba..8a43dd22b9 100644 --- a/nsprpub/pr/src/md/windows/w95io.c +++ b/nsprpub/pr/src/md/windows/w95io.c @@ -266,7 +266,7 @@ _PR_MD_OPEN_FILE(const char *name, PRIntn osflags, int mode) PRInt32 _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len) { - PRUint32 bytes; + DWORD bytes; int rv, err; rv = ReadFile((HANDLE)fd->secret->md.osfd, @@ -295,7 +295,7 @@ PRInt32 _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) { PROsfd f = fd->secret->md.osfd; - PRInt32 bytes; + DWORD bytes; int rv; rv = WriteFile((HANDLE)f, diff --git a/nsprpub/pr/src/md/windows/w95sock.c b/nsprpub/pr/src/md/windows/w95sock.c index 312dffc732..158472ee3d 100644 --- a/nsprpub/pr/src/md/windows/w95sock.c +++ b/nsprpub/pr/src/md/windows/w95sock.c @@ -7,6 +7,8 @@ * */ +/* Include Winsock 2 before primpl.h brings in windows.h and Winsock 1. */ +#include #include "primpl.h" #if defined(_WIN64) @@ -117,7 +119,7 @@ _MD_CloseSocket(PROsfd osfd) PRInt32 _MD_SocketAvailable(PRFileDesc *fd) { - PRInt32 result; + u_long result; if (ioctlsocket(fd->secret->md.osfd, FIONREAD, &result) < 0) { PR_SetError(PR_BAD_DESCRIPTOR_ERROR, WSAGetLastError()); @@ -363,7 +365,7 @@ static PRStatus PR_CALLBACK _pr_set_connectex(void) { _pr_win_connectex = NULL; SOCKET sock; - PRInt32 dwBytes; + DWORD dwBytes; int rc; /* Dummy socket needed for WSAIoctl */ @@ -445,7 +447,7 @@ _PR_MD_TCPSENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, memset(&fd->secret->ol, 0, sizeof(fd->secret->ol)); /* ConnectEx return TRUE on a success and FALSE on an error. */ if (_pr_win_connectex( (SOCKET)osfd, (struct sockaddr *) addr, - addrlen, buf, amount, + addrlen, (PVOID)buf, amount, &rvSent, &fd->secret->ol) == TRUE) { /* When ConnectEx is used, all previously set socket options and * property are not enabled and to enable them @@ -494,7 +496,7 @@ _PR_MD_TCPSENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, if ( rv < 0 ) { return -1; } - rv = GetOverlappedResult(osfd, &fd->secret->ol, &rvSent, FALSE); + rv = GetOverlappedResult((HANDLE)osfd, &fd->secret->ol, &rvSent, FALSE); if ( rv == TRUE ) { return rvSent; } else { diff --git a/old-configure.in b/old-configure.in index ed4c8f2997..8744628eae 100644 --- a/old-configure.in +++ b/old-configure.in @@ -4773,11 +4773,22 @@ if test "$MOZ_TREE_CAIRO"; then if test "$COMPILE_ENVIRONMENT"; then - MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1) + dnl SDK include paths can change between build shells. Do not cache + dnl these checks, or a stale failure disables required D3D exports. + unset ac_cv_header_d3d9_h ac_cv_header_d3d10_h + AC_MSG_CHECKING([for d3d9.h]) + AC_TRY_COMPILE([#include ], , + [MOZ_ENABLE_D3D9_LAYER=1 + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)]) dnl D3D10 Layers depend on D2D Surfaces. if test -n "$WIN32_D2D_SURFACE_FEATURE"; then - MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1) + AC_MSG_CHECKING([for d3d10.h]) + AC_TRY_COMPILE([#include ], , + [MOZ_ENABLE_D3D10_LAYER=1 + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)]) fi fi ;; From 6569a453d2d1c4fd0feda6ae2791fc03d738005a Mon Sep 17 00:00:00 2001 From: wuggy Date: Fri, 11 Sep 2026 05:11:09 -0700 Subject: [PATCH 3/3] --enable-ctypes for clang-cl --- mozconfigs/windows/uxp-win64-clang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mozconfigs/windows/uxp-win64-clang b/mozconfigs/windows/uxp-win64-clang index e39707f500..1e6ff25808 100644 --- a/mozconfigs/windows/uxp-win64-clang +++ b/mozconfigs/windows/uxp-win64-clang @@ -64,7 +64,7 @@ ac_add_options --disable-crashreporter ac_add_options --disable-eme ac_add_options --disable-maintenance-service ac_add_options --disable-parental-controls -ac_add_options --disable-ctypes +ac_add_options --enable-ctypes mk_add_options MOZ_SERVICES_HEALTHREPORT=0 export CROSS_COMPILE=0 export MOZ_CRASHREPORTER=0