tomo el fuego

Check-in [a0eff3f2f8]
Login

Check-in [a0eff3f2f8]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:correct e2aa7f441be3f42d e2aa7f441b merges conlicting info. build seems to work better with the setfcr.S and fpuctl.h fixes combined to avoid inline asm.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | improve-svc-httpd
Files: files | file ages | folders
SHA3-256: a0eff3f2f81a8e2f463b9fe146e673b69b38f85ce238dc058ad25b0f86370ba9
User & Date: r14c 2022-12-12 00:52:32
References
2022-12-12
00:58 Ticket [4ed80aa3fb] FreeBSD build issues status still Open with 5 other changes artifact: e16759b520 user: xjix
Context
2022-12-12
18:13
fix charon segfault [tomo-el-fuego#c235634a814ed923](/tktview/c235634a814ed923f35e6aae88f18b36e35716b3) check-in: c780e4a4a4 user: r14c tags: improve-svc-httpd
00:52
correct e2aa7f441be3f42d e2aa7f441b merges conlicting info. build seems to work better with the setfcr.S and fpuctl.h fixes combined to avoid inline asm. check-in: a0eff3f2f8 user: r14c tags: improve-svc-httpd
00:26
fix freebsd build errors fpuctl.h very possibly there is a clang asm ⥊ gcc interop issue that will be fixed in an update <https://github.com/llvm/llvm-project/issues/12616> check-in: e2aa7f441b user: r14c tags: improve-svc-httpd
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to FreeBSD/386/include/fpuctl.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * vi: ts=8
 * FreeBSD 386 fpu support
 * Mimic Plan9 floating point support
 */

static void
setfcr(ulong fcr)
{
	__asm__(	"xorb	$0x3f, %%al\n\t"
			"pushw	%%ax\n\t"
			"fwait\n\t"
			"fldcw	(%%esp)\n\t"
			"popw	%%ax\n\t"
			: "=a" (fcr)
			: "al" (fcr)
	);
}

static ulong
getfcr(void)
{
	ulong fcr = 0;

	__asm__(	"pushl	%%eax\n\t"
			"fwait\n\t"
			"fstcw	(%%esp)\n\t"
			"popl	%%eax\n\t"
			"xorb	$0x3f, %%al\n\t"
			: "=a"  (fcr)
			: "eax"	(fcr)
	);
	return fcr; 
}

static ulong
getfsr(void)
{
	ulong fsr = -1;
	/* FIXME FreeBSD/386/include/fpuctl.h:41:11: error: couldn't allocate input reg for constraint 'x' */
	__asm__(	"fwait\n\t"
			"fstsw	(%%eax)\n\t"
			"movl	(%%eax), %%eax\n\t"
			"andl	$0xffff, %%eax\n\t"
			: "=a"  (fsr)
			: "eax" (&fsr)
	);
	return fsr;
}

static void
setfsr(ulong fsr)
{
	__asm__("fclex\n\t");
}

/* FCR */
#define	FPINEX	(1<<5)
#define	FPUNFL	((1<<4)|(1<<1))
#define	FPOVFL	(1<<3)
#define	FPZDIV	(1<<2)
#define	FPINVAL	(1<<0)
#define	FPRNR	(0<<10)
<
|




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








1
2
3
4
5


















































6
7
8
9
10
11
12

/* vi: ts=8
 * FreeBSD 386 fpu support
 * Mimic Plan9 floating point support
 */



















































/* FCR */
#define	FPINEX	(1<<5)
#define	FPUNFL	((1<<4)|(1<<1))
#define	FPOVFL	(1<<3)
#define	FPZDIV	(1<<2)
#define	FPINVAL	(1<<0)
#define	FPRNR	(0<<10)

Added lib9/setfcr-FreeBSD-386.S.





































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#define	FN(x)	.type x,@function; .global x; x
#define	ENT	subl $16, %esp
#define	RET	addl $16, %esp; ret

	.file	"setfcr-FreeBSD-386.S"
FN(setfcr):
	ENT
	xorb	$0x3f, %al
	movl	%eax, (%esp)
	fwait
	fldcw	(%esp)
	RET

FN(getfcr):
	ENT
	fwait
	fstcw	(%esp)
	movw	(%esp), %ax
	andl	$0xffff, %eax
	xorb	$0x3f, %al
	RET

FN(getfsr):
	ENT
	fwait
	fstsw	(%esp)
	movw	(%esp), %ax
	andl	$0xffff, %eax
	RET

FN(setfsr):
	fclex
	ret