3
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
3
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
3
|
21 |
|
22 */ |
|
23 |
382
|
24 #if !defined (octave_sun_utils_h) |
|
25 #define octave_sun_utils_h 1 |
|
26 |
1359
|
27 // This is only needed to dereference pointers to doubles if mixing |
|
28 // GCC and Sun f77/cc compiled code. See the GCC manual (where the |
|
29 // function access_double() is described) and the Sun f77 manual, |
|
30 // which explains that doubles are not always aligned on 8 byte |
|
31 // boundaries. |
3
|
32 |
2401
|
33 #if defined (sun) && defined (__GNUC__) |
3
|
34 |
|
35 inline double |
|
36 access_double (double *unaligned_ptr) |
|
37 { |
|
38 union d2i { double d; int i[2]; }; |
|
39 |
|
40 union d2i *p = (union d2i *) unaligned_ptr; |
|
41 union d2i u; |
|
42 |
|
43 u.i[0] = p->i[0]; |
|
44 u.i[1] = p->i[1]; |
|
45 |
|
46 return u.d; |
|
47 } |
|
48 |
|
49 inline void |
|
50 assign_double (double *unaligned_ptr, double value) |
|
51 { |
|
52 union d2i { double d; int i[2]; }; |
|
53 |
|
54 double *ptr = &value; |
|
55 union d2i *v = (union d2i *) ptr; |
|
56 union d2i *p = (union d2i *) unaligned_ptr; |
|
57 |
|
58 p->i[0] = v->i[0]; |
|
59 p->i[1] = v->i[1]; |
|
60 } |
|
61 |
|
62 #endif |
|
63 #endif |
|
64 |
|
65 /* |
|
66 ;;; Local Variables: *** |
1994
|
67 ;;; mode: C *** |
3
|
68 ;;; page-delimiter: "^/\\*" *** |
|
69 ;;; End: *** |
|
70 */ |