3
|
1 /* |
|
2 |
1883
|
3 Copyright (C) 1996 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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
3
|
20 |
|
21 */ |
|
22 |
382
|
23 #if !defined (octave_sun_utils_h) |
|
24 #define octave_sun_utils_h 1 |
|
25 |
1296
|
26 #if defined (sun) |
3
|
27 |
1359
|
28 // I think that this is really only needed if linking to Fortran |
|
29 // compiled libraries on a Sun. It should never be called. |
|
30 // There should probably be a sysdep.cc file, eh? |
3
|
31 |
|
32 extern "C" int MAIN_ (void); |
|
33 |
1359
|
34 // This is only needed to dereference pointers to doubles if mixing |
|
35 // GCC and Sun f77/cc compiled code. See the GCC manual (where the |
|
36 // function access_double() is described) and the Sun f77 manual, |
|
37 // which explains that doubles are not always aligned on 8 byte |
|
38 // boundaries. |
3
|
39 |
1296
|
40 #if defined (__GNUC__) |
3
|
41 |
|
42 inline double |
|
43 access_double (double *unaligned_ptr) |
|
44 { |
|
45 union d2i { double d; int i[2]; }; |
|
46 |
|
47 union d2i *p = (union d2i *) unaligned_ptr; |
|
48 union d2i u; |
|
49 |
|
50 u.i[0] = p->i[0]; |
|
51 u.i[1] = p->i[1]; |
|
52 |
|
53 return u.d; |
|
54 } |
|
55 |
|
56 inline void |
|
57 assign_double (double *unaligned_ptr, double value) |
|
58 { |
|
59 union d2i { double d; int i[2]; }; |
|
60 |
|
61 double *ptr = &value; |
|
62 union d2i *v = (union d2i *) ptr; |
|
63 union d2i *p = (union d2i *) unaligned_ptr; |
|
64 |
|
65 p->i[0] = v->i[0]; |
|
66 p->i[1] = v->i[1]; |
|
67 } |
|
68 |
|
69 #endif |
|
70 #endif |
|
71 #endif |
|
72 |
|
73 /* |
|
74 ;;; Local Variables: *** |
|
75 ;;; mode: C++ *** |
|
76 ;;; page-delimiter: "^/\\*" *** |
|
77 ;;; End: *** |
|
78 */ |