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