]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgfortran/m4/minloc0.m4
Update copyright years.
[thirdparty/gcc.git] / libgfortran / m4 / minloc0.m4
CommitLineData
6de9cd9a 1`/* Implementation of the MINLOC intrinsic
7adcbafe 2 Copyright (C) 2002-2022 Free Software Foundation, Inc.
6de9cd9a
DN
3 Contributed by Paul Brook <paul@nowt.org>
4
57dea9f6 5This file is part of the GNU Fortran 95 runtime library (libgfortran).
6de9cd9a
DN
6
7Libgfortran is free software; you can redistribute it and/or
57dea9f6 8modify it under the terms of the GNU General Public
6de9cd9a 9License as published by the Free Software Foundation; either
748086b7 10version 3 of the License, or (at your option) any later version.
6de9cd9a
DN
11
12Libgfortran is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57dea9f6 15GNU General Public License for more details.
6de9cd9a 16
748086b7
JJ
17Under Section 7 of GPL version 3, you are granted additional
18permissions described in the GCC Runtime Library Exception, version
193.1, as published by the Free Software Foundation.
20
21You should have received a copy of the GNU General Public License and
22a copy of the GCC Runtime Library Exception along with this program;
23see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24<http://www.gnu.org/licenses/>. */
6de9cd9a 25
64b1806b
TK
26#include "libgfortran.h"
27#include <assert.h>'
6de9cd9a
DN
28
29include(iparm.m4)dnl
30include(iforeach.m4)dnl
31
644cb69f
FXC
32`#if defined (HAVE_'atype_name`) && defined (HAVE_'rtype_name`)'
33
6de9cd9a 34FOREACH_FUNCTION(
80927a56
JJ
35` atype_name minval;
36#if defined('atype_nan`)
37 int fast = 0;
38#endif
6de9cd9a 39
80927a56
JJ
40#if defined('atype_inf`)
41 minval = atype_inf;
42#else
43 minval = atype_max;
44#endif',
45`#if defined('atype_nan`)
80927a56
JJ
46 if (unlikely (!fast))
47 {
48 do
49 {
50 if (*base <= minval)
51 {
52 fast = 1;
53 minval = *base;
54 for (n = 0; n < rank; n++)
55 dest[n * dstride] = count[n] + 1;
56 break;
57 }
58 base += sstride[0];
59 }
60 while (++count[0] != extent[0]);
61 if (likely (fast))
62 continue;
63 }
b573f931 64 else
80927a56 65#endif
fc560ecd
JJ
66 if (back)
67 do
68 {
69 if (unlikely (*base <= minval))
70 {
71 minval = *base;
72 for (n = 0; n < rank; n++)
73 dest[n * dstride] = count[n] + 1;
74 }
75 base += sstride[0];
76 }
77 while (++count[0] != extent[0]);
78 else
79 do
80 {
81 if (unlikely (*base < minval))
82 {
83 minval = *base;
84 for (n = 0; n < rank; n++)
85 dest[n * dstride] = count[n] + 1;
86 }')
6de9cd9a 87MASKED_FOREACH_FUNCTION(
c9e66eda 88` atype_name minval;
80927a56 89 int fast = 0;
6de9cd9a 90
80927a56
JJ
91#if defined('atype_inf`)
92 minval = atype_inf;
93#else
94 minval = atype_max;
95#endif',
b573f931 96` if (unlikely (!fast))
80927a56
JJ
97 {
98 do
99 {
100 if (*mbase)
101 {
102#if defined('atype_nan`)
103 if (unlikely (dest[0] == 0))
104 for (n = 0; n < rank; n++)
105 dest[n * dstride] = count[n] + 1;
106 if (*base <= minval)
107#endif
108 {
109 fast = 1;
110 minval = *base;
111 for (n = 0; n < rank; n++)
112 dest[n * dstride] = count[n] + 1;
113 break;
114 }
115 }
116 base += sstride[0];
117 mbase += mstride[0];
118 }
119 while (++count[0] != extent[0]);
120 if (likely (fast))
121 continue;
122 }
b573f931
TK
123 else
124 if (back)
125 do
80927a56 126 {
b573f931
TK
127 if (unlikely (*mbase && (*base <= minval)))
128 {
129 minval = *base;
130 for (n = 0; n < rank; n++)
131 dest[n * dstride] = count[n] + 1;
132 }
133 base += sstride[0];
134 }
135 while (++count[0] != extent[0]);
136 else
137 do
138 {
139 if (unlikely (*mbase && (*base < minval)))
140 {
141 minval = *base;
142 for (n = 0; n < rank; n++)
143 dest[n * dstride] = count[n] + 1;
144 }')
97a62038 145SCALAR_FOREACH_FUNCTION(`0')
644cb69f 146#endif