Re: libm i386: make use of __builtin_cpu_supports()

Christian Weisgerber <[email protected]> Fri, 31 Jul 2026 14:42:08 +0200
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
Christian Weisgerber:

> On i386, libm queries the machdep.sse sysctl to check at runtime
> whether the CPU supports SSE.
> 
> kettenis@ has pointed out elsewhere that the compiler runtime on
> x86 now provides a CPU feature array that we can test with
> __builtin_cpu_supports().  No need to handroll this ourselves.

After switching over libm, we can also remove the special casing in
pledge_sysctl().

(How long would we wait before doing this?  Until after the next
release?)

Index: kern/kern_pledge.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_pledge.c,v
diff -u -p -r1.359 kern_pledge.c
--- kern/kern_pledge.c	24 Jun 2026 17:03:06 -0000	1.359
+++ kern/kern_pledge.c	31 Jul 2026 11:43:16 -0000
@@ -996,12 +996,6 @@ pledge_sysctl(struct proc *p, int miblen
 		}
 	}
 
-#ifdef CPU_SSE
-	if (miblen == 2 &&		/* i386 libm tests for SSE */
-	    mib[0] == CTL_MACHDEP && mib[1] == CPU_SSE)
-		return (0);
-#endif /* CPU_SSE */
-
 #ifdef CPU_ID_AA64ISAR0
 	if (miblen == 2 &&		/* arm64 libcrypto inspects CPU features */
 	    mib[0] == CTL_MACHDEP && mib[1] == CPU_ID_AA64ISAR0)
-- 
Christian "naddy" Weisgerber                          [email protected]