|
Message-ID: <alpine.LRH.2.02.2001261416150.4450@key0.esi.com.au> Date: Sun, 26 Jan 2020 14:28:37 +1100 (AEDT) From: Damian McGuckin <damianm@....com.au> To: musl@...ts.openwall.com Subject: Re: Considering x86-64 fenv.s to C M68K is below: I looked inside 'fenv.c' inside the .../fenv/arm directory and noticed it pulled in a default trivial 'fenv.c' from the directory above it. In the absence of an alternative, I might exploit that but say #include "../fenv-trivial.c" for that trivial case and #include "../fenv-generic.c" for the new generic architecture. Apologizing in advance for insuficient comments, but the hardware specific fenv.c for (say) the m68k is /* * 68k ARCHITECTURE * * this CPU has distinct control and status registers */ #include <fenv.h> #if __HAVE_68881 || __mcffpu__ static inline unsigned int fe_get_sr_arch() { unsigned int v; __asm__ __volatile__ ("fmove.l %%fpsr,%0" : "=dm"(v)); return v; } static inline void fe_set_sr_arch(unsigned v) { __asm__ __volatile__ ("fmove.l %0,%%fpsr" : : "dm"(v)); } static inline unsigned int fe_get_cr_arch() { unsigned int v; __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=dm"(v)); return v; } static inline void fe_set_cr_arch(unsigned v) { __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "dm"(v)); } static inline unsigned int fe_get_ia_arch() { unsigned int address; __asm__ __volatile__ ("fmove.l %%fpiar,%0" : "=dm"(address)); return address; } static inline void fe_set_ia_arch(unsigned int address) { __asm__ __volatile__ ("fmove.l %0,%%fpiar" : : "dm"(address)); } /* * Expose the above generically */ #define fe_get_sr fe_get_sr_arch #define fe_set_sr fe_set_sr_arch #define fe_get_cr fe_get_cr_arch #define fe_set_cr fe_set_cr_arch /* * Handle the environment (which is a struct) */ #define fe_get_e(e)\ ((e)->__control_register = fe_get_cr_arch(),\ (e)->__status_register = fe_get_sr_arch(),\ (e)->__archnstruction_address = fe_get_ia_arch()) #define fe_set_e(e)\ (fe_set_cr_arch((e)->__control_register),\ fe_set_sr_arch((e)->__status_register),\ fe_set_ia_arch((e)->__instruction_address)) /* the contents of the default fenv_t */ #define FE_DFL_ENV_DATA { 0, 0, 0 } #include "../fenv-generic.c" #else #include "../fenv-trivial.c" #endif Regards - Damian Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037 Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here Views & opinions here are mine and not those of any past or present employer
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.