| 1 |
/* |
| 2 |
* Copyright (c) 2021-2025 Symas Corporation |
| 3 |
* |
| 4 |
* Redistribution and use in source and binary forms, with or without |
| 5 |
* modification, are permitted provided that the following conditions are |
| 6 |
* met: |
| 7 |
* |
| 8 |
* * Redistributions of source code must retain the above copyright |
| 9 |
* notice, this list of conditions and the following disclaimer. |
| 10 |
* * Redistributions in binary form must reproduce the above |
| 11 |
* copyright notice, this list of conditions and the following disclaimer |
| 12 |
* in the documentation and/or other materials provided with the |
| 13 |
* distribution. |
| 14 |
* * Neither the name of the Symas Corporation nor the names of its |
| 15 |
* contributors may be used to endorse or promote products derived from |
| 16 |
* this software without specific prior written permission. |
| 17 |
* |
| 18 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 |
*/ |
| 30 |
#ifndef LIBGCOBOL_H_ |
| 31 |
#define LIBGCOBOL_H_ |
| 32 |
|
| 33 |
/* Many of the routines declared here are called from the gcc/cobol code by |
| 34 |
means of explicit GENERIC calls, which is why they are defined as external |
| 35 |
"C". Because there is no mechanism for checking the definitions, the caller |
| 36 |
and callee have to agree on parameter types and the types of returned |
| 37 |
values. |
| 38 |
|
| 39 |
Some are also called between source code modules in libgcobol, hence the |
| 40 |
need here for declarations. */ |
| 41 |
|
| 42 |
extern void __gg__mabort(); |
| 43 |
|
| 44 |
|
| 45 |
// The unnecessary abort() that follows is necessary to make cppcheck be |
| 46 |
// aware that massert() actually terminates processing after a failed |
| 47 |
// malloc(). |
| 48 |
#define massert(p) if(!p){__gg__mabort();abort();} |
| 49 |
|
| 50 |
extern "C" __int128 __gg__power_of_ten(int n); |
| 51 |
|
| 52 |
extern "C" __int128 __gg__dirty_to_binary_source( const char *dirty, |
| 53 |
int length, |
| 54 |
int *rdigits); |
| 55 |
extern "C" __int128 __gg__dirty_to_binary_internal( const char *dirty, |
| 56 |
int length, |
| 57 |
int *rdigits); |
| 58 |
extern "C" __int128 __gg__binary_value_from_field( int *rdigits, |
| 59 |
cblc_field_t *var); |
| 60 |
|
| 61 |
extern "C" int __gg__compare_2( cblc_field_t *left_side, |
| 62 |
unsigned char *left_location, |
| 63 |
size_t left_length, |
| 64 |
int left_attr, |
| 65 |
int left_flags, |
| 66 |
cblc_field_t *right_side, |
| 67 |
unsigned char *right_location, |
| 68 |
size_t right_length, |
| 69 |
int right_attr, |
| 70 |
int right_flags, |
| 71 |
int second_time_through); |
| 72 |
extern "C" void __gg__int128_to_field(cblc_field_t *tgt, |
| 73 |
__int128 value, |
| 74 |
int source_rdigits, |
| 75 |
enum cbl_round_t rounded, |
| 76 |
int *compute_error); |
| 77 |
extern "C" void __gg__float128_to_field(cblc_field_t *tgt, |
| 78 |
GCOB_FP128 value, |
| 79 |
enum cbl_round_t rounded, |
| 80 |
int *compute_error); |
| 81 |
extern "C" void __gg__int128_to_qualified_field(cblc_field_t *tgt, |
| 82 |
size_t offset, |
| 83 |
size_t length, |
| 84 |
__int128 value, |
| 85 |
int source_rdigits, |
| 86 |
enum cbl_round_t rounded, |
| 87 |
int *compute_error); |
| 88 |
extern "C" void __gg__float128_to_qualified_field(cblc_field_t *tgt, |
| 89 |
size_t tgt_offset, |
| 90 |
GCOB_FP128 value, |
| 91 |
enum cbl_round_t rounded, |
| 92 |
int *compute_error); |
| 93 |
extern "C" void __gg__double_to_target( cblc_field_t *tgt, |
| 94 |
double tgt_value, |
| 95 |
cbl_round_t rounded); |
| 96 |
extern "C" char __gg__get_decimal_separator(); |
| 97 |
extern "C" char __gg__get_decimal_point(); |
| 98 |
extern "C" char * __gg__get_default_currency_string(); |
| 99 |
|
| 100 |
struct cbl_timespec |
| 101 |
{ |
| 102 |
/* You keep using that word "portability". I do not think it means what |
| 103 |
you think it means. */ |
| 104 |
time_t tv_sec; // Seconds. |
| 105 |
long tv_nsec; // Nanoseconds. |
| 106 |
} ; |
| 107 |
|
| 108 |
extern "C" void __gg__clock_gettime(struct cbl_timespec *tp); |
| 109 |
|
| 110 |
extern "C" GCOB_FP128 __gg__float128_from_location( |
| 111 |
const cblc_field_t *var, |
| 112 |
const unsigned char *location); |
| 113 |
extern "C" void __gg__adjust_dest_size(cblc_field_t *dest, size_t ncount); |
| 114 |
|
| 115 |
extern "C" void __gg__realloc_if_necessary( char **dest, |
| 116 |
size_t *dest_size, |
| 117 |
size_t new_size); |
| 118 |
extern "C" void __gg__set_exception_file(const cblc_file_t *file); |
| 119 |
extern "C" void __gg__internal_to_console_in_place(char *loc, size_t length); |
| 120 |
extern "C" __int128 __gg__binary_value_from_qualified_field(int *rdigits, |
| 121 |
const cblc_field_t *var, |
| 122 |
size_t offset, |
| 123 |
size_t size); |
| 124 |
extern "C" GCOB_FP128 __gg__float128_from_qualified_field(const cblc_field_t *field, |
| 125 |
size_t offset, |
| 126 |
size_t size); |
| 127 |
extern "C" __int128 __gg__integer_from_qualified_field(cblc_field_t *var, |
| 128 |
size_t var_offset, |
| 129 |
size_t var_size); |
| 130 |
void __gg__abort(const char *msg); |
| 131 |
|
| 132 |
#endif |