1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
|
/*
*
* NCSA HDF *
* Software Development Group *
* National Center for Supercomputing Applications *
* University of Illinois at Urbana-Champaign *
* 605 E. Springfield, Champaign IL 61820 *
* *
* For conditions of distribution and use, see the accompanying *
* hdf/COPYING file. *
* *
****************************************************************************/
#ifdef RCSID
static char RcsId[] = "@(#)$Revision$";
#endif
#define H5T_PACKAGE /*suppress error about including H5Tpkg */
#include <H5private.h> /*generic functions */
#include <H5Aprivate.h> /*atom functions */
#include <H5Eprivate.h> /*error handling */
#include <H5Mprivate.h> /*meta data */
#include <H5MMprivate.h> /*memory management */
#include <H5Sprivate.h> /*data space */
#include <H5Tpkg.h> /*data-type functions */
#define PABLO_MASK H5T_mask
#define H5T_COMPND_INC 64 /*typical max numb of members per struct */
/* Interface initialization */
static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT H5T_init_interface
static void H5T_term_interface(void);
/* Predefined types */
hid_t H5T_NATIVE_CHAR_g = FAIL;
hid_t H5T_NATIVE_UCHAR_g = FAIL;
hid_t H5T_NATIVE_SHORT_g = FAIL;
hid_t H5T_NATIVE_USHORT_g = FAIL;
hid_t H5T_NATIVE_INT_g = FAIL;
hid_t H5T_NATIVE_UINT_g = FAIL;
hid_t H5T_NATIVE_LONG_g = FAIL;
hid_t H5T_NATIVE_LLONG_g = FAIL;
hid_t H5T_NATIVE_ULLONG_g = FAIL;
hid_t H5T_NATIVE_HYPER_g = FAIL;
hid_t H5T_NATIVE_UHYPER_g = FAIL;
hid_t H5T_NATIVE_INT8_g = FAIL;
hid_t H5T_NATIVE_UINT8_g = FAIL;
hid_t H5T_NATIVE_INT16_g = FAIL;
hid_t H5T_NATIVE_UINT16_g = FAIL;
hid_t H5T_NATIVE_INT32_g = FAIL;
hid_t H5T_NATIVE_UINT32_g = FAIL;
hid_t H5T_NATIVE_INT64_g = FAIL;
hid_t H5T_NATIVE_UINT64_g = FAIL;
hid_t H5T_NATIVE_ULONG_g = FAIL;
hid_t H5T_NATIVE_FLOAT_g = FAIL;
hid_t H5T_NATIVE_DOUBLE_g = FAIL;
hid_t H5T_NATIVE_TIME_g = FAIL;
hid_t H5T_NATIVE_STRING_g = FAIL;
hid_t H5T_NATIVE_BITFIELD_g = FAIL;
hid_t H5T_NATIVE_OPAQUE_g = FAIL;
/* The path database */
static intn H5T_npath_g = 0; /*num paths defined */
static intn H5T_apath_g = 0; /*num slots allocated */
static H5T_path_t *H5T_path_g = NULL; /*path array */
/* The soft conversion function master list */
static intn H5T_nsoft_g = 0; /*num soft funcs defined */
static intn H5T_asoft_g = 0; /*num slots allocated */
static H5T_soft_t *H5T_soft_g = NULL; /*master soft list */
/*--------------------------------------------------------------------------
NAME
H5T_init_interface -- Initialize interface-specific information
USAGE
herr_t H5T_init_interface()
RETURNS
SUCCEED/FAIL
DESCRIPTION
Initializes any interface-specific data or routines.
--------------------------------------------------------------------------*/
herr_t
H5T_init_interface(void)
{
H5T_t *dt = NULL;
herr_t ret_value = SUCCEED;
interface_initialize_g = TRUE;
FUNC_ENTER(H5T_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
if ((ret_value = H5A_init_group(H5_DATATYPE, H5A_DATATYPEID_HASHSIZE,
H5T_RESERVED_ATOMS,
(herr_t (*)(void *)) H5T_close)) != FAIL) {
ret_value = H5_add_exit(&H5T_term_interface);
}
/*
* Initialize pre-defined data types that depend on the architecture.
*/
ret_value = H5T_init();
/*
* Initialize pre-define data types that can be derived from
* architecture-dependent types.
*/
/* INT8 */
H5T_NATIVE_INT8_g = H5Tcopy(H5T_NATIVE_INT_g);
H5Tset_size(H5T_NATIVE_INT8_g, 1);
H5Tset_precision(H5T_NATIVE_INT8_g, 8);
H5Tlock(H5T_NATIVE_INT8_g);
/* UINT8 */
H5T_NATIVE_UINT8_g = H5Tcopy(H5T_NATIVE_UINT_g);
H5Tset_size(H5T_NATIVE_UINT8_g, 1);
H5Tset_precision(H5T_NATIVE_UINT8_g, 8);
H5Tlock(H5T_NATIVE_UINT8_g);
/* INT16 */
H5T_NATIVE_INT16_g = H5Tcopy(H5T_NATIVE_INT_g);
H5Tset_size(H5T_NATIVE_INT16_g, 2);
H5Tset_precision(H5T_NATIVE_INT16_g, 16);
H5Tlock(H5T_NATIVE_INT16_g);
/* UINT16 */
H5T_NATIVE_UINT16_g = H5Tcopy(H5T_NATIVE_UINT_g);
H5Tset_size(H5T_NATIVE_UINT16_g, 2);
H5Tset_precision(H5T_NATIVE_UINT16_g, 16);
H5Tlock(H5T_NATIVE_UINT16_g);
/* INT32 */
H5T_NATIVE_INT32_g = H5Tcopy(H5T_NATIVE_INT_g);
H5Tset_size(H5T_NATIVE_INT32_g, 4);
H5Tset_precision(H5T_NATIVE_INT32_g, 32);
H5Tlock(H5T_NATIVE_INT32_g);
/* UINT32 */
H5T_NATIVE_UINT32_g = H5Tcopy(H5T_NATIVE_UINT_g);
H5Tset_size(H5T_NATIVE_UINT32_g, 4);
H5Tset_precision(H5T_NATIVE_UINT32_g, 32);
H5Tlock(H5T_NATIVE_UINT32_g);
/* INT64 */
H5T_NATIVE_INT64_g = H5Tcopy(H5T_NATIVE_INT_g);
H5Tset_size(H5T_NATIVE_INT64_g, 8);
H5Tset_precision(H5T_NATIVE_INT64_g, 64);
H5Tlock(H5T_NATIVE_INT64_g);
/* UINT64 */
H5T_NATIVE_UINT64_g = H5Tcopy(H5T_NATIVE_UINT_g);
H5Tset_size(H5T_NATIVE_UINT64_g, 8);
H5Tset_precision(H5T_NATIVE_UINT64_g, 64);
H5Tlock(H5T_NATIVE_UINT64_g);
/*
* Initialize pre-defined data types that don't depend on architecture.
*/
/* TIME */
dt = H5MM_xcalloc(1, sizeof(H5T_t));
dt->locked = TRUE;
dt->type = H5T_TIME;
dt->size = 1;
dt->u.atomic.order = H5Tget_order(H5T_NATIVE_INT_g);
dt->u.atomic.offset = 0;
dt->u.atomic.prec = 8 * dt->size;
dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
dt->u.atomic.msb_pad = H5T_PAD_ZERO;
if ((H5T_NATIVE_TIME_g = H5A_register(H5_DATATYPE, dt)) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"can't initialize H5T layer");
}
/* STRING */
dt = H5MM_xcalloc(1, sizeof(H5T_t));
dt->locked = TRUE;
dt->type = H5T_STRING;
dt->size = 1;
dt->u.atomic.order = H5T_ORDER_NONE;
dt->u.atomic.offset = 0;
dt->u.atomic.prec = 8 * dt->size;
dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
dt->u.atomic.msb_pad = H5T_PAD_ZERO;
dt->u.atomic.u.s.cset = H5T_CSET_ASCII;
dt->u.atomic.u.s.pad = H5T_STR_NULL;
if ((H5T_NATIVE_STRING_g = H5A_register(H5_DATATYPE, dt)) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"can't initialize H5T layer");
}
/* BITFIELD */
dt = H5MM_xcalloc(1, sizeof(H5T_t));
dt->locked = TRUE;
dt->type = H5T_BITFIELD;
dt->size = 1;
dt->u.atomic.order = H5Tget_order(H5T_NATIVE_INT_g);
dt->u.atomic.offset = 0;
dt->u.atomic.prec = 8 * dt->size;
dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
dt->u.atomic.msb_pad = H5T_PAD_ZERO;
if ((H5T_NATIVE_BITFIELD_g = H5A_register(H5_DATATYPE, dt)) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize H5T layer");
}
/* OPAQUE */
dt = H5MM_xcalloc(1, sizeof(H5T_t));
dt->locked = TRUE;
dt->type = H5T_OPAQUE;
dt->size = 1;
dt->u.atomic.order = H5T_ORDER_NONE;
dt->u.atomic.offset = 0;
dt->u.atomic.prec = 8 * dt->size;
dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
dt->u.atomic.msb_pad = H5T_PAD_ZERO;
if ((H5T_NATIVE_OPAQUE_g = H5A_register(H5_DATATYPE, dt)) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to initialize H5T layer");
}
/*
* Define aliases.
*/
H5T_NATIVE_HYPER_g = H5Tcopy(H5T_NATIVE_LLONG_g);
H5Tlock(H5T_NATIVE_HYPER_g);
H5T_NATIVE_UHYPER_g = H5Tcopy(H5T_NATIVE_ULLONG_g);
H5Tlock(H5T_NATIVE_UHYPER_g);
/*
* Register conversion functions beginning with the most general and
* ending with the most specific.
*/
if (H5Tregister_soft(H5T_INTEGER, H5T_INTEGER, H5T_conv_order) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to register conversion function");
}
if (H5Tregister_soft(H5T_FLOAT, H5T_FLOAT, H5T_conv_order) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to register conversion function");
}
if (H5Tregister_soft (H5T_COMPOUND, H5T_COMPOUND, H5T_conv_struct)<0) {
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to register conversion function");
}
FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
NAME
H5T_term_interface
PURPOSE
Terminate various H5T objects
USAGE
void H5T_term_interface()
RETURNS
SUCCEED/FAIL
DESCRIPTION
Release the atom group and any other resources allocated.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Can't report errors...
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
static void
H5T_term_interface(void)
{
int i;
H5T_path_t *path = NULL;
H5T_cdata_t *pcdata = NULL;
H5T_conv_t cfunc = NULL;
/* Unregister all conversion functions */
for (i=0; i<H5T_npath_g; i++) {
path = H5T_path_g + i;
if (path->func) {
path->cdata.command = H5T_CONV_FREE;
if ((path->func)(FAIL, FAIL, &(path->cdata), 0, NULL, NULL)<0) {
#ifdef H5T_DEBUG
fprintf (stderr, "HDF5-DIAG: conversion function failed "
"to free private data\n");
#endif
H5ECLEAR; /*ignore the error*/
}
}
}
/* Clear conversion tables */
H5T_apath_g = 0;
H5T_npath_g = 0;
H5T_path_g = H5MM_xfree (H5T_path_g);
H5T_asoft_g = 0;
H5T_nsoft_g = 0;
H5T_soft_g = H5MM_xfree (H5T_soft_g);
/* Clear noop function */
if ((cfunc=H5T_find (NULL, NULL, &pcdata))) {
pcdata->command = H5T_CONV_FREE;
(cfunc)(FAIL, FAIL, pcdata, 0, NULL, NULL);
}
H5A_destroy_group(H5_DATATYPE);
H5T_NATIVE_CHAR_g = FAIL;
H5T_NATIVE_UCHAR_g = FAIL;
H5T_NATIVE_SHORT_g = FAIL;
H5T_NATIVE_USHORT_g = FAIL;
H5T_NATIVE_INT_g = FAIL;
H5T_NATIVE_UINT_g = FAIL;
H5T_NATIVE_LONG_g = FAIL;
H5T_NATIVE_LLONG_g = FAIL;
H5T_NATIVE_ULLONG_g = FAIL;
H5T_NATIVE_HYPER_g = FAIL;
H5T_NATIVE_UHYPER_g = FAIL;
H5T_NATIVE_INT8_g = FAIL;
H5T_NATIVE_UINT8_g = FAIL;
H5T_NATIVE_INT16_g = FAIL;
H5T_NATIVE_UINT16_g = FAIL;
H5T_NATIVE_INT32_g = FAIL;
H5T_NATIVE_UINT32_g = FAIL;
H5T_NATIVE_INT64_g = FAIL;
H5T_NATIVE_UINT64_g = FAIL;
H5T_NATIVE_ULONG_g = FAIL;
H5T_NATIVE_FLOAT_g = FAIL;
H5T_NATIVE_DOUBLE_g = FAIL;
H5T_NATIVE_TIME_g = FAIL;
H5T_NATIVE_STRING_g = FAIL;
H5T_NATIVE_BITFIELD_g = FAIL;
H5T_NATIVE_OPAQUE_g = FAIL;
}
/*-------------------------------------------------------------------------
* Function: H5Tcreate
*
* Purpose: Create a new type and initialize it to reasonable values.
* The type is a member of type class TYPE and is SIZE bytes.
*
* Return: Success: A new type identifier.
*
* Failure: FAIL
*
* Errors:
* ARGS BADVALUE Invalid size.
* DATATYPE CANTINIT Can't create type.
* DATATYPE CANTREGISTER Can't register data type atom.
*
* Programmer: Robb Matzke
* Friday, December 5, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hid_t
H5Tcreate(H5T_class_t type, size_t size)
{
H5T_t *dt = NULL;
hid_t ret_value = FAIL;
FUNC_ENTER(H5Tcreate, FAIL);
/* check args */
if (size <= 0) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid size");
}
/* create the type */
if (NULL == (dt = H5T_create(type, size))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't create type");
}
/* Make it an atom */
if ((ret_value = H5A_register(H5_DATATYPE, dt)) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
"can't register data type atom");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Tcopy
*
* Purpose: Copies a data type. The resulting data type is not locked.
* The data type should be closed when no longer needed by
* calling H5Tclose().
*
* Return: Success: The ID of a new data type.
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hid_t
H5Tcopy(hid_t type_id)
{
H5T_t *dt = NULL;
H5T_t *new_dt = NULL;
hid_t ret_value = FAIL;
FUNC_ENTER(H5Tcopy, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
/* Copy */
if (NULL == (new_dt = H5T_copy(dt))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't copy");
}
/* atomize result */
if ((ret_value = H5A_register(H5_DATATYPE, new_dt)) < 0) {
H5T_close(new_dt);
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
"can't register data type atom");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Tclose
*
* Purpose: Frees a data type and all associated memory.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tclose(hid_t type_id)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tclose, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "predefined data type");
}
/* When the reference count reaches zero the resources are freed */
if (H5A_dec_ref(type_id) < 0) {
HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tequal
*
* Purpose: Determines if two data types are equal.
*
* Return: Success: TRUE if equal, FALSE if unequal
*
* Failure: FAIL
*
* Errors:
*
* Programmer: Robb Matzke
* Wednesday, December 10, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hbool_t
H5Tequal(hid_t type1_id, hid_t type2_id)
{
const H5T_t *dt1 = NULL;
const H5T_t *dt2 = NULL;
hbool_t ret_value = FAIL;
FUNC_ENTER(H5Tequal, FAIL);
/* check args */
if (H5_DATATYPE != H5A_group(type1_id) ||
NULL == (dt1 = H5A_object(type1_id)) ||
H5_DATATYPE != H5A_group(type2_id) ||
NULL == (dt2 = H5A_object(type2_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
ret_value = (0 == H5T_cmp(dt1, dt2)) ? TRUE : FALSE;
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5Tlock
*
* Purpose: Locks a type, making it read only and non-destructable. This
* is normally done by the library for predefined data types so
* the application doesn't inadvertently change or delete a
* predefined type.
*
* Once a data type is locked it can never be unlocked.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tlock(hid_t type_id)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tlock, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
dt->locked = TRUE;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_class
*
* Purpose: Returns the data type class identifier for data type TYPE_ID.
*
* Return: Success: One of the non-negative data type class
* constants.
*
* Failure: H5T_NO_CLASS (-1, same as FAIL)
*
* Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_class_t
H5Tget_class(hid_t type_id)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tget_class, H5T_NO_CLASS);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type");
}
FUNC_LEAVE(dt->type);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_size
*
* Purpose: Determines the total size of a data type in bytes.
*
* Return: Success: Size of the data type in bytes. The size of
* data type is the size of an instance of that
* data type.
*
* Failure: 0 (valid data types are never zero size)
*
* Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
size_t
H5Tget_size(hid_t type_id)
{
H5T_t *dt = NULL;
size_t size;
FUNC_ENTER(H5Tget_size, 0);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
}
/* size */
size = H5T_get_size(dt);
FUNC_LEAVE(size);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_size
*
* Purpose: Sets the total size in bytes for an atomic data type (this
* operation is not permitted on compound data types). If the
* size is decreased so that the significant bits of the data
* type extend beyond the edge of the new size, then the
* `offset' property is decreased toward zero. If the `offset'
* becomes zero and the significant bits of the data type still
* hang over the edge of the new size, then the number of
* significant bits is decreased.
*
* Adjusting the size of an H5T_STRING automatically sets the
* precision to 8*size.
*
* All data types have a positive size.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_size(hid_t type_id, size_t size)
{
H5T_t *dt = NULL;
size_t prec, offset;
FUNC_ENTER(H5Tset_size, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (size <= 0) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive");
}
offset = dt->u.atomic.offset;
prec = dt->u.atomic.prec;
/* Decrement the offset and precision if necessary */
if (prec > 8 * size)
offset = 0;
else if (offset + prec > 8 * size)
offset = 8 * size - prec;
if (prec > 8 * size)
prec = 8 * size;
/* Make sure that other values are still okay */
switch (dt->type) {
case H5T_INTEGER:
case H5T_TIME:
case H5T_BITFIELD:
/* nothing to check */
break;
case H5T_STRING:
prec = 8 * size;
offset = 0;
break;
case H5T_FLOAT:
/*
* The sign, mantissa, and exponent fields should be adjusted first
* when decreasing the size of a floating point type.
*/
if (dt->u.atomic.u.f.sign >= prec ||
dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec ||
dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"adjust sign, mantissa, and exponent fields first");
}
break;
case H5T_OPAQUE:
/*
* The significant bits of an opaque type are not allowed to change
* implicitly.
*/
if (prec != dt->u.atomic.prec) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"unable to change precision of an opaque type");
}
break;
default:
assert("not implemented yet" && 0);
}
/* Commit */
dt->size = size;
dt->u.atomic.offset = offset;
dt->u.atomic.prec = prec;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_order
*
* Purpose: Returns the byte order of an atomic data type.
*
* Return: Success: A byte order constant
*
* Failure: H5T_ORDER_ERROR (-1, same as FAIL)
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_order_t
H5Tget_order(hid_t type_id)
{
H5T_t *dt = NULL;
H5T_order_t order;
FUNC_ENTER(H5Tget_order, H5T_ORDER_ERROR);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR,
"not an atomic data type");
}
/* order */
order = dt->u.atomic.order;
FUNC_LEAVE(order);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_order
*
* Purpose: Sets the byte order for an atomic data type.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_order(hid_t type_id, H5T_order_t order)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_order, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (order < 0 || order > H5T_ORDER_NONE) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal byte order");
}
/* order */
dt->u.atomic.order = order;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_precision
*
* Purpose: Gets the precision of an atomic data type. The precision is
* the number of significant bits which, unless padding is
* present, is 8 times larger than the value returned by
* H5Tget_size().
*
* Return: Success: Number of significant bits
*
* Failure: 0 (all atomic types have at least one
* significant bit)
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
size_t
H5Tget_precision(hid_t type_id)
{
H5T_t *dt = NULL;
size_t prec;
FUNC_ENTER(H5Tget_precision, 0);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an atomic data type");
}
/* precision */
prec = dt->u.atomic.prec;
FUNC_LEAVE(prec);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_precision
*
* Purpose: Sets the precision of an atomic data type. The precision is
* the number of significant bits which, unless padding is
* present, is 8 times larger than the value returned by
* H5Tget_size().
*
* If the precision is increased then the offset is decreased
* and then the size is increased to insure that significant
* bits do not "hang over" the edge of the data type.
*
* Changing the precision of an H5T_STRING automatically changes
* the size as well. The precision must be a multiple of 8.
*
* When decreasing the precision of a floating point type, set
* the locations and sizes of the sign, mantissa, and exponent
* fields first.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_precision(hid_t type_id, size_t prec)
{
H5T_t *dt = NULL;
size_t offset, size;
FUNC_ENTER(H5Tset_prec, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (prec <= 0) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"precision must be positive");
}
/* Adjust the offset and size */
offset = dt->u.atomic.offset;
size = dt->size;
if (prec > 8 * size)
offset = 0;
else if (offset + prec > 8 * size)
offset = 8 * size - prec;
if (prec > 8 * size)
size = (prec + 7) / 8;
/* Check that things are still kosher */
switch (dt->type) {
case H5T_INTEGER:
case H5T_TIME:
case H5T_BITFIELD:
case H5T_OPAQUE:
/* nothing to check */
break;
case H5T_STRING:
if (prec % 8) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"precision for this type must be a multiple of 8");
}
offset = 0;
size = prec / 8;
break;
case H5T_FLOAT:
/*
* The sign, mantissa, and exponent fields should be adjusted first
* when decreasing the precision of a floating point type.
*/
if (dt->u.atomic.u.f.sign >= prec ||
dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec ||
dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"adjust sign, mantissa, and exponent fields first");
}
break;
default:
assert("not implemented yet" && 0);
}
/* Commit */
dt->size = size;
dt->u.atomic.offset = offset;
dt->u.atomic.prec = prec;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_offset
*
* Purpose: Retrieves the bit offset of the first significant bit. The
* signficant bits of an atomic datum can be offset from the
* beginning of the memory for that datum by an amount of
* padding. The `offset' property specifies the number of bits
* of padding that appear to the "right of" the value. That is,
* if we have a 32-bit datum with 16-bits of precision having
* the value 0x1122 then it will be layed out in memory as (from
* small byte address toward larger byte addresses):
*
* Big Big Little Little
* Endian Endian Endian Endian
* offset=0 offset=16 offset=0 offset=16
*
* 0: [ pad] [0x11] [0x22] [ pad]
* 1: [ pad] [0x22] [0x11] [ pad]
* 2: [0x11] [ pad] [ pad] [0x22]
* 3: [0x22] [ pad] [ pad] [0x11]
*
* Return: Success: The offset
*
* Failure: 0
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
size_t
H5Tget_offset(hid_t type_id)
{
H5T_t *dt = NULL;
size_t offset;
FUNC_ENTER(H5Tget_offset, 0);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an atomic data type");
}
/* offset */
offset = dt->u.atomic.offset;
FUNC_LEAVE(offset);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_offset
*
* Purpose: Sets the bit offset of the first significant bit. The
* signficant bits of an atomic datum can be offset from the
* beginning of the memory for that datum by an amount of
* padding. The `offset' property specifies the number of bits
* of padding that appear to the "right of" the value. That is,
* if we have a 32-bit datum with 16-bits of precision having
* the value 0x1122 then it will be layed out in memory as (from
* small byte address toward larger byte addresses):
*
* Big Big Little Little
* Endian Endian Endian Endian
* offset=0 offset=16 offset=0 offset=16
*
* 0: [ pad] [0x11] [0x22] [ pad]
* 1: [ pad] [0x22] [0x11] [ pad]
* 2: [0x11] [ pad] [ pad] [0x22]
* 3: [0x22] [ pad] [ pad] [0x11]
*
* If the offset is incremented then the total size is
* incremented also if necessary to prevent significant bits of
* the value from hanging over the edge of the data type.
*
* The offset of an H5T_STRING cannot be set to anything but
* zero.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_offset(hid_t type_id, size_t offset)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_offset, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (H5T_STRING == dt->type && offset != 0) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"offset must be zero for this type");
}
/* Adjust the size */
if (offset + dt->u.atomic.prec > 8 * dt->size) {
dt->size = (offset + dt->u.atomic.prec + 7) / 8;
}
/* Commit */
dt->u.atomic.offset = offset;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_pad
*
* Purpose: Gets the least significant pad type and the most significant
* pad type and returns their values through the LSB and MSB
* arguments, either of which may be the null pointer.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out */ , H5T_pad_t *msb /*out */ )
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tget_pad, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
}
/* Get values */
if (lsb)
*lsb = dt->u.atomic.lsb_pad;
if (msb)
*msb = dt->u.atomic.msb_pad;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_pad
*
* Purpose: Sets the LSB and MSB pad types.
*
* Return: Success:
*
* Failure:
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_pad, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
!H5T_is_atomic(dt)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (lsb < 0 || lsb >= H5T_NPAD || msb < 0 || msb >= H5T_NPAD) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type");
}
dt->u.atomic.lsb_pad = lsb;
dt->u.atomic.msb_pad = msb;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_sign
*
* Purpose: Retrieves the sign type for an integer type.
*
* Return: Success: The sign type.
*
* Failure: H5T_SGN_ERROR (-1, same as FAIL)
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_sign_t
H5Tget_sign(hid_t type_id)
{
H5T_t *dt = NULL;
H5T_sign_t sign;
FUNC_ENTER(H5Tget_sign, H5T_SGN_ERROR);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_INTEGER != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR,
"not an integer data type");
}
/* sign */
sign = dt->u.atomic.u.i.sign;
FUNC_LEAVE(sign);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_sign
*
* Purpose: Sets the sign property for an integer.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_sign(hid_t type_id, H5T_sign_t sign)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_sign, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_INTEGER != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (sign < 0 || sign >= H5T_NSGN) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type");
}
/* sign */
dt->u.atomic.u.i.sign = sign;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_fields
*
* Purpose: Returns information about the locations of the various bit
* fields of a floating point data type. The field positions
* are bit positions in the significant region of the data type.
* Bits are numbered with the least significant bit number zero.
*
* Any (or even all) of the arguments can be null pointers.
*
* Return: Success: SUCCEED, field locations and sizes are
* returned through the arguments.
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tget_fields(hid_t type_id, size_t *spos /*out */ ,
size_t *epos /*out */ , size_t *esize /*out */ ,
size_t *mpos /*out */ , size_t *msize /*out */ )
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tget_fields, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_FLOAT != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a floating-point data type");
}
/* Get values */
if (spos)
*spos = dt->u.atomic.u.f.sign;
if (epos)
*epos = dt->u.atomic.u.f.epos;
if (esize)
*esize = dt->u.atomic.u.f.esize;
if (mpos)
*mpos = dt->u.atomic.u.f.mpos;
if (msize)
*msize = dt->u.atomic.u.f.msize;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_fields
*
* Purpose: Sets the locations and sizes of the various floating point
* bit fields. The field positions are bit positions in the
* significant region of the data type. Bits are numbered with
* the least significant bit number zero.
*
* Fields are not allowed to extend beyond the number of bits of
* precision, nor are they allowed to overlap with one another.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
size_t mpos, size_t msize)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_fields, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_FLOAT != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a floating-point data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (epos + esize > dt->u.atomic.prec) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"exponent bit field size/location is invalid");
}
if (mpos + msize > dt->u.atomic.prec) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"mantissa bit field size/location is invalid");
}
if (spos >= dt->u.atomic.prec) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"sign location is not valid");
}
/* Check for overlap */
if (spos >= epos && spos < epos + esize) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"sign bit appears within exponent field");
}
if (spos >= mpos && spos < mpos + msize) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"sign bit appears within mantissa field");
}
if ((mpos < epos && mpos + msize > epos) ||
(epos < mpos && epos + esize > mpos)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"exponent and mantissa fields overlap");
}
/* Commit */
dt->u.atomic.u.f.sign = spos;
dt->u.atomic.u.f.epos = epos;
dt->u.atomic.u.f.mpos = mpos;
dt->u.atomic.u.f.esize = esize;
dt->u.atomic.u.f.msize = msize;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_ebias
*
* Purpose: Retrieves the exponent bias of a floating-point type.
*
* Return: Success: The bias
*
* Failure: 0
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
size_t
H5Tget_ebias(hid_t type_id)
{
H5T_t *dt = NULL;
size_t ebias;
FUNC_ENTER(H5Tget_ebias, 0);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_FLOAT != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0,
"not a floating-point data type");
}
/* bias */
ebias = dt->u.atomic.u.f.ebias;
FUNC_LEAVE(ebias);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_ebias
*
* Purpose: Sets the exponent bias of a floating-point type.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_ebias(hid_t type_id, size_t ebias)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_ebias, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_FLOAT != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a floating-point data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
dt->u.atomic.u.f.ebias = ebias;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_norm
*
* Purpose: Returns the mantisssa normalization of a floating-point data
* type.
*
* Return: Success: Normalization ID
*
* Failure: H5T_NORM_ERROR (-1, same as FAIL)
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_norm_t
H5Tget_norm(hid_t type_id)
{
H5T_t *dt = NULL;
H5T_norm_t norm;
FUNC_ENTER(H5Tget_norm, H5T_NORM_ERROR);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_FLOAT != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR,
"not a floating-point data type");
}
/* norm */
norm = dt->u.atomic.u.f.norm;
FUNC_LEAVE(norm);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_norm
*
* Purpose: Sets the mantissa normalization method for a floating point
* data type.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_norm(hid_t type_id, H5T_norm_t norm)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_norm, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_FLOAT != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a floating-point data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (norm < 0 || norm > H5T_NORM_NONE) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization");
}
/* norm */
dt->u.atomic.u.f.norm = norm;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_inpad
*
* Purpose: If any internal bits of a floating point type are unused
* (that is, those significant bits which are not part of the
* sign, exponent, or mantissa) then they will be filled
* according to the value of this property.
*
* Return: Success: The internal padding type.
*
* Failure: H5T_PAD_ERROR (-1, same as FAIL)
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_pad_t
H5Tget_inpad(hid_t type_id)
{
H5T_t *dt = NULL;
H5T_pad_t pad;
FUNC_ENTER(H5Tget_inpad, H5T_PAD_ERROR);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_FLOAT != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR,
"not a floating-point data type");
}
/* pad */
pad = dt->u.atomic.u.f.pad;
FUNC_LEAVE(pad);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_inpad
*
* Purpose: If any internal bits of a floating point type are unused
* (that is, those significant bits which are not part of the
* sign, exponent, or mantissa) then they will be filled
* according to the value of this property.
*
* Return: Success:
*
* Failure:
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_inpad(hid_t type_id, H5T_pad_t pad)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_inpad, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_FLOAT != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a floating-point data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (pad < 0 || pad >= H5T_NPAD) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"illegal internal pad type");
}
/* pad */
dt->u.atomic.u.f.pad = pad;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_cset
*
* Purpose: HDF5 is able to distinguish between character sets of
* different nationalities and to convert between them to the
* extent possible.
*
* Return: Success: The character set of an H5T_STRING type.
*
* Failure: H5T_CSET_ERROR (-1, same as FAIL)
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_cset_t
H5Tget_cset(hid_t type_id)
{
H5T_t *dt = NULL;
H5T_cset_t cset;
FUNC_ENTER(H5Tget_cset, H5T_CSET_ERROR);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_STRING != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR,
"not a string data type");
}
/* result */
cset = dt->u.atomic.u.s.cset;
FUNC_LEAVE(cset);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_cset
*
* Purpose: HDF5 is able to distinguish between character sets of
* different nationalities and to convert between them to the
* extent possible.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_cset(hid_t type_id, H5T_cset_t cset)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_cset, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_STRING != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a string data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (cset < 0 || cset >= H5T_NCSET) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"illegal character set type");
}
/* set */
dt->u.atomic.u.s.cset = cset;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_strpad
*
* Purpose: The method used to store character strings differs with the
* programming language: C usually null terminates strings while
* Fortran left-justifies and space-pads strings. This property
* defines the storage mechanism for the string.
*
* Return: Success: The character set of an H5T_STRING type.
*
* Failure: H5T_STR_ERROR (-1, same as FAIL)
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_str_t
H5Tget_strpad(hid_t type_id)
{
H5T_t *dt = NULL;
H5T_str_t strpad;
FUNC_ENTER(H5Tget_strpad, H5T_STR_ERROR);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_STRING != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR,
"not a string data type");
}
/* result */
strpad = dt->u.atomic.u.s.pad;
FUNC_LEAVE(strpad);
}
/*-------------------------------------------------------------------------
* Function: H5Tset_strpad
*
* Purpose: The method used to store character strings differs with the
* programming language: C usually null terminates strings while
* Fortran left-justifies and space-pads strings. This property
* defines the storage mechanism for the string.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tset_strpad(hid_t type_id, H5T_str_t strpad)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tset_strpad, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_STRING != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a string data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
}
if (strpad < 0 || strpad >= H5T_NSTR) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type");
}
/* set */
dt->u.atomic.u.s.pad = strpad;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_nmembers
*
* Purpose: Determines how many members compound data type TYPE_ID has.
*
* Return: Success: Number of members defined in a compound data
* type.
*
* Failure: FAIL
*
* Errors:
*
* Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
intn
H5Tget_nmembers(hid_t type_id)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tget_num_members, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_COMPOUND != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
}
FUNC_LEAVE(dt->u.compnd.nmembs);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_member_name
*
* Purpose: Returns the name of a member of a compound data type.
* Members are stored in no particular order with numbers 0
* through N-1 where N is the value returned by
* H5Tget_nmembers().
*
* Return: Success: Ptr to a string allocated with malloc(). The
* caller is responsible for freeing the string.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
char *
H5Tget_member_name(hid_t type_id, int membno)
{
H5T_t *dt = NULL;
char *s = NULL;
FUNC_ENTER(H5Tget_member_name, NULL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_COMPOUND != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a compound data type");
}
if (membno < 0 || membno >= dt->u.compnd.nmembs) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number");
}
s = H5MM_xstrdup(dt->u.compnd.memb[membno].name);
FUNC_LEAVE(s);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_member_offset
*
* Purpose: Returns the byte offset of the beginning of a member with
* respect to the beginning of the compound data type datum.
*
* Return: Success: Byte offset.
*
* Failure: Zero. Zero is a valid offset, but this
* function will fail only if a call to
* H5Tget_member_dims() fails with the same
* arguments.
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
size_t
H5Tget_member_offset(hid_t type_id, int membno)
{
H5T_t *dt = NULL;
size_t offset = 0;
FUNC_ENTER(H5Tget_member_offset, 0);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_COMPOUND != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound data type");
}
if (membno < 0 || membno >= dt->u.compnd.nmembs) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number");
}
offset = dt->u.compnd.memb[membno].offset;
FUNC_LEAVE(offset);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_member_dims
*
* Purpose: Returns the dimensionality of the member. The dimensions and
* permuation vector are returned through arguments DIMS and
* PERM, both arrays of at least four elements. Either (or even
* both) may be null pointers.
*
* Return: Success: A value between zero and four, inclusive.
*
* Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
H5Tget_member_dims(hid_t type_id, int membno,
size_t dims[]/*out*/, int perm[]/*out*/)
{
H5T_t *dt = NULL;
intn ndims, i;
FUNC_ENTER(H5Tget_member_dims, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_COMPOUND != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
}
if (membno < 0 || membno >= dt->u.compnd.nmembs) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
}
ndims = dt->u.compnd.memb[membno].ndims;
for (i = 0; i < ndims; i++) {
if (dims[i])
dims[i] = dt->u.compnd.memb[membno].dim[i];
if (perm[i])
perm[i] = dt->u.compnd.memb[membno].perm[i];
}
FUNC_LEAVE(ndims);
}
/*-------------------------------------------------------------------------
* Function: H5Tget_member_type
*
* Purpose: Returns the data type of the specified member. The caller
* should invoke H5Tclose() to release resources associated with
* the type.
*
* Return: Success: An OID of a copy of the member data type;
* modifying the returned data type does not
* modify the member type.
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hid_t
H5Tget_member_type(hid_t type_id, int membno)
{
H5T_t *dt = NULL, *memb_dt = NULL;
hid_t memb_type_id;
FUNC_ENTER(H5Tget_member_type, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_COMPOUND != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
}
if (membno < 0 || membno >= dt->u.compnd.nmembs) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
}
/* Copy data type into an atom */
if (NULL == (memb_dt = H5T_copy(&(dt->u.compnd.memb[membno].type)))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to copy member data type");
}
if ((memb_type_id = H5A_register(H5_DATATYPE, memb_dt)) < 0) {
H5T_close(memb_dt);
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
"can't register data type atom");
}
FUNC_LEAVE(memb_type_id);
}
/*-------------------------------------------------------------------------
* Function: H5Tinsert
*
* Purpose: Adds another member to the compound data type PARENT_ID. The
* new member has a NAME which must be unique within the
* compound data type. The OFFSET argument defines the start of
* the member in an instance of the compound data type, and
* MEMBER_ID is the type of the new member.
*
* Note: All members of a compound data type must be atomic; a
* compound data type cannot have a member which is a compound
* data type.
*
* Return: Success: SUCCEED, the PARENT_ID compound data type is
* modified to include a copy of the member type
* MEMBER_ID.
*
* Failure: FAIL
*
* Errors:
*
* Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tinsert(hid_t parent_id, const char *name, off_t offset, hid_t member_id)
{
H5T_t *parent = NULL; /*the compound parent data type */
H5T_t *member = NULL; /*the atomic member type */
FUNC_ENTER(H5Tinsert, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(parent_id) ||
NULL == (parent = H5A_object(parent_id)) ||
H5T_COMPOUND != parent->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
}
if (parent->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only");
}
if (!name || !*name) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name");
}
if (H5_DATATYPE != H5A_group(member_id) ||
NULL == (member = H5A_object(member_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
if (H5T_insert(parent, name, offset, member) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
"can't insert member");
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tpack
*
* Purpose: Recursively removes padding from within a compound data type
* to make it more efficient (space-wise) to store that data.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tpack(hid_t type_id)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5Tpack, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(type_id) ||
NULL == (dt = H5A_object(type_id)) ||
H5T_COMPOUND != dt->type) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
}
if (dt->locked) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data type is read-only");
}
if (H5T_pack(dt) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to pack compound data type");
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tregister_hard
*
* Purpose: Register a hard conversion function for a data type
* conversion path. The path is specified by the source and
* destination data types SRC_ID and DST_ID. A conversion path
* can only have one hard function, so FUNC replaces any
* previous hard function.
*
* If FUNC is the null pointer then any hard function registered
* for this path is removed from this path. The soft functions
* are then used when determining which conversion function is
* appropriate for this path.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tregister_hard(hid_t src_id, hid_t dst_id, H5T_conv_t func)
{
H5T_t *src = NULL;
H5T_t *dst = NULL;
H5T_path_t *path = NULL;
intn i;
FUNC_ENTER(H5Tregister_hard, FAIL);
/* Check args */
if (H5_DATATYPE != H5A_group(src_id) ||
NULL == (src = H5A_object(src_id)) ||
H5_DATATYPE != H5A_group(dst_id) ||
NULL == (dst = H5A_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
/* Locate or create a new conversion path */
if (NULL == (path = H5T_path_find(src, dst, TRUE, func))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to locate/allocate conversion path");
}
/*
* Notify all other functions to recalculate private data since some
* functions might cache a list of conversion functions. For instance,
* the compound type converter caches a list of conversion functions for
* the members, so adding a new function should cause the list to be
* recalculated to use the new function.
*/
for (i=0; i<H5T_npath_g; i++) {
if (path != H5T_path_g+i) {
H5T_path_g[i].cdata.recalc = TRUE;
}
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tregister_soft
*
* Purpose: Registers a soft conversion function by adding it to the end
* of the master soft list and replacing the soft function in
* all applicable existing conversion paths.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tregister_soft(H5T_class_t src_cls, H5T_class_t dst_cls, H5T_conv_t func)
{
intn i;
hid_t src_id, dst_id;
H5T_cdata_t cdata;
FUNC_ENTER(H5Tregister_soft, FAIL);
/* Check args */
if (src_cls < 0 || src_cls >= H5T_NCLASSES ||
dst_cls < 0 || dst_cls >= H5T_NCLASSES) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"illegal source or destination data type class");
}
if (!func) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"no soft conversion function specified");
}
/* Add function to end of master list */
if (H5T_nsoft_g >= H5T_asoft_g) {
H5T_asoft_g = MAX(32, 2 * H5T_asoft_g);
H5T_soft_g = H5MM_xrealloc(H5T_soft_g,
H5T_asoft_g * sizeof(H5T_soft_t));
}
H5T_soft_g[H5T_nsoft_g].src = src_cls;
H5T_soft_g[H5T_nsoft_g].dst = dst_cls;
H5T_soft_g[H5T_nsoft_g].func = func;
H5T_nsoft_g++;
/* Replace soft functions of all appropriate paths */
for (i=0; i<H5T_npath_g; i++) {
H5T_path_t *path = H5T_path_g + i;
path->cdata.recalc = TRUE;
if (path->is_hard ||
path->src->type!=src_cls || path->dst->type!=dst_cls) {
continue;
}
/*
* Type conversion functions are app-level, so we need to convert the
* data type temporarily to an object id before we query the functions
* capabilities.
*/
if ((src_id = H5A_register(H5_DATATYPE, H5T_copy(path->src))) < 0 ||
(dst_id = H5A_register(H5_DATATYPE, H5T_copy(path->dst))) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
"unable to register data types for conv query");
}
HDmemset (&cdata, 0, sizeof cdata);
cdata.command = H5T_CONV_INIT;
if ((func) (src_id, dst_id, &cdata, 0, NULL, NULL) >= 0) {
/*
* Free resources used by the previous conversion function. We
* don't really care if this fails since at worst we'll just leak
* some memory. Then initialize the path with new info.
*/
if (path->func) {
path->cdata.command = H5T_CONV_FREE;
if ((path->func)(src_id, dst_id, &(path->cdata),
0, NULL, NULL)<0) {
#ifdef H5T_DEBUG
fprintf (stderr, "HDF5-DIAG: conversion function failed "
"to free private data.\n");
#endif
H5ECLEAR;
}
}
path->func = func;
path->cdata = cdata;
}
/* Release temporary atoms */
H5A_dec_ref(src_id);
H5A_dec_ref(dst_id);
H5ECLEAR;
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tunregister
*
* Purpose: Removes FUNC from all conversion paths.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5Tunregister(H5T_conv_t func)
{
intn i, j;
H5T_path_t *path = NULL;
hid_t src_id, dst_id;
FUNC_ENTER(H5Tunregister, FAIL);
/* Check args */
if (!func) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no conversion function");
}
/* Remove function from master soft list */
for (i=H5T_nsoft_g-1; i>=0; --i) {
if (H5T_soft_g[i].func == func) {
HDmemmove(H5T_soft_g+i, H5T_soft_g+i+1,
(H5T_nsoft_g - (i+1)) * sizeof(H5T_soft_t));
--H5T_nsoft_g;
}
}
/* Remove function from all conversion paths */
for (i=0; i<H5T_npath_g; i++) {
path = H5T_path_g + i;
if (path->func == func) {
path->func = NULL;
path->is_hard = FALSE;
/*
* Reset cdata.
*/
path->cdata.command = H5T_CONV_FREE;
if ((func)(FAIL, FAIL, &(path->cdata), 0, NULL, NULL)<0) {
#ifdef H5T_DEBUG
fprintf (stderr, "HDF5-DIAG: conversion function failed to "
"free private data.\n");
#endif
H5ECLEAR;
}
HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t));
/*
* Choose a new function.
*/
for (j=H5T_nsoft_g-1; j>=0 && !path->func; --j) {
if (path->src->type != H5T_soft_g[j].src ||
path->dst->type != H5T_soft_g[j].dst) {
continue;
}
/*
* Conversion functions are app-level, so temporarily create
* object id's for the data types.
*/
if ((src_id = H5A_register(H5_DATATYPE,
H5T_copy(path->src))) < 0 ||
(dst_id = H5A_register(H5_DATATYPE,
H5T_copy(path->dst))) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
"unable to register conv types for query");
}
path->cdata.command = H5T_CONV_INIT;
if ((H5T_soft_g[j].func)(src_id, dst_id, &(path->cdata),
0, NULL, NULL) >= 0) {
path->func = H5T_soft_g[j].func;
} else {
H5ECLEAR;
HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t));
}
H5A_dec_ref(src_id);
H5A_dec_ref(dst_id);
}
} else {
/*
* If the soft function didn't change then make sure it
* recalculates its private data at the next opportunity.
*/
path->cdata.recalc = TRUE;
}
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5Tfind
*
* Purpose: Finds a conversion function that can handle a conversion from
* type SRC_ID to type DST_ID. The PCDATA argument is a pointer
* to a pointer to type conversion data which was created and
* initialized by the soft type conversion function of this path
* when the conversion function was installed on the path.
*
* Return: Success: A pointer to a suitable conversion function.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_conv_t
H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata)
{
H5T_conv_t ret_value = NULL;
H5T_t *src = NULL, *dst = NULL;
FUNC_ENTER(H5Tfind, NULL);
/* Check args */
if (H5_DATATYPE != H5A_group(src_id) ||
NULL == (src = H5A_object(src_id)) ||
H5_DATATYPE != H5A_group(dst_id) ||
NULL == (dst = H5A_object(dst_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
}
if (!pcdata) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, NULL,
"no address to receive cdata pointer");
}
/* Find it */
*pcdata = NULL;
if (NULL == (ret_value = H5T_find(src, dst, pcdata))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL,
"conversion function not found");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* API functions are above; library-private functions are below...
*-------------------------------------------------------------------------
*/
/*-------------------------------------------------------------------------
* Function: H5T_create
*
* Purpose: Creates a new data type and initializes it to reasonable
* values. The new data type is SIZE bytes and an instance of
* the class TYPE.
*
* Return: Success: Pointer to the new type.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* Friday, December 5, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_t *
H5T_create(H5T_class_t type, size_t size)
{
H5T_t *dt = NULL;
FUNC_ENTER(H5T_create, NULL);
assert(size > 0);
switch (type) {
case H5T_INTEGER:
case H5T_FLOAT:
case H5T_TIME:
case H5T_STRING:
case H5T_BITFIELD:
case H5T_OPAQUE:
HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
"type class is not appropriate - use H5Tcopy()");
case H5T_COMPOUND:
dt = H5MM_xcalloc(1, sizeof(H5T_t));
dt->type = type;
break;
default:
HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL,
"unknown data type class");
}
dt->size = size;
FUNC_LEAVE(dt);
}
/*-------------------------------------------------------------------------
* Function: H5T_copy
*
* Purpose: Copies datatype OLD_DT. The resulting data type is not
* locked.
*
* Return: Success: Pointer to a new copy of the OLD_DT argument.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_t *
H5T_copy(const H5T_t *old_dt)
{
H5T_t *new_dt = NULL;
intn i;
char *s;
FUNC_ENTER(H5T_copy, NULL);
/* check args */
assert(old_dt);
/* copy */
new_dt = H5MM_xcalloc(1, sizeof(H5T_t));
*new_dt = *old_dt;
new_dt->locked = FALSE;
if (H5T_COMPOUND == new_dt->type) {
new_dt->u.compnd.memb = H5MM_xmalloc(new_dt->u.compnd.nmembs *
sizeof(H5T_member_t));
HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb,
new_dt->u.compnd.nmembs * sizeof(H5T_member_t));
for (i = 0; i < new_dt->u.compnd.nmembs; i++) {
s = new_dt->u.compnd.memb[i].name;
new_dt->u.compnd.memb[i].name = H5MM_xstrdup(s);
}
}
FUNC_LEAVE(new_dt);
}
/*-------------------------------------------------------------------------
* Function: H5T_close
*
* Purpose: Frees a data type and all associated memory.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_close(H5T_t *dt)
{
intn i;
FUNC_ENTER(H5T_close, FAIL);
assert(dt);
assert(!dt->locked);
if (dt && H5T_COMPOUND == dt->type) {
for (i = 0; i < dt->u.compnd.nmembs; i++) {
H5MM_xfree(dt->u.compnd.memb[i].name);
}
H5MM_xfree(dt->u.compnd.memb);
H5MM_xfree(dt);
} else if (dt) {
H5MM_xfree(dt);
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5T_is_atomic
*
* Purpose: Determines if a data type is an atomic type.
*
* Return: Success: TRUE, FALSE
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hbool_t
H5T_is_atomic(const H5T_t *dt)
{
FUNC_ENTER(H5T_is_atomic, FAIL);
assert(dt);
FUNC_LEAVE(H5T_COMPOUND == dt->type ? FALSE : TRUE);
}
/*-------------------------------------------------------------------------
* Function: H5T_get_size
*
* Purpose: Determines the total size of a data type in bytes.
*
* Return: Success: Size of the data type in bytes. The size of
* the data type is the size of an instance of
* that data type.
*
* Failure: 0 (valid data types are never zero size)
*
* Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
size_t
H5T_get_size(const H5T_t *dt)
{
FUNC_ENTER(H5T_get_size, 0);
/* check args */
assert(dt);
FUNC_LEAVE(dt->size);
}
/*-------------------------------------------------------------------------
* Function: H5T_insert
*
* Purpose: Adds a new MEMBER to the compound data type PARENT. The new
* member will have a NAME that is unique within PARENT and an
* instance of PARENT will have the member begin at byte offset
* OFFSET from the beginning.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_insert(H5T_t *parent, const char *name, off_t offset, const H5T_t *member)
{
intn i;
H5T_t *tmp = NULL;
FUNC_ENTER(H5T_insert, FAIL);
/* check args */
assert(parent && H5T_COMPOUND == parent->type);
assert(!parent->locked);
assert(member);
assert(name && *name);
/* Does NAME already exist in PARENT? */
for (i = 0; i < parent->u.compnd.nmembs; i++) {
if (!HDstrcmp(parent->u.compnd.memb[i].name, name)) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
"member name is not unique");
}
}
/* Does the new member overlap any existing member ? */
for (i = 0; i < parent->u.compnd.nmembs; i++) {
if ((offset < parent->u.compnd.memb[i].offset &&
offset + member->size > parent->u.compnd.memb[i].offset) ||
(parent->u.compnd.memb[i].offset < offset &&
parent->u.compnd.memb[i].offset +
parent->u.compnd.memb[i].type.size > offset)) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
"member overlaps with another member");
}
}
/* Increase member array if necessary */
if (parent->u.compnd.nmembs >= parent->u.compnd.nalloc) {
parent->u.compnd.nalloc += H5T_COMPND_INC;
parent->u.compnd.memb = H5MM_xrealloc(parent->u.compnd.memb,
(parent->u.compnd.nalloc *
sizeof(H5T_member_t)));
}
/* Add member to end of member array */
i = parent->u.compnd.nmembs;
parent->u.compnd.memb[i].name = H5MM_xstrdup(name);
parent->u.compnd.memb[i].offset = offset;
parent->u.compnd.memb[i].ndims = 0; /*defaults to scalar */
tmp = H5T_copy(member);
parent->u.compnd.memb[i].type = *tmp;
H5MM_xfree(tmp);
parent->u.compnd.nmembs++;
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5T_pack
*
* Purpose: Recursively packs a compound data type by removing padding
* bytes. This is done in place (that is, destructively).
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_pack(H5T_t *dt)
{
int i;
size_t offset;
FUNC_ENTER(H5T_pack, FAIL);
assert(dt);
assert(!dt->locked);
if (H5T_COMPOUND == dt->type) {
/* Recursively pack the members */
for (i = 0; i < dt->u.compnd.nmembs; i++) {
if (H5T_pack(&(dt->u.compnd.memb[i].type)) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"unable to pack part of a compound data type");
}
}
/* Remove padding between members */
H5T_sort_by_offset(dt);
for (i = 0, offset = 0; i < dt->u.compnd.nmembs; i++) {
dt->u.compnd.memb[i].offset = offset;
offset += dt->u.compnd.memb[i].type.size;
}
/* Change total size */
dt->size = MAX(1, offset);
}
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5T_sort_by_offset
*
* Purpose: Sorts the members of a compound data type by their offsets.
* This even works for locked data types since it doesn't change
* the value of the type.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_sort_by_offset(H5T_t *dt)
{
int i, j, nmembs;
hbool_t swapped;
FUNC_ENTER(H5T_sort_by_offset, FAIL);
/* Check args */
assert(dt);
assert(H5T_COMPOUND == dt->type);
/* Use a bubble sort because we can short circuit */
nmembs = dt->u.compnd.nmembs;
for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) {
for (j=0, swapped=FALSE; j<i; j++) {
if (dt->u.compnd.memb[j].offset > dt->u.compnd.memb[j+1].offset) {
H5T_member_t tmp = dt->u.compnd.memb[j];
dt->u.compnd.memb[j] = dt->u.compnd.memb[j+1];
dt->u.compnd.memb[j+1] = tmp;
swapped = TRUE;
}
}
}
#ifndef NDEBUG
/* I never trust a sort :-) */
for (i = 0; i < dt->u.compnd.nmembs - 1; i++) {
assert(dt->u.compnd.memb[i].offset < dt->u.compnd.memb[i + 1].offset);
}
#endif
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5T_cmp
*
* Purpose: Compares two data types.
*
* Return: Success: 0 if DT1 and DT2 are equal.
* <0 if DT1 is less than DT2.
* >0 if DT1 is greater than DT2.
*
* Failure: 0, never fails
*
* Programmer: Robb Matzke
* Wednesday, December 10, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
intn
H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
{
intn *idx1 = NULL, *idx2 = NULL;
intn ret_value = 0;
intn i, j, tmp;
hbool_t swapped;
FUNC_ENTER(H5T_equal, 0);
/* the easy case */
if (dt1 == dt2) HGOTO_DONE(0);
assert(dt1);
assert(dt2);
/* compare */
if (dt1->type < dt2->type) HGOTO_DONE(-1);
if (dt1->type > dt2->type) HGOTO_DONE(1);
if (dt1->size < dt2->size) HGOTO_DONE(-1);
if (dt1->size > dt2->size) HGOTO_DONE(1);
if (H5T_COMPOUND == dt1->type) {
/*
* Compound data types...
*/
if (dt1->u.compnd.nmembs < dt2->u.compnd.nmembs) HGOTO_DONE(-1);
if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs) HGOTO_DONE(1);
/* Build an index for each type so the names are sorted */
idx1 = H5MM_xmalloc(dt1->u.compnd.nmembs * sizeof(intn));
idx2 = H5MM_xmalloc(dt1->u.compnd.nmembs * sizeof(intn));
for (i=0; i<dt1->u.compnd.nmembs; i++) idx1[i] = idx2[i] = i;
for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
for (j=0, swapped=FALSE; j<i; j++) {
if (HDstrcmp(dt1->u.compnd.memb[idx1[j]].name,
dt1->u.compnd.memb[idx1[j+1]].name) > 0) {
tmp = idx1[j];
idx1[j] = idx1[j+1];
idx1[j+1] = tmp;
swapped = TRUE;
}
}
}
for (i=dt2->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
for (j=0, swapped=FALSE; j<i; j++) {
if (HDstrcmp(dt2->u.compnd.memb[idx2[j]].name,
dt2->u.compnd.memb[idx2[j+1]].name) > 0) {
tmp = idx2[j];
idx2[j] = idx2[j+1];
idx2[j+1] = tmp;
swapped = TRUE;
}
}
}
#ifdef H5T_DEBUG
/* I don't quite trust the code above yet :-) --RPM */
for (i=0; i<dt1->u.compnd.nmembs-1; i++) {
assert(HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
dt1->u.compnd.memb[idx1[i + 1]].name));
assert(HDstrcmp(dt2->u.compnd.memb[idx2[i]].name,
dt2->u.compnd.memb[idx2[i + 1]].name));
}
#endif
/* Compare the members */
for (i=0; i<dt1->u.compnd.nmembs; i++) {
tmp = HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
dt2->u.compnd.memb[idx2[i]].name);
if (tmp < 0) HGOTO_DONE(-1);
if (tmp > 0) HGOTO_DONE(1);
if (dt1->u.compnd.memb[idx1[i]].offset <
dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(-1);
if (dt1->u.compnd.memb[idx1[i]].offset >
dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(1);
if (dt1->u.compnd.memb[idx1[i]].ndims <
dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE(-1);
if (dt1->u.compnd.memb[idx1[i]].ndims >
dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE(1);
for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
if (dt1->u.compnd.memb[idx1[i]].dim[j] <
dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE(-1);
if (dt1->u.compnd.memb[idx1[i]].dim[j] >
dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE(1);
}
for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
if (dt1->u.compnd.memb[idx1[i]].perm[j] <
dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE(-1);
if (dt1->u.compnd.memb[idx1[i]].perm[j] >
dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE(1);
}
tmp = H5T_cmp(&(dt1->u.compnd.memb[idx1[i]].type),
&(dt2->u.compnd.memb[idx2[i]].type));
if (tmp < 0) HGOTO_DONE(-1);
if (tmp > 0) HGOTO_DONE(1);
}
} else {
/*
* Atomic data types...
*/
if (dt1->u.atomic.order < dt2->u.atomic.order) HGOTO_DONE(-1);
if (dt1->u.atomic.order > dt2->u.atomic.order) HGOTO_DONE(1);
if (dt1->u.atomic.prec < dt2->u.atomic.prec) HGOTO_DONE(-1);
if (dt1->u.atomic.prec > dt2->u.atomic.prec) HGOTO_DONE(1);
if (dt1->u.atomic.offset < dt2->u.atomic.offset) HGOTO_DONE(-1);
if (dt1->u.atomic.offset > dt2->u.atomic.offset) HGOTO_DONE(1);
if (dt1->u.atomic.lsb_pad < dt2->u.atomic.lsb_pad) HGOTO_DONE(-1);
if (dt1->u.atomic.lsb_pad > dt2->u.atomic.lsb_pad) HGOTO_DONE(1);
if (dt1->u.atomic.msb_pad < dt2->u.atomic.msb_pad) HGOTO_DONE(-1);
if (dt1->u.atomic.msb_pad > dt2->u.atomic.msb_pad) HGOTO_DONE(1);
switch (dt1->type) {
case H5T_INTEGER:
if (dt1->u.atomic.u.i.sign < dt2->u.atomic.u.i.sign) {
HGOTO_DONE(-1);
}
if (dt1->u.atomic.u.i.sign > dt2->u.atomic.u.i.sign) {
HGOTO_DONE(1);
}
break;
case H5T_FLOAT:
if (dt1->u.atomic.u.f.sign < dt2->u.atomic.u.f.sign) {
HGOTO_DONE(-1);
}
if (dt1->u.atomic.u.f.sign > dt2->u.atomic.u.f.sign) {
HGOTO_DONE(1);
}
if (dt1->u.atomic.u.f.epos < dt2->u.atomic.u.f.epos) {
HGOTO_DONE(-1);
}
if (dt1->u.atomic.u.f.epos > dt2->u.atomic.u.f.epos) {
HGOTO_DONE(1);
}
if (dt1->u.atomic.u.f.esize <
dt2->u.atomic.u.f.esize) HGOTO_DONE(-1);
if (dt1->u.atomic.u.f.esize >
dt2->u.atomic.u.f.esize) HGOTO_DONE(1);
if (dt1->u.atomic.u.f.ebias <
dt2->u.atomic.u.f.ebias) HGOTO_DONE(-1);
if (dt1->u.atomic.u.f.ebias >
dt2->u.atomic.u.f.ebias) HGOTO_DONE(1);
if (dt1->u.atomic.u.f.mpos < dt2->u.atomic.u.f.mpos) {
HGOTO_DONE(-1);
}
if (dt1->u.atomic.u.f.mpos > dt2->u.atomic.u.f.mpos) {
HGOTO_DONE(1);
}
if (dt1->u.atomic.u.f.msize <
dt2->u.atomic.u.f.msize) HGOTO_DONE(-1);
if (dt1->u.atomic.u.f.msize >
dt2->u.atomic.u.f.msize) HGOTO_DONE(1);
if (dt1->u.atomic.u.f.norm < dt2->u.atomic.u.f.norm) {
HGOTO_DONE(-1);
}
if (dt1->u.atomic.u.f.norm > dt2->u.atomic.u.f.norm) {
HGOTO_DONE(1);
}
if (dt1->u.atomic.u.f.pad < dt2->u.atomic.u.f.pad) {
HGOTO_DONE(-1);
}
if (dt1->u.atomic.u.f.pad > dt2->u.atomic.u.f.pad) {
HGOTO_DONE(1);
}
break;
case H5T_TIME:
/*void */
break;
case H5T_STRING:
if (dt1->u.atomic.u.s.cset < dt1->u.atomic.u.s.cset) {
HGOTO_DONE(-1);
}
if (dt1->u.atomic.u.s.cset > dt1->u.atomic.u.s.cset) {
HGOTO_DONE(1);
}
if (dt1->u.atomic.u.s.pad < dt1->u.atomic.u.s.pad) {
HGOTO_DONE(-1);
}
if (dt1->u.atomic.u.s.pad > dt1->u.atomic.u.s.pad) {
HGOTO_DONE(1);
}
break;
case H5T_BITFIELD:
/*void */
break;
case H5T_OPAQUE:
/*void */
break;
default:
assert("not implemented yet" && 0);
}
}
done:
H5MM_xfree(idx1);
H5MM_xfree(idx2);
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5T_find
*
* Purpose: Finds a conversion function for the specified path.
*
* Return: Success: A pointer to an appropriate conversion
* function. The PCDATA argument is initialized
* to point to type conversion data which should
* be passed to the type conversion function.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* Wednesday, January 14, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_conv_t
H5T_find(const H5T_t *src, const H5T_t *dst, H5T_cdata_t **pcdata)
{
H5T_path_t *path = NULL;
H5T_conv_t ret_value = NULL;
static H5T_cdata_t noop_cdata;
FUNC_ENTER(H5T_find, NULL);
/* No-op case */
if (0 == H5T_cmp(src, dst)) {
*pcdata = &noop_cdata;
HRETURN(H5T_conv_noop);
}
/* Find it */
if (NULL == (path = H5T_path_find(src, dst, TRUE, NULL))) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
"unable to create conversion path");
}
if ((ret_value=path->func)) {
*pcdata = &(path->cdata);
} else {
HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL,
"no conversion function for that path");
}
FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
* Function: H5T_path_find
*
* Purpose: Finds the path which converts type SRC_ID to type DST_ID. If
* the path isn't found and CREATE is non-zero then a new path
* is created. If FUNC is non-null then it is registered as the
* hard function for that path.
*
* Return: Success: Pointer to the path, valid until the path
* database is modified.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5T_path_t *
H5T_path_find(const H5T_t *src, const H5T_t *dst, hbool_t create,
H5T_conv_t func)
{
intn lt = 0; /*left edge (inclusive) */
intn rt = H5T_npath_g; /*right edge (exclusive) */
intn md = 0; /*middle */
intn cmp = -1; /*comparison result */
H5T_path_t *path = NULL; /*path found */
int i;
hid_t src_id, dst_id;
FUNC_ENTER(H5T_path_find, NULL);
/* Check args */
assert(src);
assert(dst);
/* Binary search */
while (lt < rt) {
md = (lt + rt) / 2;
cmp = H5T_cmp(src, H5T_path_g[md].src);
if (0 == cmp) cmp = H5T_cmp(dst, H5T_path_g[md].dst);
if (cmp < 0) {
rt = md;
} else if (cmp > 0) {
lt = md + 1;
} else {
HRETURN(H5T_path_g + md);
}
}
/* Insert */
if (create) {
if (H5T_npath_g >= H5T_apath_g) {
H5T_apath_g = MAX(64, 2 * H5T_apath_g);
H5T_path_g = H5MM_xrealloc(H5T_path_g,
H5T_apath_g * sizeof(H5T_path_t));
}
if (cmp > 0) md++;
/* make room */
HDmemmove(H5T_path_g + md + 1, H5T_path_g + md,
(H5T_npath_g - md) * sizeof(H5T_path_t));
H5T_npath_g++;
/* insert */
path = H5T_path_g + md;
HDmemset(path, 0, sizeof(H5T_path_t));
path->src = H5T_copy(src);
path->dst = H5T_copy(dst);
/* Associate a function with the path if possible */
if (func) {
path->func = func;
path->is_hard = TRUE;
path->cdata.command = H5T_CONV_INIT;
if ((src_id=H5A_register(H5_DATATYPE, H5T_copy(path->src))) < 0 ||
(dst_id=H5A_register(H5_DATATYPE, H5T_copy(path->dst))) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
"unable to register conv types for query");
}
if ((func)(src_id, dst_id, &(path->cdata), 0, NULL, NULL)<0) {
#ifdef H5T_DEBUG
fprintf (stderr, "HDF5-DIAG: conversion function init "
"failed\n");
#endif
H5ECLEAR; /*ignore the failure*/
}
H5A_dec_ref(src_id);
H5A_dec_ref(dst_id);
} else {
/* Locate a soft function */
for (i=H5T_nsoft_g-1; i>=0 && !path->func; --i) {
if (src->type!=H5T_soft_g[i].src ||
dst->type!=H5T_soft_g[i].dst) {
continue;
}
if ((src_id=H5A_register(H5_DATATYPE,
H5T_copy(path->src))) < 0 ||
(dst_id=H5A_register(H5_DATATYPE,
H5T_copy(path->dst))) < 0) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
"unable to register conv types for query");
}
path->cdata.command = H5T_CONV_INIT;
if ((H5T_soft_g[i].func) (src_id, dst_id, &(path->cdata),
H5T_CONV_INIT, NULL, NULL) < 0) {
HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t));
H5ECLEAR; /*ignore the error*/
} else {
path->func = H5T_soft_g[i].func;
}
H5A_dec_ref(src_id);
H5A_dec_ref(dst_id);
}
}
}
FUNC_LEAVE(path);
}
/*-------------------------------------------------------------------------
* Function: H5T_debug
*
* Purpose: Prints information about a data type.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_debug(H5T_t *dt, FILE * stream)
{
const char *s = "";
int i, j;
uint64 tmp;
FUNC_ENTER(H5T_debug, FAIL);
/* Check args */
assert(dt);
assert(stream);
switch (dt->type) {
case H5T_INTEGER:
s = "int";
break;
case H5T_FLOAT:
s = "float";
break;
case H5T_TIME:
s = "time";
break;
case H5T_STRING:
s = "str";
break;
case H5T_BITFIELD:
s = "bits";
break;
case H5T_OPAQUE:
s = "opaque";
break;
case H5T_COMPOUND:
s = "struct";
break;
default:
s = "";
break;
}
fprintf(stream, "%s%s {nbytes=%lu",
s, dt->locked ? "[!]" : "", (unsigned long)(dt->size));
if (H5T_is_atomic(dt)) {
switch (dt->u.atomic.order) {
case H5T_ORDER_BE:
s = "BE";
break;
case H5T_ORDER_LE:
s = "LE";
break;
case H5T_ORDER_VAX:
s = "VAX";
break;
case H5T_ORDER_NONE:
s = "NONE";
break;
default:
s = "order?";
break;
}
fprintf(stream, ", %s", s);
if (dt->u.atomic.offset) {
fprintf(stream, ", offset=%lu",
(unsigned long) (dt->u.atomic.offset));
}
if (dt->u.atomic.prec != 8 * dt->size) {
fprintf(stream, ", prec=%lu",
(unsigned long) (dt->u.atomic.prec));
}
switch (dt->type) {
case H5T_INTEGER:
switch (dt->u.atomic.u.i.sign) {
case H5T_SGN_NONE:
s = "unsigned";
break;
case H5T_SGN_2:
s = NULL;
break;
default:
s = "sign?";
break;
}
if (s)
fprintf(stream, ", %s", s);
break;
case H5T_FLOAT:
switch (dt->u.atomic.u.f.norm) {
case H5T_NORM_IMPLIED:
s = "implied";
break;
case H5T_NORM_MSBSET:
s = "msbset";
break;
case H5T_NORM_NONE:
s = "no-norm";
break;
default:
s = "norm?";
break;
}
fprintf(stream, ", sign=%lu+1",
(unsigned long) (dt->u.atomic.u.f.sign));
fprintf(stream, ", mant=%lu+%lu (%s)",
(unsigned long) (dt->u.atomic.u.f.mpos),
(unsigned long) (dt->u.atomic.u.f.msize), s);
fprintf(stream, ", exp=%lu+%lu",
(unsigned long) (dt->u.atomic.u.f.epos),
(unsigned long) (dt->u.atomic.u.f.esize));
tmp = dt->u.atomic.u.f.ebias >> 32;
if (tmp) {
size_t hi = tmp;
size_t lo = dt->u.atomic.u.f.ebias & 0xffffffff;
fprintf(stream, " bias=0x%08lx%08lx",
(unsigned long)hi, (unsigned long)lo);
} else {
size_t lo = dt->u.atomic.u.f.ebias & 0xffffffff;
fprintf(stream, " bias=0x%08lx", (unsigned long)lo);
}
break;
default:
/* No additional info */
break;
}
} else {
for (i = 0; i < dt->u.compnd.nmembs; i++) {
fprintf(stream, "\n\"%s\" @%lu",
dt->u.compnd.memb[i].name,
(unsigned long) (dt->u.compnd.memb[i].offset));
if (dt->u.compnd.memb[i].ndims) {
fprintf(stream, "[");
for (j = 0; j < dt->u.compnd.memb[i].ndims; j++) {
fprintf(stream, "%s%lu", j ? ", " : "",
(unsigned long)(dt->u.compnd.memb[i].dim[j]));
}
fprintf(stream, "]");
}
fprintf(stream, " ");
H5T_debug(&(dt->u.compnd.memb[i].type), stream);
}
fprintf(stream, "\n");
}
fprintf(stream, "}");
FUNC_LEAVE(SUCCEED);
}
|