source: CPL/oasis3-mct/branches/OASIS3-MCT_5.0_branch/lib/psmile/src/shr_reprosumx86.c @ 6331

Last change on this file since 6331 was 6331, checked in by aclsce, 17 months ago

Moved oasis-mct_5.0 in oasis3-mct/branches directory.

File size: 985 bytes
Line 
1/*
2 * src/x86.c
3 *
4 * This work was supported by the Director, Office of Science, Division
5 * of Mathematical, Information, and Computational Sciences of the
6 * U.S. Department of Energy under contract number DE-AC03-76SF00098.
7 *
8 * Copyright (c) 2000-2001
9 *
10 * Contains functions to set and restore the round-to-double flag in the
11 * control word of a x86 FPU.
12 */
13
14#ifdef x86
15#ifndef _FPU_GETCW
16#define _FPU_GETCW(x) asm volatile ("fnstcw %0":"=m" (x));
17#endif
18
19#ifndef _FPU_SETCW
20#define _FPU_SETCW(x) asm volatile ("fldcw %0": :"m" (x));
21#endif
22
23#ifndef _FPU_EXTENDED
24#define _FPU_EXTENDED 0x0300
25#endif
26
27#ifndef _FPU_DOUBLE
28#define _FPU_DOUBLE 0x0200
29#endif
30#endif  /* x86 */
31
32void shr_reprosumx86_fix_start(unsigned short *old_cw) {
33#ifdef x86
34  unsigned short new_cw;
35
36  _FPU_GETCW(*old_cw);
37  new_cw = (*old_cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;
38  _FPU_SETCW(new_cw);
39#endif
40}
41
42void shr_reprosumx86_fix_end(unsigned short *old_cw) {
43#ifdef x86
44  _FPU_SETCW(*old_cw);
45#endif
46}
47
Note: See TracBrowser for help on using the repository browser.