OSDN Git Service

gfortran ChangeLog
[pf3gnuchains/gcc-fork.git] / libgfortran / io / size_from_kind.c
1 /* Copyright (C) 2005 Free Software Foundation, Inc.
2    Contributed by Janne Blomqvist
3
4 This file is part of the GNU Fortran runtime library (libgfortran).
5
6 Libgfortran is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 In addition to the permissions in the GNU General Public License, the
12 Free Software Foundation gives you unlimited permission to link the
13 compiled version of this file into combinations with other programs,
14 and to distribute those combinations without any restriction coming
15 from the use of this file.  (The General Public License restrictions
16 do apply in other respects; for example, they cover modification of
17 the file, and distribution when not linked into a combine
18 executable.)
19
20 Libgfortran is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with Libgfortran; see the file COPYING.  If not, write to
27 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
28 Boston, MA 02110-1301, USA.  */
29
30
31 /* This file contains utility functions for determining the size of a
32    variable given its kind. */
33
34 #include "io.h"
35
36 size_t
37 size_from_real_kind (int kind)
38 {
39   switch (kind)
40     {
41 #ifdef HAVE_GFC_REAL_4
42     case 4:
43       return sizeof (GFC_REAL_4);
44 #endif
45 #ifdef HAVE_GFC_REAL_8
46     case 8:
47       return sizeof (GFC_REAL_8);
48 #endif
49 #ifdef HAVE_GFC_REAL_10
50     case 10:
51       return sizeof (GFC_REAL_10);
52 #endif
53 #ifdef HAVE_GFC_REAL_16
54     case 16:
55       return sizeof (GFC_REAL_16);
56 #endif
57     default:
58       return kind;
59     }
60 }
61
62
63 size_t
64 size_from_complex_kind (int kind)
65 {
66   switch (kind)
67     {
68 #ifdef HAVE_GFC_COMPLEX_4
69     case 4:
70       return sizeof (GFC_COMPLEX_4);
71 #endif
72 #ifdef HAVE_GFC_COMPLEX_8
73     case 8:
74       return sizeof (GFC_COMPLEX_8);
75 #endif
76 #ifdef HAVE_GFC_COMPLEX_10
77     case 10:
78       return sizeof (GFC_COMPLEX_10);
79 #endif
80 #ifdef HAVE_GFC_COMPLEX_16
81     case 16:
82       return sizeof (GFC_COMPLEX_16);
83 #endif
84     default:
85       return 2 * kind;
86     }
87 }
88