]>
Commit | Line | Data |
---|---|---|
6de9cd9a | 1 | `/* Implementation of the MAXLOC intrinsic |
85ec4feb | 2 | Copyright (C) 2002-2018 Free Software Foundation, Inc. |
6de9cd9a DN |
3 | Contributed by Paul Brook <paul@nowt.org> |
4 | ||
0cd0559e | 5 | This file is part of the GNU Fortran runtime library (libgfortran). |
6de9cd9a DN |
6 | |
7 | Libgfortran is free software; you can redistribute it and/or | |
57dea9f6 | 8 | modify it under the terms of the GNU General Public |
6de9cd9a | 9 | License as published by the Free Software Foundation; either |
748086b7 | 10 | version 3 of the License, or (at your option) any later version. |
6de9cd9a DN |
11 | |
12 | Libgfortran is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
57dea9f6 | 15 | GNU General Public License for more details. |
6de9cd9a | 16 | |
748086b7 JJ |
17 | Under Section 7 of GPL version 3, you are granted additional |
18 | permissions described in the GCC Runtime Library Exception, version | |
19 | 3.1, as published by the Free Software Foundation. | |
20 | ||
21 | You should have received a copy of the GNU General Public License and | |
22 | a copy of the GCC Runtime Library Exception along with this program; | |
23 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
24 | <http://www.gnu.org/licenses/>. */ | |
6de9cd9a | 25 | |
e034421f | 26 | #include "libgfortran.h"' |
6de9cd9a DN |
27 | |
28 | include(iparm.m4)dnl | |
29 | include(ifunction.m4)dnl | |
644cb69f FXC |
30 | |
31 | `#if defined (HAVE_'atype_name`) && defined (HAVE_'rtype_name`)' | |
32 | ||
6de9cd9a | 33 | ARRAY_FUNCTION(0, |
80927a56 JJ |
34 | ` atype_name maxval; |
35 | #if defined ('atype_inf`) | |
36 | maxval = -atype_inf; | |
37 | #else | |
38 | maxval = atype_min; | |
39 | #endif | |
40 | result = 1;', | |
41 | `#if defined ('atype_nan`) | |
42 | if (*src >= maxval) | |
43 | { | |
44 | maxval = *src; | |
45 | result = (rtype_name)n + 1; | |
46 | break; | |
47 | } | |
48 | } | |
49 | for (; n < len; n++, src += delta) | |
50 | { | |
51 | #endif | |
52 | if (*src > maxval) | |
53 | { | |
54 | maxval = *src; | |
55 | result = (rtype_name)n + 1; | |
0cd0559e | 56 | }', `') |
6de9cd9a DN |
57 | |
58 | MASKED_ARRAY_FUNCTION(0, | |
80927a56 JJ |
59 | ` atype_name maxval; |
60 | #if defined ('atype_inf`) | |
61 | maxval = -atype_inf; | |
62 | #else | |
63 | maxval = atype_min; | |
64 | #endif | |
65 | #if defined ('atype_nan`) | |
66 | rtype_name result2 = 0; | |
67 | #endif | |
68 | result = 0;', | |
69 | ` if (*msrc) | |
70 | { | |
71 | #if defined ('atype_nan`) | |
72 | if (!result2) | |
73 | result2 = (rtype_name)n + 1; | |
74 | if (*src >= maxval) | |
75 | #endif | |
76 | { | |
77 | maxval = *src; | |
78 | result = (rtype_name)n + 1; | |
79 | break; | |
80 | } | |
81 | } | |
82 | } | |
83 | #if defined ('atype_nan`) | |
84 | if (unlikely (n >= len)) | |
85 | result = result2; | |
86 | else | |
87 | #endif | |
88 | for (; n < len; n++, src += delta, msrc += mdelta) | |
89 | { | |
90 | if (*msrc && *src > maxval) | |
91 | { | |
92 | maxval = *src; | |
93 | result = (rtype_name)n + 1; | |
94 | }') | |
6de9cd9a | 95 | |
97a62038 TK |
96 | SCALAR_ARRAY_FUNCTION(0) |
97 | ||
644cb69f | 98 | #endif |