tools/testing/selftests/x86/test_FCOMI.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/x86/test_FCOMI.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/x86/test_FCOMI.c- Extension
.c- Size
- 7391 bytes
- Lines
- 333
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
unistd.hstdlib.hstring.hstdio.hsignal.hsys/types.hsys/select.hsys/time.hsys/wait.hfenv.h
Detected Declarations
function testfunction test_qnanfunction testu_qnanfunction testu_snanfunction testpfunction testp_qnanfunction testup_qnanfunction sighandlerfunction main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#undef _GNU_SOURCE
#define _GNU_SOURCE 1
#undef __USE_GNU
#define __USE_GNU 1
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <fenv.h>
enum {
CF = 1 << 0,
PF = 1 << 2,
ZF = 1 << 6,
ARITH = CF | PF | ZF,
};
long res_fcomi_pi_1;
long res_fcomi_1_pi;
long res_fcomi_1_1;
long res_fcomi_nan_1;
/* sNaN is s|111 1111 1|1xx xxxx xxxx xxxx xxxx xxxx */
/* qNaN is s|111 1111 1|0xx xxxx xxxx xxxx xxxx xxxx (some x must be nonzero) */
int snan = 0x7fc11111;
int qnan = 0x7f811111;
unsigned short snan1[5];
/* sNaN80 is s|111 1111 1111 1111 |10xx xx...xx (some x must be nonzero) */
unsigned short snan80[5] = { 0x1111, 0x1111, 0x1111, 0x8111, 0x7fff };
int test(long flags)
{
feclearexcept(FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW);
asm ("\n"
" push %0""\n"
" popf""\n"
" fld1""\n"
" fldpi""\n"
" fcomi %%st(1), %%st" "\n"
" ffree %%st(0)" "\n"
" ffree %%st(1)" "\n"
" pushf""\n"
" pop res_fcomi_1_pi""\n"
" push %0""\n"
" popf""\n"
" fldpi""\n"
" fld1""\n"
" fcomi %%st(1), %%st" "\n"
" ffree %%st(0)" "\n"
" ffree %%st(1)" "\n"
" pushf""\n"
" pop res_fcomi_pi_1""\n"
" push %0""\n"
" popf""\n"
" fld1""\n"
" fld1""\n"
" fcomi %%st(1), %%st" "\n"
" ffree %%st(0)" "\n"
" ffree %%st(1)" "\n"
" pushf""\n"
" pop res_fcomi_1_1""\n"
:
: "r" (flags)
);
if ((res_fcomi_1_pi & ARITH) != (0)) {
printf("[BAD]\tfcomi_1_pi with flags:%lx\n", flags);
return 1;
}
if ((res_fcomi_pi_1 & ARITH) != (CF)) {
printf("[BAD]\tfcomi_pi_1 with flags:%lx->%lx\n", flags, res_fcomi_pi_1 & ARITH);
return 1;
}
if ((res_fcomi_1_1 & ARITH) != (ZF)) {
printf("[BAD]\tfcomi_1_1 with flags:%lx\n", flags);
return 1;
}
if (fetestexcept(FE_INVALID) != 0) {
printf("[BAD]\tFE_INVALID is set in %s\n", __func__);
return 1;
}
return 0;
Annotation
- Immediate include surface: `unistd.h`, `stdlib.h`, `string.h`, `stdio.h`, `signal.h`, `sys/types.h`, `sys/select.h`, `sys/time.h`.
- Detected declarations: `function test`, `function test_qnan`, `function testu_qnan`, `function testu_snan`, `function testp`, `function testp_qnan`, `function testup_qnan`, `function sighandler`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.