{"id":830,"date":"2021-09-09T14:35:00","date_gmt":"2021-09-09T12:35:00","guid":{"rendered":"https:\/\/www.dereckson.be\/blog\/?p=830"},"modified":"2025-09-26T20:21:29","modified_gmt":"2025-09-26T18:21:29","slug":"iec-559-support-in-libtommath-on-freebsd","status":"publish","type":"post","link":"https:\/\/www.dereckson.be\/blog\/2021\/09\/09\/iec-559-support-in-libtommath-on-freebsd\/","title":{"rendered":"IEC 559 support in LibTomMath on FreeBSD"},"content":{"rendered":"\n<p>Raku is the new name of Perl 6, a language inspired by Perl and compiled for a virtual machine. When preparing FreeBSD ports for the Raku ecosystem, I&#8217;ve noticed those depend on <a href=\"https:\/\/www.libtom.net\/LibTomMath\/\" data-type=\"URL\" data-id=\"https:\/\/www.libtom.net\/LibTomMath\/\">LibTomMath<\/a>, with <a href=\"https:\/\/en.wikipedia.org\/wiki\/IEEE_754\">IEEE754<\/a> floating point format support.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Let&#8217;s try to call zef, a tool to manage modules (dependencies) in Raku:<\/p>\n\n\n\n<p><code>$ raku \u2026 zef \u2026<br>ld-elf.so.1: \/\/usr\/local\/lib\/libmoar.so: Undefined symbol \"mp_set_double\"<\/code><br>(<a href=\"https:\/\/www.moarvm.org\/\">MoarVM<\/a> is the virtual machine running the Raku bytecode)<\/p>\n\n\n\n<p>When building the port:<br><code>bn_mp_set_double.c:44:6: warning: \"mp_set_double implementation is<br>only available on platforms with IEEE754 floating point format\"<br>[-W#warnings]<\/code><\/p>\n\n\n\n<p>The source code protects mp_set_double function with a check for<br><strong>STDC_IEC_559<\/strong> defined.<\/p>\n\n\n\n<p>This is well supported by the OS, as documented in <a href=\"https:\/\/www.freebsd.org\/cgi\/man.cgi?query=ieee&amp;sektion=3\">man 3 ieee<\/a>, but the compilers clang and gcc don&#8217;t seem to define it. On the Linux platform, glibc defines it. <\/p>\n\n\n\n<p>The library <a href=\"https:\/\/github.com\/libtom\/libtommath\/pull\/476\">refactored the way to detect STDC_IEC_559<\/a>, but this isn&#8217;t released yet.<\/p>\n\n\n\n<p>Pietro Cerutti, who maintains the FreeBSD port for LibTomMath, <a href=\"https:\/\/cgit.freebsd.org\/ports\/commit\/?id=3b74b3446c069a4e2d88e23021c83434ea53728c\" data-type=\"URL\" data-id=\"https:\/\/cgit.freebsd.org\/ports\/commit\/?id=3b74b3446c069a4e2d88e23021c83434ea53728c\">merged this better detection patch<\/a>, so we can benefit of those features right now.<\/p>\n\n\n\n<p>So you can know use <code>mp_set_double<\/code> on FreeBSD machines too, and the zef package manager.<\/p>\n\n\n\n<p>Related links<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/dereckson\/freebsd-ports\/tree\/main\/devel\">Ports for Raku, Zef, MoarVM<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/31181897\/status-of-stdc-iec-559-with-modern-c-compilers\" data-type=\"URL\" data-id=\"https:\/\/stackoverflow.com\/questions\/31181897\/status-of-stdc-iec-559-with-modern-c-compilers\"><\/a><a href=\"https:\/\/stackoverflow.com\/questions\/31181897\/status-of-stdc-iec-559-with-modern-c-compilers\">Status of __STDC_IEC_559__ with modern C compilers<\/a> on StackOverflow<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Raku is the new name of Perl 6, a language inspired by Perl and compiled for a virtual machine. When preparing FreeBSD ports for the Raku ecosystem, I&#8217;ve noticed those depend on LibTomMath, with IEEE754 floating point format support.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[380,9,382,384],"class_list":["post-830","post","type-post","status-publish","format-standard","hentry","category-dev","tag-c-2-en","tag-freebsd","tag-libtommath-en","tag-raku-en"],"_links":{"self":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts\/830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/comments?post=830"}],"version-history":[{"count":2,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts\/830\/revisions"}],"predecessor-version":[{"id":946,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts\/830\/revisions\/946"}],"wp:attachment":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/media?parent=830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/categories?post=830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/tags?post=830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}