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