1 /*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18 /* scalar_copy.c - scalar element copy routines */
19
20 #include "stdioInterf.h"
21 #include "fioMacros.h"
22
23 static void
copy_none(__SHORT_T * rp,__SHORT_T * sp,int size)24 copy_none(__SHORT_T *rp, __SHORT_T *sp, int size)
25 {
26 __fort_abort("scalar_copy: undefined type");
27 }
28 static void
copy_short(__SHORT_T * rp,__SHORT_T * sp,int size)29 copy_short(__SHORT_T *rp, __SHORT_T *sp, int size)
30 {
31 *rp = *sp;
32 }
33 static void
copy_ushort(__USHORT_T * rp,__USHORT_T * sp,int size)34 copy_ushort(__USHORT_T *rp, __USHORT_T *sp, int size)
35 {
36 *rp = *sp;
37 }
38 static void
copy_cint(__CINT_T * rp,__CINT_T * sp,int size)39 copy_cint(__CINT_T *rp, __CINT_T *sp, int size)
40 {
41 *rp = *sp;
42 }
43 static void
copy_uint(__UINT_T * rp,__UINT_T * sp,int size)44 copy_uint(__UINT_T *rp, __UINT_T *sp, int size)
45 {
46 *rp = *sp;
47 }
48 static void
copy_long(__LONG_T * rp,__LONG_T * sp,int size)49 copy_long(__LONG_T *rp, __LONG_T *sp, int size)
50 {
51 *rp = *sp;
52 }
53 static void
copy_ulong(__ULONG_T * rp,__ULONG_T * sp,int size)54 copy_ulong(__ULONG_T *rp, __ULONG_T *sp, int size)
55 {
56 *rp = *sp;
57 }
58 static void
copy_float(__FLOAT_T * rp,__FLOAT_T * sp,int size)59 copy_float(__FLOAT_T *rp, __FLOAT_T *sp, int size)
60 {
61 *rp = *sp;
62 }
63 static void
copy_double(__DOUBLE_T * rp,__DOUBLE_T * sp,int size)64 copy_double(__DOUBLE_T *rp, __DOUBLE_T *sp, int size)
65 {
66 *rp = *sp;
67 }
68 static void
copy_cplx8(__CPLX8_T * rp,__CPLX8_T * sp,int size)69 copy_cplx8(__CPLX8_T *rp, __CPLX8_T *sp, int size)
70 {
71 *rp = *sp;
72 }
73 static void
copy_cplx16(__CPLX16_T * rp,__CPLX16_T * sp,int size)74 copy_cplx16(__CPLX16_T *rp, __CPLX16_T *sp, int size)
75 {
76 *rp = *sp;
77 }
78 static void
copy_char(__CHAR_T * rp,__CHAR_T * sp,int size)79 copy_char(__CHAR_T *rp, __CHAR_T *sp, int size)
80 {
81 *rp = *sp;
82 }
83 static void
copy_uchar(__UCHAR_T * rp,__UCHAR_T * sp,int size)84 copy_uchar(__UCHAR_T *rp, __UCHAR_T *sp, int size)
85 {
86 *rp = *sp;
87 }
88 static void
copy_longdouble(__LONGDOUBLE_T * rp,__LONGDOUBLE_T * sp,int size)89 copy_longdouble(__LONGDOUBLE_T *rp, __LONGDOUBLE_T *sp, int size)
90 {
91 *rp = *sp;
92 }
93 static void
copy_longlong(__LONGLONG_T * rp,__LONGLONG_T * sp,int size)94 copy_longlong(__LONGLONG_T *rp, __LONGLONG_T *sp, int size)
95 {
96 *rp = *sp;
97 }
98 static void
copy_ulonglong(__ULONGLONG_T * rp,__ULONGLONG_T * sp,int size)99 copy_ulonglong(__ULONGLONG_T *rp, __ULONGLONG_T *sp, int size)
100 {
101 *rp = *sp;
102 }
103 static void
copy_log1(__LOG1_T * rp,__LOG1_T * sp,int size)104 copy_log1(__LOG1_T *rp, __LOG1_T *sp, int size)
105 {
106 *rp = *sp;
107 }
108 static void
copy_log2(__LOG2_T * rp,__LOG2_T * sp,int size)109 copy_log2(__LOG2_T *rp, __LOG2_T *sp, int size)
110 {
111 *rp = *sp;
112 }
113 static void
copy_log4(__LOG4_T * rp,__LOG4_T * sp,int size)114 copy_log4(__LOG4_T *rp, __LOG4_T *sp, int size)
115 {
116 *rp = *sp;
117 }
118 static void
copy_log8(__LOG8_T * rp,__LOG8_T * sp,int size)119 copy_log8(__LOG8_T *rp, __LOG8_T *sp, int size)
120 {
121 *rp = *sp;
122 }
123 static void
copy_word4(__WORD4_T * rp,__WORD4_T * sp,int size)124 copy_word4(__WORD4_T *rp, __WORD4_T *sp, int size)
125 {
126 *rp = *sp;
127 }
128 static void
copy_word8(__WORD8_T * rp,__WORD8_T * sp,int size)129 copy_word8(__WORD8_T *rp, __WORD8_T *sp, int size)
130 {
131 *rp = *sp;
132 }
133 static void
copy_nchar(__NCHAR_T * rp,__NCHAR_T * sp,int size)134 copy_nchar(__NCHAR_T *rp, __NCHAR_T *sp, int size)
135 {
136 *rp = *sp;
137 }
138 static void
copy_int2(__INT2_T * rp,__INT2_T * sp,int size)139 copy_int2(__INT2_T *rp, __INT2_T *sp, int size)
140 {
141 *rp = *sp;
142 }
143 static void
copy_int4(__INT4_T * rp,__INT4_T * sp,int size)144 copy_int4(__INT4_T *rp, __INT4_T *sp, int size)
145 {
146 *rp = *sp;
147 }
148 static void
copy_int8(__INT8_T * rp,__INT8_T * sp,int size)149 copy_int8(__INT8_T *rp, __INT8_T *sp, int size)
150 {
151 *rp = *sp;
152 }
153 static void
copy_real4(__REAL4_T * rp,__REAL4_T * sp,int size)154 copy_real4(__REAL4_T *rp, __REAL4_T *sp, int size)
155 {
156 *rp = *sp;
157 }
158 static void
copy_real8(__REAL8_T * rp,__REAL8_T * sp,int size)159 copy_real8(__REAL8_T *rp, __REAL8_T *sp, int size)
160 {
161 *rp = *sp;
162 }
163 static void
copy_real16(__REAL16_T * rp,__REAL16_T * sp,int size)164 copy_real16(__REAL16_T *rp, __REAL16_T *sp, int size)
165 {
166 *rp = *sp;
167 }
168 static void
copy_cplx32(__CPLX32_T * rp,__CPLX32_T * sp,int size)169 copy_cplx32(__CPLX32_T *rp, __CPLX32_T *sp, int size)
170 {
171 *rp = *sp;
172 }
173 static void
copy_word16(__WORD16_T * rp,__WORD16_T * sp,int size)174 copy_word16(__WORD16_T *rp, __WORD16_T *sp, int size)
175 {
176 *rp = *sp;
177 }
178 static void
copy_int1(__INT1_T * rp,__INT1_T * sp,int size)179 copy_int1(__INT1_T *rp, __INT1_T *sp, int size)
180 {
181 *rp = *sp;
182 }
183
184 static void copy_bytes(char *, char *, int);
185
186 void (*__fort_scalar_copy[__NTYPES])() = {
187 copy_none, /* no type (absent optional argument) */
188 copy_short, /* C signed short */
189 copy_ushort, /* C unsigned short */
190 copy_cint, /* C signed int */
191 copy_uint, /* C unsigned int */
192 copy_long, /* C signed long int */
193 copy_ulong, /* C unsigned long int */
194 copy_float, /* C float */
195 copy_double, /* C double */
196 copy_cplx8, /* F complex*8 (2x real*4) */
197 copy_cplx16, /* F complex*16 (2x real*8) */
198 copy_char, /* C signed char */
199 copy_uchar, /* C unsigned char */
200 copy_longdouble, /* C long double */
201 copy_bytes, /* F character */
202 copy_longlong, /* C long long */
203 copy_ulonglong, /* C unsigned long long */
204 copy_log1, /* F logical*1 */
205 copy_log2, /* F logical*2 */
206 copy_log4, /* F logical*4 */
207 copy_log8, /* F logical*8 */
208 copy_word4, /* F typeless */
209 copy_word8, /* F double typeless */
210 copy_nchar, /* F ncharacter - kanji */
211 copy_int2, /* F integer*2 */
212 copy_int4, /* F integer*4, integer */
213 copy_int8, /* F integer*8 */
214 copy_real4, /* F real*4, real */
215 copy_real8, /* F real*8, double precision */
216 copy_real16, /* F real*16 */
217 copy_cplx32, /* F complex*32 (2x real*16) */
218 copy_word16, /* F quad typeless */
219 copy_int1, /* F integer*1 */
220 copy_bytes /* F derived type */
221 };
222
223 static void
copy_bytes(char * to,char * fr,int n)224 copy_bytes(char *to, char *fr, int n)
225 {
226 memmove(to, fr, n);
227 }
228