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