SIM-115: update simulator to use latest E2SM KPM version 3
[sim/e2-interface.git] / e2sim / asn1c / REAL.h
1 /*-
2  * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #ifndef ASN_TYPE_REAL_H
6 #define ASN_TYPE_REAL_H
7
8 #include <asn_application.h>
9 #include <asn_codecs_prim.h>
10
11 #define _ISOC99_SOURCE          /* For ilogb() and quiet NAN */
12 #ifndef _BSD_SOURCE
13 #define _BSD_SOURCE             /* To reintroduce finite(3) */
14 #endif
15 #if     defined(__alpha)
16 #include <sys/resource.h>       /* For INFINITY */
17 #endif
18 #include <math.h>
19
20 #if     !(defined(NAN) || defined(INFINITY))
21 static volatile double real_zero CC_NOTUSED = 0.0;
22 #endif
23 #ifndef NAN
24 #define NAN     (0.0/0.0)
25 #endif
26 #ifndef INFINITY
27 #define INFINITY        (1.0/0.0)
28 #endif
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 typedef enum specialRealValue {
35     SRV__NOT_A_NUMBER,
36     SRV__MINUS_INFINITY,
37     SRV__PLUS_INFINITY
38 } specialRealValue_e;
39 extern struct specialRealValue_s {
40     char *string;
41     size_t length;
42     long dv;
43 } specialRealValue[3];
44
45 typedef ASN__PRIMITIVE_TYPE_t REAL_t;
46
47 extern asn_TYPE_descriptor_t asn_DEF_REAL;
48 extern asn_TYPE_operation_t asn_OP_REAL;
49
50 #define REAL_free ASN__PRIMITIVE_TYPE_free
51
52 #if !defined(ASN_DISABLE_PRINT_SUPPORT)
53 asn_struct_print_f REAL_print;
54 #endif  /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
55
56 asn_struct_compare_f REAL_compare;
57
58 #define REAL_constraint asn_generic_no_constraint
59
60 #if !defined(ASN_DISABLE_BER_SUPPORT)
61 #define REAL_decode_ber ber_decode_primitive
62 #define REAL_encode_der der_encode_primitive
63 #endif  /* !defined(ASN_DISABLE_BER_SUPPORT) */
64
65 #if !defined(ASN_DISABLE_XER_SUPPORT)
66 xer_type_decoder_f REAL_decode_xer;
67 xer_type_encoder_f REAL_encode_xer;
68 #endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
69
70 #if !defined(ASN_DISABLE_JER_SUPPORT)
71 jer_type_encoder_f REAL_encode_jer;
72 #endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
73
74 #if !defined(ASN_DISABLE_OER_SUPPORT)
75 oer_type_decoder_f REAL_decode_oer;
76 oer_type_encoder_f REAL_encode_oer;
77 #endif  /* !defined(ASN_DISABLE_OER_SUPPORT) */
78
79 #if !defined(ASN_DISABLE_UPER_SUPPORT)
80 per_type_decoder_f REAL_decode_uper;
81 per_type_encoder_f REAL_encode_uper;
82 #endif  /* !defined(ASN_DISABLE_UPER_SUPPORT) */
83 #if !defined(ASN_DISABLE_APER_SUPPORT)
84 per_type_decoder_f REAL_decode_aper;
85 per_type_encoder_f REAL_encode_aper;
86 #endif  /* !defined(ASN_DISABLE_APER_SUPPORT) */
87
88 #if !defined(ASN_DISABLE_RFILL_SUPPORT)
89 asn_random_fill_f  REAL_random_fill;
90 #endif  /* !defined(ASN_DISABLE_RFILL_SUPPORT) */
91
92 /***********************************
93  * Some handy conversion routines. *
94  ***********************************/
95
96 ssize_t REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key);
97
98 /*
99  * Convert between native double type and REAL representation (DER).
100  * RETURN VALUES:
101  *  0: Value converted successfully
102  * -1: An error occurred while converting the value: invalid format.
103  */
104 int asn_REAL2double(const REAL_t *real_ptr, double *d);
105 int asn_double2REAL(REAL_t *real_ptr, double d);
106
107 /*
108  * Downcast double to float while checking that no overflow occurs.
109  * This allows stricter control of the input data.
110  * RETURN VALUES:
111  *  0: The conversion was successful (perhaps with a loss of precision)
112  * -1: The conversion created overflow into infinities.
113  * The (outcome) is ALWAYS set to a value you'd expect from the
114  * standard silent float to double conversion behavior.
115  */
116 int asn_double2float(double d, float *outcome);
117
118 #ifdef __cplusplus
119 }
120 #endif
121
122 #endif  /* ASN_TYPE_REAL_H */