1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
* Copyright by the Board of Trustees of the University of Illinois. *
3
* All rights reserved. *
5
* This file is part of HDF5. The full HDF5 copyright notice, including *
6
* terms governing use, modification, and redistribution, is contained in *
7
* the files COPYING and Copyright.html. COPYING can be found at the root *
8
* of the source code distribution tree; Copyright.html can be found at the *
9
* root level of an installed copy of the electronic HDF5 document set and *
10
* is linked from the top-level documents page. It can also be found at *
11
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
12
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
13
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16
* Module Info: Data type conversions for the H5T interface.
19
#define H5T_PACKAGE /*suppress error about including H5Tpkg */
22
#include "H5private.h" /*generic functions */
23
#include "H5Eprivate.h" /*error handling */
24
#include "H5FLprivate.h" /*Free Lists */
25
#include "H5Iprivate.h" /*ID functions */
26
#include "H5MMprivate.h" /*memory management */
27
#include "H5Pprivate.h" /* Property Lists */
28
#include "H5Tpkg.h" /*data-type functions */
30
/* Conversion data for H5T_conv_struct() */
31
typedef struct H5T_conv_struct_t {
32
int *src2dst; /*mapping from src to dst member num */
33
hid_t *src_memb_id; /*source member type ID's */
34
hid_t *dst_memb_id; /*destination member type ID's */
35
H5T_path_t **memb_path; /*conversion path for each member */
38
/* Conversion data for H5T_conv_enum() */
39
typedef struct H5T_enum_struct_t {
40
int base; /*lowest `in' value */
41
int length; /*num elements in arrays */
42
int *src2dst; /*map from src to dst index */
45
/* Conversion data for the hardware conversion functions */
46
typedef struct H5T_conv_hw_t {
47
size_t s_aligned; /*number source elements aligned */
48
size_t d_aligned; /*number destination elements aligned*/
51
/* Declare a free list to manage pieces of vlen data */
52
H5FL_BLK_DEFINE_STATIC(vlen_seq);
54
/* Declare a free list to manage pieces of array data */
55
H5FL_BLK_DEFINE_STATIC(array_seq);
58
* These macros are for the bodies of functions that convert buffers of one
59
* atomic type to another using hardware.
61
* They all start with `H5T_CONV_' and end with two letters that represent the
62
* source and destination types, respectively. The letters `s' and `S' refer to
63
* signed integers while the letters `u' and `U' refer to unsigned integers, and
64
* the letters `f' and `F' refer to floating-point values.
66
* The letter which is capitalized indicates that the corresponding type
67
* (source or destination) is at least as large as the other type.
69
* Certain conversions may experience overflow conditions which arise when the
70
* source value has a magnitude that cannot be represented by the destination
75
* sS: Signed integers to signed integers where the destination is
76
* at least as wide as the source. This case cannot generate
79
* sU: Signed integers to unsigned integers where the destination is
80
* at least as wide as the source. This case experiences
81
* overflows when the source value is negative.
83
* uS: Unsigned integers to signed integers where the destination is
84
* at least as wide as the source. This case can experience
85
* overflows when the source and destination are the same size.
87
* uU: Unsigned integers to unsigned integers where the destination
88
* is at least as wide as the source. Overflows are not
89
* possible in this case.
91
* Ss: Signed integers to signed integers where the source is at
92
* least as large as the destination. Overflows can occur when
93
* the destination is narrower than the source.
95
* Su: Signed integers to unsigned integers where the source is at
96
* least as large as the destination. Overflows occur when the
97
* source value is negative and can also occur if the
98
* destination is narrower than the source.
100
* Us: Unsigned integers to signed integers where the source is at
101
* least as large as the destination. Overflows can occur for
104
* Uu: Unsigned integers to unsigned integers where the source is at
105
* least as large as the destination. Overflows can occur if the
106
* destination is narrower than the source.
108
* su: Conversion from signed integers to unsigned integers where
109
* the source and destination are the same size. Overflow occurs
110
* when the source value is negative.
112
* us: Conversion from unsigned integers to signed integers where
113
* the source and destination are the same size. Overflow
114
* occurs when the source magnitude is too large for the
117
* fF: Floating-point values to floating-point values where the
118
* destination is at least as wide as the source. This case
119
* cannot generate overflows.
121
* Ff: Floating-point values to floating-point values the source is at
122
* least as large as the destination. Overflows can occur when
123
* the destination is narrower than the source.
125
* The macros take a subset of these arguments in the order listed here:
127
* CDATA: A pointer to the H5T_cdata_t structure that was passed to the
128
* conversion function.
130
* STYPE: The hid_t value for the source data type.
132
* DTYPE: The hid_t value for the destination data type.
134
* BUF: A pointer to the conversion buffer.
136
* NELMTS: The number of values to be converted.
138
* ST: The C name for source data type (e.g., int)
140
* DT: The C name for the destination data type (e.g., signed char)
142
* D_MIN: The minimum possible destination value. For unsigned
143
* destination types this should be zero. For signed
144
* destination types it's a negative value with a magnitude that
145
* is usually one greater than D_MAX. Source values which are
146
* smaller than D_MIN generate overflows.
148
* D_MAX: The maximum possible destination value. Source values which
149
* are larger than D_MAX generate overflows.
151
* The macros are implemented with a generic programming technique, similar
152
* to templates in C++. The macro which defines the "core" part of the
153
* conversion (which actually moves the data from the source to the destination)
154
* is invoked inside the H5T_CONV "template" macro by "gluing" it together,
155
* which allows the core conversion macro to be invoked as necessary.
157
* "Core" macros come in two flavors: one which calls the exception handling
158
* routine and one which doesn't (the "_NOEX" variant). The presence of the
159
* exception handling routine is detected before the loop over the values and
160
* the appropriate core routine loop is executed.
162
* The generic "core" macros are: (others are specific to particular conversion)
166
* xX: Generic Conversion where the destination is at least as
167
* wide as the source. This case cannot generate overflows.
169
* Xx: Generic signed conversion where the source is at least as large
170
* as the destination. Overflows can occur when the destination is
171
* narrower than the source.
173
* Ux: Generic conversion for the `Us', `Uu' & `us' cases
174
* Overflow occurs when the source magnitude is too large for the
178
#define H5T_CONV_xX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
179
*((DT*)D) = (DT)(*((ST*)S)); \
181
#define H5T_CONV_xX_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
182
*((DT*)D) = (DT)(*((ST*)S)); \
185
/* Added a condition branch(else if (*((ST*)S) == (DT)(D_MAX))) which seems redundant.
186
* It handles a special situation when the source is "float" and assigned the value
187
* of "INT_MAX". A compiler may do roundup making this value "INT_MAX+1". However,
188
* when do comparison "if (*((ST*)S) > (DT)(D_MAX))", the compiler may consider them
189
* equal. In this case, do not return exception but make sure the maximum is assigned
190
* to the destination. SLU - 2005/06/29
192
#define H5T_CONV_Xx_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
193
if (*((ST*)S) > (DT)(D_MAX)) { \
194
if ((H5T_overflow_g)(src_id, dst_id, S, D)<0) \
195
*((DT*)D) = (D_MAX); \
196
} else if (*((ST*)S) == (DT)(D_MAX)) { \
197
*((DT*)D) = (D_MAX); \
198
} else if (*((ST*)S) < (DT)(D_MIN)) { \
199
if ((H5T_overflow_g)(src_id, dst_id, S, D)<0) \
200
*((DT*)D) = (D_MIN); \
202
*((DT*)D) = (DT)(*((ST*)S)); \
204
#define H5T_CONV_Xx_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
205
if (*((ST*)S) > (DT)(D_MAX)) { \
206
*((DT*)D) = (D_MAX); \
207
} else if (*((ST*)S) == (DT)(D_MAX)) { \
208
*((DT*)D) = (D_MAX); \
209
} else if (*((ST*)S) < (DT)(D_MIN)) { \
210
*((DT*)D) = (D_MIN); \
212
*((DT*)D) = (DT)(*((ST*)S)); \
215
#define H5T_CONV_Ux_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
216
if (*((ST*)S) > (DT)(D_MAX)) { \
217
if ((H5T_overflow_g)(src_id, dst_id, S, D)<0) \
218
*((DT*)D) = (D_MAX); \
220
*((DT*)D) = (DT)(*((ST*)S)); \
222
#define H5T_CONV_Ux_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
223
if (*((ST*)S) > (DT)(D_MAX)) { \
224
*((DT*)D) = (D_MAX); \
226
*((DT*)D) = (DT)(*((ST*)S)); \
229
#define H5T_CONV_sS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
230
assert(sizeof(ST)<=sizeof(DT)); \
231
H5T_CONV(H5T_CONV_xX, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
234
#define H5T_CONV_sU_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
236
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \
239
*((DT*)D) = (DT)(*((ST*)S)); \
241
#define H5T_CONV_sU_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
245
*((DT*)D) = (DT)(*((ST*)S)); \
248
#define H5T_CONV_sU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
249
assert(sizeof(ST)<=sizeof(DT)); \
250
H5T_CONV(H5T_CONV_sU, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
253
#define H5T_CONV_uS_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
254
if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \
255
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \
256
*((DT*)D) = (D_MAX); \
258
*((DT*)D) = (DT)(*((ST*)S)); \
260
#define H5T_CONV_uS_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
261
if (sizeof(ST)==sizeof(DT) && *((ST*)S) > (DT)(D_MAX)) { \
262
*((DT*)D) = (D_MAX); \
264
*((DT*)D) = (DT)(*((ST*)S)); \
267
#define H5T_CONV_uS(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
268
assert(sizeof(ST)<=sizeof(DT)); \
269
H5T_CONV(H5T_CONV_uS, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
272
#define H5T_CONV_uU(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
273
assert(sizeof(ST)<=sizeof(DT)); \
274
H5T_CONV(H5T_CONV_xX, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
277
#define H5T_CONV_Ss(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
278
assert(sizeof(ST)>=sizeof(DT)); \
279
H5T_CONV(H5T_CONV_Xx, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
282
#define H5T_CONV_Su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
283
if (*((ST*)S) < 0) { \
284
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \
286
} else if (sizeof(ST)>sizeof(DT) && *((ST*)S)>(ST)(D_MAX)) { \
287
/*sign vs. unsign ok in previous line*/ \
288
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \
289
*((DT*)D) = (D_MAX); \
291
*((DT*)D) = (DT)(*((ST*)S)); \
293
#define H5T_CONV_Su_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
294
if (*((ST*)S) < 0) { \
296
} else if (sizeof(ST)>sizeof(DT) && *((ST*)S)>(ST)(D_MAX)) { \
297
/*sign vs. unsign ok in previous line*/ \
298
*((DT*)D) = (D_MAX); \
300
*((DT*)D) = (DT)(*((ST*)S)); \
303
#define H5T_CONV_Su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
304
assert(sizeof(ST)>=sizeof(DT)); \
305
H5T_CONV(H5T_CONV_Su, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
308
#define H5T_CONV_Us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
309
assert(sizeof(ST)>=sizeof(DT)); \
310
H5T_CONV(H5T_CONV_Ux, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
313
#define H5T_CONV_Uu(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
314
assert(sizeof(ST)>=sizeof(DT)); \
315
H5T_CONV(H5T_CONV_Ux, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
318
#define H5T_CONV_su_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
319
/* Assumes memory format of unsigned & signed integers is same */ \
321
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \
324
*((DT*)D) = (DT)(*((ST*)S)); \
326
#define H5T_CONV_su_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
327
/* Assumes memory format of unsigned & signed integers is same */ \
331
*((DT*)D) = (DT)(*((ST*)S)); \
334
#define H5T_CONV_su(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
335
assert(sizeof(ST)==sizeof(DT)); \
336
H5T_CONV(H5T_CONV_su, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
339
#define H5T_CONV_us_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
340
/* Assumes memory format of unsigned & signed integers is same */ \
341
if (*((ST*)S) > (DT)(D_MAX)) { \
342
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \
343
*((DT*)D) = (D_MAX); \
345
*((DT*)D) = (DT)(*((ST*)S)); \
347
#define H5T_CONV_us_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
348
/* Assumes memory format of unsigned & signed integers is same */ \
349
if (*((ST*)S) > (DT)(D_MAX)) { \
350
*((DT*)D) = (D_MAX); \
352
*((DT*)D) = (DT)(*((ST*)S)); \
355
#define H5T_CONV_us(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
356
assert(sizeof(ST)==sizeof(DT)); \
357
H5T_CONV(H5T_CONV_us, long_long, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
360
#define H5T_CONV_fF(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
361
assert(sizeof(ST)<=sizeof(DT)); \
362
H5T_CONV(H5T_CONV_xX, double, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
365
/* Same as H5T_CONV_Xx_CORE, except that instead of using D_MAX and D_MIN
366
* when an overflow occurs, use the 'float' infinity values.
368
#define H5T_CONV_Ff_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
369
if (*((ST*)S) > (DT)(D_MAX)) { \
370
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \
371
*((DT*)D) = (H5T_NATIVE_FLOAT_POS_INF_g); \
372
} else if (*((ST*)S) < (DT)(D_MIN)) { \
373
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, S, D)<0) \
374
*((DT*)D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \
376
*((DT*)D) = (DT)(*((ST*)S)); \
378
#define H5T_CONV_Ff_NOEX_CORE(S,D,ST,DT,D_MIN,D_MAX) { \
379
if (*((ST*)S) > (DT)(D_MAX)) { \
380
*((DT*)D) = (H5T_NATIVE_FLOAT_POS_INF_g); \
381
} else if (*((ST*)S) < (DT)(D_MIN)) { \
382
*((DT*)D) = (H5T_NATIVE_FLOAT_NEG_INF_g); \
384
*((DT*)D) = (DT)(*((ST*)S)); \
387
#define H5T_CONV_Ff(STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
388
assert(sizeof(ST)>=sizeof(DT)); \
389
H5T_CONV(H5T_CONV_Ff, double, STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \
392
/* The main part of every integer hardware conversion macro */
393
#define H5T_CONV(GUTS,ATYPE,STYPE,DTYPE,ST,DT,D_MIN,D_MAX) { \
394
size_t elmtno; /*element number */ \
395
uint8_t *src, *s; /*source buffer */ \
396
uint8_t *dst, *d; /*destination buffer */ \
397
H5T_t *st, *dt; /*data type descriptors */ \
398
ATYPE aligned; /*aligned type */ \
399
hbool_t s_mv, d_mv; /*move data to align it? */ \
400
ssize_t s_stride, d_stride; /*src and dst strides */ \
401
size_t safe; /* How many elements are safe to process in each pass */ \
403
switch (cdata->command) { \
404
case H5T_CONV_INIT: \
405
/* Sanity check and initialize statistics */ \
406
cdata->need_bkg = H5T_BKG_NO; \
407
if (NULL==(st=H5I_object(src_id)) || NULL==(dt=H5I_object(dst_id))) \
408
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \
409
"unable to dereference datatype object ID") \
410
if (st->shared->size!=sizeof(ST) || dt->shared->size!=sizeof(DT)) \
411
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \
412
"disagreement about datatype size") \
416
case H5T_CONV_FREE: \
417
/* Print and free statistics */ \
418
CI_PRINT_STATS(STYPE,DTYPE); \
422
case H5T_CONV_CONV: \
423
/* Initialize source & destination strides */ \
425
assert(buf_stride>=sizeof(ST)); \
426
assert(buf_stride>=sizeof(DT)); \
427
H5_CHECK_OVERFLOW(buf_stride,size_t,ssize_t); \
428
s_stride = d_stride = (ssize_t)buf_stride; \
430
s_stride = sizeof(ST); \
431
d_stride = sizeof(DT); \
434
/* Is alignment required for source or dest? */ \
435
s_mv = H5T_NATIVE_##STYPE##_ALIGN_g>1 && \
436
((size_t)buf%H5T_NATIVE_##STYPE##_ALIGN_g || \
437
/* Cray */ ((size_t)((ST*)buf)!=(size_t)buf) || \
438
s_stride%H5T_NATIVE_##STYPE##_ALIGN_g); \
439
d_mv = H5T_NATIVE_##DTYPE##_ALIGN_g>1 && \
440
((size_t)buf%H5T_NATIVE_##DTYPE##_ALIGN_g || \
441
/* Cray */ ((size_t)((DT*)buf)!=(size_t)buf) || \
442
d_stride%H5T_NATIVE_##DTYPE##_ALIGN_g); \
446
/* The outer loop of the type conversion macro, controlling which */ \
447
/* direction the buffer is walked */ \
449
/* Check if we need to go backwards through the buffer */ \
450
if(d_stride>s_stride) { \
451
/* Compute the number of "safe" destination elements at */ \
452
/* the end of the buffer (Those which don't overlap with */ \
453
/* any source elements at the beginning of the buffer) */ \
454
safe=nelmts-(((nelmts*s_stride)+(d_stride-1))/d_stride); \
456
/* If we're down to the last few elements, just wrap up */ \
457
/* with a "real" reverse copy */ \
459
src = (uint8_t*)buf+(nelmts-1)*s_stride; \
460
dst = (uint8_t*)buf+(nelmts-1)*d_stride; \
461
s_stride = -s_stride; \
462
d_stride = -d_stride; \
467
src = (uint8_t*)buf+(nelmts-safe)*s_stride; \
468
dst = (uint8_t*)buf+(nelmts-safe)*d_stride; \
472
/* Single forward pass over all data */ \
477
/* Perform loop over elements to convert */ \
478
if (s_mv && d_mv) { \
479
/* Alignment is required for both source and dest */ \
480
s = (uint8_t*)&aligned; \
481
H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DALIGN,POST_SALIGN,POST_DALIGN,GUTS,s,d,ST,DT,D_MIN,D_MAX) \
483
/* Alignment is required only for source */ \
484
s = (uint8_t*)&aligned; \
485
H5T_CONV_LOOP_OUTER(PRE_SALIGN,PRE_DNOALIGN,POST_SALIGN,POST_DNOALIGN,GUTS,s,dst,ST,DT,D_MIN,D_MAX) \
487
/* Alignment is required only for destination */ \
488
H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DALIGN,POST_SNOALIGN,POST_DALIGN,GUTS,src,d,ST,DT,D_MIN,D_MAX) \
490
/* Alignment is not required for both source and destination */ \
491
H5T_CONV_LOOP_OUTER(PRE_SNOALIGN,PRE_DNOALIGN,POST_SNOALIGN,POST_DNOALIGN,GUTS,src,dst,ST,DT,D_MIN,D_MAX) \
494
/* Decrement number of elements left to convert */ \
500
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, \
501
"unknown conversion command"); \
505
/* Macro defining action on source data which needs to be aligned (before main action) */
506
#define H5T_CONV_LOOP_PRE_SALIGN(ST) { \
507
HDmemcpy(&aligned, src, sizeof(ST)); \
510
/* Macro defining action on source data which doesn't need to be aligned (before main action) */
511
#define H5T_CONV_LOOP_PRE_SNOALIGN(ST) { \
514
/* Macro defining action on destination data which needs to be aligned (before main action) */
515
#define H5T_CONV_LOOP_PRE_DALIGN(DT) { \
516
d = (uint8_t*)&aligned; \
519
/* Macro defining action on destination data which doesn't need to be aligned (before main action) */
520
#define H5T_CONV_LOOP_PRE_DNOALIGN(DT) { \
523
/* Macro defining action on source data which needs to be aligned (after main action) */
524
#define H5T_CONV_LOOP_POST_SALIGN(ST) { \
527
/* Macro defining action on source data which doesn't need to be aligned (after main action) */
528
#define H5T_CONV_LOOP_POST_SNOALIGN(ST) { \
531
/* Macro defining action on destination data which needs to be aligned (after main action) */
532
#define H5T_CONV_LOOP_POST_DALIGN(DT) { \
533
HDmemcpy(dst, &aligned, sizeof(DT)); \
536
/* Macro defining action on destination data which doesn't need to be aligned (after main action) */
537
#define H5T_CONV_LOOP_POST_DNOALIGN(DT) { \
540
/* The outer wrapper for the type conversion loop, to check for an exception handling routine */
541
#define H5T_CONV_LOOP_OUTER(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,S,D,ST,DT,D_MIN,D_MAX) \
542
if(H5T_overflow_g) { \
543
H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,S,D,ST,DT,D_MIN,D_MAX) \
546
H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,H5_GLUE(GUTS,_NOEX),S,D,ST,DT,D_MIN,D_MAX) \
549
/* The inner loop of the type conversion macro, actually converting the elements */
550
#define H5T_CONV_LOOP(PRE_SALIGN_GUTS,PRE_DALIGN_GUTS,POST_SALIGN_GUTS,POST_DALIGN_GUTS,GUTS,S,D,ST,DT,D_MIN,D_MAX) \
551
for (elmtno=0; elmtno<safe; elmtno++) { \
552
/* Handle source pre-alignment */ \
553
H5_GLUE(H5T_CONV_LOOP_,PRE_SALIGN_GUTS)(ST) \
555
/* Handle destination pre-alignment */ \
556
H5_GLUE(H5T_CONV_LOOP_,PRE_DALIGN_GUTS)(DT) \
558
/* ... user-defined stuff here -- the conversion ... */ \
559
H5_GLUE(GUTS,_CORE)(S,D,ST,DT,D_MIN,D_MAX) \
561
/* Handle source post-alignment */ \
562
H5_GLUE(H5T_CONV_LOOP_,POST_SALIGN_GUTS)(ST) \
564
/* Handle destination post-alignment */ \
565
H5_GLUE(H5T_CONV_LOOP_,POST_DALIGN_GUTS)(DT) \
567
/* Advance pointers */ \
575
/* Print alignment statistics */
576
# define CI_PRINT_STATS(STYPE,DTYPE) { \
577
if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->s_aligned) { \
578
HDfprintf(H5DEBUG(T), \
579
" %Hu src elements aligned on %lu-byte boundaries\n", \
580
((H5T_conv_hw_t *)cdata->priv)->s_aligned, \
581
(unsigned long)H5T_NATIVE_##STYPE##_ALIGN_g); \
583
if (H5DEBUG(T) && ((H5T_conv_hw_t *)cdata->priv)->d_aligned) { \
584
HDfprintf(H5DEBUG(T), \
585
" %Hu dst elements aligned on %lu-byte boundaries\n", \
586
((H5T_conv_hw_t *)cdata->priv)->d_aligned, \
587
(unsigned long)H5T_NATIVE_##DTYPE##_ALIGN_g); \
591
/* Allocate private alignment structure for atomic types */
592
# define CI_ALLOC_PRIV \
593
if (NULL==(cdata->priv=H5MM_calloc(sizeof(H5T_conv_hw_t)))) { \
594
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, \
595
"memory allocation failed"); \
598
/* Free private alignment structure for atomic types */
599
# define CI_FREE_PRIV \
600
if(cdata->priv!=NULL) \
601
cdata->priv = H5MM_xfree(cdata->priv);
603
/* Increment source alignment counter */
604
# define CI_INC_SRC(s) if (s) ((H5T_conv_hw_t *)cdata->priv)->s_aligned += nelmts;
606
/* Increment destination alignment counter */
607
# define CI_INC_DST(d) if (d) ((H5T_conv_hw_t *)cdata->priv)->d_aligned += nelmts;
608
#else /* H5T_DEBUG */
609
# define CI_PRINT_STATS(STYPE,DTYPE) /*void*/
610
# define CI_ALLOC_PRIV cdata->priv=NULL;
611
# define CI_FREE_PRIV /* void */
612
# define CI_INC_SRC(s) /* void */
613
# define CI_INC_DST(d) /* void */
614
#endif /* H5T_DEBUG */
616
/* Swap two elements (I & J) of an array using a temporary variable */
617
#define H5_SWAP_BYTES(ARRAY,I,J) {uint8_t _tmp; _tmp=ARRAY[I]; ARRAY[I]=ARRAY[J]; ARRAY[J]=_tmp;}
619
/* Minimum size of variable-length conversion buffer */
620
#define H5T_VLEN_MIN_CONF_BUF_SIZE 4096
623
/*-------------------------------------------------------------------------
624
* Function: H5T_conv_noop
626
* Purpose: The no-op conversion. The library knows about this
627
* conversion without it being registered.
629
* Return: Non-negative on success/Negative on failure
631
* Programmer: Robb Matzke
632
* Wednesday, January 14, 1998
636
*-------------------------------------------------------------------------
639
H5T_conv_noop(hid_t UNUSED src_id, hid_t UNUSED dst_id, H5T_cdata_t *cdata,
640
size_t UNUSED nelmts, size_t UNUSED buf_stride,
641
size_t UNUSED bkg_stride, void UNUSED *buf,
642
void UNUSED *background, hid_t UNUSED dxpl_id)
644
herr_t ret_value=SUCCEED; /* Return value */
646
FUNC_ENTER_NOAPI(H5T_conv_noop, FAIL);
648
switch (cdata->command) {
650
cdata->need_bkg = H5T_BKG_NO;
654
/* Nothing to convert */
661
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
665
FUNC_LEAVE_NOAPI(ret_value);
669
/*-------------------------------------------------------------------------
670
* Function: H5T_conv_order_opt
672
* Purpose: Convert one type to another when byte order is the only
673
* difference. This is the optimized version of H5T_conv_order()
674
* for a handful of different sizes.
676
* Note: This is a soft conversion function.
678
* Return: Non-negative on success/Negative on failure
680
* Programmer: Robb Matzke
681
* Friday, January 25, 2002
685
*-------------------------------------------------------------------------
688
H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
689
size_t nelmts, size_t buf_stride,
690
size_t UNUSED bkg_stride, void *_buf,
691
void UNUSED *background, hid_t UNUSED dxpl_id)
693
uint8_t *buf = (uint8_t*)_buf;
697
herr_t ret_value=SUCCEED; /* Return value */
699
FUNC_ENTER_NOAPI(H5T_conv_order_opt, FAIL);
701
switch (cdata->command) {
703
/* Capability query */
704
if (NULL == (src = H5I_object(src_id)) ||
705
NULL == (dst = H5I_object(dst_id)))
706
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
707
if (src->shared->size != dst->shared->size ||
708
0 != src->shared->u.atomic.offset ||
709
0 != dst->shared->u.atomic.offset ||
710
!((H5T_ORDER_BE == src->shared->u.atomic.order &&
711
H5T_ORDER_LE == dst->shared->u.atomic.order) ||
712
(H5T_ORDER_LE == src->shared->u.atomic.order &&
713
H5T_ORDER_BE == dst->shared->u.atomic.order)))
714
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
715
if (src->shared->size!=1 && src->shared->size!=2 && src->shared->size!=4 &&
716
src->shared->size!=8 && src->shared->size!=16)
717
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
718
switch (src->shared->type) {
721
/* nothing to check */
725
if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign ||
726
src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos ||
727
src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize ||
728
src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias ||
729
src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos ||
730
src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize ||
731
src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm ||
732
src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad)
733
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
737
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
739
cdata->need_bkg = H5T_BKG_NO;
744
if (NULL == (src = H5I_object(src_id)) ||
745
NULL == (dst = H5I_object(dst_id)))
746
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
748
buf_stride = buf_stride ? buf_stride : src->shared->size;
749
switch (src->shared->size) {
754
for (/*void*/; nelmts>=20; nelmts-=20) {
755
H5_SWAP_BYTES(buf, 0, 1); /* 0 */
757
H5_SWAP_BYTES(buf, 0, 1); /* 1 */
759
H5_SWAP_BYTES(buf, 0, 1); /* 2 */
761
H5_SWAP_BYTES(buf, 0, 1); /* 3 */
763
H5_SWAP_BYTES(buf, 0, 1); /* 4 */
765
H5_SWAP_BYTES(buf, 0, 1); /* 5 */
767
H5_SWAP_BYTES(buf, 0, 1); /* 6 */
769
H5_SWAP_BYTES(buf, 0, 1); /* 7 */
771
H5_SWAP_BYTES(buf, 0, 1); /* 8 */
773
H5_SWAP_BYTES(buf, 0, 1); /* 9 */
775
H5_SWAP_BYTES(buf, 0, 1); /* 10 */
777
H5_SWAP_BYTES(buf, 0, 1); /* 11 */
779
H5_SWAP_BYTES(buf, 0, 1); /* 12 */
781
H5_SWAP_BYTES(buf, 0, 1); /* 13 */
783
H5_SWAP_BYTES(buf, 0, 1); /* 14 */
785
H5_SWAP_BYTES(buf, 0, 1); /* 15 */
787
H5_SWAP_BYTES(buf, 0, 1); /* 16 */
789
H5_SWAP_BYTES(buf, 0, 1); /* 17 */
791
H5_SWAP_BYTES(buf, 0, 1); /* 18 */
793
H5_SWAP_BYTES(buf, 0, 1); /* 19 */
796
for (i=0; i<nelmts; i++, buf+=buf_stride) {
797
H5_SWAP_BYTES(buf, 0, 1);
801
for (/*void*/; nelmts>=20; nelmts-=20) {
802
H5_SWAP_BYTES(buf, 0, 3); /* 0 */
803
H5_SWAP_BYTES(buf, 1, 2);
805
H5_SWAP_BYTES(buf, 0, 3); /* 1 */
806
H5_SWAP_BYTES(buf, 1, 2);
808
H5_SWAP_BYTES(buf, 0, 3); /* 2 */
809
H5_SWAP_BYTES(buf, 1, 2);
811
H5_SWAP_BYTES(buf, 0, 3); /* 3 */
812
H5_SWAP_BYTES(buf, 1, 2);
814
H5_SWAP_BYTES(buf, 0, 3); /* 4 */
815
H5_SWAP_BYTES(buf, 1, 2);
817
H5_SWAP_BYTES(buf, 0, 3); /* 5 */
818
H5_SWAP_BYTES(buf, 1, 2);
820
H5_SWAP_BYTES(buf, 0, 3); /* 6 */
821
H5_SWAP_BYTES(buf, 1, 2);
823
H5_SWAP_BYTES(buf, 0, 3); /* 7 */
824
H5_SWAP_BYTES(buf, 1, 2);
826
H5_SWAP_BYTES(buf, 0, 3); /* 8 */
827
H5_SWAP_BYTES(buf, 1, 2);
829
H5_SWAP_BYTES(buf, 0, 3); /* 9 */
830
H5_SWAP_BYTES(buf, 1, 2);
832
H5_SWAP_BYTES(buf, 0, 3); /* 10 */
833
H5_SWAP_BYTES(buf, 1, 2);
835
H5_SWAP_BYTES(buf, 0, 3); /* 11 */
836
H5_SWAP_BYTES(buf, 1, 2);
838
H5_SWAP_BYTES(buf, 0, 3); /* 12 */
839
H5_SWAP_BYTES(buf, 1, 2);
841
H5_SWAP_BYTES(buf, 0, 3); /* 13 */
842
H5_SWAP_BYTES(buf, 1, 2);
844
H5_SWAP_BYTES(buf, 0, 3); /* 14 */
845
H5_SWAP_BYTES(buf, 1, 2);
847
H5_SWAP_BYTES(buf, 0, 3); /* 15 */
848
H5_SWAP_BYTES(buf, 1, 2);
850
H5_SWAP_BYTES(buf, 0, 3); /* 16 */
851
H5_SWAP_BYTES(buf, 1, 2);
853
H5_SWAP_BYTES(buf, 0, 3); /* 17 */
854
H5_SWAP_BYTES(buf, 1, 2);
856
H5_SWAP_BYTES(buf, 0, 3); /* 18 */
857
H5_SWAP_BYTES(buf, 1, 2);
859
H5_SWAP_BYTES(buf, 0, 3); /* 19 */
860
H5_SWAP_BYTES(buf, 1, 2);
863
for (i=0; i<nelmts; i++, buf+=buf_stride) {
864
H5_SWAP_BYTES(buf, 0, 3);
865
H5_SWAP_BYTES(buf, 1, 2);
869
for (/*void*/; nelmts>=10; nelmts-=10) {
870
H5_SWAP_BYTES(buf, 0, 7); /* 0 */
871
H5_SWAP_BYTES(buf, 1, 6);
872
H5_SWAP_BYTES(buf, 2, 5);
873
H5_SWAP_BYTES(buf, 3, 4);
875
H5_SWAP_BYTES(buf, 0, 7); /* 1 */
876
H5_SWAP_BYTES(buf, 1, 6);
877
H5_SWAP_BYTES(buf, 2, 5);
878
H5_SWAP_BYTES(buf, 3, 4);
880
H5_SWAP_BYTES(buf, 0, 7); /* 2 */
881
H5_SWAP_BYTES(buf, 1, 6);
882
H5_SWAP_BYTES(buf, 2, 5);
883
H5_SWAP_BYTES(buf, 3, 4);
885
H5_SWAP_BYTES(buf, 0, 7); /* 3 */
886
H5_SWAP_BYTES(buf, 1, 6);
887
H5_SWAP_BYTES(buf, 2, 5);
888
H5_SWAP_BYTES(buf, 3, 4);
890
H5_SWAP_BYTES(buf, 0, 7); /* 4 */
891
H5_SWAP_BYTES(buf, 1, 6);
892
H5_SWAP_BYTES(buf, 2, 5);
893
H5_SWAP_BYTES(buf, 3, 4);
895
H5_SWAP_BYTES(buf, 0, 7); /* 5 */
896
H5_SWAP_BYTES(buf, 1, 6);
897
H5_SWAP_BYTES(buf, 2, 5);
898
H5_SWAP_BYTES(buf, 3, 4);
900
H5_SWAP_BYTES(buf, 0, 7); /* 6 */
901
H5_SWAP_BYTES(buf, 1, 6);
902
H5_SWAP_BYTES(buf, 2, 5);
903
H5_SWAP_BYTES(buf, 3, 4);
905
H5_SWAP_BYTES(buf, 0, 7); /* 7 */
906
H5_SWAP_BYTES(buf, 1, 6);
907
H5_SWAP_BYTES(buf, 2, 5);
908
H5_SWAP_BYTES(buf, 3, 4);
910
H5_SWAP_BYTES(buf, 0, 7); /* 8 */
911
H5_SWAP_BYTES(buf, 1, 6);
912
H5_SWAP_BYTES(buf, 2, 5);
913
H5_SWAP_BYTES(buf, 3, 4);
915
H5_SWAP_BYTES(buf, 0, 7); /* 9 */
916
H5_SWAP_BYTES(buf, 1, 6);
917
H5_SWAP_BYTES(buf, 2, 5);
918
H5_SWAP_BYTES(buf, 3, 4);
921
for (i=0; i<nelmts; i++, buf+=buf_stride) {
922
H5_SWAP_BYTES(buf, 0, 7);
923
H5_SWAP_BYTES(buf, 1, 6);
924
H5_SWAP_BYTES(buf, 2, 5);
925
H5_SWAP_BYTES(buf, 3, 4);
929
for (/*void*/; nelmts>=10; nelmts-=10) {
930
H5_SWAP_BYTES(buf, 0, 15); /* 0 */
931
H5_SWAP_BYTES(buf, 1, 14);
932
H5_SWAP_BYTES(buf, 2, 13);
933
H5_SWAP_BYTES(buf, 3, 12);
934
H5_SWAP_BYTES(buf, 4, 11);
935
H5_SWAP_BYTES(buf, 5, 10);
936
H5_SWAP_BYTES(buf, 6, 9);
937
H5_SWAP_BYTES(buf, 7, 8);
939
H5_SWAP_BYTES(buf, 0, 15); /* 1 */
940
H5_SWAP_BYTES(buf, 1, 14);
941
H5_SWAP_BYTES(buf, 2, 13);
942
H5_SWAP_BYTES(buf, 3, 12);
943
H5_SWAP_BYTES(buf, 4, 11);
944
H5_SWAP_BYTES(buf, 5, 10);
945
H5_SWAP_BYTES(buf, 6, 9);
946
H5_SWAP_BYTES(buf, 7, 8);
948
H5_SWAP_BYTES(buf, 0, 15); /* 2 */
949
H5_SWAP_BYTES(buf, 1, 14);
950
H5_SWAP_BYTES(buf, 2, 13);
951
H5_SWAP_BYTES(buf, 3, 12);
952
H5_SWAP_BYTES(buf, 4, 11);
953
H5_SWAP_BYTES(buf, 5, 10);
954
H5_SWAP_BYTES(buf, 6, 9);
955
H5_SWAP_BYTES(buf, 7, 8);
957
H5_SWAP_BYTES(buf, 0, 15); /* 3 */
958
H5_SWAP_BYTES(buf, 1, 14);
959
H5_SWAP_BYTES(buf, 2, 13);
960
H5_SWAP_BYTES(buf, 3, 12);
961
H5_SWAP_BYTES(buf, 4, 11);
962
H5_SWAP_BYTES(buf, 5, 10);
963
H5_SWAP_BYTES(buf, 6, 9);
964
H5_SWAP_BYTES(buf, 7, 8);
966
H5_SWAP_BYTES(buf, 0, 15); /* 4 */
967
H5_SWAP_BYTES(buf, 1, 14);
968
H5_SWAP_BYTES(buf, 2, 13);
969
H5_SWAP_BYTES(buf, 3, 12);
970
H5_SWAP_BYTES(buf, 4, 11);
971
H5_SWAP_BYTES(buf, 5, 10);
972
H5_SWAP_BYTES(buf, 6, 9);
973
H5_SWAP_BYTES(buf, 7, 8);
975
H5_SWAP_BYTES(buf, 0, 15); /* 5 */
976
H5_SWAP_BYTES(buf, 1, 14);
977
H5_SWAP_BYTES(buf, 2, 13);
978
H5_SWAP_BYTES(buf, 3, 12);
979
H5_SWAP_BYTES(buf, 4, 11);
980
H5_SWAP_BYTES(buf, 5, 10);
981
H5_SWAP_BYTES(buf, 6, 9);
982
H5_SWAP_BYTES(buf, 7, 8);
984
H5_SWAP_BYTES(buf, 0, 15); /* 6 */
985
H5_SWAP_BYTES(buf, 1, 14);
986
H5_SWAP_BYTES(buf, 2, 13);
987
H5_SWAP_BYTES(buf, 3, 12);
988
H5_SWAP_BYTES(buf, 4, 11);
989
H5_SWAP_BYTES(buf, 5, 10);
990
H5_SWAP_BYTES(buf, 6, 9);
991
H5_SWAP_BYTES(buf, 7, 8);
993
H5_SWAP_BYTES(buf, 0, 15); /* 7 */
994
H5_SWAP_BYTES(buf, 1, 14);
995
H5_SWAP_BYTES(buf, 2, 13);
996
H5_SWAP_BYTES(buf, 3, 12);
997
H5_SWAP_BYTES(buf, 4, 11);
998
H5_SWAP_BYTES(buf, 5, 10);
999
H5_SWAP_BYTES(buf, 6, 9);
1000
H5_SWAP_BYTES(buf, 7, 8);
1002
H5_SWAP_BYTES(buf, 0, 15); /* 8 */
1003
H5_SWAP_BYTES(buf, 1, 14);
1004
H5_SWAP_BYTES(buf, 2, 13);
1005
H5_SWAP_BYTES(buf, 3, 12);
1006
H5_SWAP_BYTES(buf, 4, 11);
1007
H5_SWAP_BYTES(buf, 5, 10);
1008
H5_SWAP_BYTES(buf, 6, 9);
1009
H5_SWAP_BYTES(buf, 7, 8);
1011
H5_SWAP_BYTES(buf, 0, 15); /* 9 */
1012
H5_SWAP_BYTES(buf, 1, 14);
1013
H5_SWAP_BYTES(buf, 2, 13);
1014
H5_SWAP_BYTES(buf, 3, 12);
1015
H5_SWAP_BYTES(buf, 4, 11);
1016
H5_SWAP_BYTES(buf, 5, 10);
1017
H5_SWAP_BYTES(buf, 6, 9);
1018
H5_SWAP_BYTES(buf, 7, 8);
1021
for (i=0; i<nelmts; i++, buf+=buf_stride) {
1022
H5_SWAP_BYTES(buf, 0, 15);
1023
H5_SWAP_BYTES(buf, 1, 14);
1024
H5_SWAP_BYTES(buf, 2, 13);
1025
H5_SWAP_BYTES(buf, 3, 12);
1026
H5_SWAP_BYTES(buf, 4, 11);
1027
H5_SWAP_BYTES(buf, 5, 10);
1028
H5_SWAP_BYTES(buf, 6, 9);
1029
H5_SWAP_BYTES(buf, 7, 8);
1036
/* Free private data */
1040
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
1044
FUNC_LEAVE_NOAPI(ret_value);
1048
/*-------------------------------------------------------------------------
1049
* Function: H5T_conv_order
1051
* Purpose: Convert one type to another when byte order is the only
1054
* Note: This is a soft conversion function.
1056
* Return: Non-negative on success/Negative on failure
1058
* Programmer: Robb Matzke
1059
* Tuesday, January 13, 1998
1062
* Robb Matzke, 1999-06-16
1063
* Added the `stride' argument. If its value is non-zero then we
1064
* stride through memory converting one value at each location;
1065
* otherwise we assume that the values should be packed.
1067
* Robb Matzke, 1999-06-16
1068
* Added support for bitfields.
1069
*-------------------------------------------------------------------------
1072
H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
1073
size_t buf_stride, size_t UNUSED bkg_stride, void *_buf,
1074
void UNUSED *background, hid_t UNUSED dxpl_id)
1076
uint8_t *buf = (uint8_t*)_buf;
1081
herr_t ret_value=SUCCEED; /* Return value */
1083
FUNC_ENTER_NOAPI(H5T_conv_order, FAIL);
1085
switch (cdata->command) {
1087
/* Capability query */
1088
if (NULL == (src = H5I_object(src_id)) ||
1089
NULL == (dst = H5I_object(dst_id)))
1090
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
1091
if (src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset ||
1092
0 != dst->shared->u.atomic.offset ||
1093
!((H5T_ORDER_BE == src->shared->u.atomic.order &&
1094
H5T_ORDER_LE == dst->shared->u.atomic.order) ||
1095
(H5T_ORDER_LE == src->shared->u.atomic.order &&
1096
H5T_ORDER_BE == dst->shared->u.atomic.order)))
1097
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
1098
switch (src->shared->type) {
1101
/* nothing to check */
1105
if (src->shared->u.atomic.u.f.sign != dst->shared->u.atomic.u.f.sign ||
1106
src->shared->u.atomic.u.f.epos != dst->shared->u.atomic.u.f.epos ||
1107
src->shared->u.atomic.u.f.esize != dst->shared->u.atomic.u.f.esize ||
1108
src->shared->u.atomic.u.f.ebias != dst->shared->u.atomic.u.f.ebias ||
1109
src->shared->u.atomic.u.f.mpos != dst->shared->u.atomic.u.f.mpos ||
1110
src->shared->u.atomic.u.f.msize != dst->shared->u.atomic.u.f.msize ||
1111
src->shared->u.atomic.u.f.norm != dst->shared->u.atomic.u.f.norm ||
1112
src->shared->u.atomic.u.f.pad != dst->shared->u.atomic.u.f.pad) {
1113
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
1118
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
1120
cdata->need_bkg = H5T_BKG_NO;
1124
/* The conversion */
1125
if (NULL == (src = H5I_object(src_id)) ||
1126
NULL == (dst = H5I_object(dst_id)))
1127
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
1129
buf_stride = buf_stride ? buf_stride : src->shared->size;
1130
md = src->shared->size / 2;
1131
for (i=0; i<nelmts; i++, buf+=buf_stride) {
1132
for (j=0; j<md; j++)
1133
H5_SWAP_BYTES(buf, j, src->shared->size-(j+1));
1138
/* Free private data */
1142
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
1146
FUNC_LEAVE_NOAPI(ret_value);
1150
/*-------------------------------------------------------------------------
1151
* Function: H5T_conv_b_b
1153
* Purpose: Convert from one bitfield to any other bitfield.
1155
* Return: Non-negative on success/Negative on failure
1157
* Programmer: Robb Matzke
1158
* Thursday, May 20, 1999
1161
* Robb Matzke, 1999-06-16
1162
* Added support for non-zero strides. If BUF_STRIDE is non-zero
1163
* then convert one value at each memory location advancing
1164
* BUF_STRIDE bytes each time; otherwise assume both source and
1165
* destination values are packed.
1166
*-------------------------------------------------------------------------
1169
H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
1170
size_t buf_stride, size_t UNUSED bkg_stride, void *_buf,
1171
void UNUSED *background, hid_t UNUSED dxpl_id)
1173
uint8_t *buf = (uint8_t*)_buf;
1174
H5T_t *src=NULL, *dst=NULL; /*source and dest data types */
1175
int direction; /*direction of traversal */
1176
size_t elmtno; /*element number */
1177
size_t olap; /*num overlapping elements */
1178
size_t half_size; /*1/2 of total size for swapping*/
1179
uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/
1180
uint8_t dbuf[256]; /*temp destination buffer */
1181
size_t msb_pad_offset; /*offset for dest MSB padding */
1183
herr_t ret_value=SUCCEED; /* Return value */
1185
FUNC_ENTER_NOAPI(H5T_conv_b_b, FAIL);
1187
switch(cdata->command) {
1189
/* Capability query */
1190
if (NULL == (src = H5I_object(src_id)) ||
1191
NULL == (dst = H5I_object(dst_id)))
1192
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
1193
if (H5T_ORDER_LE!=src->shared->u.atomic.order &&
1194
H5T_ORDER_BE!=src->shared->u.atomic.order)
1195
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
1196
if (H5T_ORDER_LE!=dst->shared->u.atomic.order &&
1197
H5T_ORDER_BE!=dst->shared->u.atomic.order)
1198
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
1199
cdata->need_bkg = H5T_BKG_NO;
1206
/* Get the data types */
1207
if (NULL==(src=H5I_object(src_id)) ||
1208
NULL==(dst=H5I_object(dst_id)))
1209
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
1212
* Do we process the values from beginning to end or vice versa? Also,
1213
* how many of the elements have the source and destination areas
1216
if (src->shared->size==dst->shared->size || buf_stride) {
1217
sp = dp = (uint8_t*)buf;
1220
} else if (src->shared->size>=dst->shared->size) {
1221
double olap_d = HDceil((double)(dst->shared->size)/
1222
(double)(src->shared->size-dst->shared->size));
1224
olap = (size_t)olap_d;
1225
sp = dp = (uint8_t*)buf;
1228
double olap_d = HDceil((double)(src->shared->size)/
1229
(double)(dst->shared->size-src->shared->size));
1230
olap = (size_t)olap_d;
1231
sp = (uint8_t*)buf + (nelmts-1) * src->shared->size;
1232
dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size;
1236
/* The conversion loop */
1237
for (elmtno=0; elmtno<nelmts; elmtno++) {
1240
* If the source and destination buffers overlap then use a
1241
* temporary buffer for the destination.
1245
d = elmtno<olap ? dbuf : dp;
1248
d = elmtno+olap >= nelmts ? dbuf : dp;
1251
/* I don't quite trust the overlap calculations yet --rpm */
1253
assert ((dp>=sp && dp<sp+src->shared->size) ||
1254
(sp>=dp && sp<dp+dst->shared->size));
1256
assert ((dp<sp && dp+dst->shared->size<=sp) ||
1257
(sp<dp && sp+src->shared->size<=dp));
1262
* Put the data in little endian order so our loops aren't so
1263
* complicated. We'll do all the conversion stuff assuming
1264
* little endian and then we'll fix the order at the end.
1266
if (H5T_ORDER_BE==src->shared->u.atomic.order) {
1267
half_size = src->shared->size/2;
1268
for (i=0; i<half_size; i++) {
1269
uint8_t tmp = s[src->shared->size-(i+1)];
1270
s[src->shared->size-(i+1)] = s[i];
1276
* Copy the significant part of the value. If the source is larger
1277
* than the destination then invoke the overflow function or copy
1278
* as many bits as possible. Zero extra bits in the destination.
1280
if (src->shared->u.atomic.prec>dst->shared->u.atomic.prec) {
1281
if (!H5T_overflow_g ||
1282
(H5T_overflow_g)(src_id, dst_id, s, d)<0) {
1283
H5T_bit_copy(d, dst->shared->u.atomic.offset,
1284
s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec);
1287
H5T_bit_copy(d, dst->shared->u.atomic.offset,
1288
s, src->shared->u.atomic.offset,
1289
src->shared->u.atomic.prec);
1290
H5T_bit_set(d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec,
1291
dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE);
1295
* Fill the destination padding areas.
1297
switch (dst->shared->u.atomic.lsb_pad) {
1299
H5T_bit_set(d, 0, dst->shared->u.atomic.offset, FALSE);
1302
H5T_bit_set(d, 0, dst->shared->u.atomic.offset, TRUE);
1305
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported LSB padding");
1307
msb_pad_offset = dst->shared->u.atomic.offset + dst->shared->u.atomic.prec;
1308
switch (dst->shared->u.atomic.msb_pad) {
1310
H5T_bit_set(d, msb_pad_offset, 8*dst->shared->size-msb_pad_offset,
1314
H5T_bit_set(d, msb_pad_offset, 8*dst->shared->size-msb_pad_offset,
1318
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported MSB padding");
1322
* Put the destination in the correct byte order. See note at
1323
* beginning of loop.
1325
if (H5T_ORDER_BE==dst->shared->u.atomic.order) {
1326
half_size = dst->shared->size/2;
1327
for (i=0; i<half_size; i++) {
1328
uint8_t tmp = d[dst->shared->size-(i+1)];
1329
d[dst->shared->size-(i+1)] = d[i];
1335
* If we had used a temporary buffer for the destination then we
1336
* should copy the value to the true destination buffer.
1338
if (d==dbuf) HDmemcpy (dp, d, dst->shared->size);
1340
sp += direction * buf_stride;
1341
dp += direction * buf_stride;
1343
sp += direction * src->shared->size;
1344
dp += direction * dst->shared->size;
1351
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
1355
FUNC_LEAVE_NOAPI(ret_value);
1359
/*-------------------------------------------------------------------------
1360
* Function: H5T_conv_struct_init
1362
* Purpose: Initialize the `priv' field of `cdata' with conversion
1363
* information that is relatively constant. If `priv' is
1364
* already initialized then the member conversion functions
1367
* Priv fields are indexed by source member number or
1368
* destination member number depending on whether the field
1369
* contains information about the source data type or the
1370
* destination data type (fields that contains the same
1371
* information for both source and destination are indexed by
1372
* source member number). The src2dst[] priv array maps source
1373
* member numbers to destination member numbers, but if the
1374
* source member doesn't have a corresponding destination member
1375
* then the src2dst[i]=-1.
1377
* Return: Non-negative on success/Negative on failure
1379
* Programmer: Robb Matzke
1380
* Monday, January 26, 1998
1384
*-------------------------------------------------------------------------
1387
H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id)
1389
H5T_conv_struct_t *priv = (H5T_conv_struct_t*)(cdata->priv);
1390
int *src2dst = NULL;
1394
herr_t ret_value=SUCCEED; /* Return value */
1396
FUNC_ENTER_NOAPI_NOINIT(H5T_conv_struct_init);
1400
* Allocate private data structure and arrays.
1402
if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t))) ||
1403
NULL==(priv->src2dst=H5MM_malloc(src->shared->u.compnd.nmembs *
1405
NULL==(priv->src_memb_id=H5MM_malloc(src->shared->u.compnd.nmembs *
1407
NULL==(priv->dst_memb_id=H5MM_malloc(dst->shared->u.compnd.nmembs *
1409
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
1410
src2dst = priv->src2dst;
1413
* Insure that members are sorted.
1415
H5T_sort_value(src, NULL);
1416
H5T_sort_value(dst, NULL);
1419
* Build a mapping from source member number to destination member
1420
* number. If some source member is not a destination member then that
1421
* mapping element will be negative. Also create atoms for each
1422
* source and destination member data type so we can look up the
1423
* member data type conversion functions later.
1425
for (i=0; i<src->shared->u.compnd.nmembs; i++) {
1427
for (j=0; j<dst->shared->u.compnd.nmembs; j++) {
1428
if (!HDstrcmp (src->shared->u.compnd.memb[i].name,
1429
dst->shared->u.compnd.memb[j].name)) {
1434
if (src2dst[i]>=0) {
1435
type = H5T_copy (src->shared->u.compnd.memb[i].type, H5T_COPY_ALL);
1436
tid = H5I_register (H5I_DATATYPE, type);
1438
priv->src_memb_id[i] = tid;
1440
type = H5T_copy (dst->shared->u.compnd.memb[src2dst[i]].type,
1442
tid = H5I_register (H5I_DATATYPE, type);
1444
priv->dst_memb_id[src2dst[i]] = tid;
1449
/* Restore sorted conditions for the datatypes */
1450
/* (Required for the src2dst array to be valid) */
1451
H5T_sort_value(src, NULL);
1452
H5T_sort_value(dst, NULL);
1456
* (Re)build the cache of member conversion functions and pointers to
1457
* their cdata entries.
1459
src2dst = priv->src2dst;
1460
H5MM_xfree(priv->memb_path);
1461
if (NULL==(priv->memb_path=H5MM_malloc(src->shared->u.compnd.nmembs *
1462
sizeof(H5T_path_t*))))
1463
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
1465
for (i=0; i<src->shared->u.compnd.nmembs; i++) {
1466
if (src2dst[i]>=0) {
1467
H5T_path_t *tpath = H5T_path_find(src->shared->u.compnd.memb[i].type,
1468
dst->shared->u.compnd.memb[src2dst[i]].type, NULL, NULL, dxpl_id);
1470
if (NULL==(priv->memb_path[i] = tpath)) {
1471
H5MM_xfree(priv->src2dst);
1472
H5MM_xfree(priv->src_memb_id);
1473
H5MM_xfree(priv->dst_memb_id);
1474
H5MM_xfree(priv->memb_path);
1475
cdata->priv = priv = H5MM_xfree (priv);
1476
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert member data type");
1481
/* Check if we need a background buffer */
1482
if (H5T_detect_class(src,H5T_COMPOUND)==TRUE || H5T_detect_class(dst,H5T_COMPOUND)==TRUE)
1483
cdata->need_bkg = H5T_BKG_YES;
1485
cdata->recalc = FALSE;
1488
FUNC_LEAVE_NOAPI(ret_value);
1492
/*-------------------------------------------------------------------------
1493
* Function: H5T_conv_struct
1495
* Purpose: Converts between compound data types. This is a soft
1496
* conversion function. The algorithm is basically:
1498
* For each element do
1499
* For I=1..NELMTS do
1500
* If sizeof detination type <= sizeof source type then
1501
* Convert member to destination type;
1502
* Move member as far left as possible;
1504
* For I=NELMTS..1 do
1505
* If not destination type then
1506
* Convert member to destination type;
1507
* Move member to correct position in BKG
1511
* Return: Non-negative on success/Negative on failure
1513
* Programmer: Robb Matzke
1514
* Thursday, January 22, 1998
1517
* Robb Matzke, 1999-06-16
1518
* Added support for non-zero strides. If BUF_STRIDE is
1519
* non-zero then convert one value at each memory location
1520
* advancing BUF_STRIDE bytes each time; otherwise assume
1521
* both source and destination values are packed.
1523
* Robb Matzke, 2000-05-17
1524
* Added the BKG_STRIDE argument to fix a design bug. If
1525
* BUF_STRIDE and BKG_STRIDE are both non-zero then each
1526
* data element converted will be placed temporarily at a
1527
* multiple of BKG_STRIDE in the BKG buffer; otherwise the
1528
* BKG buffer is assumed to be a packed array of destination
1530
*-------------------------------------------------------------------------
1533
H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
1534
size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg,
1537
uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */
1538
uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */
1539
uint8_t *xbuf=buf, *xbkg=bkg; /*temp pointers into buf and bkg*/
1540
H5T_t *src = NULL; /*source data type */
1541
H5T_t *dst = NULL; /*destination data type */
1542
int *src2dst = NULL; /*maps src member to dst member */
1543
H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/
1544
H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */
1545
size_t offset; /*byte offset wrt struct */
1546
size_t src_delta; /*source stride */
1548
unsigned u; /*counters */
1549
int i; /*counters */
1550
H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv);
1551
herr_t ret_value=SUCCEED; /* Return value */
1553
FUNC_ENTER_NOAPI(H5T_conv_struct, FAIL);
1555
switch (cdata->command) {
1558
* First, determine if this conversion function applies to the
1559
* conversion path SRC_ID-->DST_ID. If not, return failure;
1560
* otherwise initialize the `priv' field of `cdata' with information
1561
* that remains (almost) constant for this conversion path.
1563
if (NULL == (src = H5I_object(src_id)) ||
1564
NULL == (dst = H5I_object(dst_id)))
1565
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
1566
assert (H5T_COMPOUND==src->shared->type);
1567
assert (H5T_COMPOUND==dst->shared->type);
1569
if (H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0)
1570
HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data");
1575
* Free the private conversion data.
1577
H5MM_xfree(priv->src2dst);
1578
H5MM_xfree(priv->src_memb_id);
1579
H5MM_xfree(priv->dst_memb_id);
1580
H5MM_xfree(priv->memb_path);
1581
cdata->priv = priv = H5MM_xfree (priv);
1588
if (NULL == (src = H5I_object(src_id)) ||
1589
NULL == (dst = H5I_object(dst_id)))
1590
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
1592
assert (bkg && cdata->need_bkg);
1594
if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0)
1595
HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data");
1598
* Insure that members are sorted.
1600
H5T_sort_value(src, NULL);
1601
H5T_sort_value(dst, NULL);
1602
src2dst = priv->src2dst;
1605
* Direction of conversion and striding through background.
1608
src_delta = buf_stride;
1610
bkg_stride = dst->shared->size;
1611
} else if (dst->shared->size <= src->shared->size) {
1612
src_delta = src->shared->size;
1613
bkg_stride = dst->shared->size;
1615
src_delta = -(int)src->shared->size; /*overflow shouldn't be possible*/
1616
bkg_stride = -(int)dst->shared->size; /*overflow shouldn't be possible*/
1617
xbuf += (nelmts-1) * src->shared->size;
1618
xbkg += (nelmts-1) * dst->shared->size;
1621
/* Conversion loop... */
1622
for (elmtno=0; elmtno<nelmts; elmtno++) {
1624
* For each source member which will be present in the
1625
* destination, convert the member to the destination type unless
1626
* it is larger than the source type. Then move the member to the
1627
* left-most unoccupied position in the buffer. This makes the
1628
* data point as small as possible with all the free space on the
1631
for (u=0, offset=0; u<src->shared->u.compnd.nmembs; u++) {
1632
if (src2dst[u]<0) continue; /*subsetting*/
1633
src_memb = src->shared->u.compnd.memb + u;
1634
dst_memb = dst->shared->u.compnd.memb + src2dst[u];
1636
if (dst_memb->size <= src_memb->size) {
1637
if (H5T_convert(priv->memb_path[u], priv->src_memb_id[u],
1638
priv->dst_memb_id[src2dst[u]],
1639
1, 0, 0, /*no striding (packed array)*/
1640
xbuf+src_memb->offset, xbkg+dst_memb->offset,
1642
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member");
1643
HDmemmove (xbuf+offset, xbuf+src_memb->offset,
1645
offset += dst_memb->size;
1647
HDmemmove (xbuf+offset, xbuf+src_memb->offset,
1649
offset += src_memb->size;
1654
* For each source member which will be present in the
1655
* destination, convert the member to the destination type if it
1656
* is larger than the source type (that is, has not been converted
1657
* yet). Then copy the member to the destination offset in the
1658
* background buffer.
1660
for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) {
1661
if (src2dst[i]<0) continue; /*subsetting*/
1662
src_memb = src->shared->u.compnd.memb + i;
1663
dst_memb = dst->shared->u.compnd.memb + src2dst[i];
1665
if (dst_memb->size > src_memb->size) {
1666
offset -= src_memb->size;
1667
if (H5T_convert(priv->memb_path[i],
1668
priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]],
1669
1, 0, 0, /*no striding (packed array)*/
1670
xbuf+offset, xbkg+dst_memb->offset,
1672
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member");
1674
offset -= dst_memb->size;
1676
HDmemmove (xbkg+dst_memb->offset, xbuf+offset, dst_memb->size);
1687
/* If the bkg_stride was set to -(dst->shared->size), make it positive now */
1688
if(buf_stride==0 && dst->shared->size>src->shared->size)
1689
bkg_stride=dst->shared->size;
1692
* Copy the background buffer back into the in-place conversion
1695
for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
1696
HDmemmove(xbuf, xbkg, dst->shared->size);
1697
xbuf += buf_stride ? buf_stride : dst->shared->size;
1703
/* Some other command we don't know about yet.*/
1704
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
1708
FUNC_LEAVE_NOAPI(ret_value);
1712
/*-------------------------------------------------------------------------
1713
* Function: H5T_conv_struct_opt
1715
* Purpose: Converts between compound data types in a manner more
1716
* efficient than the general-purpose H5T_conv_struct()
1717
* function. This function isn't applicable if the destination
1718
* is larger than the source type. This is a soft conversion
1719
* function. The algorithm is basically:
1721
* For each member of the struct
1722
* If sizeof detination type <= sizeof source type then
1723
* Convert member to destination type for all elements
1724
* Move memb to BKG buffer for all elements
1726
* Move member as far left as possible for all elements
1728
* For each member of the struct (in reverse order)
1729
* If not destination type then
1730
* Convert member to destination type for all elements
1731
* Move member to correct position in BKG for all elements
1733
* Copy BKG to BUF for all elements
1735
* Return: Non-negative on success/Negative on failure
1737
* Programmer: Robb Matzke
1738
* Thursday, January 22, 1998
1741
* Robb Matzke, 1999-06-16
1742
* Added support for non-zero strides. If BUF_STRIDE is
1743
* non-zero then convert one value at each memory location
1744
* advancing BUF_STRIDE bytes each time; otherwise assume both
1745
* source and destination values are packed.
1747
* Robb Matzke, 1999-06-16
1748
* If the source and destination data structs are the same size
1749
* then we can convert on a field-by-field basis instead of an
1750
* element by element basis. In other words, for all struct
1751
* elements being converted by this function call, first convert
1752
* all of the field1's, then all field2's, etc. This can
1753
* drastically reduce the number of calls to H5T_convert() and
1754
* thereby eliminate most of the conversion constant overhead.
1756
* Robb Matzke, 2000-05-17
1757
* Added the BKG_STRIDE argument to fix a design bug. If
1758
* BUF_STRIDE and BKG_STRIDE are both non-zero then each
1759
* data element converted will be placed temporarily at a
1760
* multiple of BKG_STRIDE in the BKG buffer; otherwise the
1761
* BKG buffer is assumed to be a packed array of destination
1763
*-------------------------------------------------------------------------
1766
H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
1767
size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf,
1768
void *_bkg, hid_t dxpl_id)
1770
uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */
1771
uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */
1772
uint8_t *xbuf = NULL; /*temporary pointer into `buf' */
1773
uint8_t *xbkg = NULL; /*temporary pointer into `bkg' */
1774
H5T_t *src = NULL; /*source data type */
1775
H5T_t *dst = NULL; /*destination data type */
1776
int *src2dst = NULL; /*maps src member to dst member */
1777
H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/
1778
H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */
1779
size_t offset; /*byte offset wrt struct */
1780
size_t elmtno; /*element counter */
1781
unsigned u; /*counters */
1782
int i; /*counters */
1783
H5T_conv_struct_t *priv = NULL; /*private data */
1784
herr_t ret_value=SUCCEED; /* Return value */
1786
FUNC_ENTER_NOAPI(H5T_conv_struct_opt, FAIL);
1788
switch (cdata->command) {
1791
* First, determine if this conversion function applies to the
1792
* conversion path SRC_ID-->DST_ID. If not, return failure;
1793
* otherwise initialize the `priv' field of `cdata' with information
1794
* that remains (almost) constant for this conversion path.
1796
if (NULL == (src = H5I_object(src_id)) ||
1797
NULL == (dst = H5I_object(dst_id)))
1798
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
1799
assert (H5T_COMPOUND==src->shared->type);
1800
assert (H5T_COMPOUND==dst->shared->type);
1802
/* Initialize data which is relatively constant */
1803
if (H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0)
1804
HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data");
1805
priv = (H5T_conv_struct_t *)(cdata->priv);
1806
src2dst = priv->src2dst;
1809
* If the destination type is not larger than the source type then
1810
* this conversion function is guaranteed to work (provided all
1811
* members can be converted also). Otherwise the determination is
1812
* quite a bit more complicated. Essentially we have to make sure
1813
* that there is always room in the source buffer to do the
1814
* conversion of a member in place. This is basically the same pair
1815
* of loops as in the actual conversion except it checks that there
1816
* is room for each conversion instead of actually doing anything.
1818
if (dst->shared->size > src->shared->size) {
1819
for (u=0, offset=0; u<src->shared->u.compnd.nmembs; u++) {
1822
src_memb = src->shared->u.compnd.memb + u;
1823
dst_memb = dst->shared->u.compnd.memb + src2dst[u];
1824
if (dst_memb->size > src_memb->size)
1825
offset += src_memb->size;
1827
for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) {
1830
src_memb = src->shared->u.compnd.memb + i;
1831
dst_memb = dst->shared->u.compnd.memb + src2dst[i];
1832
if (dst_memb->size > src_memb->size) {
1833
offset -= src_memb->size;
1834
if (dst_memb->size > src->shared->size-offset) {
1835
H5MM_xfree(priv->src2dst);
1836
H5MM_xfree(priv->src_memb_id);
1837
H5MM_xfree(priv->dst_memb_id);
1838
H5MM_xfree(priv->memb_path);
1839
cdata->priv = priv = H5MM_xfree (priv);
1840
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "convertion is unsupported by this function");
1849
* Free the private conversion data.
1851
priv = (H5T_conv_struct_t *)(cdata->priv);
1852
H5MM_xfree(priv->src2dst);
1853
H5MM_xfree(priv->src_memb_id);
1854
H5MM_xfree(priv->dst_memb_id);
1855
H5MM_xfree(priv->memb_path);
1856
cdata->priv = priv = H5MM_xfree (priv);
1863
if (NULL == (src = H5I_object(src_id)) ||
1864
NULL == (dst = H5I_object(dst_id)))
1865
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
1867
/* Update cached data if necessary */
1868
if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata, dxpl_id)<0)
1869
HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data");
1870
priv = (H5T_conv_struct_t *)(cdata->priv);
1871
src2dst = priv->src2dst;
1873
assert(bkg && cdata->need_bkg);
1876
* Insure that members are sorted.
1878
H5T_sort_value(src, NULL);
1879
H5T_sort_value(dst, NULL);
1882
* Calculate strides. If BUF_STRIDE is non-zero then convert one
1883
* data element at every BUF_STRIDE bytes through the main buffer
1884
* (BUF), leaving the result of each conversion at the same
1885
* location; otherwise assume the source and destination data are
1886
* packed tightly based on src->shared->size and dst->shared->size. Also, if
1887
* BUF_STRIDE and BKG_STRIDE are both non-zero then place
1888
* background data into the BKG buffer at multiples of BKG_STRIDE;
1889
* otherwise assume BKG buffer is the packed destination datatype.
1891
if (!buf_stride || !bkg_stride) bkg_stride = dst->shared->size;
1894
* For each member where the destination is not larger than the
1895
* source, stride through all the elements converting only that member
1896
* in each element and then copying the element to its final
1897
* destination in the bkg buffer. Otherwise move the element as far
1898
* left as possible in the buffer.
1900
for (u=0, offset=0; u<src->shared->u.compnd.nmembs; u++) {
1901
if (src2dst[u]<0) continue; /*subsetting*/
1902
src_memb = src->shared->u.compnd.memb + u;
1903
dst_memb = dst->shared->u.compnd.memb + src2dst[u];
1905
if (dst_memb->size <= src_memb->size) {
1906
xbuf = buf + src_memb->offset;
1907
xbkg = bkg + dst_memb->offset;
1908
if (H5T_convert(priv->memb_path[u],
1909
priv->src_memb_id[u],
1910
priv->dst_memb_id[src2dst[u]], nelmts,
1911
buf_stride ? buf_stride : src->shared->size,
1912
bkg_stride, xbuf, xbkg,
1914
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member");
1915
for (elmtno=0; elmtno<nelmts; elmtno++) {
1916
HDmemmove(xbkg, xbuf, dst_memb->size);
1917
xbuf += buf_stride ? buf_stride : src->shared->size;
1921
for (xbuf=buf, elmtno=0; elmtno<nelmts; elmtno++) {
1922
HDmemmove(xbuf+offset, xbuf+src_memb->offset,
1924
xbuf += buf_stride ? buf_stride : src->shared->size;
1926
offset += src_memb->size;
1931
* Work from right to left, converting those members that weren't
1932
* converted in the previous loop (those members where the destination
1933
* is larger than the source) and them to their final position in the
1936
for (i=src->shared->u.compnd.nmembs-1; i>=0; --i) {
1939
src_memb = src->shared->u.compnd.memb + i;
1940
dst_memb = dst->shared->u.compnd.memb + src2dst[i];
1942
if (dst_memb->size > src_memb->size) {
1943
offset -= src_memb->size;
1944
xbuf = buf + offset;
1945
xbkg = bkg + dst_memb->offset;
1946
if (H5T_convert(priv->memb_path[i],
1947
priv->src_memb_id[i],
1948
priv->dst_memb_id[src2dst[i]], nelmts,
1949
buf_stride ? buf_stride : src->shared->size,
1950
bkg_stride, xbuf, xbkg,
1952
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member");
1953
for (elmtno=0; elmtno<nelmts; elmtno++) {
1954
HDmemmove(xbkg, xbuf, dst_memb->size);
1955
xbuf += buf_stride ? buf_stride : src->shared->size;
1961
/* Move background buffer into result buffer */
1962
for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
1963
HDmemmove(xbuf, xbkg, dst->shared->size);
1964
xbuf += buf_stride ? buf_stride : dst->shared->size;
1970
/* Some other command we don't know about yet.*/
1971
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
1975
FUNC_LEAVE_NOAPI(ret_value);
1979
/*-------------------------------------------------------------------------
1980
* Function: H5T_conv_enum_init
1982
* Purpose: Initialize information for H5T_conv_enum().
1984
* Return: Success: Non-negative
1988
* Programmer: Robb Matzke
1989
* Monday, January 4, 1999
1993
*-------------------------------------------------------------------------
1996
H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
1998
H5T_enum_struct_t *priv=NULL; /*private conversion data */
1999
int n; /*src value cast as native int */
2000
int domain[2]; /*min and max source values */
2001
int *map=NULL; /*map from src value to dst idx */
2002
unsigned length; /*nelmts in map array */
2003
unsigned i, j; /*counters */
2004
herr_t ret_value=SUCCEED; /* Return value */
2006
FUNC_ENTER_NOAPI_NOINIT(H5T_conv_enum_init);
2008
cdata->need_bkg = H5T_BKG_NO;
2009
if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(*priv))))
2010
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
2011
if (0==src->shared->u.enumer.nmembs)
2012
HGOTO_DONE(SUCCEED);
2015
* Check that the source symbol names are a subset of the destination
2016
* symbol names and build a map from source member index to destination
2019
H5T_sort_name(src, NULL);
2020
H5T_sort_name(dst, NULL);
2021
if (NULL==(priv->src2dst=H5MM_malloc(src->shared->u.enumer.nmembs*sizeof(int))))
2022
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");;
2024
i<src->shared->u.enumer.nmembs && j<dst->shared->u.enumer.nmembs;
2026
while (j<dst->shared->u.enumer.nmembs &&
2027
HDstrcmp(src->shared->u.enumer.name[i], dst->shared->u.enumer.name[j]))
2029
if (j>=dst->shared->u.enumer.nmembs)
2030
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source type is not a subset of destination type");
2031
priv->src2dst[i] = j;
2035
* The conversion function will use an O(log N) lookup method for each
2036
* value converted. However, if all of the following constraints are met
2037
* then we can build a perfect hash table and use an O(1) lookup method.
2039
* A: The source data type size matches one of our native data type
2042
* B: After casting the source value bit pattern to a native type
2043
* the size of the range of values is less than 20% larger than
2044
* the number of values.
2046
* If this special case is met then we use the source bit pattern cast as
2047
* a native integer type as an index into the `val2dst'. The values of
2048
* that array are the index numbers in the destination type or negative
2049
* if the entry is unused.
2051
if (1==src->shared->size || sizeof(short)==src->shared->size || sizeof(int)==src->shared->size) {
2052
for (i=0; i<src->shared->u.enumer.nmembs; i++) {
2053
if (1==src->shared->size) {
2054
n = *((signed char*)(src->shared->u.enumer.value+i));
2055
} else if (sizeof(short)==src->shared->size) {
2056
n = *((short*)(src->shared->u.enumer.value+i*src->shared->size));
2058
n = *((int*)(src->shared->u.enumer.value+i*src->shared->size));
2061
domain[0] = domain[1] = n;
2063
domain[0] = MIN(domain[0], n);
2064
domain[1] = MAX(domain[1], n);
2068
length = (domain[1]-domain[0])+1;
2069
if (src->shared->u.enumer.nmembs<2 ||
2070
(double)length/src->shared->u.enumer.nmembs<1.2) {
2071
priv->base = domain[0];
2072
priv->length = length;
2073
if (NULL==(map=H5MM_malloc(length*sizeof(int))))
2074
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
2075
for (i=0; i<length; i++)
2076
map[i] = -1; /*entry unused*/
2077
for (i=0; i<src->shared->u.enumer.nmembs; i++) {
2078
if (1==src->shared->size) {
2079
n = *((signed char*)(src->shared->u.enumer.value+i));
2080
} else if (sizeof(short)==src->shared->size) {
2081
n = *((short*)(src->shared->u.enumer.value+i*src->shared->size));
2083
n = *((int*)(src->shared->u.enumer.value+i*src->shared->size));
2086
assert(n>=0 && n<priv->length);
2088
map[n] = priv->src2dst[i];
2092
* Replace original src2dst array with our new one. The original
2093
* was indexed by source member number while the new one is
2094
* indexed by source values.
2096
H5MM_xfree(priv->src2dst);
2097
priv->src2dst = map;
2098
HGOTO_DONE(SUCCEED);
2102
/* Sort source type by value and adjust src2dst[] appropriately */
2103
H5T_sort_value(src, priv->src2dst);
2106
if (ret_value<0 && priv) {
2107
H5MM_xfree(priv->src2dst);
2111
FUNC_LEAVE_NOAPI(ret_value);
2115
/*-------------------------------------------------------------------------
2116
* Function: H5T_conv_enum
2118
* Purpose: Converts one type of enumerated data to another.
2120
* Return: Success: Non-negative
2124
* Programmer: Robb Matzke
2125
* Monday, January 4, 1999
2128
* Robb Matzke, 1999-06-16
2129
* Added support for non-zero strides. If BUF_STRIDE is non-zero
2130
* then convert one value at each memory location advancing
2131
* BUF_STRIDE bytes each time; otherwise assume both source and
2132
* destination values are packed.
2133
*-------------------------------------------------------------------------
2136
H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
2137
size_t buf_stride, size_t UNUSED bkg_stride, void *_buf,
2138
void UNUSED *bkg, hid_t UNUSED dxpl_id)
2140
uint8_t *buf = (uint8_t*)_buf; /*cast for pointer arithmetic */
2141
H5T_t *src=NULL, *dst=NULL; /*src and dst data types */
2142
uint8_t *s=NULL, *d=NULL; /*src and dst BUF pointers */
2143
int src_delta, dst_delta; /*conversion strides */
2144
int n; /*src value cast as native int */
2145
size_t i; /*counters */
2146
H5T_enum_struct_t *priv = (H5T_enum_struct_t*)(cdata->priv);
2147
herr_t ret_value=SUCCEED; /* Return value */
2149
FUNC_ENTER_NOAPI(H5T_conv_enum, FAIL);
2151
switch (cdata->command) {
2154
* Determine if this conversion function applies to the conversion
2155
* path SRC_ID->DST_ID. If not return failure; otherwise initialize
2156
* the `priv' field of `cdata' with information about the underlying
2157
* integer conversion.
2159
if (NULL == (src = H5I_object(src_id)) ||
2160
NULL == (dst = H5I_object(dst_id)))
2161
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
2162
assert (H5T_ENUM==src->shared->type);
2163
assert (H5T_ENUM==dst->shared->type);
2164
if (H5T_conv_enum_init(src, dst, cdata)<0)
2165
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize private data");
2171
fprintf(H5DEBUG(T), " Using %s mapping function%s\n",
2172
priv->length?"O(1)":"O(log N)",
2173
priv->length?"":", where N is the number of enum members");
2177
H5MM_xfree(priv->src2dst);
2184
if (NULL == (src = H5I_object(src_id)) ||
2185
NULL == (dst = H5I_object(dst_id)))
2186
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
2187
assert (H5T_ENUM==src->shared->type);
2188
assert (H5T_ENUM==dst->shared->type);
2190
/* priv->src2dst map was computed for certain sort keys. Make sure those same
2191
* sort keys are used here during conversion. See H5T_conv_enum_init(). But
2192
* we actually don't care about the source type's order when doing the O(1)
2193
* conversion algorithm, which is turned on by non-zero priv->length */
2194
H5T_sort_name(dst, NULL);
2195
if (!priv->length) H5T_sort_value(src, NULL);
2198
* Direction of conversion.
2201
src_delta = dst_delta = (int)buf_stride;
2203
} else if (dst->shared->size <= src->shared->size) {
2204
src_delta = (int)src->shared->size; /*overflow shouldn't be possible*/
2205
dst_delta = (int)dst->shared->size; /*overflow shouldn't be possible*/
2208
src_delta = -(int)src->shared->size; /*overflow shouldn't be possible*/
2209
dst_delta = -(int)dst->shared->size; /*overflow shouldn't be possible*/
2210
s = buf + (nelmts-1) * src->shared->size;
2211
d = buf + (nelmts-1) * dst->shared->size;
2214
for (i=0; i<nelmts; i++, s+=src_delta, d+=dst_delta) {
2216
/* Use O(1) lookup */
2217
if (1==src->shared->size) {
2218
n = *((signed char*)s);
2219
} else if (sizeof(short)==src->shared->size) {
2225
if (n<0 || n>=priv->length || priv->src2dst[n]<0) {
2226
if (!H5T_overflow_g ||
2227
(H5T_overflow_g)(src_id, dst_id, s, d)<0) {
2228
HDmemset(d, 0xff, dst->shared->size);
2232
dst->shared->u.enumer.value+priv->src2dst[n]*dst->shared->size,
2236
/* Use O(log N) lookup */
2238
int rt = src->shared->u.enumer.nmembs;
2242
cmp = HDmemcmp(s, src->shared->u.enumer.value+md*src->shared->size,
2253
if (!H5T_overflow_g ||
2254
(H5T_overflow_g)(src_id, dst_id, s, d)<0) {
2255
HDmemset(d, 0xff, dst->shared->size);
2259
dst->shared->u.enumer.value+priv->src2dst[md]*dst->shared->size,
2267
/* Some other command we don't know about yet.*/
2268
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
2272
FUNC_LEAVE_NOAPI(ret_value);
2276
/*-------------------------------------------------------------------------
2277
* Function: H5T_conv_vlen
2279
* Purpose: Converts between VL data types in memory and on disk.
2280
* This is a soft conversion function. The algorithm is
2283
* For every VL struct in the main buffer:
2284
* 1. Allocate space for temporary dst VL data (reuse buffer
2286
* 2. Copy VL data from src buffer into dst buffer
2287
* 3. Convert VL data into dst representation
2288
* 4. Allocate buffer in dst heap
2289
* 5. Free heap objects storing old data
2290
* 6. Write dst VL data into dst heap
2291
* 7. Store (heap ID or pointer) and length in main dst buffer
2293
* Return: Non-negative on success/Negative on failure
2295
* Programmer: Quincey Koziol
2296
* Wednesday, May 26, 1999
2300
* Quincey Koziol, 2 July, 1999
2301
* Enabled support for non-zero strides. If BUF_STRIDE is non-zero
2302
* then convert one value at each memory location advancing
2303
* BUF_STRIDE bytes each time; otherwise assume both source and
2304
* destination values are packed.
2306
* Raymond Lu, 26 June, 2002
2307
* Background buffer is used for freeing heap objects storing
2308
* old data. At this moment, it only frees the first level of
2309
* VL datatype. It doesn't handle nested VL datatypes.
2311
*-------------------------------------------------------------------------
2314
H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
2315
size_t buf_stride, size_t bkg_stride, void *buf,
2316
void *bkg, hid_t dxpl_id)
2318
H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */
2319
H5T_vlen_alloc_info_t *vl_alloc_info=&_vl_alloc_info; /* VL allocation info */
2320
H5T_path_t *tpath; /* Type conversion path */
2321
hbool_t noop_conv=FALSE; /* Flag to indicate a noop conversion */
2322
hbool_t write_to_file=FALSE; /* Flag to indicate writing to file */
2323
hbool_t parent_is_vlen; /* Flag to indicate parent is vlen datatyp */
2324
hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */
2325
H5T_t *src = NULL; /*source data type */
2326
H5T_t *dst = NULL; /*destination data type */
2327
H5HG_t bg_hobjid, parent_hobjid;
2328
uint8_t *s; /*source buffer */
2329
uint8_t *d; /*destination buffer */
2330
uint8_t *b; /*background buffer */
2331
ssize_t s_stride, d_stride; /*src and dst strides */
2332
ssize_t b_stride; /*bkg stride */
2333
size_t safe; /*how many elements are safe to process in each pass */
2334
ssize_t seq_len; /*the number of elements in the current sequence*/
2335
size_t bg_seq_len=0;
2336
size_t src_base_size, dst_base_size;/*source & destination base size*/
2337
void *conv_buf=NULL; /*temporary conversion buffer */
2338
size_t conv_buf_size=0; /*size of conversion buffer in bytes */
2339
void *tmp_buf=NULL; /*temporary background buffer */
2340
size_t tmp_buf_size=0; /*size of temporary bkg buffer */
2341
hbool_t nested=FALSE; /*flag of nested VL case */
2342
size_t elmtno; /*element number counter */
2343
herr_t ret_value=SUCCEED; /* Return value */
2345
FUNC_ENTER_NOAPI(H5T_conv_vlen, FAIL);
2347
switch (cdata->command) {
2350
* First, determine if this conversion function applies to the
2351
* conversion path SRC_ID-->DST_ID. If not, return failure;
2352
* otherwise initialize the `priv' field of `cdata' with
2353
* information that remains (almost) constant for this
2356
if (NULL == (src = H5I_object(src_id)) ||
2357
NULL == (dst = H5I_object(dst_id)))
2358
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
2359
assert (H5T_VLEN==src->shared->type);
2360
assert (H5T_VLEN==dst->shared->type);
2362
/* Variable-length types don't need a background buffer */
2363
cdata->need_bkg = H5T_BKG_NO;
2368
/* QAK - Nothing to do currently */
2375
if (NULL == (src = H5I_object(src_id)) ||
2376
NULL == (dst = H5I_object(dst_id)))
2377
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
2379
/* Initialize source & destination strides */
2381
assert(buf_stride>=src->shared->size);
2382
assert(buf_stride>=dst->shared->size);
2383
H5_CHECK_OVERFLOW(buf_stride,size_t,ssize_t);
2384
s_stride = d_stride = (ssize_t)buf_stride;
2386
H5_CHECK_OVERFLOW(src->shared->size,size_t,ssize_t);
2387
H5_CHECK_OVERFLOW(dst->shared->size,size_t,ssize_t);
2388
s_stride = (ssize_t)src->shared->size;
2389
d_stride = (ssize_t)dst->shared->size;
2393
H5_CHECK_OVERFLOW(bkg_stride,size_t,ssize_t);
2394
b_stride=(ssize_t)bkg_stride;
2402
/* Get the size of the base types in src & dst */
2403
src_base_size=H5T_get_size(src->shared->parent);
2404
dst_base_size=H5T_get_size(dst->shared->parent);
2406
/* Set up conversion path for base elements */
2407
if (NULL==(tpath=H5T_path_find(src->shared->parent, dst->shared->parent, NULL, NULL, dxpl_id))) {
2408
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes");
2409
} else if (!H5T_path_noop(tpath)) {
2410
if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL)))<0 ||
2411
(tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL)))<0)
2412
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion");
2416
/* Check if we need a temporary buffer for this conversion */
2417
parent_is_vlen=H5T_detect_class(dst->shared->parent,H5T_VLEN);
2418
if(tpath->cdata.need_bkg || parent_is_vlen) {
2419
/* Set up initial background buffer */
2420
tmp_buf_size=MAX(src_base_size,dst_base_size);
2421
if ((tmp_buf=H5FL_BLK_MALLOC(vlen_seq,tmp_buf_size))==NULL)
2422
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
2425
/* Get the allocation info */
2426
if(H5T_vlen_get_alloc_info(dxpl_id,&vl_alloc_info)<0)
2427
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info");
2429
/* Set flags to indicate we are writing to or reading from the file */
2430
if(dst->shared->u.vlen.f!=NULL)
2433
/* Set the flag for nested VL case */
2434
if(write_to_file && parent_is_vlen && bkg!=NULL)
2437
/* The outer loop of the type conversion macro, controlling which */
2438
/* direction the buffer is walked */
2440
/* Check if we need to go backwards through the buffer */
2441
if(d_stride>s_stride) {
2442
/* Compute the number of "safe" destination elements at */
2443
/* the end of the buffer (Those which don't overlap with */
2444
/* any source elements at the beginning of the buffer) */
2445
safe=nelmts-(((nelmts*s_stride)+(d_stride-1))/d_stride);
2447
/* If we're down to the last few elements, just wrap up */
2448
/* with a "real" reverse copy */
2450
s = (uint8_t*)buf+(nelmts-1)*s_stride;
2451
d = (uint8_t*)buf+(nelmts-1)*d_stride;
2452
b = (uint8_t*)bkg+(nelmts-1)*b_stride;
2453
s_stride = -s_stride;
2454
d_stride = -d_stride;
2455
b_stride = -b_stride;
2460
s = (uint8_t*)buf+(nelmts-safe)*s_stride;
2461
d = (uint8_t*)buf+(nelmts-safe)*d_stride;
2462
b = (uint8_t*)bkg+(nelmts-safe)*b_stride;
2466
/* Single forward pass over all data */
2472
for (elmtno=0; elmtno<safe; elmtno++) {
2473
/* Check for "nil" source sequence */
2474
if((*(src->shared->u.vlen.isnull))(src->shared->u.vlen.f,s)) {
2475
/* Write "nil" sequence to destination location */
2476
if((*(dst->shared->u.vlen.setnull))(dst->shared->u.vlen.f,dxpl_id,d,b)<0)
2477
HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't set VL data to 'nil'");
2480
/* Get length of element sequences */
2481
if((seq_len=(*(src->shared->u.vlen.getlen))(s))<0)
2482
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "incorrect length");
2484
/* If we are reading from memory and there is no conversion, just get the pointer to sequence */
2485
if(write_to_file && noop_conv) {
2486
/* Get direct pointer to sequence */
2487
if((conv_buf=(*(src->shared->u.vlen.getptr))(s))==NULL)
2488
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid source pointer");
2491
size_t src_size, dst_size; /*source & destination total size in bytes*/
2493
src_size=seq_len*src_base_size;
2494
dst_size=seq_len*dst_base_size;
2496
/* Check if conversion buffer is large enough, resize if
2498
if(conv_buf_size<MAX(src_size,dst_size)) {
2499
/* Only allocate conversion buffer in H5T_VLEN_MIN_CONF_BUF_SIZE increments */
2500
conv_buf_size=((MAX(src_size,dst_size)/H5T_VLEN_MIN_CONF_BUF_SIZE)+1)*H5T_VLEN_MIN_CONF_BUF_SIZE;
2501
if((conv_buf=H5FL_BLK_REALLOC(vlen_seq,conv_buf, conv_buf_size))==NULL)
2502
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
2505
/* Read in VL sequence */
2506
if((*(src->shared->u.vlen.read))(src->shared->u.vlen.f,dxpl_id,s,conv_buf,src_size)<0)
2507
HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data");
2511
/* Check if temporary buffer is large enough, resize if necessary */
2512
/* (Chain off the conversion buffer size) */
2513
if(tmp_buf && tmp_buf_size<conv_buf_size) {
2514
/* Set up initial background buffer */
2515
tmp_buf_size=conv_buf_size;
2516
if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf,tmp_buf_size))==NULL)
2517
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
2520
/* If we are writing and there is a nested VL type, read
2521
* the sequence into the background buffer */
2524
UINT32DECODE(tmp, bg_seq_len);
2527
if(tmp_buf_size<(bg_seq_len*MAX(src_base_size, dst_base_size))) {
2528
tmp_buf_size=(bg_seq_len*MAX(src_base_size, dst_base_size));
2529
if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf, tmp_buf_size))==NULL)
2530
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
2532
H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp, &(bg_hobjid.addr));
2533
INT32DECODE(tmp, bg_hobjid.idx);
2534
if(H5HG_read(dst->shared->u.vlen.f,dxpl_id,&bg_hobjid,tmp_buf)==NULL)
2535
HGOTO_ERROR (H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer");
2538
/* If the sequence gets shorter, pad out the original sequence with zeros */
2539
H5_CHECK_OVERFLOW(bg_seq_len,size_t,ssize_t);
2540
if((ssize_t)bg_seq_len<seq_len) {
2541
HDmemset((uint8_t *)tmp_buf+dst_base_size*bg_seq_len,0,(seq_len-bg_seq_len)*dst_base_size);
2545
/* Convert VL sequence */
2546
H5_CHECK_OVERFLOW(seq_len,ssize_t,size_t);
2547
if (H5T_convert(tpath, tsrc_id, tdst_id, (size_t)seq_len, 0, 0, conv_buf, tmp_buf, dxpl_id)<0)
2548
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed");
2551
/* Write sequence to destination location */
2552
if((*(dst->shared->u.vlen.write))(dst->shared->u.vlen.f,dxpl_id,vl_alloc_info,d,conv_buf, b, (size_t)seq_len, dst_base_size)<0)
2553
HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data");
2556
/* For nested VL case, free leftover heap objects from the deeper level if the length of new data elements is shorter than the old data elements.*/
2557
H5_CHECK_OVERFLOW(bg_seq_len,size_t,ssize_t);
2558
if(nested && seq_len<(ssize_t)bg_seq_len) {
2559
size_t parent_seq_len;
2562
uint8_t *tmp_p=tmp_buf;
2563
tmp_p += seq_len*dst_base_size;
2564
for(u=0; u<(bg_seq_len-seq_len); u++) {
2565
UINT32DECODE(tmp_p, parent_seq_len);
2566
if(parent_seq_len>0) {
2567
H5F_addr_decode(dst->shared->u.vlen.f, (const uint8_t **)&tmp_p, &(parent_hobjid.addr));
2568
INT32DECODE(tmp_p, parent_hobjid.idx);
2569
if(H5HG_remove(dst->shared->u.vlen.f, dxpl_id,&parent_hobjid)<0)
2570
HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object");
2577
/* Advance pointers */
2583
/* Decrement number of elements left to convert */
2587
/* Release the temporary datatype IDs used */
2589
H5I_dec_ref(tsrc_id);
2591
H5I_dec_ref(tdst_id);
2594
default: /* Some other command we don't know about yet.*/
2595
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
2599
/* If the conversion buffer doesn't need to be freed, reset its pointer */
2600
if(write_to_file && noop_conv)
2602
/* Release the conversion buffer (always allocated, except on errors) */
2604
H5FL_BLK_FREE(vlen_seq,conv_buf);
2605
/* Release the background buffer, if we have one */
2607
H5FL_BLK_FREE(vlen_seq,tmp_buf);
2609
FUNC_LEAVE_NOAPI(ret_value);
2613
/*-------------------------------------------------------------------------
2614
* Function: H5T_conv_array
2616
* Purpose: Converts between array data types in memory and on disk.
2617
* This is a soft conversion function.
2619
* Return: Non-negative on success/Negative on failure
2621
* Programmer: Quincey Koziol
2622
* Monday, November 6, 2000
2626
*-------------------------------------------------------------------------
2629
H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
2630
size_t buf_stride, size_t bkg_stride, void *_buf,
2631
void UNUSED *_bkg, hid_t dxpl_id)
2633
H5T_path_t *tpath; /* Type conversion path */
2634
hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */
2635
H5T_t *src = NULL; /*source data type */
2636
H5T_t *dst = NULL; /*destination data type */
2637
uint8_t *sp, *dp; /*source and dest traversal ptrs */
2638
size_t src_delta, dst_delta; /*source & destination stride */
2639
int direction; /*direction of traversal */
2640
size_t elmtno; /*element number counter */
2641
int i; /* local index variable */
2642
void *bkg_buf=NULL; /*temporary background buffer */
2643
size_t bkg_buf_size=0; /*size of background buffer in bytes */
2644
herr_t ret_value=SUCCEED; /* Return value */
2646
FUNC_ENTER_NOAPI(H5T_conv_array, FAIL);
2648
switch (cdata->command) {
2651
* First, determine if this conversion function applies to the
2652
* conversion path SRC_ID-->DST_ID. If not, return failure;
2653
* otherwise initialize the `priv' field of `cdata' with
2654
* information that remains (almost) constant for this
2657
if (NULL == (src = H5I_object(src_id)) ||
2658
NULL == (dst = H5I_object(dst_id)))
2659
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
2660
assert (H5T_ARRAY==src->shared->type);
2661
assert (H5T_ARRAY==dst->shared->type);
2663
/* Check the number and sizes of the dimensions */
2664
if(src->shared->u.array.ndims!=dst->shared->u.array.ndims)
2665
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same number of dimensions");
2666
for(i=0; i<src->shared->u.array.ndims; i++)
2667
if(src->shared->u.array.dim[i]!=dst->shared->u.array.dim[i])
2668
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same sizes of dimensions");
2670
for(i=0; i<src->shared->u.array.ndims; i++)
2671
if(src->shared->u.array.perm[i]!=dst->shared->u.array.perm[i])
2672
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same dimension permutations");
2675
/* Array datatypes don't need a background buffer */
2676
cdata->need_bkg = H5T_BKG_NO;
2681
/* QAK - Nothing to do currently */
2688
if (NULL == (src = H5I_object(src_id)) ||
2689
NULL == (dst = H5I_object(dst_id)))
2690
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
2693
* Do we process the values from beginning to end or vice
2694
* versa? Also, how many of the elements have the source and
2695
* destination areas overlapping?
2697
if (src->shared->size>=dst->shared->size || buf_stride>0) {
2698
sp = dp = (uint8_t*)_buf;
2701
sp = (uint8_t*)_buf + (nelmts-1) *
2702
(buf_stride ? buf_stride : src->shared->size);
2703
dp = (uint8_t*)_buf + (nelmts-1) *
2704
(buf_stride ? buf_stride : dst->shared->size);
2709
* Direction & size of buffer traversal.
2711
src_delta = direction * (buf_stride ? buf_stride : src->shared->size);
2712
dst_delta = direction * (buf_stride ? buf_stride : dst->shared->size);
2714
/* Set up conversion path for base elements */
2715
if (NULL==(tpath=H5T_path_find(src->shared->parent, dst->shared->parent, NULL, NULL, dxpl_id))) {
2716
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes");
2717
} else if (!H5T_path_noop(tpath)) {
2718
if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->shared->parent, H5T_COPY_ALL)))<0 ||
2719
(tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->shared->parent, H5T_COPY_ALL)))<0)
2720
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion");
2723
/* Check if we need a background buffer for this conversion */
2724
if(tpath->cdata.need_bkg) {
2725
/* Allocate background buffer */
2726
bkg_buf_size=src->shared->u.array.nelem*MAX(src->shared->size,dst->shared->size);
2727
if ((bkg_buf=H5FL_BLK_CALLOC(array_seq,bkg_buf_size))==NULL)
2728
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
2731
/* Perform the actual conversion */
2732
for (elmtno=0; elmtno<nelmts; elmtno++) {
2733
/* Copy the source array into the correct location for the destination */
2734
HDmemmove(dp, sp, src->shared->size);
2737
if (H5T_convert(tpath, tsrc_id, tdst_id, src->shared->u.array.nelem, 0, bkg_stride, dp, bkg_buf, dxpl_id)<0)
2738
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed");
2740
/* Advance the source & destination pointers */
2745
/* Release the background buffer, if we have one */
2747
H5FL_BLK_FREE(array_seq,bkg_buf);
2749
/* Release the temporary datatype IDs used */
2751
H5I_dec_ref(tsrc_id);
2753
H5I_dec_ref(tdst_id);
2756
default: /* Some other command we don't know about yet.*/
2757
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
2761
FUNC_LEAVE_NOAPI(ret_value);
2762
} /* end H5T_conv_array() */
2765
/*-------------------------------------------------------------------------
2766
* Function: H5T_conv_i_i
2768
* Purpose: Convert one integer type to another. This is the catch-all
2769
* function for integer conversions and is probably not
2770
* particularly fast.
2772
* Return: Non-negative on success/Negative on failure
2774
* Programmer: Robb Matzke
2775
* Wednesday, June 10, 1998
2778
* Robb Matzke, 7 Jul 1998
2779
* Added overflow handling.
2781
* Robb Matzke, 1999-06-16
2782
* Added support for non-zero strides. If BUF_STRIDE is non-zero
2783
* then convert one value at each memory location advancing
2784
* BUF_STRIDE bytes each time; otherwise assume both source and
2785
* destination values are packed.
2786
*-------------------------------------------------------------------------
2789
H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
2790
size_t buf_stride, size_t UNUSED bkg_stride, void *buf,
2791
void UNUSED *bkg, hid_t UNUSED dxpl_id)
2793
H5T_t *src = NULL; /*source data type */
2794
H5T_t *dst = NULL; /*destination data type */
2795
int direction; /*direction of traversal */
2796
size_t elmtno; /*element number */
2797
size_t half_size; /*half the type size */
2798
size_t olap; /*num overlapping elements */
2799
uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/
2800
uint8_t dbuf[64]; /*temp destination buffer */
2802
ssize_t sfirst; /*a signed version of `first' */
2803
size_t i; /*Local index variables */
2804
herr_t ret_value=SUCCEED; /* Return value */
2806
FUNC_ENTER_NOAPI(H5T_conv_i_i, FAIL);
2808
switch (cdata->command) {
2810
if (NULL==(src=H5I_object(src_id)) ||
2811
NULL==(dst=H5I_object(dst_id)))
2812
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
2813
if (H5T_ORDER_LE!=src->shared->u.atomic.order &&
2814
H5T_ORDER_BE!=src->shared->u.atomic.order)
2815
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
2816
if (H5T_ORDER_LE!=dst->shared->u.atomic.order &&
2817
H5T_ORDER_BE!=dst->shared->u.atomic.order)
2818
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
2819
if (dst->shared->size>sizeof dbuf)
2820
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large");
2821
cdata->need_bkg = H5T_BKG_NO;
2828
/* Get the data types */
2829
if (NULL==(src=H5I_object(src_id)) ||
2830
NULL==(dst=H5I_object(dst_id)))
2831
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
2834
* Do we process the values from beginning to end or vice versa? Also,
2835
* how many of the elements have the source and destination areas
2838
if (src->shared->size==dst->shared->size || buf_stride) {
2839
sp = dp = (uint8_t*)buf;
2842
} else if (src->shared->size>=dst->shared->size) {
2843
double olap_d = HDceil((double)(dst->shared->size)/
2844
(double)(src->shared->size-dst->shared->size));
2846
olap = (size_t)olap_d;
2847
sp = dp = (uint8_t*)buf;
2850
double olap_d = HDceil((double)(src->shared->size)/
2851
(double)(dst->shared->size-src->shared->size));
2852
olap = (size_t)olap_d;
2853
sp = (uint8_t*)buf + (nelmts-1) * src->shared->size;
2854
dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size;
2858
/* The conversion loop */
2859
for (elmtno=0; elmtno<nelmts; elmtno++) {
2862
* If the source and destination buffers overlap then use a
2863
* temporary buffer for the destination.
2867
d = elmtno<olap ? dbuf : dp;
2870
d = elmtno+olap >= nelmts ? dbuf : dp;
2873
/* I don't quite trust the overlap calculations yet --rpm */
2875
assert ((dp>=sp && dp<sp+src->shared->size) || (sp>=dp && sp<dp+dst->shared->size));
2877
assert ((dp<sp && dp+dst->shared->size<=sp) || (sp<dp && sp+src->shared->size<=dp));
2882
* Put the data in little endian order so our loops aren't so
2883
* complicated. We'll do all the conversion stuff assuming
2884
* little endian and then we'll fix the order at the end.
2886
if (H5T_ORDER_BE==src->shared->u.atomic.order) {
2887
half_size = src->shared->size/2;
2888
for (i=0; i<half_size; i++) {
2889
uint8_t tmp = s[src->shared->size-(i+1)];
2890
s[src->shared->size-(i+1)] = s[i];
2896
* What is the bit number for the msb bit of S which is set? The
2897
* bit number is relative to the significant part of the number.
2899
sfirst = H5T_bit_find (s, src->shared->u.atomic.offset, src->shared->u.atomic.prec,
2901
first = (size_t)sfirst;
2905
* The source has no bits set and must therefore be zero.
2906
* Set the destination to zero.
2908
H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE);
2910
} else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign &&
2911
H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) {
2913
* Source and destination are both unsigned, but if the
2914
* source has more precision bits than the destination then
2915
* it's possible to overflow. When overflow occurs the
2916
* destination will be set to the maximum possible value.
2918
if (src->shared->u.atomic.prec <= dst->shared->u.atomic.prec) {
2919
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset,
2920
src->shared->u.atomic.prec);
2921
H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec,
2922
dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE);
2923
} else if (first>=dst->shared->u.atomic.prec) {
2925
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
2926
H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE);
2929
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset,
2930
dst->shared->u.atomic.prec);
2933
} else if (H5T_SGN_2==src->shared->u.atomic.u.i.sign &&
2934
H5T_SGN_NONE==dst->shared->u.atomic.u.i.sign) {
2936
* If the source is signed and the destination isn't then we
2937
* can have overflow if the source contains more bits than
2938
* the destination (destination is set to the maximum
2939
* possible value) or overflow if the source is negative
2940
* (destination is set to zero).
2942
if (first+1 == src->shared->u.atomic.prec) {
2944
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
2945
H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, FALSE);
2947
} else if (src->shared->u.atomic.prec < dst->shared->u.atomic.prec) {
2948
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset,
2949
src->shared->u.atomic.prec-1);
2950
H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec-1,
2951
(dst->shared->u.atomic.prec-src->shared->u.atomic.prec)+1, FALSE);
2952
} else if (first>=dst->shared->u.atomic.prec) {
2954
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
2955
H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec, TRUE);
2958
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset,
2959
dst->shared->u.atomic.prec);
2962
} else if (H5T_SGN_NONE==src->shared->u.atomic.u.i.sign &&
2963
H5T_SGN_2==dst->shared->u.atomic.u.i.sign) {
2965
* If the source is not signed but the destination is then
2966
* overflow can occur in which case the destination is set to
2967
* the largest possible value (all bits set except the msb).
2969
if (first+1 >= dst->shared->u.atomic.prec) {
2971
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
2972
H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE);
2973
H5T_bit_set (d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), 1, FALSE);
2975
} else if (src->shared->u.atomic.prec<dst->shared->u.atomic.prec) {
2976
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset,
2977
src->shared->u.atomic.prec);
2978
H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec,
2979
dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE);
2981
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset,
2982
dst->shared->u.atomic.prec);
2984
} else if (first+1 == src->shared->u.atomic.prec) {
2986
* Both the source and the destination are signed and the
2987
* source value is negative. We could experience overflow
2988
* if the destination isn't wide enough in which case the
2989
* destination is set to a negative number with the largest
2990
* possible magnitude.
2992
ssize_t sfz = H5T_bit_find (s, src->shared->u.atomic.offset,
2993
src->shared->u.atomic.prec-1, H5T_BIT_MSB, FALSE);
2994
size_t fz = (size_t)sfz;
2996
if (sfz>=0 && fz+1>=dst->shared->u.atomic.prec) {
2998
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
2999
H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, FALSE);
3000
H5T_bit_set (d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), 1, TRUE);
3002
} else if (src->shared->u.atomic.prec<dst->shared->u.atomic.prec) {
3003
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, src->shared->u.atomic.prec);
3004
H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec, dst->shared->u.atomic.prec-src->shared->u.atomic.prec, TRUE);
3006
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset, dst->shared->u.atomic.prec);
3011
* Source and destination are both signed but the source
3012
* value is positive. We could have an overflow in which
3013
* case the destination is set to the largest possible
3016
if (first+1>=dst->shared->u.atomic.prec) {
3018
if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
3019
H5T_bit_set (d, dst->shared->u.atomic.offset, dst->shared->u.atomic.prec-1, TRUE);
3020
H5T_bit_set (d, (dst->shared->u.atomic.offset + dst->shared->u.atomic.prec-1), 1, FALSE);
3022
} else if (src->shared->u.atomic.prec<dst->shared->u.atomic.prec) {
3023
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset,
3024
src->shared->u.atomic.prec);
3025
H5T_bit_set (d, dst->shared->u.atomic.offset+src->shared->u.atomic.prec,
3026
dst->shared->u.atomic.prec-src->shared->u.atomic.prec, FALSE);
3028
H5T_bit_copy (d, dst->shared->u.atomic.offset, s, src->shared->u.atomic.offset,
3029
dst->shared->u.atomic.prec);
3034
* Set padding areas in destination.
3036
if (dst->shared->u.atomic.offset>0) {
3037
assert (H5T_PAD_ZERO==dst->shared->u.atomic.lsb_pad || H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad);
3038
H5T_bit_set (d, 0, dst->shared->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.lsb_pad));
3040
if (dst->shared->u.atomic.offset+dst->shared->u.atomic.prec!=8*dst->shared->size) {
3041
assert (H5T_PAD_ZERO==dst->shared->u.atomic.msb_pad || H5T_PAD_ONE==dst->shared->u.atomic.msb_pad);
3042
H5T_bit_set (d, dst->shared->u.atomic.offset+dst->shared->u.atomic.prec,
3043
8*dst->shared->size - (dst->shared->u.atomic.offset+ dst->shared->u.atomic.prec),
3044
(hbool_t)(H5T_PAD_ONE==dst->shared->u.atomic.msb_pad));
3048
* Put the destination in the correct byte order. See note at
3049
* beginning of loop.
3051
if (H5T_ORDER_BE==dst->shared->u.atomic.order) {
3052
half_size = dst->shared->size/2;
3053
for (i=0; i<half_size; i++) {
3054
uint8_t tmp = d[dst->shared->size-(i+1)];
3055
d[dst->shared->size-(i+1)] = d[i];
3061
* If we had used a temporary buffer for the destination then we
3062
* should copy the value to the true destination buffer.
3065
HDmemcpy (dp, d, dst->shared->size);
3067
sp += direction * buf_stride;
3068
dp += direction * buf_stride;
3070
sp += direction * src->shared->size;
3071
dp += direction * dst->shared->size;
3078
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
3082
FUNC_LEAVE_NOAPI(ret_value);
3086
/*-------------------------------------------------------------------------
3087
* Function: H5T_conv_f_f
3089
* Purpose: Convert one floating point type to another. This is a catch
3090
* all for floating point conversions and is probably not
3091
* particularly fast!
3093
* Return: Non-negative on success/Negative on failure
3095
* Programmer: Robb Matzke
3096
* Tuesday, June 23, 1998
3099
* Robb Matzke, 7 Jul 1998
3100
* Added overflow handling.
3102
* Robb Matzke, 1999-06-16
3103
* Added support for non-zero strides. If BUF_STRIDE is non-zero
3104
* then convert one value at each memory location advancing
3105
* BUF_STRIDE bytes each time; otherwise assume both source and
3106
* destination values are packed.
3108
* Robb Matzke, 2001-02-02
3109
* Oops, forgot to increment the exponent when rounding the
3110
* significand resulted in a carry. Thanks to Guillaume Colin
3111
* de Verdiere for finding this one!
3112
*-------------------------------------------------------------------------
3115
H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
3116
size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
3117
hid_t UNUSED dxpl_id)
3119
/* Traversal-related variables */
3120
H5T_t *src_p; /*source data type */
3121
H5T_t *dst_p; /*destination data type */
3122
H5T_atomic_t src; /*atomic source info */
3123
H5T_atomic_t dst; /*atomic destination info */
3124
int direction; /*forward or backward traversal */
3125
hbool_t denormalized=FALSE; /*is either source or destination denormalized?*/
3126
size_t elmtno; /*element number */
3127
size_t half_size; /*half the type size */
3128
size_t olap; /*num overlapping elements */
3129
ssize_t bitno=-1; /*bit number */
3130
uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/
3131
uint8_t dbuf[64]; /*temp destination buffer */
3133
/* Conversion-related variables */
3134
hssize_t expo; /*exponent */
3135
hssize_t expo_max; /*maximum possible dst exponent */
3136
size_t msize=0; /*useful size of mantissa in src*/
3137
size_t mpos; /*offset to useful mant is src */
3138
size_t mrsh; /*amount to right shift mantissa*/
3139
hbool_t carry=0; /*carry after rounding mantissa */
3140
size_t i; /*miscellaneous counters */
3141
size_t implied; /*destination implied bits */
3142
herr_t ret_value=SUCCEED; /*return value */
3144
FUNC_ENTER_NOAPI(H5T_conv_f_f, FAIL);
3146
switch (cdata->command) {
3148
if (NULL==(src_p=H5I_object(src_id)) ||
3149
NULL==(dst_p=H5I_object(dst_id)))
3150
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
3151
src = src_p->shared->u.atomic;
3152
dst = dst_p->shared->u.atomic;
3153
if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order)
3154
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
3155
if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order)
3156
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
3157
if (dst_p->shared->size>sizeof(dbuf))
3158
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large");
3159
if (8*sizeof(expo)-1<src.u.f.esize || 8*sizeof(expo)-1<dst.u.f.esize)
3160
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large");
3161
cdata->need_bkg = H5T_BKG_NO;
3168
/* Get the data types */
3169
if (NULL==(src_p=H5I_object(src_id)) ||
3170
NULL==(dst_p=H5I_object(dst_id)))
3171
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
3172
src = src_p->shared->u.atomic;
3173
dst = dst_p->shared->u.atomic;
3174
expo_max = ((hssize_t)1 << dst.u.f.esize) - 1;
3177
* Do we process the values from beginning to end or vice versa? Also,
3178
* how many of the elements have the source and destination areas
3181
if (src_p->shared->size==dst_p->shared->size || buf_stride) {
3182
sp = dp = (uint8_t*)buf;
3185
} else if (src_p->shared->size>=dst_p->shared->size) {
3186
double olap_d = HDceil((double)(dst_p->shared->size)/
3187
(double)(src_p->shared->size-dst_p->shared->size));
3188
olap = (size_t)olap_d;
3189
sp = dp = (uint8_t*)buf;
3192
double olap_d = HDceil((double)(src_p->shared->size)/
3193
(double)(dst_p->shared->size-src_p->shared->size));
3194
olap = (size_t)olap_d;
3195
sp = (uint8_t*)buf + (nelmts-1) * src_p->shared->size;
3196
dp = (uint8_t*)buf + (nelmts-1) * dst_p->shared->size;
3200
/* The conversion loop */
3201
for (elmtno=0; elmtno<nelmts; elmtno++) {
3203
* If the source and destination buffers overlap then use a
3204
* temporary buffer for the destination.
3208
d = elmtno<olap ? dbuf : dp;
3211
d = elmtno+olap >= nelmts ? dbuf : dp;
3214
/* I don't quite trust the overlap calculations yet --rpm */
3216
assert ((dp>=sp && dp<sp+src_p->shared->size) ||
3217
(sp>=dp && sp<dp+dst_p->shared->size));
3219
assert ((dp<sp && dp+dst_p->shared->size<=sp) ||
3220
(sp<dp && sp+src_p->shared->size<=dp));
3225
* Put the data in little endian order so our loops aren't so
3226
* complicated. We'll do all the conversion stuff assuming
3227
* little endian and then we'll fix the order at the end.
3229
if (H5T_ORDER_BE==src.order) {
3230
half_size = src_p->shared->size/2;
3231
for (i=0; i<half_size; i++) {
3232
uint8_t tmp = s[src_p->shared->size-(i+1)];
3233
s[src_p->shared->size-(i+1)] = s[i];
3239
* Check for special cases: +0, -0, +Inf, -Inf, NaN
3241
if (H5T_bit_find (s, src.u.f.mpos, src.u.f.msize,
3242
H5T_BIT_LSB, TRUE)<0) {
3243
if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
3244
H5T_BIT_LSB, TRUE)<0) {
3246
H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
3247
H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, FALSE);
3248
H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE);
3250
} else if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
3251
H5T_BIT_LSB, FALSE)<0) {
3253
H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
3254
H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE);
3255
H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE);
3256
/*If the destination no implied mantissa bit, we'll need to set
3257
*the 1st bit of mantissa to 1. The Intel-Linux long double is
3259
if (H5T_NORM_NONE==dst.u.f.norm)
3260
H5T_bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, 1, TRUE);
3263
} else if (H5T_NORM_NONE==src.u.f.norm && H5T_bit_find (s, src.u.f.mpos, src.u.f.msize-1,
3264
H5T_BIT_LSB, TRUE)<0 && H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
3265
H5T_BIT_LSB, FALSE)<0) {
3266
/*This is a special case for the source of no implied mantissa bit.
3267
*If the exponent bits are all 1s and only the 1st bit of mantissa
3268
*is set to 1. It's infinity. The Intel-Linux "long double" is this case.*/
3270
H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
3271
H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE);
3272
H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE);
3273
/*If the destination no implied mantissa bit, we'll need to set
3274
*the 1st bit of mantissa to 1.*/
3275
if (H5T_NORM_NONE==dst.u.f.norm)
3276
H5T_bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, 1, TRUE);
3278
} else if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
3279
H5T_BIT_LSB, FALSE)<0) {
3281
* NaN. There are many NaN values, so we just set all bits of
3284
H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
3285
H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE);
3286
H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, TRUE);
3291
* Get the exponent as an unsigned quantity from the section of
3292
* the source bit field where it's located. Don't worry about
3293
* the exponent bias yet.
3295
expo = H5T_bit_get_d(s, src.u.f.epos, src.u.f.esize);
3301
* Set markers for the source mantissa, excluding the leading `1'
3302
* (might be implied).
3305
mpos = src.u.f.mpos;
3307
if (0==expo || H5T_NORM_NONE==src.u.f.norm) {
3308
if ((bitno=H5T_bit_find(s, src.u.f.mpos, src.u.f.msize,
3309
H5T_BIT_MSB, TRUE))>0) {
3311
} else if (0==bitno) {
3313
H5T_bit_set(s, src.u.f.mpos, 1, FALSE);
3315
} else if (H5T_NORM_IMPLIED==src.u.f.norm) {
3316
msize = src.u.f.msize;
3318
assert("normalization method not implemented yet" && 0);
3323
* The sign for the destination is the same as the sign for the
3324
* source in all cases.
3326
H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
3329
* Calculate the true source exponent by adjusting according to
3330
* the source exponent bias.
3332
if (0==expo || H5T_NORM_NONE==src.u.f.norm) {
3334
expo -= (src.u.f.ebias-1) + (src.u.f.msize-bitno);
3335
} else if (H5T_NORM_IMPLIED==src.u.f.norm) {
3336
expo -= src.u.f.ebias;
3338
assert("normalization method not implemented yet" && 0);
3343
* If the destination is not normalized then right shift the
3346
if (H5T_NORM_NONE==dst.u.f.norm)
3350
* Calculate the destination exponent by adding the destination
3351
* bias and clipping by the minimum and maximum possible
3352
* destination exponent values.
3354
expo += dst.u.f.ebias;
3355
if (expo < -(hssize_t)(dst.u.f.msize)) {
3356
/* The exponent is way too small. Result is zero. */
3358
H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
3360
} else if (expo<=0) {
3362
* The exponent is too small to fit in the exponent field,
3363
* but by shifting the mantissa to the right we can
3364
* accomodate that value. The mantissa of course is no
3365
* longer normalized.
3367
H5_ASSIGN_OVERFLOW(mrsh,(mrsh+1-expo),hssize_t,size_t);
3370
} else if (expo>=expo_max) {
3372
* The exponent is too large to fit in the available region
3373
* or it results in the maximum possible value. Use positive
3374
* or negative infinity instead unless the application
3375
* specifies something else. Before calling the overflow
3376
* handler make sure the source buffer we hand it is in the
3377
* original byte order.
3379
if (H5T_overflow_g) {
3380
uint8_t over_src[256];
3381
assert(src_p->shared->size<=sizeof over_src);
3382
if (H5T_ORDER_BE==src.order) {
3383
for (i=0; i<src_p->shared->size; i++) {
3384
over_src[src_p->shared->size-(i+1)] = s[i];
3387
for (i=0; i<src_p->shared->size; i++) {
3391
if ((H5T_overflow_g)(src_id, dst_id, over_src, d)>=0) {
3396
H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
3401
* If the destination mantissa is smaller than the source
3402
* mantissa then round the source mantissa. Rounding may cause a
3403
* carry in which case the exponent has to be re-evaluated for
3404
* overflow. That is, if `carry' is clear then the implied
3405
* mantissa bit is `1', else it is `10' binary.
3407
if (msize>0 && mrsh<=dst.u.f.msize && mrsh+msize>dst.u.f.msize) {
3408
bitno = (ssize_t)(mrsh+msize - dst.u.f.msize);
3409
assert(bitno>=0 && (size_t)bitno<=msize);
3410
/*If the 1st bit being cut off is set and source isn't denormalized.*/
3411
if(H5T_bit_get_d(s, mpos+bitno-1, 1) && !denormalized) {
3412
/*Don't do rounding if exponent is 111...110 and mantissa is 111...11.
3413
*To do rounding and increment exponent in this case will create an infinity value.*/
3414
if((H5T_bit_find(s, mpos+bitno, msize-bitno, H5T_BIT_LSB, FALSE)>=0 || expo<expo_max-1)) {
3415
carry = H5T_bit_inc(s, mpos+bitno-1, 1+msize-bitno);
3419
} else if(H5T_bit_get_d(s, mpos+bitno-1, 1) && denormalized)
3420
/*For either source or destination, denormalized value doesn't increment carry.*/
3421
H5T_bit_inc(s, mpos+bitno-1, 1+msize-bitno);
3427
* Write the mantissa to the destination
3429
if (mrsh>dst.u.f.msize+1) {
3430
H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
3431
} else if (mrsh==dst.u.f.msize+1) {
3432
H5T_bit_set(d, dst.u.f.mpos+1, dst.u.f.msize-1, FALSE);
3433
H5T_bit_set(d, dst.u.f.mpos, 1, TRUE);
3434
} else if (mrsh==dst.u.f.msize) {
3435
H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
3436
H5T_bit_set_d(d, dst.u.f.mpos, MIN(2, dst.u.f.msize), (hsize_t)implied);
3439
H5T_bit_set(d, dst.u.f.mpos+dst.u.f.msize-mrsh, mrsh,
3441
H5T_bit_set_d(d, dst.u.f.mpos+dst.u.f.msize-mrsh, 2,
3444
if (mrsh+msize>=dst.u.f.msize) {
3445
H5T_bit_copy(d, dst.u.f.mpos,
3446
s, (mpos+msize+mrsh-dst.u.f.msize),
3447
dst.u.f.msize-mrsh);
3449
H5T_bit_copy(d, dst.u.f.mpos+dst.u.f.msize-(mrsh+msize),
3451
H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize-(mrsh+msize),
3456
/* Write the exponent */
3459
if (expo>=expo_max) {
3461
* The exponent is too large to fit in the available
3462
* region or it results in the maximum possible value.
3463
* Use positive or negative infinity instead unless the
3464
* application specifies something else. Before
3465
* calling the overflow handler make sure the source
3466
* buffer we hand it is in the original byte order.
3468
if (H5T_overflow_g) {
3469
uint8_t over_src[256];
3470
assert(src_p->shared->size<=sizeof over_src);
3471
if (H5T_ORDER_BE==src.order) {
3472
for (i=0; i<src_p->shared->size; i++)
3473
over_src[src_p->shared->size-(i+1)] = s[i];
3475
for (i=0; i<src_p->shared->size; i++)
3478
if ((H5T_overflow_g)(src_id, dst_id, over_src, d)>=0)
3482
H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
3488
H5_CHECK_OVERFLOW(expo,hssize_t,hsize_t);
3489
H5T_bit_set_d(d, dst.u.f.epos, dst.u.f.esize, (hsize_t)expo);
3493
* Set external padding areas
3496
assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad);
3497
H5T_bit_set (d, 0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad));
3499
if (dst.offset+dst.prec!=8*dst_p->shared->size) {
3500
assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad);
3501
H5T_bit_set (d, dst.offset+dst.prec, 8*dst_p->shared->size - (dst.offset+dst.prec),
3502
(hbool_t)(H5T_PAD_ONE==dst.msb_pad));
3506
* Put the destination in the correct byte order. See note at
3507
* beginning of loop.
3509
if (H5T_ORDER_BE==dst.order) {
3510
half_size = dst_p->shared->size/2;
3511
for (i=0; i<half_size; i++) {
3512
uint8_t tmp = d[dst_p->shared->size-(i+1)];
3513
d[dst_p->shared->size-(i+1)] = d[i];
3519
* If we had used a temporary buffer for the destination then we
3520
* should copy the value to the true destination buffer.
3524
HDmemcpy (dp, d, dst_p->shared->size);
3526
sp += direction * buf_stride;
3527
dp += direction * buf_stride;
3529
sp += direction * src_p->shared->size;
3530
dp += direction * dst_p->shared->size;
3537
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
3541
FUNC_LEAVE_NOAPI(ret_value);
3545
/*-------------------------------------------------------------------------
3546
* Function: H5T_conv_s_s
3548
* Purpose: Convert one fixed-length string type to another.
3550
* Return: Non-negative on success/Negative on failure
3552
* Programmer: Robb Matzke
3553
* Friday, August 7, 1998
3556
* Robb Matzke, 1999-06-16
3557
* Added support for non-zero strides. If BUF_STRIDE is non-zero
3558
* then convert one value at each memory location advancing
3559
* BUF_STRIDE bytes each time; otherwise assume both source and
3560
* destination values are packed.
3561
*-------------------------------------------------------------------------
3564
H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
3565
size_t buf_stride, size_t UNUSED bkg_stride, void *buf,
3566
void UNUSED *bkg, hid_t UNUSED dxpl_id)
3568
H5T_t *src=NULL; /*source data type */
3569
H5T_t *dst=NULL; /*destination data type */
3570
int direction; /*direction of traversal */
3571
size_t elmtno; /*element number */
3572
size_t olap; /*num overlapping elements */
3573
size_t nchars=0; /*number of characters copied */
3574
uint8_t *s, *sp, *d, *dp; /*src and dst traversal pointers*/
3575
uint8_t *dbuf=NULL; /*temp buf for overlap convers. */
3576
herr_t ret_value=SUCCEED; /* Return value */
3578
FUNC_ENTER_NOAPI(H5T_conv_s_s, FAIL);
3580
switch (cdata->command) {
3582
if (NULL==(src=H5I_object(src_id)) ||
3583
NULL==(dst=H5I_object(dst_id)))
3584
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
3585
if (8*src->shared->size != src->shared->u.atomic.prec || 8*dst->shared->size != dst->shared->u.atomic.prec)
3586
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision");
3587
if (0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset)
3588
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset");
3589
if (H5T_CSET_ASCII != src->shared->u.atomic.u.s.cset || H5T_CSET_ASCII != dst->shared->u.atomic.u.s.cset)
3590
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character set");
3591
if (src->shared->u.atomic.u.s.pad<0 || src->shared->u.atomic.u.s.pad>=H5T_NPAD ||
3592
dst->shared->u.atomic.u.s.pad<0 || dst->shared->u.atomic.u.s.pad>=H5T_NPAD)
3593
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding");
3594
cdata->need_bkg = H5T_BKG_NO;
3601
/* Get the data types */
3602
if (NULL==(src=H5I_object(src_id)) ||
3603
NULL==(dst=H5I_object(dst_id)))
3604
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
3607
* Do we process the values from beginning to end or vice versa? Also,
3608
* how many of the elements have the source and destination areas
3611
if (src->shared->size==dst->shared->size || buf_stride) {
3613
* When the source and destination are the same size we can do
3614
* all the conversions in place.
3616
sp = dp = (uint8_t*)buf;
3619
} else if (src->shared->size>=dst->shared->size) {
3620
double olapd = HDceil((double)(dst->shared->size)/
3621
(double)(src->shared->size-dst->shared->size));
3622
olap = (size_t)olapd;
3623
sp = dp = (uint8_t*)buf;
3626
double olapd = HDceil((double)(src->shared->size)/
3627
(double)(dst->shared->size-src->shared->size));
3628
olap = (size_t)olapd;
3629
sp = (uint8_t*)buf + (nelmts-1) * src->shared->size;
3630
dp = (uint8_t*)buf + (nelmts-1) * dst->shared->size;
3634
/* Allocate the overlap buffer */
3635
if (NULL==(dbuf=H5MM_malloc(dst->shared->size)))
3636
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion");
3638
/* The conversion loop. */
3639
for (elmtno=0; elmtno<nelmts; elmtno++) {
3642
* If the source and destination buffers overlap then use a
3643
* temporary buffer for the destination.
3647
d = elmtno<olap ? dbuf : dp;
3650
d = elmtno+olap >= nelmts ? dbuf : dp;
3653
/* I don't quite trust the overlap calculations yet --rpm */
3654
if (src->shared->size==dst->shared->size || buf_stride) {
3656
} else if (d==dbuf) {
3657
assert((dp>=sp && dp<sp+src->shared->size) ||
3658
(sp>=dp && sp<dp+dst->shared->size));
3660
assert((dp<sp && dp+dst->shared->size<=sp) ||
3661
(sp<dp && sp+src->shared->size<=dp));
3665
/* Copy characters from source to destination */
3666
switch (src->shared->u.atomic.u.s.pad) {
3667
case H5T_STR_NULLTERM:
3669
nchars<dst->shared->size && nchars<src->shared->size && s[nchars];
3671
d[nchars] = s[nchars];
3675
case H5T_STR_NULLPAD:
3677
nchars<dst->shared->size && nchars<src->shared->size && s[nchars];
3679
d[nchars] = s[nchars];
3683
case H5T_STR_SPACEPAD:
3684
nchars = src->shared->size;
3685
while (nchars>0 && ' '==s[nchars-1])
3687
nchars = MIN(dst->shared->size, nchars);
3688
HDmemcpy(d, s, nchars);
3691
case H5T_STR_RESERVED_3:
3692
case H5T_STR_RESERVED_4:
3693
case H5T_STR_RESERVED_5:
3694
case H5T_STR_RESERVED_6:
3695
case H5T_STR_RESERVED_7:
3696
case H5T_STR_RESERVED_8:
3697
case H5T_STR_RESERVED_9:
3698
case H5T_STR_RESERVED_10:
3699
case H5T_STR_RESERVED_11:
3700
case H5T_STR_RESERVED_12:
3701
case H5T_STR_RESERVED_13:
3702
case H5T_STR_RESERVED_14:
3703
case H5T_STR_RESERVED_15:
3705
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source string padding method not supported");
3708
/* Terminate or pad the destination */
3709
switch (dst->shared->u.atomic.u.s.pad) {
3710
case H5T_STR_NULLTERM:
3711
while (nchars<dst->shared->size)
3713
d[dst->shared->size-1] = '\0';
3716
case H5T_STR_NULLPAD:
3717
while (nchars<dst->shared->size)
3721
case H5T_STR_SPACEPAD:
3722
while (nchars<dst->shared->size)
3726
case H5T_STR_RESERVED_3:
3727
case H5T_STR_RESERVED_4:
3728
case H5T_STR_RESERVED_5:
3729
case H5T_STR_RESERVED_6:
3730
case H5T_STR_RESERVED_7:
3731
case H5T_STR_RESERVED_8:
3732
case H5T_STR_RESERVED_9:
3733
case H5T_STR_RESERVED_10:
3734
case H5T_STR_RESERVED_11:
3735
case H5T_STR_RESERVED_12:
3736
case H5T_STR_RESERVED_13:
3737
case H5T_STR_RESERVED_14:
3738
case H5T_STR_RESERVED_15:
3740
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination string padding method not supported");
3744
* If we used a temporary buffer for the destination then we
3745
* should copy the value to the true destination buffer.
3748
HDmemcpy(dp, d, dst->shared->size);
3750
sp += direction * buf_stride;
3751
dp += direction * buf_stride;
3753
sp += direction * src->shared->size;
3754
dp += direction * dst->shared->size;
3760
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown converson command");
3765
FUNC_LEAVE_NOAPI(ret_value);
3769
/*-------------------------------------------------------------------------
3770
* Function: H5T_conv_schar_uchar
3772
* Purpose: Converts `signed char' to `unsigned char'
3774
* Return: Success: non-negative
3778
* Programmer: Robb Matzke
3779
* Monday, November 16, 1998
3783
*-------------------------------------------------------------------------
3786
H5T_conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
3787
size_t nelmts, size_t buf_stride,
3788
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
3789
hid_t UNUSED dxpl_id)
3791
herr_t ret_value=SUCCEED; /* Return value */
3793
FUNC_ENTER_NOAPI(H5T_conv_schar_uchar, FAIL);
3795
H5T_CONV_su(SCHAR, UCHAR, signed char, unsigned char, -, -);
3798
FUNC_LEAVE_NOAPI(ret_value);
3802
/*-------------------------------------------------------------------------
3803
* Function: H5T_conv_uchar_schar
3805
* Purpose: Converts `unsigned char' to `signed char'
3807
* Return: Success: non-negative
3811
* Programmer: Robb Matzke
3812
* Monday, November 16, 1998
3816
*-------------------------------------------------------------------------
3819
H5T_conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
3820
size_t nelmts, size_t buf_stride,
3821
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
3822
hid_t UNUSED dxpl_id)
3824
herr_t ret_value=SUCCEED; /* Return value */
3826
FUNC_ENTER_NOAPI(H5T_conv_uchar_schar, FAIL);
3828
H5T_CONV_us(UCHAR, SCHAR, unsigned char, signed char, -, SCHAR_MAX);
3831
FUNC_LEAVE_NOAPI(ret_value);
3835
/*-------------------------------------------------------------------------
3836
* Function: H5T_conv_schar_short
3838
* Purpose: Converts `signed char' to `short'
3840
* Return: Success: Non-negative
3844
* Programmer: Robb Matzke
3845
* Friday, November 13, 1998
3849
*-------------------------------------------------------------------------
3852
H5T_conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
3853
size_t nelmts, size_t buf_stride,
3854
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
3855
hid_t UNUSED dxpl_id)
3857
herr_t ret_value=SUCCEED; /* Return value */
3859
FUNC_ENTER_NOAPI(H5T_conv_schar_short, FAIL);
3861
H5T_CONV_sS(SCHAR, SHORT, signed char, short, -, -);
3864
FUNC_LEAVE_NOAPI(ret_value);
3868
/*-------------------------------------------------------------------------
3869
* Function: H5T_conv_schar_ushort
3871
* Purpose: Converts `signed char' to `unsigned short'
3873
* Return: Success: Non-negative
3877
* Programmer: Robb Matzke
3878
* Friday, November 13, 1998
3882
*-------------------------------------------------------------------------
3885
H5T_conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
3886
size_t nelmts, size_t buf_stride,
3887
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
3888
hid_t UNUSED dxpl_id)
3890
herr_t ret_value=SUCCEED; /* Return value */
3892
FUNC_ENTER_NOAPI(H5T_conv_schar_ushort, FAIL);
3894
H5T_CONV_sU(SCHAR, USHORT, signed char, unsigned short, -, -);
3897
FUNC_LEAVE_NOAPI(ret_value);
3901
/*-------------------------------------------------------------------------
3902
* Function: H5T_conv_uchar_short
3904
* Purpose: Converts `unsigned char' to `short'
3906
* Return: Success: non-negative
3910
* Programmer: Robb Matzke
3911
* Friday, November 13, 1998
3915
*-------------------------------------------------------------------------
3918
H5T_conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
3919
size_t nelmts, size_t buf_stride,
3920
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
3921
hid_t UNUSED dxpl_id)
3923
herr_t ret_value=SUCCEED; /* Return value */
3925
FUNC_ENTER_NOAPI(H5T_conv_uchar_short, FAIL);
3927
H5T_CONV_uS(UCHAR, SHORT, unsigned char, short, -, SHRT_MAX);
3930
FUNC_LEAVE_NOAPI(ret_value);
3934
/*-------------------------------------------------------------------------
3935
* Function: H5T_conv_uchar_ushort
3937
* Purpose: Converts `unsigned char' to `unsigned short'
3939
* Return: Success: non-negative
3943
* Programmer: Robb Matzke
3944
* Friday, November 13, 1998
3948
*-------------------------------------------------------------------------
3951
H5T_conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
3952
size_t nelmts, size_t buf_stride,
3953
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
3954
hid_t UNUSED dxpl_id)
3956
herr_t ret_value=SUCCEED; /* Return value */
3958
FUNC_ENTER_NOAPI(H5T_conv_uchar_ushort, FAIL);
3960
H5T_CONV_uU(UCHAR, USHORT, unsigned char, unsigned short, -, -);
3963
FUNC_LEAVE_NOAPI(ret_value);
3967
/*-------------------------------------------------------------------------
3968
* Function: H5T_conv_schar_int
3970
* Purpose: Converts `signed char' to `int'
3972
* Return: Success: Non-negative
3976
* Programmer: Robb Matzke
3977
* Friday, November 13, 1998
3981
*-------------------------------------------------------------------------
3984
H5T_conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
3985
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
3986
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
3988
herr_t ret_value=SUCCEED; /* Return value */
3990
FUNC_ENTER_NOAPI(H5T_conv_schar_int, FAIL);
3992
H5T_CONV_sS(SCHAR, INT, signed char, int, -, -);
3995
FUNC_LEAVE_NOAPI(ret_value);
3999
/*-------------------------------------------------------------------------
4000
* Function: H5T_conv_schar_uint
4002
* Purpose: Converts `signed char' to `unsigned int'
4004
* Return: Success: Non-negative
4008
* Programmer: Robb Matzke
4009
* Friday, November 13, 1998
4013
*-------------------------------------------------------------------------
4016
H5T_conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4017
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
4018
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
4020
herr_t ret_value=SUCCEED; /* Return value */
4022
FUNC_ENTER_NOAPI(H5T_conv_schar_uint, FAIL);
4024
H5T_CONV_sU(SCHAR, UINT, signed char, unsigned, -, -);
4027
FUNC_LEAVE_NOAPI(ret_value);
4031
/*-------------------------------------------------------------------------
4032
* Function: H5T_conv_uchar_int
4034
* Purpose: Converts `unsigned char' to `int'
4036
* Return: Success: Non-negative
4040
* Programmer: Robb Matzke
4041
* Friday, November 13, 1998
4045
*-------------------------------------------------------------------------
4048
H5T_conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4049
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
4050
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
4052
herr_t ret_value=SUCCEED; /* Return value */
4054
FUNC_ENTER_NOAPI(H5T_conv_uchar_int, FAIL);
4056
H5T_CONV_uS(UCHAR, INT, unsigned char, int, -, INT_MAX);
4059
FUNC_LEAVE_NOAPI(ret_value);
4063
/*-------------------------------------------------------------------------
4064
* Function: H5T_conv_uchar_uint
4066
* Purpose: Converts `unsigned char' to `unsigned int'
4068
* Return: Success: Non-negative
4072
* Programmer: Robb Matzke
4073
* Friday, November 13, 1998
4077
*-------------------------------------------------------------------------
4080
H5T_conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4081
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
4082
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
4084
herr_t ret_value=SUCCEED; /* Return value */
4086
FUNC_ENTER_NOAPI(H5T_conv_uchar_uint, FAIL);
4088
H5T_CONV_uU(UCHAR, UINT, unsigned char, unsigned, -, -);
4091
FUNC_LEAVE_NOAPI(ret_value);
4095
/*-------------------------------------------------------------------------
4096
* Function: H5T_conv_schar_long
4098
* Purpose: Converts `signed char' to `long'
4100
* Return: Success: Non-negative
4104
* Programmer: Robb Matzke
4105
* Friday, November 13, 1998
4109
*-------------------------------------------------------------------------
4112
H5T_conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4113
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
4114
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
4116
herr_t ret_value=SUCCEED; /* Return value */
4118
FUNC_ENTER_NOAPI(H5T_conv_schar_long, FAIL);
4120
H5T_CONV_sS(SCHAR, LONG, signed char, long, -, -);
4123
FUNC_LEAVE_NOAPI(ret_value);
4127
/*-------------------------------------------------------------------------
4128
* Function: H5T_conv_schar_ulong
4130
* Purpose: Converts `signed char' to `unsigned long'
4132
* Return: Success: Non-negative
4136
* Programmer: Robb Matzke
4137
* Friday, November 13, 1998
4141
*-------------------------------------------------------------------------
4144
H5T_conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4145
size_t nelmts, size_t buf_stride,
4146
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4147
hid_t UNUSED dxpl_id)
4149
herr_t ret_value=SUCCEED; /* Return value */
4151
FUNC_ENTER_NOAPI(H5T_conv_schar_ulong, FAIL);
4153
H5T_CONV_sU(SCHAR, ULONG, signed char, unsigned long, -, -);
4156
FUNC_LEAVE_NOAPI(ret_value);
4160
/*-------------------------------------------------------------------------
4161
* Function: H5T_conv_uchar_long
4163
* Purpose: Converts `unsigned char' to `long'
4165
* Return: Success: Non-negative
4169
* Programmer: Robb Matzke
4170
* Friday, November 13, 1998
4174
*-------------------------------------------------------------------------
4177
H5T_conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4178
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
4179
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
4181
herr_t ret_value=SUCCEED; /* Return value */
4183
FUNC_ENTER_NOAPI(H5T_conv_uchar_long, FAIL);
4185
H5T_CONV_uS(UCHAR, LONG, unsigned char, long, -, LONG_MAX);
4188
FUNC_LEAVE_NOAPI(ret_value);
4192
/*-------------------------------------------------------------------------
4193
* Function: H5T_conv_uchar_ulong
4195
* Purpose: Converts `unsigned char' to `unsigned long'
4197
* Return: Success: Non-negative
4201
* Programmer: Robb Matzke
4202
* Friday, November 13, 1998
4206
*-------------------------------------------------------------------------
4209
H5T_conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4210
size_t nelmts, size_t buf_stride,
4211
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4212
hid_t UNUSED dxpl_id)
4214
herr_t ret_value=SUCCEED; /* Return value */
4216
FUNC_ENTER_NOAPI(H5T_conv_uchar_ulong, FAIL);
4218
H5T_CONV_uU(UCHAR, ULONG, unsigned char, unsigned long, -, -);
4221
FUNC_LEAVE_NOAPI(ret_value);
4225
/*-------------------------------------------------------------------------
4226
* Function: H5T_conv_schar_llong
4228
* Purpose: Converts `signed char' to `long_long'
4230
* Return: Success: Non-negative
4234
* Programmer: Robb Matzke
4235
* Friday, November 13, 1998
4239
*-------------------------------------------------------------------------
4242
H5T_conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4243
size_t nelmts, size_t buf_stride,
4244
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4245
hid_t UNUSED dxpl_id)
4247
herr_t ret_value=SUCCEED; /* Return value */
4249
FUNC_ENTER_NOAPI(H5T_conv_schar_llong, FAIL);
4251
H5T_CONV_sS(SCHAR, LLONG, signed char, long_long, -, -);
4254
FUNC_LEAVE_NOAPI(ret_value);
4258
/*-------------------------------------------------------------------------
4259
* Function: H5T_conv_schar_ullong
4261
* Purpose: Converts `signed char' to `unsigned long_long'
4263
* Return: Success: Non-negative
4267
* Programmer: Robb Matzke
4268
* Friday, November 13, 1998
4272
*-------------------------------------------------------------------------
4275
H5T_conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4276
size_t nelmts, size_t buf_stride,
4277
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4278
hid_t UNUSED dxpl_id)
4280
herr_t ret_value=SUCCEED; /* Return value */
4282
FUNC_ENTER_NOAPI(H5T_conv_schar_ullong, FAIL);
4284
H5T_CONV_sU(SCHAR, ULLONG, signed char, unsigned long_long, -, -);
4287
FUNC_LEAVE_NOAPI(ret_value);
4291
/*-------------------------------------------------------------------------
4292
* Function: H5T_conv_uchar_llong
4294
* Purpose: Converts `unsigned char' to `long_long'
4296
* Return: Success: Non-negative
4300
* Programmer: Robb Matzke
4301
* Friday, November 13, 1998
4305
*-------------------------------------------------------------------------
4308
H5T_conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4309
size_t nelmts, size_t buf_stride,
4310
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4311
hid_t UNUSED dxpl_id)
4313
herr_t ret_value=SUCCEED; /* Return value */
4315
FUNC_ENTER_NOAPI(H5T_conv_uchar_llong, FAIL);
4317
H5T_CONV_uS(UCHAR, LLONG, unsigned char, long_long, -, LLONG_MAX);
4320
FUNC_LEAVE_NOAPI(ret_value);
4324
/*-------------------------------------------------------------------------
4325
* Function: H5T_conv_uchar_ullong
4327
* Purpose: Converts `unsigned char' to `unsigned long_long'
4329
* Return: Success: Non-negative
4333
* Programmer: Robb Matzke
4334
* Friday, November 13, 1998
4338
*-------------------------------------------------------------------------
4341
H5T_conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4342
size_t nelmts, size_t buf_stride,
4343
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4344
hid_t UNUSED dxpl_id)
4346
herr_t ret_value=SUCCEED; /* Return value */
4348
FUNC_ENTER_NOAPI(H5T_conv_uchar_ullong, FAIL);
4350
H5T_CONV_uU(UCHAR, ULLONG, unsigned char, unsigned long_long, -, -);
4353
FUNC_LEAVE_NOAPI(ret_value);
4357
/*-------------------------------------------------------------------------
4358
* Function: H5T_conv_short_schar
4360
* Purpose: Converts `short' to `signed char'
4362
* Return: Success: non-negative
4366
* Programmer: Robb Matzke
4367
* Friday, November 13, 1998
4371
*-------------------------------------------------------------------------
4374
H5T_conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4375
size_t nelmts, size_t buf_stride,
4376
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4377
hid_t UNUSED dxpl_id)
4379
herr_t ret_value=SUCCEED; /* Return value */
4381
FUNC_ENTER_NOAPI(H5T_conv_short_schar, FAIL);
4383
H5T_CONV_Ss(SHORT, SCHAR, short, signed char, SCHAR_MIN, SCHAR_MAX);
4386
FUNC_LEAVE_NOAPI(ret_value);
4390
/*-------------------------------------------------------------------------
4391
* Function: H5T_conv_short_uchar
4393
* Purpose: Converts `short' to `unsigned char'
4395
* Return: Success: non-negative
4399
* Programmer: Robb Matzke
4400
* Friday, November 13, 1998
4404
*-------------------------------------------------------------------------
4407
H5T_conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4408
size_t nelmts, size_t buf_stride,
4409
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4410
hid_t UNUSED dxpl_id)
4412
herr_t ret_value=SUCCEED; /* Return value */
4414
FUNC_ENTER_NOAPI(H5T_conv_short_uchar, FAIL);
4416
H5T_CONV_Su(SHORT, UCHAR, short, unsigned char, -, UCHAR_MAX);
4419
FUNC_LEAVE_NOAPI(ret_value);
4423
/*-------------------------------------------------------------------------
4424
* Function: H5T_conv_ushort_schar
4426
* Purpose: Converts `unsigned short' to `signed char'
4428
* Return: Success: non-negative
4432
* Programmer: Robb Matzke
4433
* Friday, November 13, 1998
4437
*-------------------------------------------------------------------------
4440
H5T_conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4441
size_t nelmts, size_t buf_stride,
4442
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4443
hid_t UNUSED dxpl_id)
4445
herr_t ret_value=SUCCEED; /* Return value */
4447
FUNC_ENTER_NOAPI(H5T_conv_ushort_schar, FAIL);
4449
H5T_CONV_Us(USHORT, SCHAR, unsigned short, signed char, -, SCHAR_MAX);
4452
FUNC_LEAVE_NOAPI(ret_value);
4456
/*-------------------------------------------------------------------------
4457
* Function: H5T_conv_ushort_uchar
4459
* Purpose: Converts `unsigned short' to `unsigned char'
4461
* Return: Success: non-negative
4465
* Programmer: Robb Matzke
4466
* Friday, November 13, 1998
4470
*-------------------------------------------------------------------------
4473
H5T_conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4474
size_t nelmts, size_t buf_stride,
4475
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4476
hid_t UNUSED dxpl_id)
4478
herr_t ret_value=SUCCEED; /* Return value */
4480
FUNC_ENTER_NOAPI(H5T_conv_ushort_uchar, FAIL);
4482
H5T_CONV_Uu(USHORT, UCHAR, unsigned short, unsigned char, -, UCHAR_MAX);
4485
FUNC_LEAVE_NOAPI(ret_value);
4489
/*-------------------------------------------------------------------------
4490
* Function: H5T_conv_short_ushort
4492
* Purpose: Converts `short' to `unsigned short'
4494
* Return: Success: non-negative
4498
* Programmer: Robb Matzke
4499
* Monday, November 16, 1998
4503
*-------------------------------------------------------------------------
4506
H5T_conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4507
size_t nelmts, size_t buf_stride,
4508
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4509
hid_t UNUSED dxpl_id)
4511
herr_t ret_value=SUCCEED; /* Return value */
4513
FUNC_ENTER_NOAPI(H5T_conv_short_ushort, FAIL);
4515
H5T_CONV_su(SHORT, USHORT, short, unsigned short, -, -);
4518
FUNC_LEAVE_NOAPI(ret_value);
4522
/*-------------------------------------------------------------------------
4523
* Function: H5T_conv_ushort_short
4525
* Purpose: Converts `unsigned short' to `short'
4527
* Return: Success: non-negative
4531
* Programmer: Robb Matzke
4532
* Monday, November 16, 1998
4536
*-------------------------------------------------------------------------
4539
H5T_conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4540
size_t nelmts, size_t buf_stride,
4541
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4542
hid_t UNUSED dxpl_id)
4544
herr_t ret_value=SUCCEED; /* Return value */
4546
FUNC_ENTER_NOAPI(H5T_conv_ushort_short, FAIL);
4548
H5T_CONV_us(USHORT, SHORT, unsigned short, short, -, SHRT_MAX);
4551
FUNC_LEAVE_NOAPI(ret_value);
4555
/*-------------------------------------------------------------------------
4556
* Function: H5T_conv_short_int
4558
* Purpose: Converts `short' to `int'
4560
* Return: Success: non-negative
4564
* Programmer: Robb Matzke
4565
* Friday, November 13, 1998
4569
*-------------------------------------------------------------------------
4572
H5T_conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4573
size_t nelmts, size_t buf_stride,
4574
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4575
hid_t UNUSED dxpl_id)
4577
herr_t ret_value=SUCCEED; /* Return value */
4579
FUNC_ENTER_NOAPI(H5T_conv_short_int, FAIL);
4581
H5T_CONV_sS(SHORT, INT, short, int, -, -);
4584
FUNC_LEAVE_NOAPI(ret_value);
4588
/*-------------------------------------------------------------------------
4589
* Function: H5T_conv_short_uint
4591
* Purpose: Converts `short' to `unsigned int'
4593
* Return: Success: Non-negative
4597
* Programmer: Robb Matzke
4598
* Friday, November 13, 1998
4602
*-------------------------------------------------------------------------
4605
H5T_conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4606
size_t nelmts, size_t buf_stride,
4607
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4608
hid_t UNUSED dxpl_id)
4610
herr_t ret_value=SUCCEED; /* Return value */
4612
FUNC_ENTER_NOAPI(H5T_conv_short_uint, FAIL);
4614
H5T_CONV_sU(SHORT, UINT, short, unsigned, -, -);
4617
FUNC_LEAVE_NOAPI(ret_value);
4621
/*-------------------------------------------------------------------------
4622
* Function: H5T_conv_ushort_int
4624
* Purpose: Converts `unsigned short' to `int'
4626
* Return: Success: Non-negative
4630
* Programmer: Robb Matzke
4631
* Friday, November 13, 1998
4635
*-------------------------------------------------------------------------
4638
H5T_conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4639
size_t nelmts, size_t buf_stride,
4640
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4641
hid_t UNUSED dxpl_id)
4643
herr_t ret_value=SUCCEED; /* Return value */
4645
FUNC_ENTER_NOAPI(H5T_conv_ushort_int, FAIL);
4647
H5T_CONV_uS(USHORT, INT, unsigned short, int, -, INT_MAX);
4650
FUNC_LEAVE_NOAPI(ret_value);
4654
/*-------------------------------------------------------------------------
4655
* Function: H5T_conv_ushort_uint
4657
* Purpose: Converts `unsigned short' to `unsigned int'
4659
* Return: Success: non-negative
4663
* Programmer: Robb Matzke
4664
* Friday, November 13, 1998
4668
*-------------------------------------------------------------------------
4671
H5T_conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4672
size_t nelmts, size_t buf_stride,
4673
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4674
hid_t UNUSED dxpl_id)
4676
herr_t ret_value=SUCCEED; /* Return value */
4678
FUNC_ENTER_NOAPI(H5T_conv_ushort_uint, FAIL);
4680
H5T_CONV_uU(USHORT, UINT, unsigned short, unsigned, -, -);
4683
FUNC_LEAVE_NOAPI(ret_value);
4687
/*-------------------------------------------------------------------------
4688
* Function: H5T_conv_short_long
4690
* Purpose: Converts `short' to `long'
4692
* Return: Success: non-negative
4696
* Programmer: Robb Matzke
4697
* Friday, November 13, 1998
4701
*-------------------------------------------------------------------------
4704
H5T_conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4705
size_t nelmts, size_t buf_stride,
4706
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4707
hid_t UNUSED dxpl_id)
4709
herr_t ret_value=SUCCEED; /* Return value */
4711
FUNC_ENTER_NOAPI(H5T_conv_short_long, FAIL);
4713
H5T_CONV_sS(SHORT, LONG, short, long, -, -);
4716
FUNC_LEAVE_NOAPI(ret_value);
4720
/*-------------------------------------------------------------------------
4721
* Function: H5T_conv_short_ulong
4723
* Purpose: Converts `short' to `unsigned long'
4725
* Return: Success: Non-negative
4729
* Programmer: Robb Matzke
4730
* Friday, November 13, 1998
4734
*-------------------------------------------------------------------------
4737
H5T_conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4738
size_t nelmts, size_t buf_stride,
4739
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4740
hid_t UNUSED dxpl_id)
4742
herr_t ret_value=SUCCEED; /* Return value */
4744
FUNC_ENTER_NOAPI(H5T_conv_short_ulong, FAIL);
4746
H5T_CONV_sU(SHORT, ULONG, short, unsigned long, -, -);
4749
FUNC_LEAVE_NOAPI(ret_value);
4753
/*-------------------------------------------------------------------------
4754
* Function: H5T_conv_ushort_long
4756
* Purpose: Converts `unsigned short' to `long'
4758
* Return: Success: Non-negative
4762
* Programmer: Robb Matzke
4763
* Friday, November 13, 1998
4767
*-------------------------------------------------------------------------
4770
H5T_conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4771
size_t nelmts, size_t buf_stride,
4772
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4773
hid_t UNUSED dxpl_id)
4775
herr_t ret_value=SUCCEED; /* Return value */
4777
FUNC_ENTER_NOAPI(H5T_conv_ushort_long, FAIL);
4779
H5T_CONV_uS(USHORT, LONG, unsigned short, long, -, LONG_MAX);
4782
FUNC_LEAVE_NOAPI(ret_value);
4786
/*-------------------------------------------------------------------------
4787
* Function: H5T_conv_ushort_ulong
4789
* Purpose: Converts `unsigned short' to `unsigned long'
4791
* Return: Success: non-negative
4795
* Programmer: Robb Matzke
4796
* Friday, November 13, 1998
4800
*-------------------------------------------------------------------------
4803
H5T_conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4804
size_t nelmts, size_t buf_stride,
4805
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4806
hid_t UNUSED dxpl_id)
4808
herr_t ret_value=SUCCEED; /* Return value */
4810
FUNC_ENTER_NOAPI(H5T_conv_ushort_ulong, FAIL);
4812
H5T_CONV_uU(USHORT, ULONG, unsigned short, unsigned long, -, -);
4815
FUNC_LEAVE_NOAPI(ret_value);
4819
/*-------------------------------------------------------------------------
4820
* Function: H5T_conv_short_llong
4822
* Purpose: Converts `short' to `long_long'
4824
* Return: Success: Non-negative
4828
* Programmer: Robb Matzke
4829
* Friday, November 13, 1998
4833
*-------------------------------------------------------------------------
4836
H5T_conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4837
size_t nelmts, size_t buf_stride,
4838
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4839
hid_t UNUSED dxpl_id)
4841
herr_t ret_value=SUCCEED; /* Return value */
4843
FUNC_ENTER_NOAPI(H5T_conv_short_llong, FAIL);
4845
H5T_CONV_sS(SHORT, LLONG, short, long_long, -, -);
4848
FUNC_LEAVE_NOAPI(ret_value);
4852
/*-------------------------------------------------------------------------
4853
* Function: H5T_conv_short_ullong
4855
* Purpose: Converts `short' to `unsigned long_long'
4857
* Return: Success: Non-negative
4861
* Programmer: Robb Matzke
4862
* Friday, November 13, 1998
4866
*-------------------------------------------------------------------------
4869
H5T_conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4870
size_t nelmts, size_t buf_stride,
4871
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4872
hid_t UNUSED dxpl_id)
4874
herr_t ret_value=SUCCEED; /* Return value */
4876
FUNC_ENTER_NOAPI(H5T_conv_short_ullong, FAIL);
4878
H5T_CONV_sU(SHORT, ULLONG, short, unsigned long_long, -, -);
4881
FUNC_LEAVE_NOAPI(ret_value);
4885
/*-------------------------------------------------------------------------
4886
* Function: H5T_conv_ushort_llong
4888
* Purpose: Converts `unsigned short' to `long_long'
4890
* Return: Success: Non-negative
4894
* Programmer: Robb Matzke
4895
* Friday, November 13, 1998
4899
*-------------------------------------------------------------------------
4902
H5T_conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4903
size_t nelmts, size_t buf_stride,
4904
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4905
hid_t UNUSED dxpl_id)
4907
herr_t ret_value=SUCCEED; /* Return value */
4909
FUNC_ENTER_NOAPI(H5T_conv_ushort_llong, FAIL);
4911
H5T_CONV_uS(USHORT, LLONG, unsigned short, long_long, -, LLONG_MAX);
4914
FUNC_LEAVE_NOAPI(ret_value);
4918
/*-------------------------------------------------------------------------
4919
* Function: H5T_conv_ushort_ullong
4921
* Purpose: Converts `unsigned short' to `unsigned long_long'
4923
* Return: Success: Non-negative
4927
* Programmer: Robb Matzke
4928
* Friday, November 13, 1998
4932
*-------------------------------------------------------------------------
4935
H5T_conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4936
size_t nelmts, size_t buf_stride,
4937
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4938
hid_t UNUSED dxpl_id)
4940
herr_t ret_value=SUCCEED; /* Return value */
4942
FUNC_ENTER_NOAPI(H5T_conv_ushort_ullong, FAIL);
4944
H5T_CONV_uU(USHORT, ULLONG, unsigned short, unsigned long_long, -, -);
4947
FUNC_LEAVE_NOAPI(ret_value);
4951
/*-------------------------------------------------------------------------
4952
* Function: H5T_conv_int_schar
4954
* Purpose: Converts `int' to `signed char'
4956
* Return: Success: non-negative
4960
* Programmer: Robb Matzke
4961
* Friday, November 13, 1998
4965
*-------------------------------------------------------------------------
4968
H5T_conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
4969
size_t nelmts, size_t buf_stride,
4970
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
4971
hid_t UNUSED dxpl_id)
4973
herr_t ret_value=SUCCEED; /* Return value */
4975
FUNC_ENTER_NOAPI(H5T_conv_int_schar, FAIL);
4977
H5T_CONV_Ss(INT, SCHAR, int, signed char, SCHAR_MIN, SCHAR_MAX);
4980
FUNC_LEAVE_NOAPI(ret_value);
4984
/*-------------------------------------------------------------------------
4985
* Function: H5T_conv_int_uchar
4987
* Purpose: Converts `int' to `unsigned char'
4989
* Return: Success: non-negative
4993
* Programmer: Robb Matzke
4994
* Friday, November 13, 1998
4998
*-------------------------------------------------------------------------
5001
H5T_conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5002
size_t nelmts, size_t buf_stride,
5003
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5004
hid_t UNUSED dxpl_id)
5006
herr_t ret_value=SUCCEED; /* Return value */
5008
FUNC_ENTER_NOAPI(H5T_conv_int_uchar, FAIL);
5010
H5T_CONV_Su(INT, UCHAR, int, unsigned char, -, UCHAR_MAX);
5013
FUNC_LEAVE_NOAPI(ret_value);
5017
/*-------------------------------------------------------------------------
5018
* Function: H5T_conv_uint_schar
5020
* Purpose: Converts `unsigned int' to `signed char'
5022
* Return: Success: non-negative
5026
* Programmer: Robb Matzke
5027
* Friday, November 13, 1998
5031
*-------------------------------------------------------------------------
5034
H5T_conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5035
size_t nelmts, size_t buf_stride,
5036
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5037
hid_t UNUSED dxpl_id)
5039
herr_t ret_value=SUCCEED; /* Return value */
5041
FUNC_ENTER_NOAPI(H5T_conv_uint_schar, FAIL);
5043
H5T_CONV_Us(UINT, SCHAR, unsigned, signed char, -, SCHAR_MAX);
5046
FUNC_LEAVE_NOAPI(ret_value);
5050
/*-------------------------------------------------------------------------
5051
* Function: H5T_conv_uint_uchar
5053
* Purpose: Converts `unsigned int' to `unsigned char'
5055
* Return: Success: non-negative
5059
* Programmer: Robb Matzke
5060
* Friday, November 13, 1998
5064
*-------------------------------------------------------------------------
5067
H5T_conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5068
size_t nelmts, size_t buf_stride,
5069
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5070
hid_t UNUSED dxpl_id)
5072
herr_t ret_value=SUCCEED; /* Return value */
5074
FUNC_ENTER_NOAPI(H5T_conv_uint_uchar, FAIL);
5076
H5T_CONV_Uu(UINT, UCHAR, unsigned, unsigned char, -, UCHAR_MAX);
5079
FUNC_LEAVE_NOAPI(ret_value);
5083
/*-------------------------------------------------------------------------
5084
* Function: H5T_conv_int_short
5086
* Purpose: Converts `int' to `short'
5088
* Return: Success: non-negative
5092
* Programmer: Robb Matzke
5093
* Friday, November 13, 1998
5097
*-------------------------------------------------------------------------
5100
H5T_conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5101
size_t nelmts, size_t buf_stride,
5102
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5103
hid_t UNUSED dxpl_id)
5105
herr_t ret_value=SUCCEED; /* Return value */
5107
FUNC_ENTER_NOAPI(H5T_conv_int_short, FAIL);
5109
H5T_CONV_Ss(INT, SHORT, int, short, SHRT_MIN, SHRT_MAX);
5112
FUNC_LEAVE_NOAPI(ret_value);
5116
/*-------------------------------------------------------------------------
5117
* Function: H5T_conv_int_ushort
5119
* Purpose: Converts `int' to `unsigned short'
5121
* Return: Success: non-negative
5125
* Programmer: Robb Matzke
5126
* Friday, November 13, 1998
5130
*-------------------------------------------------------------------------
5133
H5T_conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5134
size_t nelmts, size_t buf_stride,
5135
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5136
hid_t UNUSED dxpl_id)
5138
herr_t ret_value=SUCCEED; /* Return value */
5140
FUNC_ENTER_NOAPI(H5T_conv_int_ushort, FAIL);
5142
H5T_CONV_Su(INT, USHORT, int, unsigned short, -, USHRT_MAX);
5145
FUNC_LEAVE_NOAPI(ret_value);
5149
/*-------------------------------------------------------------------------
5150
* Function: H5T_conv_uint_short
5152
* Purpose: Converts `unsigned int' to `short'
5154
* Return: Success: non-negative
5158
* Programmer: Robb Matzke
5159
* Friday, November 13, 1998
5163
*-------------------------------------------------------------------------
5166
H5T_conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5167
size_t nelmts, size_t buf_stride,
5168
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5169
hid_t UNUSED dxpl_id)
5171
herr_t ret_value=SUCCEED; /* Return value */
5173
FUNC_ENTER_NOAPI(H5T_conv_uint_short, FAIL);
5175
H5T_CONV_Us(UINT, SHORT, unsigned, short, -, SHRT_MAX);
5178
FUNC_LEAVE_NOAPI(ret_value);
5182
/*-------------------------------------------------------------------------
5183
* Function: H5T_conv_uint_ushort
5185
* Purpose: Converts `unsigned int' to `unsigned short'
5187
* Return: Success: non-negative
5191
* Programmer: Robb Matzke
5192
* Friday, November 13, 1998
5196
*-------------------------------------------------------------------------
5199
H5T_conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5200
size_t nelmts, size_t buf_stride,
5201
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5202
hid_t UNUSED dxpl_id)
5204
herr_t ret_value=SUCCEED; /* Return value */
5206
FUNC_ENTER_NOAPI(H5T_conv_uint_ushort, FAIL);
5208
H5T_CONV_Uu(UINT, USHORT, unsigned, unsigned short, -, USHRT_MAX);
5211
FUNC_LEAVE_NOAPI(ret_value);
5215
/*-------------------------------------------------------------------------
5216
* Function: H5T_conv_int_uint
5218
* Purpose: Converts `int' to `unsigned int'
5220
* Return: Success: non-negative
5224
* Programmer: Robb Matzke
5225
* Monday, November 16, 1998
5229
*-------------------------------------------------------------------------
5232
H5T_conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5233
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5234
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5236
herr_t ret_value=SUCCEED; /* Return value */
5238
FUNC_ENTER_NOAPI(H5T_conv_int_uint, FAIL);
5240
H5T_CONV_su(INT, UINT, int, unsigned, -, -);
5243
FUNC_LEAVE_NOAPI(ret_value);
5247
/*-------------------------------------------------------------------------
5248
* Function: H5T_conv_uint_int
5250
* Purpose: Converts `unsigned int' to `int'
5252
* Return: Success: non-negative
5256
* Programmer: Robb Matzke
5257
* Monday, November 16, 1998
5261
*-------------------------------------------------------------------------
5264
H5T_conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5265
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5266
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5268
herr_t ret_value=SUCCEED; /* Return value */
5270
FUNC_ENTER_NOAPI(H5T_conv_uint_int, FAIL);
5272
H5T_CONV_us(UINT, INT, unsigned, int, -, INT_MAX);
5275
FUNC_LEAVE_NOAPI(ret_value);
5279
/*-------------------------------------------------------------------------
5280
* Function: H5T_conv_int_long
5282
* Purpose: Converts `int' to `long'
5284
* Return: Success: non-negative
5288
* Programmer: Robb Matzke
5289
* Friday, November 13, 1998
5293
*-------------------------------------------------------------------------
5296
H5T_conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5297
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5298
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5300
herr_t ret_value=SUCCEED; /* Return value */
5302
FUNC_ENTER_NOAPI(H5T_conv_int_long, FAIL);
5304
H5T_CONV_sS(INT, LONG, int, long, -, -);
5307
FUNC_LEAVE_NOAPI(ret_value);
5311
/*-------------------------------------------------------------------------
5312
* Function: H5T_conv_int_ulong
5314
* Purpose: Converts `int' to `unsigned long'
5316
* Return: Success: Non-negative
5320
* Programmer: Robb Matzke
5321
* Friday, November 13, 1998
5325
*-------------------------------------------------------------------------
5328
H5T_conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5329
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5330
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5332
herr_t ret_value=SUCCEED; /* Return value */
5334
FUNC_ENTER_NOAPI(H5T_conv_int_ulong, FAIL);
5336
H5T_CONV_sU(INT, LONG, int, unsigned long, -, -);
5339
FUNC_LEAVE_NOAPI(ret_value);
5343
/*-------------------------------------------------------------------------
5344
* Function: H5T_conv_uint_long
5346
* Purpose: Converts `unsigned int' to `long'
5348
* Return: Success: Non-negative
5352
* Programmer: Robb Matzke
5353
* Friday, November 13, 1998
5357
*-------------------------------------------------------------------------
5360
H5T_conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5361
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5362
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5364
herr_t ret_value=SUCCEED; /* Return value */
5366
FUNC_ENTER_NOAPI(H5T_conv_uint_long, FAIL);
5368
H5T_CONV_uS(UINT, LONG, unsigned, long, -, LONG_MAX);
5371
FUNC_LEAVE_NOAPI(ret_value);
5375
/*-------------------------------------------------------------------------
5376
* Function: H5T_conv_uint_ulong
5378
* Purpose: Converts `unsigned int' to `unsigned long'
5380
* Return: Success: non-negative
5384
* Programmer: Robb Matzke
5385
* Friday, November 13, 1998
5389
*-------------------------------------------------------------------------
5392
H5T_conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5393
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5394
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5396
herr_t ret_value=SUCCEED; /* Return value */
5398
FUNC_ENTER_NOAPI(H5T_conv_uint_ulong, FAIL);
5400
H5T_CONV_uU(UINT, ULONG, unsigned, unsigned long, -, -);
5403
FUNC_LEAVE_NOAPI(ret_value);
5407
/*-------------------------------------------------------------------------
5408
* Function: H5T_conv_int_llong
5410
* Purpose: Converts `int' to `long_long'
5412
* Return: Success: Non-negative
5416
* Programmer: Robb Matzke
5417
* Friday, November 13, 1998
5421
*-------------------------------------------------------------------------
5424
H5T_conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5425
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5426
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5428
herr_t ret_value=SUCCEED; /* Return value */
5430
FUNC_ENTER_NOAPI(H5T_conv_int_llong, FAIL);
5432
H5T_CONV_sS(INT, LLONG, int, long_long, -, -);
5435
FUNC_LEAVE_NOAPI(ret_value);
5439
/*-------------------------------------------------------------------------
5440
* Function: H5T_conv_int_ullong
5442
* Purpose: Converts `int' to `unsigned long_long'
5444
* Return: Success: Non-negative
5448
* Programmer: Robb Matzke
5449
* Friday, November 13, 1998
5453
*-------------------------------------------------------------------------
5456
H5T_conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5457
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5458
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5460
herr_t ret_value=SUCCEED; /* Return value */
5462
FUNC_ENTER_NOAPI(H5T_conv_int_ullong, FAIL);
5464
H5T_CONV_sU(INT, ULLONG, int, unsigned long_long, -, -);
5467
FUNC_LEAVE_NOAPI(ret_value);
5471
/*-------------------------------------------------------------------------
5472
* Function: H5T_conv_uint_llong
5474
* Purpose: Converts `unsigned int' to `long_long'
5476
* Return: Success: Non-negative
5480
* Programmer: Robb Matzke
5481
* Friday, November 13, 1998
5485
*-------------------------------------------------------------------------
5488
H5T_conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5489
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5490
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5492
herr_t ret_value=SUCCEED; /* Return value */
5494
FUNC_ENTER_NOAPI(H5T_conv_uint_llong, FAIL);
5496
H5T_CONV_uS(UINT, LLONG, unsigned, long_long, -, LLONG_MAX);
5499
FUNC_LEAVE_NOAPI(ret_value);
5503
/*-------------------------------------------------------------------------
5504
* Function: H5T_conv_uint_ullong
5506
* Purpose: Converts `unsigned int' to `unsigned long_long'
5508
* Return: Success: Non-negative
5512
* Programmer: Robb Matzke
5513
* Friday, November 13, 1998
5517
*-------------------------------------------------------------------------
5520
H5T_conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5521
size_t nelmts, size_t buf_stride,
5522
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5523
hid_t UNUSED dxpl_id)
5525
herr_t ret_value=SUCCEED; /* Return value */
5527
FUNC_ENTER_NOAPI(H5T_conv_uint_ullong, FAIL);
5529
H5T_CONV_uU(UINT, ULLONG, unsigned, unsigned long_long, -, -);
5532
FUNC_LEAVE_NOAPI(ret_value);
5536
/*-------------------------------------------------------------------------
5537
* Function: H5T_conv_long_schar
5539
* Purpose: Converts `long' to `signed char'
5541
* Return: Success: non-negative
5545
* Programmer: Robb Matzke
5546
* Friday, November 13, 1998
5550
*-------------------------------------------------------------------------
5553
H5T_conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5554
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5555
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5557
herr_t ret_value=SUCCEED; /* Return value */
5559
FUNC_ENTER_NOAPI(H5T_conv_long_schar, FAIL);
5561
H5T_CONV_Ss(LONG, SCHAR, long, signed char, SCHAR_MIN, SCHAR_MAX);
5564
FUNC_LEAVE_NOAPI(ret_value);
5568
/*-------------------------------------------------------------------------
5569
* Function: H5T_conv_long_uchar
5571
* Purpose: Converts `long' to `unsigned char'
5573
* Return: Success: non-negative
5577
* Programmer: Robb Matzke
5578
* Friday, November 13, 1998
5582
*-------------------------------------------------------------------------
5585
H5T_conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5586
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5587
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5589
herr_t ret_value=SUCCEED; /* Return value */
5591
FUNC_ENTER_NOAPI(H5T_conv_long_uchar, FAIL);
5593
H5T_CONV_Su(LONG, UCHAR, long, unsigned char, -, UCHAR_MAX);
5596
FUNC_LEAVE_NOAPI(ret_value);
5600
/*-------------------------------------------------------------------------
5601
* Function: H5T_conv_ulong_schar
5603
* Purpose: Converts `unsigned long' to `signed char'
5605
* Return: Success: non-negative
5609
* Programmer: Robb Matzke
5610
* Friday, November 13, 1998
5614
*-------------------------------------------------------------------------
5617
H5T_conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5618
size_t nelmts, size_t buf_stride,
5619
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5620
hid_t UNUSED dxpl_id)
5622
herr_t ret_value=SUCCEED; /* Return value */
5624
FUNC_ENTER_NOAPI(H5T_conv_ulong_schar, FAIL);
5626
H5T_CONV_Us(ULONG, SCHAR, unsigned long, signed char, -, SCHAR_MAX);
5629
FUNC_LEAVE_NOAPI(ret_value);
5633
/*-------------------------------------------------------------------------
5634
* Function: H5T_conv_ulong_uchar
5636
* Purpose: Converts `unsigned long' to `unsigned char'
5638
* Return: Success: non-negative
5642
* Programmer: Robb Matzke
5643
* Friday, November 13, 1998
5647
*-------------------------------------------------------------------------
5650
H5T_conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5651
size_t nelmts, size_t buf_stride,
5652
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5653
hid_t UNUSED dxpl_id)
5655
herr_t ret_value=SUCCEED; /* Return value */
5657
FUNC_ENTER_NOAPI(H5T_conv_ulong_uchar, FAIL);
5659
H5T_CONV_Uu(ULONG, UCHAR, unsigned long, unsigned char, -, UCHAR_MAX);
5662
FUNC_LEAVE_NOAPI(ret_value);
5666
/*-------------------------------------------------------------------------
5667
* Function: H5T_conv_long_short
5669
* Purpose: Converts `long' to `short'
5671
* Return: Success: non-negative
5675
* Programmer: Robb Matzke
5676
* Friday, November 13, 1998
5680
*-------------------------------------------------------------------------
5683
H5T_conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5684
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5685
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5687
herr_t ret_value=SUCCEED; /* Return value */
5689
FUNC_ENTER_NOAPI(H5T_conv_long_short, FAIL);
5691
H5T_CONV_Ss(LONG, SHORT, long, short, SHRT_MIN, SHRT_MAX);
5694
FUNC_LEAVE_NOAPI(ret_value);
5698
/*-------------------------------------------------------------------------
5699
* Function: H5T_conv_long_ushort
5701
* Purpose: Converts `long' to `unsigned short'
5703
* Return: Success: non-negative
5707
* Programmer: Robb Matzke
5708
* Friday, November 13, 1998
5712
*-------------------------------------------------------------------------
5715
H5T_conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5716
size_t nelmts, size_t buf_stride,
5717
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5718
hid_t UNUSED dxpl_id)
5720
herr_t ret_value=SUCCEED; /* Return value */
5722
FUNC_ENTER_NOAPI(H5T_conv_long_ushort, FAIL);
5724
H5T_CONV_Su(LONG, USHORT, long, unsigned short, -, USHRT_MAX);
5727
FUNC_LEAVE_NOAPI(ret_value);
5731
/*-------------------------------------------------------------------------
5732
* Function: H5T_conv_ulong_short
5734
* Purpose: Converts `unsigned long' to `short'
5736
* Return: Success: non-negative
5740
* Programmer: Robb Matzke
5741
* Friday, November 13, 1998
5745
*-------------------------------------------------------------------------
5748
H5T_conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5749
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5750
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5752
herr_t ret_value=SUCCEED; /* Return value */
5754
FUNC_ENTER_NOAPI(H5T_conv_ulong_short, FAIL);
5756
H5T_CONV_Us(ULONG, SHORT, unsigned long, short, -, SHRT_MAX);
5759
FUNC_LEAVE_NOAPI(ret_value);
5763
/*-------------------------------------------------------------------------
5764
* Function: H5T_conv_ulong_ushort
5766
* Purpose: Converts `unsigned long' to `unsigned short'
5768
* Return: Success: non-negative
5772
* Programmer: Robb Matzke
5773
* Friday, November 13, 1998
5777
*-------------------------------------------------------------------------
5780
H5T_conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5781
size_t nelmts, size_t buf_stride,
5782
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
5783
hid_t UNUSED dxpl_id)
5785
herr_t ret_value=SUCCEED; /* Return value */
5787
FUNC_ENTER_NOAPI(H5T_conv_ulong_ushort, FAIL);
5789
H5T_CONV_Uu(ULONG, USHORT, unsigned long, unsigned short, -, USHRT_MAX);
5792
FUNC_LEAVE_NOAPI(ret_value);
5796
/*-------------------------------------------------------------------------
5797
* Function: H5T_conv_long_int
5799
* Purpose: Converts `long' to `int'
5801
* Return: Success: non-negative
5805
* Programmer: Robb Matzke
5806
* Friday, November 13, 1998
5810
*-------------------------------------------------------------------------
5813
H5T_conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5814
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5815
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5817
herr_t ret_value=SUCCEED; /* Return value */
5819
FUNC_ENTER_NOAPI(H5T_conv_long_int, FAIL);
5821
H5T_CONV_Ss(LONG, INT, long, int, INT_MIN, INT_MAX);
5824
FUNC_LEAVE_NOAPI(ret_value);
5828
/*-------------------------------------------------------------------------
5829
* Function: H5T_conv_long_uint
5831
* Purpose: Converts `long' to `unsigned int'
5833
* Return: Success: non-negative
5837
* Programmer: Robb Matzke
5838
* Friday, November 13, 1998
5842
*-------------------------------------------------------------------------
5845
H5T_conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5846
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5847
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5849
herr_t ret_value=SUCCEED; /* Return value */
5851
FUNC_ENTER_NOAPI(H5T_conv_long_uint, FAIL);
5853
H5T_CONV_Su(LONG, UINT, long, unsigned, -, UINT_MAX);
5856
FUNC_LEAVE_NOAPI(ret_value);
5860
/*-------------------------------------------------------------------------
5861
* Function: H5T_conv_ulong_int
5863
* Purpose: Converts `unsigned long' to `int'
5865
* Return: Success: non-negative
5869
* Programmer: Robb Matzke
5870
* Friday, November 13, 1998
5874
*-------------------------------------------------------------------------
5877
H5T_conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5878
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5879
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5881
herr_t ret_value=SUCCEED; /* Return value */
5883
FUNC_ENTER_NOAPI(H5T_conv_ulong_int, FAIL);
5885
H5T_CONV_Us(ULONG, INT, unsigned long, int, -, INT_MAX);
5888
FUNC_LEAVE_NOAPI(ret_value);
5892
/*-------------------------------------------------------------------------
5893
* Function: H5T_conv_ulong_uint
5895
* Purpose: Converts `unsigned long' to `unsigned int'
5897
* Return: Success: non-negative
5901
* Programmer: Robb Matzke
5902
* Friday, November 13, 1998
5906
*-------------------------------------------------------------------------
5909
H5T_conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5910
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5911
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5913
herr_t ret_value=SUCCEED; /* Return value */
5915
FUNC_ENTER_NOAPI(H5T_conv_ulong_uint, FAIL);
5917
H5T_CONV_Uu(ULONG, UINT, unsigned long, unsigned, -, UINT_MAX);
5920
FUNC_LEAVE_NOAPI(ret_value);
5924
/*-------------------------------------------------------------------------
5925
* Function: H5T_conv_long_ulong
5927
* Purpose: Converts `long' to `unsigned long'
5929
* Return: Success: non-negative
5933
* Programmer: Robb Matzke
5934
* Monday, November 16, 1998
5938
*-------------------------------------------------------------------------
5941
H5T_conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5942
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5943
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5945
herr_t ret_value=SUCCEED; /* Return value */
5947
FUNC_ENTER_NOAPI(H5T_conv_long_ulong, FAIL);
5949
H5T_CONV_su(LONG, ULONG, long, unsigned long, -, -);
5952
FUNC_LEAVE_NOAPI(ret_value);
5956
/*-------------------------------------------------------------------------
5957
* Function: H5T_conv_ulong_long
5959
* Purpose: Converts `unsigned long' to `long'
5961
* Return: Success: non-negative
5965
* Programmer: Robb Matzke
5966
* Monday, November 16, 1998
5970
*-------------------------------------------------------------------------
5973
H5T_conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
5974
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
5975
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
5977
herr_t ret_value=SUCCEED; /* Return value */
5979
FUNC_ENTER_NOAPI(H5T_conv_ulong_long, FAIL);
5981
H5T_CONV_us(ULONG, LONG, unsigned long, long, -, LONG_MAX);
5984
FUNC_LEAVE_NOAPI(ret_value);
5988
/*-------------------------------------------------------------------------
5989
* Function: H5T_conv_long_llong
5991
* Purpose: Converts `long' to `long_long'
5993
* Return: Success: Non-negative
5997
* Programmer: Robb Matzke
5998
* Friday, November 13, 1998
6002
*-------------------------------------------------------------------------
6005
H5T_conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6006
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
6007
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
6009
herr_t ret_value=SUCCEED; /* Return value */
6011
FUNC_ENTER_NOAPI(H5T_conv_long_llong, FAIL);
6013
H5T_CONV_sS(LONG, LLONG, long, long_long, -, -);
6016
FUNC_LEAVE_NOAPI(ret_value);
6020
/*-------------------------------------------------------------------------
6021
* Function: H5T_conv_long_ullong
6023
* Purpose: Converts `long' to `unsigned long_long'
6025
* Return: Success: Non-negative
6029
* Programmer: Robb Matzke
6030
* Friday, November 13, 1998
6034
*-------------------------------------------------------------------------
6037
H5T_conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6038
size_t nelmts, size_t buf_stride,
6039
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6040
hid_t UNUSED dxpl_id)
6042
herr_t ret_value=SUCCEED; /* Return value */
6044
FUNC_ENTER_NOAPI(H5T_conv_long_ullong, FAIL);
6046
H5T_CONV_sU(LONG, ULLONG, long, unsigned long_long, -, -);
6049
FUNC_LEAVE_NOAPI(ret_value);
6053
/*-------------------------------------------------------------------------
6054
* Function: H5T_conv_ulong_llong
6056
* Purpose: Converts `unsigned long' to `long_long'
6058
* Return: Success: Non-negative
6062
* Programmer: Robb Matzke
6063
* Friday, November 13, 1998
6067
*-------------------------------------------------------------------------
6070
H5T_conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6071
size_t nelmts, size_t buf_stride,
6072
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6073
hid_t UNUSED dxpl_id)
6075
herr_t ret_value=SUCCEED; /* Return value */
6077
FUNC_ENTER_NOAPI(H5T_conv_ulong_llong, FAIL);
6079
H5T_CONV_uS(ULONG, LLONG, unsigned long, long_long, -, LLONG_MAX);
6082
FUNC_LEAVE_NOAPI(ret_value);
6086
/*-------------------------------------------------------------------------
6087
* Function: H5T_conv_ulong_ullong
6089
* Purpose: Converts `unsigned long' to `unsigned long_long'
6091
* Return: Success: Non-negative
6095
* Programmer: Robb Matzke
6096
* Friday, November 13, 1998
6100
*-------------------------------------------------------------------------
6103
H5T_conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6104
size_t nelmts, size_t buf_stride,
6105
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6106
hid_t UNUSED dxpl_id)
6108
herr_t ret_value=SUCCEED; /* Return value */
6110
FUNC_ENTER_NOAPI(H5T_conv_ulong_ullong, FAIL);
6112
H5T_CONV_uU(ULONG, ULLONG, unsigned long, unsigned long_long, -, -);
6115
FUNC_LEAVE_NOAPI(ret_value);
6119
/*-------------------------------------------------------------------------
6120
* Function: H5T_conv_llong_schar
6122
* Purpose: Converts `long_long' to `signed char'
6124
* Return: Success: Non-negative
6128
* Programmer: Robb Matzke
6129
* Friday, November 13, 1998
6133
*-------------------------------------------------------------------------
6136
H5T_conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6137
size_t nelmts, size_t buf_stride,
6138
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6139
hid_t UNUSED dxpl_id)
6141
herr_t ret_value=SUCCEED; /* Return value */
6143
FUNC_ENTER_NOAPI(H5T_conv_llong_schar, FAIL);
6145
H5T_CONV_Ss(LLONG, SCHAR, long_long, signed char, SCHAR_MIN, SCHAR_MAX);
6148
FUNC_LEAVE_NOAPI(ret_value);
6152
/*-------------------------------------------------------------------------
6153
* Function: H5T_conv_llong_uchar
6155
* Purpose: Converts `long_long' to `unsigned char'
6157
* Return: Success: Non-negative
6161
* Programmer: Robb Matzke
6162
* Friday, November 13, 1998
6166
*-------------------------------------------------------------------------
6169
H5T_conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6170
size_t nelmts, size_t buf_stride,
6171
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6172
hid_t UNUSED dxpl_id)
6174
herr_t ret_value=SUCCEED; /* Return value */
6176
FUNC_ENTER_NOAPI(H5T_conv_llong_uchar, FAIL);
6178
H5T_CONV_Su(LLONG, UCHAR, long_long, unsigned char, -, UCHAR_MAX);
6181
FUNC_LEAVE_NOAPI(ret_value);
6185
/*-------------------------------------------------------------------------
6186
* Function: H5T_conv_ullong_schar
6188
* Purpose: Converts `unsigned long_long' to `signed char'
6190
* Return: Success: Non-negative
6194
* Programmer: Robb Matzke
6195
* Friday, November 13, 1998
6199
*-------------------------------------------------------------------------
6202
H5T_conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6203
size_t nelmts, size_t buf_stride,
6204
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6205
hid_t UNUSED dxpl_id)
6207
herr_t ret_value=SUCCEED; /* Return value */
6209
FUNC_ENTER_NOAPI(H5T_conv_ullong_schar, FAIL);
6211
H5T_CONV_Us(ULLONG, SCHAR, unsigned long_long, signed char, -, SCHAR_MAX);
6214
FUNC_LEAVE_NOAPI(ret_value);
6218
/*-------------------------------------------------------------------------
6219
* Function: H5T_conv_ullong_uchar
6221
* Purpose: Converts `unsigned long_long' to `unsigned char'
6223
* Return: Success: Non-negative
6227
* Programmer: Robb Matzke
6228
* Friday, November 13, 1998
6232
*-------------------------------------------------------------------------
6235
H5T_conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6236
size_t nelmts, size_t buf_stride,
6237
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6238
hid_t UNUSED dxpl_id)
6240
herr_t ret_value=SUCCEED; /* Return value */
6242
FUNC_ENTER_NOAPI(H5T_conv_ullong_uchar, FAIL);
6244
H5T_CONV_Uu(ULLONG, UCHAR, unsigned long_long, unsigned char, -, UCHAR_MAX);
6247
FUNC_LEAVE_NOAPI(ret_value);
6251
/*-------------------------------------------------------------------------
6252
* Function: H5T_conv_llong_short
6254
* Purpose: Converts `long_long' to `short'
6256
* Return: Success: Non-negative
6260
* Programmer: Robb Matzke
6261
* Friday, November 13, 1998
6265
*-------------------------------------------------------------------------
6268
H5T_conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6269
size_t nelmts, size_t buf_stride,
6270
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6271
hid_t UNUSED dxpl_id)
6273
herr_t ret_value=SUCCEED; /* Return value */
6275
FUNC_ENTER_NOAPI(H5T_conv_llong_short, FAIL);
6277
H5T_CONV_Ss(LLONG, SHORT, long_long, short, SHRT_MIN, SHRT_MAX);
6280
FUNC_LEAVE_NOAPI(ret_value);
6284
/*-------------------------------------------------------------------------
6285
* Function: H5T_conv_llong_ushort
6287
* Purpose: Converts `long_long' to `unsigned short'
6289
* Return: Success: Non-negative
6293
* Programmer: Robb Matzke
6294
* Friday, November 13, 1998
6298
*-------------------------------------------------------------------------
6301
H5T_conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6302
size_t nelmts, size_t buf_stride,
6303
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6304
hid_t UNUSED dxpl_id)
6306
herr_t ret_value=SUCCEED; /* Return value */
6308
FUNC_ENTER_NOAPI(H5T_conv_llong_ushort, FAIL);
6310
H5T_CONV_Su(LLONG, USHORT, long_long, unsigned short, -, USHRT_MAX);
6313
FUNC_LEAVE_NOAPI(ret_value);
6317
/*-------------------------------------------------------------------------
6318
* Function: H5T_conv_ullong_short
6320
* Purpose: Converts `unsigned long_long' to `short'
6322
* Return: Success: Non-negative
6326
* Programmer: Robb Matzke
6327
* Friday, November 13, 1998
6331
*-------------------------------------------------------------------------
6334
H5T_conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6335
size_t nelmts, size_t buf_stride,
6336
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6337
hid_t UNUSED dxpl_id)
6339
herr_t ret_value=SUCCEED; /* Return value */
6341
FUNC_ENTER_NOAPI(H5T_conv_ullong_short, FAIL);
6343
H5T_CONV_Us(ULLONG, SHORT, unsigned long_long, short, -, SHRT_MAX);
6346
FUNC_LEAVE_NOAPI(ret_value);
6350
/*-------------------------------------------------------------------------
6351
* Function: H5T_conv_ullong_ushort
6353
* Purpose: Converts `unsigned long_long' to `unsigned short'
6355
* Return: Success: Non-negative
6359
* Programmer: Robb Matzke
6360
* Friday, November 13, 1998
6364
*-------------------------------------------------------------------------
6367
H5T_conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6368
size_t nelmts, size_t buf_stride,
6369
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6370
hid_t UNUSED dxpl_id)
6372
herr_t ret_value=SUCCEED; /* Return value */
6374
FUNC_ENTER_NOAPI(H5T_conv_ullong_ushort, FAIL);
6376
H5T_CONV_Uu(ULLONG, USHORT, unsigned long_long, unsigned short, -, USHRT_MAX);
6379
FUNC_LEAVE_NOAPI(ret_value);
6383
/*-------------------------------------------------------------------------
6384
* Function: H5T_conv_llong_int
6386
* Purpose: Converts `long_long' to `int'
6388
* Return: Success: Non-negative
6392
* Programmer: Robb Matzke
6393
* Friday, November 13, 1998
6397
*-------------------------------------------------------------------------
6400
H5T_conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6401
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
6402
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
6404
herr_t ret_value=SUCCEED; /* Return value */
6406
FUNC_ENTER_NOAPI(H5T_conv_llong_int, FAIL);
6408
H5T_CONV_Ss(LLONG, INT, long_long, int, INT_MIN, INT_MAX);
6411
FUNC_LEAVE_NOAPI(ret_value);
6415
/*-------------------------------------------------------------------------
6416
* Function: H5T_conv_llong_uint
6418
* Purpose: Converts `long_long' to `unsigned int'
6420
* Return: Success: Non-negative
6424
* Programmer: Robb Matzke
6425
* Friday, November 13, 1998
6429
*-------------------------------------------------------------------------
6432
H5T_conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6433
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
6434
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
6436
herr_t ret_value=SUCCEED; /* Return value */
6438
FUNC_ENTER_NOAPI(H5T_conv_llong_uint, FAIL);
6440
H5T_CONV_Su(LLONG, UINT, long_long, unsigned, -, UINT_MAX);
6443
FUNC_LEAVE_NOAPI(ret_value);
6447
/*-------------------------------------------------------------------------
6448
* Function: H5T_conv_ullong_int
6450
* Purpose: Converts `unsigned long_long' to `int'
6452
* Return: Success: Non-negative
6456
* Programmer: Robb Matzke
6457
* Friday, November 13, 1998
6461
*-------------------------------------------------------------------------
6464
H5T_conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6465
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
6466
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
6468
herr_t ret_value=SUCCEED; /* Return value */
6470
FUNC_ENTER_NOAPI(H5T_conv_ullong_int, FAIL);
6472
H5T_CONV_Us(ULLONG, INT, unsigned long_long, int, -, INT_MAX);
6475
FUNC_LEAVE_NOAPI(ret_value);
6479
/*-------------------------------------------------------------------------
6480
* Function: H5T_conv_ullong_uint
6482
* Purpose: Converts `unsigned long_long' to `unsigned int'
6484
* Return: Success: Non-negative
6488
* Programmer: Robb Matzke
6489
* Friday, November 13, 1998
6493
*-------------------------------------------------------------------------
6496
H5T_conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6497
size_t nelmts, size_t buf_stride,
6498
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6499
hid_t UNUSED dxpl_id)
6501
herr_t ret_value=SUCCEED; /* Return value */
6503
FUNC_ENTER_NOAPI(H5T_conv_ullong_uint, FAIL);
6505
H5T_CONV_Uu(ULLONG, UINT, unsigned long_long, unsigned, -, UINT_MAX);
6508
FUNC_LEAVE_NOAPI(ret_value);
6512
/*-------------------------------------------------------------------------
6513
* Function: H5T_conv_llong_long
6515
* Purpose: Converts `long_long' to `long'
6517
* Return: Success: Non-negative
6521
* Programmer: Robb Matzke
6522
* Friday, November 13, 1998
6526
*-------------------------------------------------------------------------
6529
H5T_conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6530
size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
6531
void *buf, void UNUSED *bkg, hid_t UNUSED dxpl_id)
6533
herr_t ret_value=SUCCEED; /* Return value */
6535
FUNC_ENTER_NOAPI(H5T_conv_llong_long, FAIL);
6537
H5T_CONV_Ss(LLONG, LONG, long_long, long, LONG_MIN, LONG_MAX);
6540
FUNC_LEAVE_NOAPI(ret_value);
6544
/*-------------------------------------------------------------------------
6545
* Function: H5T_conv_llong_ulong
6547
* Purpose: Converts `long_long' to `unsigned long'
6549
* Return: Success: Non-negative
6553
* Programmer: Robb Matzke
6554
* Friday, November 13, 1998
6558
*-------------------------------------------------------------------------
6561
H5T_conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6562
size_t nelmts, size_t buf_stride,
6563
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6564
hid_t UNUSED dxpl_id)
6566
herr_t ret_value=SUCCEED; /* Return value */
6568
FUNC_ENTER_NOAPI(H5T_conv_llong_ulong, FAIL);
6570
H5T_CONV_Su(LLONG, ULONG, long_long, unsigned long, -, ULONG_MAX);
6573
FUNC_LEAVE_NOAPI(ret_value);
6577
/*-------------------------------------------------------------------------
6578
* Function: H5T_conv_ullong_long
6580
* Purpose: Converts `unsigned long_long' to `long'
6582
* Return: Success: Non-negative
6586
* Programmer: Robb Matzke
6587
* Friday, November 13, 1998
6591
*-------------------------------------------------------------------------
6594
H5T_conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6595
size_t nelmts, size_t buf_stride,
6596
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6597
hid_t UNUSED dxpl_id)
6599
herr_t ret_value=SUCCEED; /* Return value */
6601
FUNC_ENTER_NOAPI(H5T_conv_ullong_long, FAIL);
6603
H5T_CONV_Us(ULLONG, LONG, unsigned long_long, long, -, LONG_MAX);
6606
FUNC_LEAVE_NOAPI(ret_value);
6610
/*-------------------------------------------------------------------------
6611
* Function: H5T_conv_ullong_ulong
6613
* Purpose: Converts `unsigned long_long' to `unsigned long'
6615
* Return: Success: Non-negative
6619
* Programmer: Robb Matzke
6620
* Friday, November 13, 1998
6624
*-------------------------------------------------------------------------
6627
H5T_conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6628
size_t nelmts, size_t buf_stride,
6629
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6630
hid_t UNUSED dxpl_id)
6632
herr_t ret_value=SUCCEED; /* Return value */
6634
FUNC_ENTER_NOAPI(H5T_conv_ullong_ulong, FAIL);
6636
H5T_CONV_Uu(ULLONG, ULONG, unsigned long_long, unsigned long, -, ULONG_MAX);
6639
FUNC_LEAVE_NOAPI(ret_value);
6643
/*-------------------------------------------------------------------------
6644
* Function: H5T_conv_llong_ullong
6646
* Purpose: Converts `long_long' to `unsigned long_long'
6648
* Return: Success: non-negative
6652
* Programmer: Robb Matzke
6653
* Monday, November 16, 1998
6657
*-------------------------------------------------------------------------
6660
H5T_conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6661
size_t nelmts, size_t buf_stride,
6662
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6663
hid_t UNUSED dxpl_id)
6665
herr_t ret_value=SUCCEED; /* Return value */
6667
FUNC_ENTER_NOAPI(H5T_conv_llong_ullong, FAIL);
6669
H5T_CONV_su(LLONG, ULLONG, long_long, unsigned long_long, -, -);
6672
FUNC_LEAVE_NOAPI(ret_value);
6676
/*-------------------------------------------------------------------------
6677
* Function: H5T_conv_ullong_llong
6679
* Purpose: Converts `unsigned long_long' to `long_long'
6681
* Return: Success: non-negative
6685
* Programmer: Robb Matzke
6686
* Monday, November 16, 1998
6690
*-------------------------------------------------------------------------
6693
H5T_conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6694
size_t nelmts, size_t buf_stride,
6695
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6696
hid_t UNUSED dxpl_id)
6698
herr_t ret_value=SUCCEED; /* Return value */
6700
FUNC_ENTER_NOAPI(H5T_conv_ullong_llong, FAIL);
6702
H5T_CONV_us(ULLONG, LLONG, unsigned long_long, long_long, -, LLONG_MAX);
6705
FUNC_LEAVE_NOAPI(ret_value);
6709
/*-------------------------------------------------------------------------
6710
* Function: H5T_conv_float_double
6712
* Purpose: Convert native `float' to native `double' using hardware.
6713
* This is a fast special case.
6715
* Return: Non-negative on success/Negative on failure
6717
* Programmer: Robb Matzke
6718
* Tuesday, June 23, 1998
6721
* Robb Matzke, 1999-06-16
6722
* Added support for non-zero strides. If BUF_STRIDE is non-zero
6723
* then convert one value at each memory location advancing
6724
* BUF_STRIDE bytes each time; otherwise assume both source and
6725
* destination values are packed.
6726
*-------------------------------------------------------------------------
6729
H5T_conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6730
size_t nelmts, size_t buf_stride,
6731
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6732
hid_t UNUSED dxpl_id)
6734
herr_t ret_value=SUCCEED; /* Return value */
6736
FUNC_ENTER_NOAPI(H5T_conv_float_double, FAIL);
6738
H5T_CONV_fF(FLOAT, DOUBLE, float, double, -, -);
6741
FUNC_LEAVE_NOAPI(ret_value);
6745
/*-------------------------------------------------------------------------
6746
* Function: H5T_conv_double_float
6748
* Purpose: Convert native `double' to native `float' using hardware.
6749
* This is a fast special case.
6751
* Return: Non-negative on success/Negative on failure
6753
* Programmer: Robb Matzke
6754
* Tuesday, June 23, 1998
6757
* Robb Matzke, 7 Jul 1998
6758
* Added overflow handling.
6760
* Robb Matzke, 1999-06-16
6761
* Added support for non-zero strides. If BUF_STRIDE is non-zero
6762
* then convert one value at each memory location advancing
6763
* BUF_STRIDE bytes each time; otherwise assume both source and
6764
* destination values are packed.
6765
*-------------------------------------------------------------------------
6768
H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6769
size_t nelmts, size_t buf_stride,
6770
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6771
hid_t UNUSED dxpl_id)
6773
herr_t ret_value=SUCCEED; /* Return value */
6775
FUNC_ENTER_NOAPI(H5T_conv_double_float, FAIL);
6777
H5T_CONV_Ff(DOUBLE, FLOAT, double, float, -FLT_MAX, FLT_MAX);
6780
FUNC_LEAVE_NOAPI(ret_value);
6784
/*-------------------------------------------------------------------------
6785
* Function: H5T_conv_i32le_f64le
6787
* Purpose: Converts 4-byte little-endian integers (signed or unsigned)
6788
* to 8-byte litte-endian IEEE floating point.
6790
* Return: Non-negative on success/Negative on failure
6793
* Programmer: Robb Matzke
6794
* Wednesday, June 10, 1998
6797
* Robb Matzke, 1999-06-16
6798
* Added support for non-zero strides. If BUF_STRIDE is non-zero
6799
* then convert one value at each memory location advancing
6800
* BUF_STRIDE bytes each time; otherwise assume both source and
6801
* destination values are packed.
6802
*-------------------------------------------------------------------------
6805
H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
6806
size_t nelmts, size_t buf_stride,
6807
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
6808
hid_t UNUSED dxpl_id)
6810
uint8_t *s=NULL, *d=NULL; /*src and dst buf pointers */
6811
uint8_t tmp[8]; /*temporary destination buffer */
6812
H5T_t *src = NULL; /*source data type */
6813
size_t elmtno; /*element counter */
6814
unsigned sign; /*sign bit */
6815
unsigned cin, cout; /*carry in/out */
6816
unsigned mbits=0; /*mantissa bits */
6817
unsigned exponent; /*exponent */
6819
herr_t ret_value=SUCCEED; /* Return value */
6821
FUNC_ENTER_NOAPI(H5T_conv_i32le_f64le, FAIL);
6823
switch (cdata->command) {
6825
assert (sizeof(int)>=4);
6826
cdata->need_bkg = H5T_BKG_NO;
6830
/* Free private data */
6834
/* The conversion */
6835
if (NULL==(src=H5I_object(src_id)) ||
6836
NULL==H5I_object(dst_id))
6837
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
6839
s = (uint8_t*)buf + (buf_stride?buf_stride:4)*(nelmts-1);
6840
d = (uint8_t*)buf + (buf_stride?buf_stride:8)*(nelmts-1);
6841
for (elmtno=0; elmtno<nelmts; elmtno++) {
6844
* If this is the last element to convert (that is, the first
6845
* element of the buffer) then the source and destination areas
6846
* overlap so we need to use a temp buf for the destination.
6851
/* Convert the integer to a sign and magnitude */
6852
switch (src->shared->u.atomic.u.i.sign) {
6860
for (i=0,cin=1; i<4; i++,cin=cout) {
6862
cout = ((unsigned)(s[i])+cin > 0xff) ? 1 : 0;
6871
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported integer sign method");
6875
* Where is the most significant bit that is set? We could do
6876
* this in a loop, but testing it this way might be faster.
6879
if (s[3] & 0x80) mbits = 32;
6880
else if (s[3] & 0x40) mbits = 31;
6881
else if (s[3] & 0x20) mbits = 30;
6882
else if (s[3] & 0x10) mbits = 29;
6883
else if (s[3] & 0x08) mbits = 28;
6884
else if (s[3] & 0x04) mbits = 27;
6885
else if (s[3] & 0x02) mbits = 26;
6886
else if (s[3] & 0x01) mbits = 25;
6888
if (s[2] & 0x80) mbits = 24;
6889
else if (s[2] & 0x40) mbits = 23;
6890
else if (s[2] & 0x20) mbits = 22;
6891
else if (s[2] & 0x10) mbits = 21;
6892
else if (s[2] & 0x08) mbits = 20;
6893
else if (s[2] & 0x04) mbits = 19;
6894
else if (s[2] & 0x02) mbits = 18;
6895
else if (s[2] & 0x01) mbits = 17;
6897
if (s[1] & 0x80) mbits = 16;
6898
else if (s[1] & 0x40) mbits = 15;
6899
else if (s[1] & 0x20) mbits = 14;
6900
else if (s[1] & 0x10) mbits = 13;
6901
else if (s[1] & 0x08) mbits = 12;
6902
else if (s[1] & 0x04) mbits = 11;
6903
else if (s[1] & 0x02) mbits = 10;
6904
else if (s[1] & 0x01) mbits = 9;
6906
if (s[0] & 0x80) mbits = 8;
6907
else if (s[0] & 0x40) mbits = 7;
6908
else if (s[0] & 0x20) mbits = 6;
6909
else if (s[0] & 0x10) mbits = 5;
6910
else if (s[0] & 0x08) mbits = 4;
6911
else if (s[0] & 0x04) mbits = 3;
6912
else if (s[0] & 0x02) mbits = 2;
6913
else if (s[0] & 0x01) mbits = 1;
6916
d[7] = d[6] = d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0;
6921
* The sign and exponent.
6923
exponent = (mbits - 1) + 1023;
6924
d[7] = (sign<<7) | ((exponent>>4) & 0x7f);
6925
d[6] = (exponent & 0x0f) << 4;
6932
d[5] = d[4] = d[3] = d[1] = d[0] = 0;
6936
d[6] |= 0x0f & (s[3]>>2);
6937
d[5] = (s[3]<<6) | (s[2]>>2);
6938
d[4] = (s[2]<<6) | (s[1]>>2);
6939
d[3] = (s[1]<<6) | (s[0]>>2);
6945
d[6] |= 0x0f & (s[3]>>1);
6946
d[5] = (s[3]<<7) | (s[2]>>1);
6947
d[4] = (s[2]<<7) | (s[1]>>1);
6948
d[3] = (s[1]<<7) | (s[0]>>1);
6954
d[6] |= 0x0f & s[3];
6958
d[2] = d[1] = d[0] = 0;
6962
d[6] |= ((s[3]<<1) | (s[2]>>7)) & 0x0f;
6963
d[5] = (s[2]<<1) | (s[1]>>7);
6964
d[4] = (s[1]<<1) | (s[0]>>7);
6966
d[2] = d[1] = d[0] = 0;
6970
d[6] |= ((s[3]<<2) | (s[2]>>6)) & 0x0f;
6971
d[5] = (s[2]<<2) | (s[1]>>6);
6972
d[4] = (s[1]<<2) | (s[0]>>6);
6974
d[2] = d[1] = d[0] = 0;
6978
d[6] |= ((s[3]<<3) | (s[2]>>5)) & 0x0f;
6979
d[5] = (s[2]<<3) | (s[1]>>5);
6980
d[4] = (s[1]<<3) | (s[0]>>5);
6982
d[2] = d[1] = d[0] = 0;
6986
d[6] |= 0x0f & (s[2]>>4);
6987
d[5] = (s[2]<<4) | (s[1]>>4);
6988
d[4] = (s[1]<<4) | (s[0]>>4);
6990
d[2] = d[1] = d[0] = 0;
6994
d[6] |= 0x0f & (s[2]>>3);
6995
d[5] = (s[2]<<5) | (s[1]>>3);
6996
d[4] = (s[1]<<5) | (s[0]>>3);
6998
d[2] = d[1] = d[0] = 0;
7002
d[6] |= 0x0f & (s[2]>>2);
7003
d[5] = (s[2]<<6) | (s[1]>>2);
7004
d[4] = (s[1]<<6) | (s[0]>>2);
7006
d[2] = d[1] = d[0] = 0;
7010
d[6] |= 0x0f & (s[2]>>1);
7011
d[5] = (s[2]<<7) | (s[1]>>1);
7012
d[4] = (s[1]<<7) | (s[0]>>1);
7014
d[2] = d[1] = d[0] = 0;
7018
d[6] |= 0x0f & s[2];
7021
d[3] = d[2] = d[1] = d[0] = 0;
7025
d[6] |= ((s[2]<<1) | (s[1]>>7)) & 0x0f;
7026
d[5] = (s[1]<<1) | (s[0]>>7);
7028
d[3] = d[2] = d[1] = d[0] = 0;
7032
d[6] |= ((s[2]<<2) | (s[1]>>6)) & 0x0f;
7033
d[5] = (s[1]<<2) | (s[0]>>6);
7035
d[3] = d[2] = d[1] = d[0] = 0;
7039
d[6] |= ((s[2]<<3) | (s[1]>>5)) & 0x0f;
7040
d[5] = (s[1]<<3) | (s[0]>>5);
7042
d[3] = d[2] = d[1] = d[0] = 0;
7046
d[6] |= 0x0f & (s[1]>>4);
7047
d[5] = (s[1]<<4) | (s[0]>>4);
7049
d[3] = d[2] = d[1] = d[0] = 0;
7053
d[6] |= 0x0f & (s[1]>>3);
7054
d[5] = (s[1]<<5) | (s[0]>>3);
7056
d[3] = d[2] = d[1] = d[0] = 0;
7060
d[6] |= 0x0f & (s[1]>>2);
7061
d[5] = (s[1]<<6) | (s[0]>>2);
7063
d[3] = d[2] = d[1] = d[0] = 0;
7067
d[6] |= 0x0f & (s[1]>>1);
7068
d[5] = (s[1]<<7) | (s[0]>>1);
7070
d[3] = d[2] = d[1] = d[0] = 0;
7074
d[6] |= 0x0f & s[1];
7076
d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7080
d[6] |= ((s[1]<<1) | (s[0]>>7)) & 0x0f;
7082
d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7086
d[6] |= ((s[1]<<2) | (s[0]>>6)) & 0x0f;
7088
d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7092
d[6] |= ((s[1]<<3) | (s[0]>>5)) & 0x0f;
7094
d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7098
d[6] |= 0x0f & (s[0]>>4);
7100
d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7104
d[6] |= 0x0f & (s[0]>>3);
7106
d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7110
d[6] |= 0x0f & (s[0]>>2);
7112
d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7116
d[6] |= 0x0f & (s[0]>>1);
7118
d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7122
d[6] |= 0x0f & s[0];
7123
d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7127
d[6] |= (s[0]<<1) & 0x0f;
7128
d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7132
d[6] |= (s[0]<<2) & 0x0f;
7133
d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7137
d[6] |= (s[0]<<3) & 0x0f;
7138
d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7142
d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0;
7147
* Copy temp buffer to the destination. This only happens for
7148
* the first value in the array, the last value processed. See
7149
* beginning of loop.
7154
/* Advance pointers */
7166
/* Some other command we don't know about yet.*/
7167
HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
7171
FUNC_LEAVE_NOAPI(ret_value);