€•ÊCŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ+/translations/zh_CN/core-api/floating-point”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ+/translations/zh_TW/core-api/floating-point”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ+/translations/it_IT/core-api/floating-point”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ+/translations/ja_JP/core-api/floating-point”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ+/translations/ko_KR/core-api/floating-point”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ+/translations/sp_SP/core-api/floating-point”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ!SPDX-License-Identifier: GPL-2.0+”h]”hŒ!SPDX-License-Identifier: GPL-2.0+”…””}”hh£sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1h¡hhhžhhŸŒE/var/lib/git/docbuild/linux/Documentation/core-api/floating-point.rst”h KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒFloating-point API”h]”hŒFloating-point API”…””}”(hh»hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hh¶hžhhŸh³h KubhŒ paragraph”“”)”}”(hXKernel code is normally prohibited from using floating-point (FP) registers or instructions, including the C float and double data types. This rule reduces system call overhead, because the kernel does not need to save and restore the userspace floating-point register state.”h]”hXKernel code is normally prohibited from using floating-point (FP) registers or instructions, including the C float and double data types. This rule reduces system call overhead, because the kernel does not need to save and restore the userspace floating-point register state.”…””}”(hhËhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhÊ)”}”(hXNHowever, occasionally drivers or library functions may need to include FP code. This is supported by isolating the functions containing FP code to a separate translation unit (a separate source file), and saving/restoring the FP register state around calls to those functions. This creates "critical sections" of floating-point usage.”h]”hXRHowever, occasionally drivers or library functions may need to include FP code. This is supported by isolating the functions containing FP code to a separate translation unit (a separate source file), and saving/restoring the FP register state around calls to those functions. This creates “critical sections†of floating-point usage.”…””}”(hhÙhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K hh¶hžhubhÊ)”}”(hX-The reason for this isolation is to prevent the compiler from generating code touching the FP registers outside these critical sections. Compilers sometimes use FP registers to optimize inlined ``memcpy`` or variable assignment, as floating-point registers may be wider than general-purpose registers.”h]”(hŒÂThe reason for this isolation is to prevent the compiler from generating code touching the FP registers outside these critical sections. Compilers sometimes use FP registers to optimize inlined ”…””}”(hhçhžhhŸNh NubhŒliteral”“”)”}”(hŒ ``memcpy``”h]”hŒmemcpy”…””}”(hhñhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hïhhçubhŒa or variable assignment, as floating-point registers may be wider than general-purpose registers.”…””}”(hhçhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhÊ)”}”(hX Usability of floating-point code within the kernel is architecture-specific. Additionally, because a single kernel may be configured to support platforms both with and without a floating-point unit, FPU availability must be checked both at build time and at run time.”h]”hX Usability of floating-point code within the kernel is architecture-specific. Additionally, because a single kernel may be configured to support platforms both with and without a floating-point unit, FPU availability must be checked both at build time and at run time.”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhÊ)”}”(hŒÊSeveral architectures implement the generic kernel floating-point API from ``linux/fpu.h``, as described below. Some other architectures implement their own unique APIs, which are documented separately.”h]”(hŒKSeveral architectures implement the generic kernel floating-point API from ”…””}”(hjhžhhŸNh Nubhð)”}”(hŒ``linux/fpu.h``”h]”hŒ linux/fpu.h”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hïhjubhŒp, as described below. Some other architectures implement their own unique APIs, which are documented separately.”…””}”(hjhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhµ)”}”(hhh]”(hº)”}”(hŒBuild-time API”h]”hŒBuild-time API”…””}”(hj:hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hj7hžhhŸh³h K ubhÊ)”}”(hŒèFloating-point code may be built if the option ``ARCH_HAS_KERNEL_FPU_SUPPORT`` is enabled. For C code, such code must be placed in a separate file, and that file must have its compilation flags adjusted using the following pattern::”h]”(hŒ/Floating-point code may be built if the option ”…””}”(hjHhžhhŸNh Nubhð)”}”(hŒ``ARCH_HAS_KERNEL_FPU_SUPPORT``”h]”hŒARCH_HAS_KERNEL_FPU_SUPPORT”…””}”(hjPhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hïhjHubhŒ™ is enabled. For C code, such code must be placed in a separate file, and that file must have its compilation flags adjusted using the following pattern:”…””}”(hjHhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K"hj7hžhubhŒ literal_block”“”)”}”(hŒICFLAGS_foo.o += $(CC_FLAGS_FPU) CFLAGS_REMOVE_foo.o += $(CC_FLAGS_NO_FPU)”h]”hŒICFLAGS_foo.o += $(CC_FLAGS_FPU) CFLAGS_REMOVE_foo.o += $(CC_FLAGS_NO_FPU)”…””}”hjjsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jhhŸh³h K&hj7hžhubhÊ)”}”(hŒxArchitectures are expected to define one or both of these variables in their top-level Makefile as needed. For example::”h]”hŒwArchitectures are expected to define one or both of these variables in their top-level Makefile as needed. For example:”…””}”(hjxhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K)hj7hžhubji)”}”(hŒCC_FLAGS_FPU := -mhard-float”h]”hŒCC_FLAGS_FPU := -mhard-float”…””}”hj†sbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jhhŸh³h K,hj7hžhubhÊ)”}”(hŒor::”h]”hŒor:”…””}”(hj”hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K.hj7hžhubji)”}”(hŒCC_FLAGS_NO_FPU := -msoft-float”h]”hŒCC_FLAGS_NO_FPU := -msoft-float”…””}”hj¢sbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jhhŸh³h K0hj7hžhubhÊ)”}”(hŒKNormal kernel code is assumed to use the equivalent of ``CC_FLAGS_NO_FPU``.”h]”(hŒ7Normal kernel code is assumed to use the equivalent of ”…””}”(hj°hžhhŸNh Nubhð)”}”(hŒ``CC_FLAGS_NO_FPU``”h]”hŒCC_FLAGS_NO_FPU”…””}”(hj¸hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hïhj°ubhŒ.”…””}”(hj°hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K2hj7hžhubeh}”(h]”Œbuild-time-api”ah ]”h"]”Œbuild-time api”ah$]”h&]”uh1h´hh¶hžhhŸh³h K ubhµ)”}”(hhh]”(hº)”}”(hŒ Runtime API”h]”hŒ Runtime API”…””}”(hjÛhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjØhžhhŸh³h K5ubhÊ)”}”(hŒëThe runtime API is provided in ``linux/fpu.h``. This header cannot be included from files implementing FP code (those with their compilation flags adjusted as above). Instead, it must be included when defining the FP critical sections.”h]”(hŒThe runtime API is provided in ”…””}”(hjéhžhhŸNh Nubhð)”}”(hŒ``linux/fpu.h``”h]”hŒ linux/fpu.h”…””}”(hjñhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hïhjéubhŒ½. This header cannot be included from files implementing FP code (those with their compilation flags adjusted as above). Instead, it must be included when defining the FP critical sections.”…””}”(hjéhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K7hjØhžhubhŒindex”“”)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”(Œsingle”Œ!kernel_fpu_available (C function)”Œc.kernel_fpu_available”hNt”auh1j hjØhžhhŸh³h NubhŒdesc”“”)”}”(hhh]”(hŒdesc_signature”“”)”}”(hŒ!bool kernel_fpu_available( void )”h]”hŒdesc_signature_line”“”)”}”(hŒbool kernel_fpu_available(void)”h]”(hŒdesc_sig_keyword_type”“”)”}”(hŒbool”h]”hŒbool”…””}”(hj-hžhhŸNh Nubah}”(h]”h ]”Œkt”ah"]”h$]”h&]”uh1j+hj'hžhhŸh³h K;ubhŒdesc_sig_space”“”)”}”(hŒ ”h]”hŒ ”…””}”(hj>hžhhŸNh Nubah}”(h]”h ]”Œw”ah"]”h$]”h&]”uh1j<hj'hžhhŸh³h K;ubhŒ desc_name”“”)”}”(hŒkernel_fpu_available”h]”hŒ desc_sig_name”“”)”}”(hŒkernel_fpu_available”h]”hŒkernel_fpu_available”…””}”(hjUhžhhŸNh Nubah}”(h]”h ]”Œn”ah"]”h$]”h&]”uh1jShjOubah}”(h]”h ]”(Œsig-name”Œdescname”eh"]”h$]”h&]”h±h²uh1jMhj'hžhhŸh³h K;ubhŒdesc_parameterlist”“”)”}”(hŒ(void)”h]”hŒdesc_parameter”“”)”}”(hŒvoid”h]”j,)”}”(hŒvoid”h]”hŒvoid”…””}”(hjxhžhhŸNh Nubah}”(h]”h ]”j8ah"]”h$]”h&]”uh1j+hjtubah}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆh±h²uh1jrhjnubah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jlhj'hžhhŸh³h K;ubeh}”(h]”h ]”h"]”h$]”h&]”h±h²Œ add_permalink”ˆuh1j%Œsphinx_line_type”Œ declarator”hj!hžhhŸh³h K;ubah}”(h]”jah ]”(Œsig”Œ sig-object”eh"]”h$]”h&]”Œ is_multiline”ˆŒ _toc_parts”)Œ _toc_name”huh1jhŸh³h K;hjhžhubhŒ desc_content”“”)”}”(hhh]”hÊ)”}”(hŒâThis function reports if floating-point code can be used on this CPU or platform. The value returned by this function is not expected to change at runtime, so it only needs to be called once, not before every critical section.”h]”hŒâThis function reports if floating-point code can be used on this CPU or platform. The value returned by this function is not expected to change at runtime, so it only needs to be called once, not before every critical section.”…””}”(hj¬hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K=hj©hžhubah}”(h]”h ]”h"]”h$]”h&]”uh1j§hjhžhhŸh³h K;ubeh}”(h]”h ]”(Œc”Œfunction”eh"]”h$]”h&]”Œdomain”jÃŒobjtype”jÄŒdesctype”jÄŒnoindex”‰Œ noindexentry”‰Œnocontentsentry”‰uh1jhžhhjØhŸh³h Nubj )”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”Œentries”]”((jŒkernel_fpu_begin (C function)”Œc.kernel_fpu_begin”hNt”(jŒkernel_fpu_end (C function)”Œc.kernel_fpu_end”hNt”euh1j hjØhžhhŸh³h Nubj)”}”(hhh]”(j )”}”(hŒvoid kernel_fpu_begin( void )”h]”j&)”}”(hŒvoid kernel_fpu_begin(void)”h]”(j,)”}”(hŒvoid”h]”hŒvoid”…””}”(hjêhžhhŸNh Nubah}”(h]”h ]”j8ah"]”h$]”h&]”uh1j+hjæhžhhŸh³h KBubj=)”}”(hŒ ”h]”hŒ ”…””}”(hjøhžhhŸNh Nubah}”(h]”h ]”jIah"]”h$]”h&]”uh1j<hjæhžhhŸh³h KBubjN)”}”(hŒkernel_fpu_begin”h]”jT)”}”(hŒkernel_fpu_begin”h]”hŒkernel_fpu_begin”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”j`ah"]”h$]”h&]”uh1jShjubah}”(h]”h ]”(jgjheh"]”h$]”h&]”h±h²uh1jMhjæhžhhŸh³h KBubjm)”}”(hŒ(void)”h]”js)”}”(hŒvoid”h]”j,)”}”(hŒvoid”h]”hŒvoid”…””}”(hj&hžhhŸNh Nubah}”(h]”h ]”j8ah"]”h$]”h&]”uh1j+hj"ubah}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆh±h²uh1jrhjubah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jlhjæhžhhŸh³h KBubeh}”(h]”h ]”h"]”h$]”h&]”h±h²j™ˆuh1j%jšj›hjâhžhhŸh³h KBubah}”(h]”jÚah ]”(jŸj eh"]”h$]”h&]”j¤ˆj¥)j¦huh1jhŸh³h KBhjßhžhubj )”}”(hŒvoid kernel_fpu_end( void )”h]”j&)”}”(hŒvoid kernel_fpu_end(void)”h]”(j,)”}”(hŒvoid”h]”hŒvoid”…””}”(hjUhžhhŸNh Nubah}”(h]”h ]”j8ah"]”h$]”h&]”uh1j+hjQhžhhŸh³h KBubj=)”}”(hŒ ”h]”hŒ ”…””}”(hjchžhhŸNh Nubah}”(h]”h ]”jIah"]”h$]”h&]”uh1j<hjQhžhhŸh³h KBubjN)”}”(hŒkernel_fpu_end”h]”jT)”}”(hŒkernel_fpu_end”h]”hŒkernel_fpu_end”…””}”(hjuhžhhŸNh Nubah}”(h]”h ]”j`ah"]”h$]”h&]”uh1jShjqubah}”(h]”h ]”(jgjheh"]”h$]”h&]”h±h²uh1jMhjQhžhhŸh³h KBubjm)”}”(hŒ(void)”h]”js)”}”(hŒvoid”h]”j,)”}”(hŒvoid”h]”hŒvoid”…””}”(hj‘hžhhŸNh Nubah}”(h]”h ]”j8ah"]”h$]”h&]”uh1j+hjubah}”(h]”h ]”h"]”h$]”h&]”Œnoemph”ˆh±h²uh1jrhj‰ubah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jlhjQhžhhŸh³h KBubeh}”(h]”h ]”h"]”h$]”h&]”h±h²j™ˆuh1j%jšj›hjMhžhhŸh³h KBubah}”(h]”jÝah ]”(jŸj eh"]”h$]”h&]”j¤ˆj¥)j¦huh1jhŸh³h KBhjßhžhubj¨)”}”(hhh]”(hÊ)”}”(hXThese functions create a floating-point critical section. It is only valid to call ``kernel_fpu_begin()`` after a previous call to ``kernel_fpu_available()`` returned ``true``. These functions are only guaranteed to be callable from (preemptible or non-preemptible) process context.”h]”(hŒSThese functions create a floating-point critical section. It is only valid to call ”…””}”(hj»hžhhŸNh Nubhð)”}”(hŒ``kernel_fpu_begin()``”h]”hŒkernel_fpu_begin()”…””}”(hjÃhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hïhj»ubhŒ after a previous call to ”…””}”(hj»hžhhŸNh Nubhð)”}”(hŒ``kernel_fpu_available()``”h]”hŒkernel_fpu_available()”…””}”(hjÕhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hïhj»ubhŒ returned ”…””}”(hj»hžhhŸNh Nubhð)”}”(hŒ``true``”h]”hŒtrue”…””}”(hjçhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hïhj»ubhŒk. These functions are only guaranteed to be callable from (preemptible or non-preemptible) process context.”…””}”(hj»hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KEhj¸hžhubhÊ)”}”(hŒßPreemption may be disabled inside critical sections, so their size should be minimized. They are *not* required to be reentrant. If the caller expects to nest critical sections, it must implement its own reference counting.”h]”(hŒaPreemption may be disabled inside critical sections, so their size should be minimized. They are ”…””}”(hjÿhžhhŸNh NubhŒemphasis”“”)”}”(hŒ*not*”h]”hŒnot”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÿubhŒy required to be reentrant. If the caller expects to nest critical sections, it must implement its own reference counting.”…””}”(hjÿhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KKhj¸hžhubeh}”(h]”h ]”h"]”h$]”h&]”uh1j§hjßhžhhŸh³h KBubeh}”(h]”h ]”(jÃŒfunction”eh"]”h$]”h&]”jÈjÃjÉj*jÊj*jˉj̉j͉uh1jhžhhjØhŸh³h Nubeh}”(h]”Œ runtime-api”ah ]”h"]”Œ runtime api”ah$]”h&]”uh1h´hh¶hžhhŸh³h K5ubeh}”(h]”Œfloating-point-api”ah ]”h"]”Œfloating-point api”ah$]”h&]”uh1h´hhhžhhŸh³h Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h³uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(h¹NŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jaŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h³Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j;j8jÕjÒj3j0uŒ nametypes”}”(j;‰jÕ‰j3‰uh}”(j8h¶jÒj7j0jØjj!jÚjâjÝjMuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.