3
|
1 // sun-utils.h -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 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 |
|
29 /* |
|
30 * I think that this is really only needed if linking to Fortran |
|
31 * compiled libraries on a Sun. It should never be called. |
|
32 * There should probably be a sysdep.cc file, eh? |
|
33 */ |
|
34 |
|
35 extern "C" int MAIN_ (void); |
|
36 |
|
37 /* |
|
38 * This is only needed to dereference pointers to doubles if mixing |
|
39 * GCC and Sun f77/cc compiled code. See the GCC manual (where the |
|
40 * function access_double() is described) and the Sun f77 manual, |
|
41 * which explains that doubles are not always aligned on 8 byte |
|
42 * boundaries. |
|
43 */ |
|
44 |
1296
|
45 #if defined (__GNUC__) |
3
|
46 |
|
47 inline double |
|
48 access_double (double *unaligned_ptr) |
|
49 { |
|
50 union d2i { double d; int i[2]; }; |
|
51 |
|
52 union d2i *p = (union d2i *) unaligned_ptr; |
|
53 union d2i u; |
|
54 |
|
55 u.i[0] = p->i[0]; |
|
56 u.i[1] = p->i[1]; |
|
57 |
|
58 return u.d; |
|
59 } |
|
60 |
|
61 inline void |
|
62 assign_double (double *unaligned_ptr, double value) |
|
63 { |
|
64 union d2i { double d; int i[2]; }; |
|
65 |
|
66 double *ptr = &value; |
|
67 union d2i *v = (union d2i *) ptr; |
|
68 union d2i *p = (union d2i *) unaligned_ptr; |
|
69 |
|
70 p->i[0] = v->i[0]; |
|
71 p->i[1] = v->i[1]; |
|
72 } |
|
73 |
|
74 #endif |
|
75 #endif |
|
76 #endif |
|
77 |
|
78 /* |
|
79 ;;; Local Variables: *** |
|
80 ;;; mode: C++ *** |
|
81 ;;; page-delimiter: "^/\\*" *** |
|
82 ;;; End: *** |
|
83 */ |