Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: gcc/libgfortran/generated/count_16_l.c

Issue 3050029: [gcc] GCC 4.5.0=>4.5.1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/nacl-toolchain.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gcc/libgfortran/generated/any_l2.c ('k') | gcc/libgfortran/generated/count_1_l.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Implementation of the COUNT intrinsic 1 /* Implementation of the COUNT intrinsic
2 Copyright 2002, 2007, 2009 Free Software Foundation, Inc. 2 Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
3 Contributed by Paul Brook <paul@nowt.org> 3 Contributed by Paul Brook <paul@nowt.org>
4 4
5 This file is part of the GNU Fortran 95 runtime library (libgfortran). 5 This file is part of the GNU Fortran 95 runtime library (libgfortran).
6 6
7 Libgfortran is free software; you can redistribute it and/or 7 Libgfortran is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 3 of the License, or (at your option) any later version. 10 version 3 of the License, or (at your option) any later version.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 index_type dim; 53 index_type dim;
54 int src_kind; 54 int src_kind;
55 int continue_loop; 55 int continue_loop;
56 56
57 /* Make dim zero based to avoid confusion. */ 57 /* Make dim zero based to avoid confusion. */
58 dim = (*pdim) - 1; 58 dim = (*pdim) - 1;
59 rank = GFC_DESCRIPTOR_RANK (array) - 1; 59 rank = GFC_DESCRIPTOR_RANK (array) - 1;
60 60
61 src_kind = GFC_DESCRIPTOR_SIZE (array); 61 src_kind = GFC_DESCRIPTOR_SIZE (array);
62 62
63 len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; 63 len = GFC_DESCRIPTOR_EXTENT(array,dim);
64 if (len < 0) 64 if (len < 0)
65 len = 0; 65 len = 0;
66 66
67 delta = array->dim[dim].stride * src_kind; 67 delta = GFC_DESCRIPTOR_STRIDE_BYTES(array,dim);
68 68
69 for (n = 0; n < dim; n++) 69 for (n = 0; n < dim; n++)
70 { 70 {
71 sstride[n] = array->dim[n].stride * src_kind; 71 sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n);
72 extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; 72 extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);
73 73
74 if (extent[n] < 0) 74 if (extent[n] < 0)
75 extent[n] = 0; 75 extent[n] = 0;
76 } 76 }
77 for (n = dim; n < rank; n++) 77 for (n = dim; n < rank; n++)
78 { 78 {
79 sstride[n] = array->dim[n + 1].stride * src_kind; 79 sstride[n] = GFC_DESCRIPTOR_STRIDE_BYTES(array,n + 1);
80 extent[n] = 80 extent[n] = GFC_DESCRIPTOR_EXTENT(array,n + 1);
81 array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound;
82 81
83 if (extent[n] < 0) 82 if (extent[n] < 0)
84 extent[n] = 0; 83 extent[n] = 0;
85 } 84 }
86 85
87 if (retarray->data == NULL) 86 if (retarray->data == NULL)
88 { 87 {
89 size_t alloc_size; 88 size_t alloc_size, str;
90 89
91 for (n = 0; n < rank; n++) 90 for (n = 0; n < rank; n++)
92 { 91 {
93 retarray->dim[n].lbound = 0;
94 retarray->dim[n].ubound = extent[n]-1;
95 if (n == 0) 92 if (n == 0)
96 retarray->dim[n].stride = 1; 93 str = 1;
97 else 94 else
98 retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; 95 str = GFC_DESCRIPTOR_STRIDE(retarray,n-1) * extent[n-1];
96
97 » GFC_DIMENSION_SET(retarray->dim[n], 0, extent[n] - 1, str);
98
99 } 99 }
100 100
101 retarray->offset = 0; 101 retarray->offset = 0;
102 retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; 102 retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank;
103 103
104 alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride 104 alloc_size = sizeof (GFC_INTEGER_16) * GFC_DESCRIPTOR_STRIDE(retarray,rank -1)
105 * extent[rank-1]; 105 * extent[rank-1];
106 106
107 if (alloc_size == 0) 107 if (alloc_size == 0)
108 { 108 {
109 /* Make sure we have a zero-sized array. */ 109 /* Make sure we have a zero-sized array. */
110 » retarray->dim[0].lbound = 0; 110 » GFC_DIMENSION_SET(retarray->dim[0], 0, -1, 1);
111 » retarray->dim[0].ubound = -1;
112 return; 111 return;
113 } 112 }
114 else 113 else
115 retarray->data = internal_malloc_size (alloc_size); 114 retarray->data = internal_malloc_size (alloc_size);
116 } 115 }
117 else 116 else
118 { 117 {
119 if (rank != GFC_DESCRIPTOR_RANK (retarray)) 118 if (rank != GFC_DESCRIPTOR_RANK (retarray))
120 runtime_error ("rank of return array incorrect in" 119 runtime_error ("rank of return array incorrect in"
121 " COUNT intrinsic: is %ld, should be %ld", 120 " COUNT intrinsic: is %ld, should be %ld",
122 (long int) GFC_DESCRIPTOR_RANK (retarray), 121 (long int) GFC_DESCRIPTOR_RANK (retarray),
123 (long int) rank); 122 (long int) rank);
124 123
125 if (unlikely (compile_options.bounds_check)) 124 if (unlikely (compile_options.bounds_check))
126 { 125 {
127 for (n=0; n < rank; n++) 126 for (n=0; n < rank; n++)
128 { 127 {
129 index_type ret_extent; 128 index_type ret_extent;
130 129
131 » ret_extent = retarray->dim[n].ubound + 1 130 » ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n);
132 » » - retarray->dim[n].lbound;
133 if (extent[n] != ret_extent) 131 if (extent[n] != ret_extent)
134 runtime_error ("Incorrect extent in return value of" 132 runtime_error ("Incorrect extent in return value of"
135 " COUNT intrinsic in dimension %d:" 133 " COUNT intrinsic in dimension %d:"
136 " is %ld, should be %ld", (int) n + 1, 134 " is %ld, should be %ld", (int) n + 1,
137 (long int) ret_extent, (long int) extent[n]); 135 (long int) ret_extent, (long int) extent[n]);
138 } 136 }
139 } 137 }
140 } 138 }
141 139
142 for (n = 0; n < rank; n++) 140 for (n = 0; n < rank; n++)
143 { 141 {
144 count[n] = 0; 142 count[n] = 0;
145 dstride[n] = retarray->dim[n].stride; 143 dstride[n] = GFC_DESCRIPTOR_STRIDE(retarray,n);
146 if (extent[n] <= 0) 144 if (extent[n] <= 0)
147 len = 0; 145 len = 0;
148 } 146 }
149 147
150 base = array->data; 148 base = array->data;
151 149
152 if (src_kind == 1 || src_kind == 2 || src_kind == 4 || src_kind == 8 150 if (src_kind == 1 || src_kind == 2 || src_kind == 4 || src_kind == 8
153 #ifdef HAVE_GFC_LOGICAL_16 151 #ifdef HAVE_GFC_LOGICAL_16
154 || src_kind == 16 152 || src_kind == 16
155 #endif 153 #endif
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 { 208 {
211 count[n]++; 209 count[n]++;
212 base += sstride[n]; 210 base += sstride[n];
213 dest += dstride[n]; 211 dest += dstride[n];
214 } 212 }
215 } 213 }
216 } 214 }
217 } 215 }
218 216
219 #endif 217 #endif
OLDNEW
« no previous file with comments | « gcc/libgfortran/generated/any_l2.c ('k') | gcc/libgfortran/generated/count_1_l.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698