From 132a3879a87b8dc52c7eff5fd04f4e779ce96c38 Mon Sep 17 00:00:00 2001 From: Philip Oetinger Date: Mon, 30 Oct 2023 16:11:58 +0100 Subject: [PATCH 1/9] Introduce ddsrt_abort This will consolidate abort calls. This will make it easy to override, change, or suppress the abort feature. Borrowing a bit of structure from Rust, the new `ddsrt_abort` was placed inside ddsrt::process. --- src/ddsrt/include/dds/ddsrt/process.h | 8 ++++++++ src/ddsrt/src/process/posix/process.c | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/ddsrt/include/dds/ddsrt/process.h b/src/ddsrt/include/dds/ddsrt/process.h index 8d4a1da7b7..2869a8a370 100644 --- a/src/ddsrt/include/dds/ddsrt/process.h +++ b/src/ddsrt/include/dds/ddsrt/process.h @@ -70,6 +70,14 @@ ddsrt_getpid(void); DDS_EXPORT char * ddsrt_getprocessname(void); +/** + * @brief Terminates the process in an abnormal fashion. + * + * Does not return. Immediately terminates the process. + */ +DDS_EXPORT void +ddsrt_abort(void); + #if defined (__cplusplus) } #endif diff --git a/src/ddsrt/src/process/posix/process.c b/src/ddsrt/src/process/posix/process.c index aebb278098..a44d6f4e35 100644 --- a/src/ddsrt/src/process/posix/process.c +++ b/src/ddsrt/src/process/posix/process.c @@ -84,3 +84,8 @@ ddsrt_getprocessname(void) } } +void +ddsrt_abort(void) +{ + abort(); +} From f46a9451b2e6626e8d316adc37e36dcdf116c380 Mon Sep 17 00:00:00 2001 From: Philip Oetinger Date: Mon, 30 Oct 2023 16:14:52 +0100 Subject: [PATCH 2/9] Replace `abort` with `ddsrt_abort` --- src/core/cdr/src/dds_cdrstream.c | 183 ++++++++++--------- src/core/ddsc/src/dds_builtin.c | 5 +- src/core/ddsc/src/dds_entity.c | 7 +- src/core/ddsc/src/dds_readcond.c | 3 +- src/core/ddsc/src/dds_reader.c | 3 +- src/core/ddsc/src/dds_serdata_builtintopic.c | 7 +- src/core/ddsc/src/dds_serdata_default.c | 5 +- src/core/ddsc/src/dds_sertype_default.c | 5 +- src/core/ddsi/src/ddsi_dynamic_type.c | 7 +- src/core/ddsi/src/ddsi_init.c | 2 +- src/core/ddsi/src/ddsi_ipaddr.c | 3 +- src/core/ddsi/src/ddsi_radmin.c | 7 +- src/core/ddsi/src/ddsi_security_omg.c | 3 +- src/core/ddsi/src/ddsi_serdata_cdr.c | 5 +- src/core/ddsi/src/ddsi_serdata_plist.c | 3 +- src/core/ddsi/src/ddsi_serdata_pserop.c | 5 +- src/core/ddsi/src/ddsi_sertype.c | 7 +- src/core/ddsi/src/ddsi_sockwaitset.c | 7 +- src/core/ddsi/src/ddsi_thread.c | 3 +- src/core/ddsi/src/ddsi_tran.c | 3 +- src/core/ddsi/src/ddsi_typebuilder.c | 9 +- src/core/ddsi/src/ddsi_typelib.c | 3 +- src/core/ddsi/src/ddsi_typewrap.c | 17 +- src/ddsrt/src/expand_vars.c | 2 +- src/ddsrt/src/heap/posix/heap.c | 7 +- src/ddsrt/src/log.c | 4 +- src/ddsrt/src/sync/posix/sync.c | 27 +-- 27 files changed, 184 insertions(+), 158 deletions(-) diff --git a/src/core/cdr/src/dds_cdrstream.c b/src/core/cdr/src/dds_cdrstream.c index 31873a807f..9198bea1e5 100644 --- a/src/core/cdr/src/dds_cdrstream.c +++ b/src/core/cdr/src/dds_cdrstream.c @@ -15,6 +15,7 @@ #include "dds/ddsrt/endian.h" #include "dds/ddsrt/md5.h" #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/string.h" #include "dds/ddsrt/static_assert.h" #include "dds/cdr/dds_cdrstream.h" @@ -488,7 +489,7 @@ static uint32_t get_collection_elem_size (uint32_t insn, const uint32_t * __rest case DDS_OP_VAL_EXT: break; } - abort (); + ddsrt_abort(); return 0u; } @@ -531,7 +532,7 @@ static uint32_t get_adr_type_size (uint32_t insn, const uint32_t * __restrict op case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: /* for UNI and STU members are externally defined, so are using EXT type */ - abort (); + ddsrt_abort(); break; } return sz; @@ -562,7 +563,7 @@ static uint32_t get_jeq4_type_size (const enum dds_stream_typecode valtype, cons sz = jeq_op[3]; break; case DDS_OP_VAL_EXT: - abort (); + ddsrt_abort(); break; } return sz; @@ -734,7 +735,7 @@ static const uint32_t *dds_stream_get_ops_info_seq (const uint32_t * __restrict break; } case DDS_OP_VAL_EXT: - abort (); // not allowed + ddsrt_abort(); // not allowed break; } if (ops > info->ops_end) @@ -777,7 +778,7 @@ static const uint32_t *dds_stream_get_ops_info_arr (const uint32_t * __restrict break; } case DDS_OP_VAL_EXT: - abort (); // not allowed + ddsrt_abort(); // not allowed break; } if (ops > info->ops_end) @@ -816,7 +817,7 @@ static const uint32_t *dds_stream_get_ops_info_uni (const uint32_t * __restrict dds_stream_get_ops_info1 (jeq_op + DDS_OP_ADR_JSR (jeq_op[0]), nestc + (valtype == DDS_OP_VAL_UNI || valtype == DDS_OP_VAL_STU ? 1 : 0), info); break; case DDS_OP_VAL_EXT: - abort (); // not allowed + ddsrt_abort(); // not allowed break; } jeq_op += (DDS_OP (jeq_op[0]) == DDS_OP_JEQ) ? 3 : 4; @@ -849,7 +850,7 @@ static const uint32_t *dds_stream_get_ops_info_pl (const uint32_t * __restrict o break; } default: - abort (); /* only list of (PLM, member-id) supported */ + ddsrt_abort(); /* only list of (PLM, member-id) supported */ break; } } @@ -929,7 +930,7 @@ static void dds_stream_get_ops_info1 (const uint32_t * __restrict ops, uint32_t break; } case DDS_OP_VAL_STU: - abort (); /* op type STU only supported as subtype */ + ddsrt_abort(); /* op type STU only supported as subtype */ break; } break; @@ -941,7 +942,7 @@ static void dds_stream_get_ops_info1 (const uint32_t * __restrict ops, uint32_t break; } case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: { - abort (); + ddsrt_abort(); break; } case DDS_OP_DLC: { @@ -1063,12 +1064,12 @@ static uint32_t read_union_discriminant (dds_istream_t * __restrict is, uint32_t case 1: return dds_is_get1 (is); case 2: return dds_is_get2 (is); case 4: return dds_is_get4 (is); - default: abort (); + default: ddsrt_abort(); } break; default: return 0; } - abort (); + ddsrt_abort(); return 0; } @@ -1120,7 +1121,7 @@ static const uint32_t *skip_sequence_insns (uint32_t insn, const uint32_t * __re return ops + (jmp ? jmp : 4 + bound_op); /* FIXME: why would jmp be 0? */ } case DDS_OP_VAL_EXT: { - abort (); /* not allowed */ + ddsrt_abort(); /* not allowed */ break; } } @@ -1144,7 +1145,7 @@ static const uint32_t *skip_array_insns (uint32_t insn, const uint32_t * __restr return ops + (jmp ? jmp : 5); } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -1189,7 +1190,7 @@ static const uint32_t *skip_array_default (uint32_t insn, char * __restrict data return ops + (jmp ? jmp : 5); } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -1256,7 +1257,7 @@ static const uint32_t * skip_union_default (uint32_t insn, char * __restrict dis (void) dds_stream_skip_default (valaddr, allocator, jeq_op + DDS_OP_ADR_JSR (jeq_op[0]), sample_state); break; case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -1290,10 +1291,10 @@ static uint32_t get_length_code_seq (const enum dds_stream_typecode subtype) /* not supported */ case DDS_OP_VAL_EXT: - abort (); + ddsrt_abort(); break; } - abort (); + ddsrt_abort(); return 0u; } @@ -1313,10 +1314,10 @@ static uint32_t get_length_code_arr (const enum dds_stream_typecode subtype) /* not supported */ case DDS_OP_VAL_EXT: - abort (); + ddsrt_abort(); break; } - abort (); + ddsrt_abort(); return 0u; } @@ -1348,18 +1349,18 @@ static uint32_t get_length_code (const uint32_t * __restrict ops) case DDS_OP_VAL_UNI: case DDS_OP_VAL_EXT: { return LENGTH_CODE_NEXTINT; /* FIXME: may be optimized for specific cases, e.g. when EXT type is appendable */ } - case DDS_OP_VAL_STU: abort (); break; /* op type STU only supported as subtype */ + case DDS_OP_VAL_STU: ddsrt_abort(); break; /* op type STU only supported as subtype */ } break; } case DDS_OP_JSR: return get_length_code (ops + DDS_OP_JUMP (insn)); case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; case DDS_OP_DLC: case DDS_OP_PLC: /* members of (final/appendable/mutable) aggregated types are included using ADR | EXT */ - abort(); + ddsrt_abort(); break; } return 0; @@ -1386,11 +1387,11 @@ static bool is_member_present (const char * __restrict data, const uint32_t * __ return is_member_present (data, ops + DDS_OP_JUMP (insn)); case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_DLC: case DDS_OP_PLC: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; } } - abort (); + ddsrt_abort(); return false; } @@ -1678,7 +1679,7 @@ static const uint32_t *dds_stream_read_seq (dds_istream_t * __restrict is, char return ops + (jmp ? jmp : (4 + bound_op)); /* FIXME: why would jmp be 0? */ } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -1716,7 +1717,7 @@ static const uint32_t *dds_stream_read_arr (dds_istream_t * __restrict is, char dds_is_get_bytes (is, addr, num, 4); break; default: - abort (); + ddsrt_abort(); } return ops + 4; } @@ -1747,7 +1748,7 @@ static const uint32_t *dds_stream_read_arr (dds_istream_t * __restrict is, char return ops + (jmp ? jmp : 5); } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -1779,7 +1780,7 @@ static const uint32_t *dds_stream_read_uni (dds_istream_t * __restrict is, char case 1: *((uint32_t *) valaddr) = dds_is_get1 (is); break; case 2: *((uint32_t *) valaddr) = dds_is_get2 (is); break; case 4: *((uint32_t *) valaddr) = dds_is_get4 (is); break; - default: abort (); + default: ddsrt_abort(); } break; case DDS_OP_VAL_STR: @@ -1794,7 +1795,7 @@ static const uint32_t *dds_stream_read_uni (dds_istream_t * __restrict is, char break; } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -1852,7 +1853,7 @@ static inline const uint32_t *dds_stream_read_adr (uint32_t insn, dds_istream_t case 1: *((uint32_t *) addr) = dds_is_get1 (is); break; case 2: *((uint32_t *) addr) = dds_is_get2 (is); break; case 4: *((uint32_t *) addr) = dds_is_get4 (is); break; - default: abort (); + default: ddsrt_abort(); } ops += 3; break; @@ -1864,7 +1865,7 @@ static inline const uint32_t *dds_stream_read_adr (uint32_t insn, dds_istream_t case 2: *((uint16_t *) addr) = dds_is_get2 (is); break; case 4: *((uint32_t *) addr) = dds_is_get4 (is); break; case 8: *((uint64_t *) addr) = dds_is_get8 (is); break; - default: abort (); + default: ddsrt_abort(); } ops += 4; break; @@ -1882,7 +1883,7 @@ static inline const uint32_t *dds_stream_read_adr (uint32_t insn, dds_istream_t ops += jmp ? jmp : 3; break; } - case DDS_OP_VAL_STU: abort(); break; /* op type STU only supported as subtype */ + case DDS_OP_VAL_STU: ddsrt_abort(); break; /* op type STU only supported as subtype */ } return ops; } @@ -1913,7 +1914,7 @@ static const uint32_t *dds_stream_skip_adr (uint32_t insn, const uint32_t * __re return ops + (jmp ? jmp : 3); } case DDS_OP_VAL_STU: { - abort(); /* op type STU only supported as subtype */ + ddsrt_abort(); /* op type STU only supported as subtype */ break; } } @@ -1949,7 +1950,7 @@ static const uint32_t *dds_stream_skip_adr_default (uint32_t insn, char * __rest case 2: *(uint16_t *) addr = 0; break; case 4: *(uint32_t *) addr = 0; break; case 8: *(uint64_t *) addr = 0; break; - default: abort (); + default: ddsrt_abort(); } return ops + 4; case DDS_OP_VAL_SEQ: case DDS_OP_VAL_BSQ: { @@ -1970,7 +1971,7 @@ static const uint32_t *dds_stream_skip_adr_default (uint32_t insn, char * __rest return ops + (jmp ? jmp : 3); } case DDS_OP_VAL_STU: { - abort(); /* op type STU only supported as subtype */ + ddsrt_abort(); /* op type STU only supported as subtype */ break; } } @@ -2000,7 +2001,7 @@ static void dds_stream_skip_pl_member_default (char * __restrict data, const str break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_DLC: case DDS_OP_PLC: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; } } @@ -2030,7 +2031,7 @@ static const uint32_t *dds_stream_skip_pl_memberlist_default (char * __restrict break; } default: - abort (); /* other ops not supported at this point */ + ddsrt_abort(); /* other ops not supported at this point */ break; } } @@ -2060,7 +2061,7 @@ static const uint32_t *dds_stream_skip_default (char * __restrict data, const st break; } case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; case DDS_OP_DLC: ops = dds_stream_skip_delimited_default (data, allocator, ops, sample_state); @@ -2092,7 +2093,7 @@ static const uint32_t *dds_stream_read_delimited (dds_istream_t * __restrict is, break; } case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_DLC: case DDS_OP_PLC: case DDS_OP_PLM: { - abort (); + ddsrt_abort(); break; } } @@ -2164,7 +2165,7 @@ static const uint32_t *dds_stream_read_pl (dds_istream_t * __restrict is, char * msz <<= (lc - 4); break; default: - abort (); + ddsrt_abort(); break; } @@ -2199,7 +2200,7 @@ static const uint32_t *dds_stream_read_impl (dds_istream_t * __restrict is, char ops++; break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; case DDS_OP_DLC: assert (is->m_xcdr_version == DDSI_RTPS_CDR_ENC_VERSION_2); @@ -2468,7 +2469,7 @@ static bool read_normalize_bitmask (uint64_t * __restrict val, char * __restrict return false; break; default: - abort (); + ddsrt_abort(); } if (!bitmask_value_valid (*val, bits_h, bits_l)) return normalize_error_bool (); @@ -2528,7 +2529,7 @@ static bool normalize_primarray (char * __restrict data, uint32_t * __restrict o *off += 8 * num; return true; default: - abort (); + ddsrt_abort(); break; } return false; @@ -2715,7 +2716,7 @@ static const uint32_t *normalize_seq (char * __restrict data, uint32_t * __restr } case DDS_OP_VAL_EXT: ops = NULL; - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } if (has_dheader && *off != size1) @@ -2773,7 +2774,7 @@ static const uint32_t *normalize_arr (char * __restrict data, uint32_t * __restr } case DDS_OP_VAL_EXT: ops = NULL; - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } if (has_dheader && *off != size1) @@ -2818,7 +2819,7 @@ static bool normalize_uni_disc (uint32_t * __restrict val, char * __restrict dat case DDS_OP_VAL_ENU: return read_normalize_enum (val, data, off, size, bswap, insn, ops[4]); default: - abort (); + ddsrt_abort(); } return false; } @@ -2848,7 +2849,7 @@ static const uint32_t *normalize_uni (char * __restrict data, uint32_t * __restr return NULL; break; case DDS_OP_VAL_EXT: - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -2902,7 +2903,7 @@ static const uint32_t *stream_normalize_adr (uint32_t insn, char * __restrict da break; } case DDS_OP_VAL_STU: - abort (); /* op type STU only supported as subtype */ + ddsrt_abort(); /* op type STU only supported as subtype */ break; } return ops; @@ -2939,7 +2940,7 @@ static const uint32_t *stream_normalize_delimited (char * __restrict data, uint3 ops++; break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_DLC: case DDS_OP_PLC: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; } } @@ -3051,7 +3052,7 @@ static const uint32_t *stream_normalize_pl (char * __restrict data, uint32_t * _ msz += 4; break; default: - abort (); + ddsrt_abort(); break; } // reject if fewer than msz bytes remain in declared size of the parameter list @@ -3107,7 +3108,7 @@ static const uint32_t *stream_normalize_data_impl (char * __restrict data, uint3 break; } case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: { - abort (); + ddsrt_abort(); break; } case DDS_OP_DLC: { @@ -3159,7 +3160,7 @@ static bool stream_normalize_key_impl (void * __restrict data, uint32_t size, ui break; } case DDS_OP_VAL_SEQ: case DDS_OP_VAL_BSQ: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: - abort (); + ddsrt_abort(); break; } return true; @@ -3199,7 +3200,7 @@ static bool stream_normalize_key (void * __restrict data, uint32_t size, bool bs break; } default: - abort (); + ddsrt_abort(); break; } } @@ -3270,7 +3271,7 @@ static const uint32_t *dds_stream_free_sample_seq (char * __restrict addr, const break; } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -3317,7 +3318,7 @@ static const uint32_t *dds_stream_free_sample_arr (char * __restrict addr, const break; } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -3332,7 +3333,7 @@ static const uint32_t *dds_stream_free_sample_uni (char * __restrict discaddr, c case DDS_OP_VAL_BLN: case DDS_OP_VAL_1BY: disc = *((uint8_t *) discaddr); break; case DDS_OP_VAL_2BY: disc = *((uint16_t *) discaddr); break; case DDS_OP_VAL_4BY: case DDS_OP_VAL_ENU: disc = *((uint32_t *) discaddr); break; - default: abort(); break; + default: ddsrt_abort(); break; } uint32_t const * const jeq_op = find_union_case (ops, disc); ops += DDS_OP_ADR_JMP (ops[3]); @@ -3361,7 +3362,7 @@ static const uint32_t *dds_stream_free_sample_uni (char * __restrict discaddr, c dds_stream_free_sample (valaddr, allocator, jeq_op + DDS_OP_ADR_JSR (jeq_op[0])); break; case DDS_OP_VAL_EXT: - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } @@ -3396,7 +3397,7 @@ static const uint32_t *dds_stream_free_sample_pl (char * __restrict addr, const break; } default: - abort (); /* other ops not supported at this point */ + ddsrt_abort(); /* other ops not supported at this point */ break; } } @@ -3429,7 +3430,7 @@ static const uint32_t *stream_free_sample_adr_nonexternal (uint32_t insn, void * break; } case DDS_OP_VAL_STU: - abort (); /* op type STU only supported as subtype */ + ddsrt_abort(); /* op type STU only supported as subtype */ break; } @@ -3477,7 +3478,7 @@ void dds_stream_free_sample (void * __restrict data, const struct dds_cdrstream_ ops++; break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; case DDS_OP_DLC: ops++; @@ -3515,7 +3516,7 @@ static void dds_stream_extract_key_from_key_prim_op (dds_istream_t * __restrict case 2: dds_os_put2 (os, allocator, dds_is_get2 (is)); break; case 4: dds_os_put4 (os, allocator, dds_is_get4 (is)); break; case 8: assert (DDS_OP_TYPE(insn) == DDS_OP_VAL_BMK); dds_os_put8 (os, allocator, dds_is_get8 (is)); break; - default: abort (); + default: ddsrt_abort(); } break; case DDS_OP_VAL_STR: case DDS_OP_VAL_BST: { @@ -3541,7 +3542,7 @@ static void dds_stream_extract_key_from_key_prim_op (dds_istream_t * __restrict else if (subtype == DDS_OP_VAL_ENU || subtype == DDS_OP_VAL_BMK) elem_size = DDS_OP_TYPE_SZ (insn); else - abort (); + ddsrt_abort(); const align_t cdr_align = dds_cdr_get_align (os->m_xcdr_version, elem_size); const uint32_t num = ops[2]; dds_cdr_alignto (is, cdr_align); @@ -3561,7 +3562,7 @@ static void dds_stream_extract_key_from_key_prim_op (dds_istream_t * __restrict break; } case DDS_OP_VAL_SEQ: case DDS_OP_VAL_BSQ: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: { - abort (); + ddsrt_abort(); break; } } @@ -3622,7 +3623,7 @@ static void dds_stream_extract_keyBE_from_key_prim_op (dds_istream_t * __restric case 2: dds_os_put2BE (os, allocator, dds_is_get2 (is)); break; case 4: dds_os_put4BE (os, allocator, dds_is_get4 (is)); break; case 8: assert (DDS_OP_TYPE (insn) == DDS_OP_VAL_BMK); dds_os_put8BE (os, allocator, dds_is_get8 (is)); break; - default: abort (); + default: ddsrt_abort(); } break; case DDS_OP_VAL_STR: case DDS_OP_VAL_BST: { @@ -3648,7 +3649,7 @@ static void dds_stream_extract_keyBE_from_key_prim_op (dds_istream_t * __restric else if (subtype == DDS_OP_VAL_ENU || subtype == DDS_OP_VAL_BMK) elem_size = DDS_OP_TYPE_SZ (insn); else - abort (); + ddsrt_abort(); const align_t cdr_align = dds_cdr_get_align (os->x.m_xcdr_version, elem_size); const uint32_t num = ops[2]; dds_cdr_alignto (is, cdr_align); @@ -3675,7 +3676,7 @@ static void dds_stream_extract_keyBE_from_key_prim_op (dds_istream_t * __restric break; } case DDS_OP_VAL_SEQ: case DDS_OP_VAL_BSQ: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: { - abort (); + ddsrt_abort(); break; } } @@ -3716,7 +3717,7 @@ static void dds_stream_extract_key_from_data_skip_subtype (dds_istream_t * __res break; } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -3802,7 +3803,7 @@ static const uint32_t *dds_stream_extract_key_from_data_skip_adr (dds_istream_t ops = dds_stream_extract_key_from_data_skip_union (is, ops); break; case DDS_OP_VAL_STU: - abort (); /* op type STU only supported as subtype */ + ddsrt_abort(); /* op type STU only supported as subtype */ break; } return ops; @@ -3852,7 +3853,7 @@ static void dds_stream_read_key_impl (dds_istream_t * __restrict is, char * __re case 1: *((uint32_t *) dst) = dds_is_get1 (is); break; case 2: *((uint32_t *) dst) = dds_is_get2 (is); break; case 4: *((uint32_t *) dst) = dds_is_get4 (is); break; - default: abort (); + default: ddsrt_abort(); } break; case DDS_OP_VAL_BMK: @@ -3862,7 +3863,7 @@ static void dds_stream_read_key_impl (dds_istream_t * __restrict is, char * __re case 2: *((uint16_t *) dst) = dds_is_get2 (is); break; case 4: *((uint32_t *) dst) = dds_is_get4 (is); break; case 8: *((uint64_t *) dst) = dds_is_get8 (is); break; - default: abort (); + default: ddsrt_abort(); } break; case DDS_OP_VAL_STR: *((char **) dst) = dds_stream_reuse_string (is, *((char **) dst), allocator, sample_state); break; @@ -3900,11 +3901,11 @@ static void dds_stream_read_key_impl (dds_istream_t * __restrict is, char * __re break; } default: - abort (); + ddsrt_abort(); } break; } - case DDS_OP_VAL_SEQ: case DDS_OP_VAL_BSQ: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: abort (); break; + case DDS_OP_VAL_SEQ: case DDS_OP_VAL_BSQ: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: ddsrt_abort(); break; case DDS_OP_VAL_EXT: { assert (key_offset_count > 0); @@ -3943,7 +3944,7 @@ void dds_stream_read_key (dds_istream_t * __restrict is, char * __restrict sampl break; } default: - abort (); + ddsrt_abort(); break; } } @@ -4059,7 +4060,7 @@ static bool prtf_enum_bitmask (char * __restrict *buf, size_t * __restrict bufsi return prtf (buf, bufsize, "%"PRIu64, val); } default: - abort (); + ddsrt_abort(); } return false; } @@ -4108,7 +4109,7 @@ static bool prtf_simple (char * __restrict *buf, size_t * __restrict bufsize, dd return prtf_enum_bitmask (buf, bufsize, is, flags); case DDS_OP_VAL_STR: case DDS_OP_VAL_BST: return prtf_str (buf, bufsize, is); case DDS_OP_VAL_ARR: case DDS_OP_VAL_SEQ: case DDS_OP_VAL_BSQ: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: case DDS_OP_VAL_EXT: - abort (); + ddsrt_abort(); } return false; } @@ -4160,7 +4161,7 @@ static bool prtf_simple_array (char * __restrict *buf, size_t * __restrict bufsi } break; default: - abort (); + ddsrt_abort(); break; } return prtf (buf, bufsize, "}"); @@ -4209,7 +4210,7 @@ static const uint32_t *prtf_seq (char * __restrict *buf, size_t *bufsize, dds_is return ops + (jmp ? jmp : (4 + bound_op)); /* FIXME: why would jmp be 0? */ } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -4247,7 +4248,7 @@ static const uint32_t *prtf_arr (char * __restrict *buf, size_t *bufsize, dds_is return ops + (jmp ? jmp : 5); } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -4273,7 +4274,7 @@ static const uint32_t *prtf_uni (char * __restrict *buf, size_t *bufsize, dds_is (void) dds_stream_print_sample1 (buf, bufsize, is, jeq_op + DDS_OP_ADR_JSR (jeq_op[0]), valtype == DDS_OP_VAL_STU, false, cdr_kind); break; case DDS_OP_VAL_EXT: { - abort (); /* not supported, use UNI instead */ + ddsrt_abort(); /* not supported, use UNI instead */ break; } } @@ -4326,7 +4327,7 @@ static const uint32_t * dds_stream_print_adr (char * __restrict *buf, size_t * _ break; } case DDS_OP_VAL_STU: - abort (); /* op type STU only supported as subtype */ + ddsrt_abort(); /* op type STU only supported as subtype */ break; } return ops; @@ -4357,7 +4358,7 @@ static const uint32_t *prtf_delimited (char * __restrict *buf, size_t *bufsize, ops++; break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_DLC: case DDS_OP_PLC: case DDS_OP_PLM: { - abort (); + ddsrt_abort(); break; } } @@ -4424,7 +4425,7 @@ static const uint32_t *prtf_pl (char * __restrict *buf, size_t *bufsize, dds_ist msz <<= (lc - 4); break; default: - abort (); + ddsrt_abort(); break; } @@ -4466,7 +4467,7 @@ static const uint32_t * dds_stream_print_sample1 (char * __restrict *buf, size_t ops++; break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; case DDS_OP_DLC: assert (is->m_xcdr_version == DDSI_RTPS_CDR_ENC_VERSION_2); @@ -4539,7 +4540,7 @@ bool dds_stream_extensibility (const uint32_t * __restrict ops, enum dds_cdr_typ *ext = DDS_CDR_TYPE_EXT_MUTABLE; return true; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; } } @@ -4660,7 +4661,7 @@ static const uint32_t *dds_stream_key_size_arr (const uint32_t * __restrict ops, return ops + (jmp ? jmp : 5); } case DDS_OP_VAL_EXT: { - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -4729,7 +4730,7 @@ static const uint32_t *dds_stream_key_size_adr (const uint32_t * __restrict ops, ops += jmp ? jmp : 3; break; } - case DDS_OP_VAL_STU: abort(); break; /* op type STU only supported as subtype */ + case DDS_OP_VAL_STU: ddsrt_abort(); break; /* op type STU only supported as subtype */ } return ops; } @@ -4757,7 +4758,7 @@ static const uint32_t *dds_stream_key_size_delimited (const uint32_t * __restric break; } case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_DLC: case DDS_OP_PLC: case DDS_OP_PLM: { - abort (); + ddsrt_abort(); break; } } @@ -4806,7 +4807,7 @@ static const uint32_t *dds_stream_key_size_pl_memberlist (const uint32_t * __res break; } default: - abort (); /* other ops not supported at this point */ + ddsrt_abort(); /* other ops not supported at this point */ break; } } @@ -4844,7 +4845,7 @@ static void dds_stream_key_size_prim_op (const uint32_t * __restrict ops, uint16 dds_stream_key_size_prim_op (jsr_ops, --key_offset_count, ++key_offset_insn, k); break; } - case DDS_OP_VAL_STU: abort(); break; /* op type STU only supported as subtype */ + case DDS_OP_VAL_STU: ddsrt_abort(); break; /* op type STU only supported as subtype */ } } @@ -4869,7 +4870,7 @@ static void dds_stream_key_size_keyhash (struct dds_cdrstream_desc *desc, struct break; } default: - abort (); + ddsrt_abort(); break; } } @@ -4890,7 +4891,7 @@ static const uint32_t *dds_stream_key_size (const uint32_t * __restrict ops, str ops++; break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: - abort (); + ddsrt_abort(); break; case DDS_OP_DLC: k->is_appendable = true; diff --git a/src/core/ddsc/src/dds_builtin.c b/src/core/ddsc/src/dds_builtin.c index c39abeb56a..c32dd049bf 100644 --- a/src/core/ddsc/src/dds_builtin.c +++ b/src/core/ddsc/src/dds_builtin.c @@ -11,6 +11,7 @@ #include #include #include "dds/ddsrt/string.h" +#include "dds/ddsrt/process.h" #include "dds/ddsi/ddsi_entity.h" #include "dds/ddsi/ddsi_topic.h" #include "dds/ddsi/ddsi_endpoint.h" @@ -282,7 +283,7 @@ struct ddsi_serdata *dds__builtin_make_sample_endpoint (const struct ddsi_entity type = dom->builtin_reader_type; break; default: - abort (); + ddsrt_abort(); break; } assert (type != NULL); @@ -344,7 +345,7 @@ static void dds__builtin_write_endpoint (const struct ddsi_entity_common *e, dds bwr = dom->builtintopic_writer_subscriptions; break; default: - abort (); + ddsrt_abort(); break; } dds_writecdr_local_orphan_impl (bwr, serdata); diff --git a/src/core/ddsc/src/dds_entity.c b/src/core/ddsc/src/dds_entity.c index 4abc8e254e..39437d4ce9 100644 --- a/src/core/ddsc/src/dds_entity.c +++ b/src/core/ddsc/src/dds_entity.c @@ -13,6 +13,7 @@ #include "dds/ddsrt/heap.h" #include "dds/ddsrt/log.h" +#include "dds/ddsrt/process.h" #include "dds__entity.h" #include "dds__write.h" #include "dds__writer.h" @@ -162,7 +163,7 @@ static bool entity_has_status (const dds_entity *e) case DDS_KIND_CYCLONEDDS: break; case DDS_KIND_DONTCARE: - abort (); + ddsrt_abort(); break; } return false; @@ -187,7 +188,7 @@ static bool entity_may_have_children (const dds_entity *e) case DDS_KIND_CYCLONEDDS: break; case DDS_KIND_DONTCARE: - abort (); + ddsrt_abort(); break; } return true; @@ -213,7 +214,7 @@ static bool entity_kind_has_qos (dds_entity_kind_t kind) case DDS_KIND_CYCLONEDDS: break; case DDS_KIND_DONTCARE: - abort (); + ddsrt_abort(); break; } return false; diff --git a/src/core/ddsc/src/dds_readcond.c b/src/core/ddsc/src/dds_readcond.c index adff35724b..64fc637b37 100644 --- a/src/core/ddsc/src/dds_readcond.c +++ b/src/core/ddsc/src/dds_readcond.c @@ -17,6 +17,7 @@ #include "dds/ddsi/ddsi_entity_index.h" #include "dds/ddsi/ddsi_entity.h" #include "dds/ddsi/ddsi_thread.h" +#include "dds/ddsrt/process.h" static void dds_readcond_close (dds_entity *e) ddsrt_nonnull_all; @@ -60,7 +61,7 @@ dds_readcond *dds_create_readcond_impl (dds_reader *rd, dds_entity_kind_t kind, { /* FIXME: current entity management code can't deal with an error late in the creation of the entity because it doesn't allow deleting it again ... */ - abort(); + ddsrt_abort(); } return cond; } diff --git a/src/core/ddsc/src/dds_reader.c b/src/core/ddsc/src/dds_reader.c index 80b4567ad9..5476d54dc2 100644 --- a/src/core/ddsc/src/dds_reader.c +++ b/src/core/ddsc/src/dds_reader.c @@ -15,6 +15,7 @@ #include "dds/ddsrt/static_assert.h" #include "dds/ddsrt/io.h" #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsi/ddsi_entity.h" #include "dds/ddsi/ddsi_endpoint.h" #include "dds/ddsi/ddsi_thread.h" @@ -632,7 +633,7 @@ static dds_entity_t dds_create_reader_int (dds_entity_t participant_or_subscribe if (dds_rhc_associate (rd->m_rhc, rd, tp->m_stype, rd->m_entity.m_domain->gv.m_tkmap) < 0) { /* FIXME: see also create_querycond, need to be able to undo entity_init */ - abort (); + ddsrt_abort(); } dds_entity_add_ref_locked (&tp->m_entity); diff --git a/src/core/ddsc/src/dds_serdata_builtintopic.c b/src/core/ddsc/src/dds_serdata_builtintopic.c index 303183f49d..6138a9ad12 100644 --- a/src/core/ddsc/src/dds_serdata_builtintopic.c +++ b/src/core/ddsc/src/dds_serdata_builtintopic.c @@ -16,6 +16,7 @@ #include "dds/ddsrt/string.h" #include "dds/ddsrt/heap.h" #include "dds/ddsrt/md5.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/hopscotch.h" #include "dds/ddsi/ddsi_xqos.h" @@ -97,7 +98,7 @@ static size_t serdata_builtin_sizeof(enum ddsi_sertype_builtintopic_entity_kind case DSBT_WRITER: return sizeof (struct ddsi_serdata_builtintopic_endpoint); } - abort (); + ddsrt_abort(); return 0; } @@ -244,7 +245,7 @@ struct ddsi_serdata *dds_serdata_builtin_from_endpoint (const struct ddsi_sertyp from_entity_proxy_wr ((struct ddsi_serdata_builtintopic_endpoint *) d, (const struct ddsi_proxy_writer *) entity); break; case DDSI_EK_TOPIC: - abort (); + ddsrt_abort(); break; } ddsrt_mutex_unlock (&entity->qos_lock); @@ -375,7 +376,7 @@ static bool serdata_builtin_untyped_to_sample (const struct ddsi_sertype *type, { const struct ddsi_serdata_builtintopic *d = (const struct ddsi_serdata_builtintopic *)serdata_common; const struct ddsi_sertype_builtintopic *tp = (const struct ddsi_sertype_builtintopic *)type; - if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ + if (bufptr) ddsrt_abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ /* FIXME: completing builtin topic support along these lines requires subscribers, publishers and topics to also become DDSI entities - which is probably a good thing anyway */ switch (tp->entity_kind) { diff --git a/src/core/ddsc/src/dds_serdata_default.c b/src/core/ddsc/src/dds_serdata_default.c index 161305907c..717619a984 100644 --- a/src/core/ddsc/src/dds_serdata_default.c +++ b/src/core/ddsc/src/dds_serdata_default.c @@ -17,6 +17,7 @@ #include "dds/ddsrt/log.h" #include "dds/ddsrt/md5.h" #include "dds/ddsrt/mh3.h" +#include "dds/ddsrt/process.h" #include "dds/ddsi/ddsi_freelist.h" #include "dds/ddsi/ddsi_tkmap.h" #include "dds/cdr/dds_cdrstream.h" @@ -713,7 +714,7 @@ static bool serdata_default_to_sample_cdr (const struct ddsi_serdata *serdata_co const struct dds_serdata_default *d = (const struct dds_serdata_default *)serdata_common; const struct dds_sertype_default *tp = (const struct dds_sertype_default *) d->c.type; dds_istream_t is; - if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ + if (bufptr) ddsrt_abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ if (d->c.loan != NULL && (d->c.loan->metadata->sample_state == DDS_LOANED_SAMPLE_STATE_RAW_DATA || d->c.loan->metadata->sample_state == DDS_LOANED_SAMPLE_STATE_RAW_KEY)) @@ -742,7 +743,7 @@ static bool serdata_default_untyped_to_sample_cdr (const struct ddsi_sertype *se assert (d->c.kind == SDK_KEY); assert (d->c.ops == sertype_common->serdata_ops); assert (DDSI_RTPS_CDR_ENC_IS_NATIVE (d->hdr.identifier)); - if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ + if (bufptr) ddsrt_abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ dds_istream_init (&is, d->key.keysize, serdata_default_keybuf (d), DDSI_RTPS_CDR_ENC_VERSION_2); dds_stream_read_key (&is, sample, &dds_cdrstream_default_allocator, &tp->type); return true; /* FIXME: can't conversion to sample fail? */ diff --git a/src/core/ddsc/src/dds_sertype_default.c b/src/core/ddsc/src/dds_sertype_default.c index 1fb8ad1391..f3d8e1224f 100644 --- a/src/core/ddsc/src/dds_sertype_default.c +++ b/src/core/ddsc/src/dds_sertype_default.c @@ -17,6 +17,7 @@ #include "dds/ddsrt/md5.h" #include "dds/ddsrt/mh3.h" #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/string.h" #include "dds/ddsi/ddsi_domaingv.h" #include "dds/ddsi/ddsi_freelist.h" @@ -197,7 +198,7 @@ static struct ddsi_sertype * sertype_default_derive_sertype (const struct ddsi_s else if (data_representation == DDS_DATA_REPRESENTATION_XCDR2) required_ops = base_sertype->has_key ? &dds_serdata_ops_xcdr2 : &dds_serdata_ops_xcdr2_nokey; else - abort (); + ddsrt_abort(); if (base_sertype->serdata_ops == required_ops) derived_sertype = (struct dds_sertype_default *) base_sertype_default; @@ -285,7 +286,7 @@ dds_return_t dds_sertype_default_init (const struct dds_domain *domain, struct d serdata_ops = desc->m_nkeys ? &dds_serdata_ops_xcdr2 : &dds_serdata_ops_xcdr2_nokey; break; default: - abort (); + ddsrt_abort(); } /* Get the extensility of the outermost object in the type used for the topic. Note that the diff --git a/src/core/ddsi/src/ddsi_dynamic_type.c b/src/core/ddsi/src/ddsi_dynamic_type.c index 8240ed299a..e746de221f 100644 --- a/src/core/ddsi/src/ddsi_dynamic_type.c +++ b/src/core/ddsi/src/ddsi_dynamic_type.c @@ -13,6 +13,7 @@ #include "dds/dds.h" #include "dds/ddsrt/heap.h" #include "dds/ddsrt/md5.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/string.h" #include "dds/ddsi/ddsi_entity.h" #include "dds/ddsi/ddsi_typelib.h" @@ -357,7 +358,7 @@ static dds_return_t set_type_flags (struct ddsi_type *type, uint16_t flag, uint1 type->xt._u.union_type.flags = (type->xt._u.union_type.flags & (uint16_t) ~mask) | flag; break; default: - abort (); + ddsrt_abort(); } return ret; } @@ -376,7 +377,7 @@ dds_return_t ddsi_dynamic_type_set_extensibility (struct ddsi_type *type, enum d else if (extensibility == DDS_DYNAMIC_TYPE_EXT_MUTABLE) flag = DDS_XTypes_IS_MUTABLE; else - abort (); + ddsrt_abort(); return set_type_flags (type, flag, DDS_DYNAMIC_TYPE_EXT_FINAL | DDS_DYNAMIC_TYPE_EXT_APPENDABLE | DDS_DYNAMIC_TYPE_EXT_MUTABLE); } @@ -421,7 +422,7 @@ dds_return_t ddsi_dynamic_type_set_bitbound (struct ddsi_type *type, uint16_t bi } break; default: - abort (); + ddsrt_abort(); } return ret; } diff --git a/src/core/ddsi/src/ddsi_init.c b/src/core/ddsi/src/ddsi_init.c index d662e8b469..7bca985136 100644 --- a/src/core/ddsi/src/ddsi_init.c +++ b/src/core/ddsi/src/ddsi_init.c @@ -757,7 +757,7 @@ static void wait_for_receive_threads_helper (struct ddsi_domaingv *gv, struct dd struct wait_for_receive_threads_helper_arg * const arg = varg; (void) xp; if (arg->count++ == gv->config.recv_thread_stop_maxretries) - abort (); + ddsrt_abort(); ddsi_trigger_recv_threads (gv); (void) ddsi_resched_xevent_if_earlier (xev, ddsrt_mtime_add_duration (tnow, DDS_SECS (1))); } diff --git a/src/core/ddsi/src/ddsi_ipaddr.c b/src/core/ddsi/src/ddsi_ipaddr.c index 16e4321e9b..d0679dd8fb 100644 --- a/src/core/ddsi/src/ddsi_ipaddr.c +++ b/src/core/ddsi/src/ddsi_ipaddr.c @@ -15,6 +15,7 @@ #include "dds/ddsrt/heap.h" #include "dds/ddsrt/log.h" #include "dds/ddsrt/bits.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/sockets.h" #include "dds/ddsrt/string.h" #include "dds/ddsi/ddsi_domaingv.h" @@ -255,7 +256,7 @@ enum ddsi_locator_from_string_result ddsi_ipaddr_from_string (ddsi_locator_t *lo struct sockaddr_in6 *x = (struct sockaddr_in6 *) &tmpaddr; x->sin6_port = htons (port); #else - abort (); + ddsrt_abort(); #endif } ddsi_ipaddr_to_loc (loc, (struct sockaddr *)&tmpaddr, kind); diff --git a/src/core/ddsi/src/ddsi_radmin.c b/src/core/ddsi/src/ddsi_radmin.c index 2ad8d8500f..d89d857a5a 100644 --- a/src/core/ddsi/src/ddsi_radmin.c +++ b/src/core/ddsi/src/ddsi_radmin.c @@ -22,6 +22,7 @@ #endif #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/threads.h" #include "dds/ddsrt/sync.h" #include "dds/ddsrt/string.h" @@ -740,7 +741,7 @@ static void ddsi_rdata_addbias (struct ddsi_rdata *rdata) #ifndef NDEBUG ASSERT_RBUFPOOL_OWNER (rmsg->chunk.rbuf->rbufpool); if (ddsrt_atomic_inc32_nv (&rdata->refcount_bias_added) != 1) - abort (); + ddsrt_abort(); #endif ddsi_rmsg_addbias (rmsg); } @@ -751,7 +752,7 @@ static void ddsi_rdata_rmbias_and_adjust (struct ddsi_rdata *rdata, int adjust) RMSGTRACE ("rdata_rmbias_and_adjust(%p, %d)\n", (void *) rdata, adjust); #ifndef NDEBUG if (ddsrt_atomic_dec32_ov (&rdata->refcount_bias_added) != 1) - abort (); + ddsrt_abort(); #endif ddsi_rmsg_rmbias_and_adjust (rmsg, adjust); } @@ -2574,7 +2575,7 @@ static uint32_t dqueue_thread (struct ddsi_dqueue *q) switch (b->kind) { case DDSI_DQBK_STOP: - abort (); + ddsrt_abort(); case DDSI_DQBK_CALLBACK: b->u.cb.cb (b->u.cb.arg); break; diff --git a/src/core/ddsi/src/ddsi_security_omg.c b/src/core/ddsi/src/ddsi_security_omg.c index 8caed00795..3556aee323 100644 --- a/src/core/ddsi/src/ddsi_security_omg.c +++ b/src/core/ddsi/src/ddsi_security_omg.c @@ -19,6 +19,7 @@ #include "dds/ddsrt/string.h" #include "dds/ddsrt/misc.h" #include "dds/ddsrt/avl.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/sync.h" #include "dds/ddsrt/hopscotch.h" #include "dds/ddsi/ddsi_domaingv.h" @@ -1727,7 +1728,7 @@ unsigned ddsi_determine_publication_writer (const struct ddsi_writer *wr) unsigned ddsi_determine_topic_writer (const struct ddsi_topic *tp) { if (ddsi_omg_participant_is_discovery_protected (tp->pp)) - abort (); /* FIXME: not implemented */ + ddsrt_abort(); /* FIXME: not implemented */ return DDSI_ENTITYID_SEDP_BUILTIN_TOPIC_WRITER; } #endif diff --git a/src/core/ddsi/src/ddsi_serdata_cdr.c b/src/core/ddsi/src/ddsi_serdata_cdr.c index e809130057..aeccb74b5f 100644 --- a/src/core/ddsi/src/ddsi_serdata_cdr.c +++ b/src/core/ddsi/src/ddsi_serdata_cdr.c @@ -17,6 +17,7 @@ #include "dds/ddsrt/log.h" #include "dds/ddsrt/md5.h" #include "dds/ddsrt/mh3.h" +#include "dds/ddsrt/process.h" #include "dds/ddsi/ddsi_freelist.h" #include "dds/ddsi/ddsi_tkmap.h" #include "dds/ddsi/ddsi_domaingv.h" @@ -250,7 +251,7 @@ static struct ddsi_serdata_cdr *serdata_cdr_from_sample_cdr_common (const struct ostream_add_to_serdata_cdr (&os, &d); break; case SDK_KEY: - abort (); + ddsrt_abort(); break; case SDK_DATA: if (!dds_stream_write_sample (&os, &dds_cdrstream_default_allocator, sample, &tp->type)) @@ -314,7 +315,7 @@ static bool serdata_cdr_to_sample_cdr (const struct ddsi_serdata *serdata_common const struct ddsi_serdata_cdr *d = (const struct ddsi_serdata_cdr *)serdata_common; const struct ddsi_sertype_cdr *tp = (const struct ddsi_sertype_cdr *) d->c.type; dds_istream_t is; - if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ + if (bufptr) ddsrt_abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ assert (DDSI_RTPS_CDR_ENC_IS_NATIVE (d->hdr.identifier)); istream_from_serdata_cdr(&is, d); dds_stream_read_sample (&is, sample, &dds_cdrstream_default_allocator, &tp->type); diff --git a/src/core/ddsi/src/ddsi_serdata_plist.c b/src/core/ddsi/src/ddsi_serdata_plist.c index 911618b5f5..ab6551d966 100644 --- a/src/core/ddsi/src/ddsi_serdata_plist.c +++ b/src/core/ddsi/src/ddsi_serdata_plist.c @@ -17,6 +17,7 @@ #include "dds/ddsrt/log.h" #include "dds/ddsrt/md5.h" #include "dds/ddsrt/mh3.h" +#include "dds/ddsrt/process.h" #include "dds/ddsi/ddsi_freelist.h" #include "dds/ddsi/ddsi_tkmap.h" #include "dds/ddsi/ddsi_domaingv.h" @@ -184,7 +185,7 @@ static bool serdata_plist_untyped_to_sample (const struct ddsi_sertype *tpcmn, c const struct ddsi_serdata_plist *d = (const struct ddsi_serdata_plist *)serdata_common; const struct ddsi_sertype_plist *tp = (const struct ddsi_sertype_plist *)tpcmn; struct ddsi_domaingv * const gv = ddsrt_atomic_ldvoidp (&tp->c.gv); - if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ + if (bufptr) ddsrt_abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ ddsi_plist_src_t src = { .buf = (const unsigned char *) d->data, .bufsz = d->pos, diff --git a/src/core/ddsi/src/ddsi_serdata_pserop.c b/src/core/ddsi/src/ddsi_serdata_pserop.c index 1241e66feb..46dfc1af5c 100644 --- a/src/core/ddsi/src/ddsi_serdata_pserop.c +++ b/src/core/ddsi/src/ddsi_serdata_pserop.c @@ -17,6 +17,7 @@ #include "dds/ddsrt/log.h" #include "dds/ddsrt/md5.h" #include "dds/ddsrt/mh3.h" +#include "dds/ddsrt/process.h" #include "dds/ddsi/ddsi_freelist.h" #include "dds/ddsi/ddsi_tkmap.h" #include "dds/ddsi/ddsi_domaingv.h" @@ -169,7 +170,7 @@ static bool serdata_pserop_to_sample (const struct ddsi_serdata *serdata_common, { const struct ddsi_serdata_pserop *d = (const struct ddsi_serdata_pserop *)serdata_common; const struct ddsi_sertype_pserop *tp = (const struct ddsi_sertype_pserop *) d->c.type; - if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ + if (bufptr) ddsrt_abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ if (d->c.kind == SDK_KEY) memcpy (sample, d->sample, 16); else @@ -251,7 +252,7 @@ static bool serdata_pserop_untyped_to_sample (const struct ddsi_sertype *type_co { const struct ddsi_serdata_pserop *d = (const struct ddsi_serdata_pserop *)serdata_common; const struct ddsi_sertype_pserop *tp = (const struct ddsi_sertype_pserop *)type_common; - if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ + if (bufptr) ddsrt_abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ if (tp->ops_key) memcpy (sample, d->sample, 16); return true; diff --git a/src/core/ddsi/src/ddsi_sertype.c b/src/core/ddsi/src/ddsi_sertype.c index 29ac6d9bb7..0bf64abd4f 100644 --- a/src/core/ddsi/src/ddsi_sertype.c +++ b/src/core/ddsi/src/ddsi_sertype.c @@ -17,6 +17,7 @@ #include "dds/ddsrt/md5.h" #include "dds/ddsrt/mh3.h" #include "dds/ddsrt/hopscotch.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/string.h" #include "dds/ddsi/ddsi_freelist.h" #include "dds/ddsi/ddsi_iid.h" @@ -244,7 +245,7 @@ uint16_t ddsi_sertype_get_native_enc_identifier (uint32_t enc_version, uint32_t return CONCAT(DDSI_RTPS_D_CDR2, SUFFIX); return CONCAT(DDSI_RTPS_CDR2, SUFFIX); default: - abort (); /* unsupported */ + ddsrt_abort(); /* unsupported */ } #undef SUFFIX #undef CONCAT @@ -262,7 +263,7 @@ uint16_t ddsi_sertype_extensibility_enc_format (enum dds_cdr_type_extensibility case DDS_CDR_TYPE_EXT_MUTABLE: return DDSI_RTPS_CDR_ENC_FORMAT_PL; default: - abort (); + ddsrt_abort(); } } @@ -293,7 +294,7 @@ uint32_t ddsi_sertype_enc_id_enc_format (uint16_t cdr_identifier) case DDSI_RTPS_PL_CDR2_LE: case DDSI_RTPS_PL_CDR2_BE: return DDSI_RTPS_CDR_ENC_FORMAT_PL; default: - abort (); + ddsrt_abort(); } } diff --git a/src/core/ddsi/src/ddsi_sockwaitset.c b/src/core/ddsi/src/ddsi_sockwaitset.c index a430799b74..05040199b2 100644 --- a/src/core/ddsi/src/ddsi_sockwaitset.c +++ b/src/core/ddsi/src/ddsi_sockwaitset.c @@ -13,6 +13,7 @@ #include #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/sockets.h" #include "dds/ddsrt/sync.h" @@ -195,13 +196,13 @@ void ddsi_sock_waitset_purge (struct ddsi_sock_waitset * ws, unsigned index) sz = ddsrt_atomic_ld32 (&ws->sz); close (ws->kqueue); if ((ws->kqueue = kqueue()) == -1) - abort (); /* FIXME */ + ddsrt_abort(); /* FIXME */ for (i = 0; i <= index; i++) { assert (ws->entries[i].fd >= 0); EV_SET(&kev, (unsigned)ws->entries[i].fd, EVFILT_READ, EV_ADD, 0, 0, &ws->entries[i]); if (kevent(ws->kqueue, &kev, 1, NULL, 0, NULL) == -1) - abort (); /* FIXME */ + ddsrt_abort(); /* FIXME */ } for (; i < sz; i++) { @@ -226,7 +227,7 @@ void ddsi_sock_waitset_remove (struct ddsi_sock_waitset * ws, struct ddsi_tran_c struct kevent kev; EV_SET(&kev, (unsigned)ws->entries[i].fd, EVFILT_READ, EV_DELETE, 0, 0, 0); if (kevent(ws->kqueue, &kev, 1, NULL, 0, NULL) == -1) - abort (); /* FIXME */ + ddsrt_abort(); /* FIXME */ ws->entries[i].fd = -1; } ddsrt_mutex_unlock (&ws->lock); diff --git a/src/core/ddsi/src/ddsi_thread.c b/src/core/ddsi/src/ddsi_thread.c index 5f9b0e3bf2..b24907de13 100644 --- a/src/core/ddsi/src/ddsi_thread.c +++ b/src/core/ddsi/src/ddsi_thread.c @@ -15,6 +15,7 @@ #include "dds/ddsrt/cdtors.h" #include "dds/ddsrt/heap.h" #include "dds/ddsrt/log.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/string.h" #include "dds/ddsrt/sync.h" #include "dds/ddsrt/threads.h" @@ -351,7 +352,7 @@ static dds_return_t create_thread_int (struct ddsi_thread_state **ts1_out, const fatal: ddsrt_mutex_unlock (&thread_states.lock); *ts1_out = NULL; - abort (); + ddsrt_abort(); return DDS_RETCODE_ERROR; } diff --git a/src/core/ddsi/src/ddsi_tran.c b/src/core/ddsi/src/ddsi_tran.c index 52de6b88e6..d5dc59c9e5 100644 --- a/src/core/ddsi/src/ddsi_tran.c +++ b/src/core/ddsi/src/ddsi_tran.c @@ -14,6 +14,7 @@ #include #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/string.h" #include "dds/ddsrt/ifaddrs.h" #include "dds/ddsi/ddsi_log.h" @@ -147,7 +148,7 @@ void ddsi_conn_free (struct ddsi_tran_conn * conn) break; case DDSI_RTM_SINGLE: if (conn->m_base.gv->recv_threads[i].arg.u.single.conn == conn) - abort(); + ddsrt_abort(); break; } } diff --git a/src/core/ddsi/src/ddsi_typebuilder.c b/src/core/ddsi/src/ddsi_typebuilder.c index 57fd733e9d..4df0eea211 100644 --- a/src/core/ddsi/src/ddsi_typebuilder.c +++ b/src/core/ddsi/src/ddsi_typebuilder.c @@ -12,6 +12,7 @@ #include #include "dds/features.h" #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/string.h" #include "dds/ddsi/ddsi_domaingv.h" #include "dds/ddsi/ddsi_serdata.h" @@ -1242,7 +1243,7 @@ static dds_return_t get_ops_aggrtype (struct typebuilder_aggregated_type *tb_agg } break; default: - abort (); + ddsrt_abort(); } // mutable types have an RTS instruction per member @@ -1373,7 +1374,7 @@ static dds_return_t resolve_ops_offsets_aggrtype (const struct typebuilder_aggre ret = resolve_ops_offsets_union (&tb_aggrtype->detail._union, ops); break; default: - abort (); + ddsrt_abort(); } return ret; } @@ -1486,7 +1487,7 @@ static dds_return_t get_keys_aggrtype (struct typebuilder_data *tbd, struct type ret = DDS_RETCODE_OK; break; default: - abort (); + ddsrt_abort(); } return ret; } @@ -1671,7 +1672,7 @@ static dds_return_t set_implicit_keys_aggrtype (struct typebuilder_aggregated_ty ret = DDS_RETCODE_OK; break; default: - abort (); + ddsrt_abort(); } return ret; } diff --git a/src/core/ddsi/src/ddsi_typelib.c b/src/core/ddsi/src/ddsi_typelib.c index a124b8d675..a7d72af55a 100644 --- a/src/core/ddsi/src/ddsi_typelib.c +++ b/src/core/ddsi/src/ddsi_typelib.c @@ -13,6 +13,7 @@ #include #include #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/string.h" #include "dds/ddsi/ddsi_domaingv.h" #include "dds/ddsi/ddsi_sertype.h" @@ -930,7 +931,7 @@ static dds_return_t ddsi_type_get_typeinfo_toplevel (struct ddsi_domaingv *gv, s { ddsi_typeid_t ti_c; if (ddsi_typeobj_get_hash_id (&to_c, &ti_c) != 0) - abort (); + ddsrt_abort(); assert (ddsi_typeid_compare (&type_c->xt.id, &ti_c) == 0); ddsi_typeid_fini (&ti_c); } diff --git a/src/core/ddsi/src/ddsi_typewrap.c b/src/core/ddsi/src/ddsi_typewrap.c index fda899893e..f344d9b03f 100644 --- a/src/core/ddsi/src/ddsi_typewrap.c +++ b/src/core/ddsi/src/ddsi_typewrap.c @@ -13,6 +13,7 @@ #include "dds/features.h" #include "dds/ddsrt/heap.h" #include "dds/ddsrt/md5.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/string.h" #include "dds/ddsi/ddsi_domaingv.h" #include "dds/ddsi/ddsi_xt_typemap.h" @@ -1679,7 +1680,7 @@ void ddsi_xt_type_fini (struct ddsi_domaingv *gv, struct xt_type *xt, bool inclu ddsi_type_unref_locked (gv, xt->_u.alias.related_type); break; case DDS_XTypes_TK_ANNOTATION: - abort (); /* FIXME: not implemented */ + ddsrt_abort(); /* FIXME: not implemented */ break; case DDS_XTypes_TK_STRUCTURE: if (xt->_u.structure.base_type) @@ -2185,7 +2186,7 @@ static bool xt_is_plain_collection_equiv_kind (const struct xt_type *t, DDS_XTyp case DDS_XTypes_TK_MAP: return t->_u.map.c.ek == ek; default: - abort (); + ddsrt_abort(); } } @@ -2226,7 +2227,7 @@ static DDS_XTypes_LBound xt_string_bound (const struct xt_type *t) case DDS_XTypes_TK_STRING16: return t->_u.str16.bound; default: - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ } } @@ -2784,7 +2785,7 @@ static ddsi_typeid_kind_t ddsi_typeid_kind_impl (const struct DDS_XTypes_TypeIde element_kind = ddsi_typeid_kind_impl (type_id->_u.map_ldefn.element_identifier); break; default: - abort (); + ddsrt_abort(); } switch (element_kind) { case DDSI_TYPEID_KIND_MINIMAL: @@ -2989,7 +2990,7 @@ void ddsi_xt_get_typeobject_kind_impl (const struct xt_type *xt, struct DDS_XTyp break; } case DDS_XTypes_TK_ANNOTATION: - abort (); /* FIXME: not implemented */ + ddsrt_abort(); /* FIXME: not implemented */ break; case DDS_XTypes_TK_STRUCTURE: { @@ -3103,7 +3104,7 @@ void ddsi_xt_get_typeobject_kind_impl (const struct xt_type *xt, struct DDS_XTyp break; } default: - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } @@ -3125,7 +3126,7 @@ void ddsi_xt_get_typeobject_kind_impl (const struct xt_type *xt, struct DDS_XTyp break; } case DDS_XTypes_TK_ANNOTATION: - abort (); /* FIXME: not implemented */ + ddsrt_abort(); /* FIXME: not implemented */ break; case DDS_XTypes_TK_STRUCTURE: { @@ -3247,7 +3248,7 @@ void ddsi_xt_get_typeobject_kind_impl (const struct xt_type *xt, struct DDS_XTyp break; } default: - abort (); /* not supported */ + ddsrt_abort(); /* not supported */ break; } } diff --git a/src/ddsrt/src/expand_vars.c b/src/ddsrt/src/expand_vars.c index a2e5df039f..a88fe70c7c 100644 --- a/src/ddsrt/src/expand_vars.c +++ b/src/ddsrt/src/expand_vars.c @@ -77,7 +77,7 @@ static char *expand_var (const char *name, char op, const char *alt, expand_fn e case '+': return val && *val ? expand (alt, lookup, data, depth + 1) : ddsrt_strdup (""); default: - abort (); + ddsrt_abort(); return NULL; } } diff --git a/src/ddsrt/src/heap/posix/heap.c b/src/ddsrt/src/heap/posix/heap.c index 642209a4cc..f15d283ad3 100644 --- a/src/ddsrt/src/heap/posix/heap.c +++ b/src/ddsrt/src/heap/posix/heap.c @@ -12,6 +12,7 @@ #include "dds/ddsrt/attributes.h" #include "dds/ddsrt/heap.h" +#include "dds/ddsrt/process.h" static ddsrt_allocation_ops_t ddsrt_allocator = { .malloc = malloc, @@ -40,7 +41,7 @@ ddsrt_malloc(size_t size) if (ptr == NULL) { /* Heap exhausted */ - abort(); + ddsrt_abort(); } return ptr; @@ -55,7 +56,7 @@ ddsrt_calloc(size_t count, size_t size) if (ptr == NULL) { /* Heap exhausted */ - abort(); + ddsrt_abort(); } return ptr; @@ -79,7 +80,7 @@ ddsrt_realloc(void *memblk, size_t size) if (ptr == NULL){ /* Heap exhausted */ - abort(); + ddsrt_abort(); } return ptr; diff --git a/src/ddsrt/src/log.c b/src/ddsrt/src/log.c index 1e73c18844..83fc8b10e7 100644 --- a/src/ddsrt/src/log.c +++ b/src/ddsrt/src/log.c @@ -17,6 +17,8 @@ #include "dds/ddsrt/log.h" #include "dds/ddsrt/sync.h" #include "dds/ddsrt/threads.h" +#include "dds/ddsrt/process.h" +#include "dds/ddsrt/static_assert.h" #include "dds/ddsrt/static_assert.h" #define MAX_ID_LEN (10) @@ -298,7 +300,7 @@ static void vlog (const struct ddsrt_log_cfg_impl *cfg, uint32_t cat, uint32_t d vlog1 (cfg, cat, domid, file, line, func, fmt, ap); unlock_sink (); if (cat & DDS_LC_FATAL) - abort(); + ddsrt_abort(); } void dds_log_cfg (const struct ddsrt_log_cfg *cfg, uint32_t cat, const char *file, uint32_t line, const char *func, const char *fmt, ...) diff --git a/src/ddsrt/src/sync/posix/sync.c b/src/ddsrt/src/sync/posix/sync.c index e8f028504b..9c418f375f 100644 --- a/src/ddsrt/src/sync/posix/sync.c +++ b/src/ddsrt/src/sync/posix/sync.c @@ -18,6 +18,7 @@ #include "dds/ddsrt/sync.h" #include "dds/ddsrt/time.h" +#include "dds/ddsrt/process.h" void ddsrt_mutex_init (ddsrt_mutex_t *mutex) { @@ -30,7 +31,7 @@ void ddsrt_mutex_destroy (ddsrt_mutex_t *mutex) assert (mutex != NULL); if (pthread_mutex_destroy (&mutex->mutex) != 0) - abort(); + ddsrt_abort(); } void ddsrt_mutex_lock (ddsrt_mutex_t *mutex) @@ -38,7 +39,7 @@ void ddsrt_mutex_lock (ddsrt_mutex_t *mutex) assert (mutex != NULL); if (pthread_mutex_lock (&mutex->mutex) != 0) - abort(); + ddsrt_abort(); } bool @@ -49,7 +50,7 @@ ddsrt_mutex_trylock (ddsrt_mutex_t *mutex) err = pthread_mutex_trylock (&mutex->mutex); if (err != 0 && err != EBUSY) - abort(); + ddsrt_abort(); return (err == 0); } @@ -59,7 +60,7 @@ ddsrt_mutex_unlock (ddsrt_mutex_t *mutex) assert (mutex != NULL); if (pthread_mutex_unlock (&mutex->mutex) != 0) - abort(); + ddsrt_abort(); } void @@ -76,7 +77,7 @@ ddsrt_cond_destroy (ddsrt_cond_t *cond) assert (cond != NULL); if (pthread_cond_destroy (&cond->cond) != 0) - abort(); + ddsrt_abort(); } void @@ -86,7 +87,7 @@ ddsrt_cond_wait (ddsrt_cond_t *cond, ddsrt_mutex_t *mutex) assert (mutex != NULL); if (pthread_cond_wait (&cond->cond, &mutex->mutex) != 0) - abort(); + ddsrt_abort(); } bool @@ -118,7 +119,7 @@ ddsrt_cond_waituntil( break; } - abort(); + ddsrt_abort(); return false; } @@ -141,7 +142,7 @@ ddsrt_cond_signal (ddsrt_cond_t *cond) assert (cond != NULL); if (pthread_cond_signal (&cond->cond) != 0) - abort(); + ddsrt_abort(); } void @@ -150,7 +151,7 @@ ddsrt_cond_broadcast (ddsrt_cond_t *cond) assert (cond != NULL); if (pthread_cond_broadcast (&cond->cond) != 0) - abort(); + ddsrt_abort(); } void @@ -160,11 +161,11 @@ ddsrt_rwlock_init (ddsrt_rwlock_t *rwlock) #if __SunOS_5_6 if (pthread_mutex_init(&rwlock->rwlock, NULL) != 0) - abort(); + ddsrt_abort(); #else /* process-shared attribute is set to PTHREAD_PROCESS_PRIVATE by default */ if (pthread_rwlock_init(&rwlock->rwlock, NULL) != 0) - abort(); + ddsrt_abort(); #endif } @@ -174,10 +175,10 @@ ddsrt_rwlock_destroy (ddsrt_rwlock_t *rwlock) assert(rwlock != NULL); #if __SunOS_5_6 if (pthread_mutex_destroy(&rwlock->rwlock) != 0) - abort(); + ddsrt_abort(); #else if (pthread_rwlock_destroy(&rwlock->rwlock) != 0) - abort(); + ddsrt_abort(); #endif } From 43093e4b3ac4695b4d6a7e047921cccf860d17be Mon Sep 17 00:00:00 2001 From: Philip Oetinger Date: Mon, 30 Oct 2023 16:28:27 +0100 Subject: [PATCH 3/9] Add `ddsrt_abort` to the symbol export test --- src/core/xtests/symbol_export/symbol_export.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/xtests/symbol_export/symbol_export.c b/src/core/xtests/symbol_export/symbol_export.c index 1a70c8c00c..ef86d00222 100644 --- a/src/core/xtests/symbol_export/symbol_export.c +++ b/src/core/xtests/symbol_export/symbol_export.c @@ -847,6 +847,7 @@ int main (int argc, char **argv) // ddsrt/process.h ddsrt_getpid (); ddsrt_getprocessname (); + ddsrt_abort (); // ddsrt/time.h ddsrt_mtime_t mt = { .v = 0}; From f5515ebdcf14481f35dde7de99513279b8ae601a Mon Sep 17 00:00:00 2001 From: Philip Oetinger Date: Tue, 7 Nov 2023 13:22:16 +0100 Subject: [PATCH 4/9] introduce ddsrt_exit --- src/core/xtests/symbol_export/symbol_export.c | 1 + src/ddsrt/include/dds/ddsrt/process.h | 9 +++++++++ src/ddsrt/src/process/posix/process.c | 6 ++++++ src/ddsrt/tests/thread.c | 5 +++-- src/tools/ddsperf/ddsperf.c | 12 ++++++------ 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/core/xtests/symbol_export/symbol_export.c b/src/core/xtests/symbol_export/symbol_export.c index ef86d00222..f9f4fe59ab 100644 --- a/src/core/xtests/symbol_export/symbol_export.c +++ b/src/core/xtests/symbol_export/symbol_export.c @@ -848,6 +848,7 @@ int main (int argc, char **argv) ddsrt_getpid (); ddsrt_getprocessname (); ddsrt_abort (); + ddsrt_exit(0); // ddsrt/time.h ddsrt_mtime_t mt = { .v = 0}; diff --git a/src/ddsrt/include/dds/ddsrt/process.h b/src/ddsrt/include/dds/ddsrt/process.h index 2869a8a370..a9d9be7391 100644 --- a/src/ddsrt/include/dds/ddsrt/process.h +++ b/src/ddsrt/include/dds/ddsrt/process.h @@ -78,6 +78,15 @@ ddsrt_getprocessname(void); DDS_EXPORT void ddsrt_abort(void); +/** + * @brief Performs a normal process termination. + * + * @param status + * @returns The least significant byte of `status` is returned to the parent. + */ +DDS_EXPORT void +ddsrt_exit(int status); + #if defined (__cplusplus) } #endif diff --git a/src/ddsrt/src/process/posix/process.c b/src/ddsrt/src/process/posix/process.c index a44d6f4e35..9455c21a8e 100644 --- a/src/ddsrt/src/process/posix/process.c +++ b/src/ddsrt/src/process/posix/process.c @@ -89,3 +89,9 @@ ddsrt_abort(void) { abort(); } + +void +ddsrt_exit(int status) +{ + exit(status); +} diff --git a/src/ddsrt/tests/thread.c b/src/ddsrt/tests/thread.c index b1df2dbc02..dcd55d125e 100644 --- a/src/ddsrt/tests/thread.c +++ b/src/ddsrt/tests/thread.c @@ -22,6 +22,7 @@ #include "dds/ddsrt/cdtors.h" #include "dds/ddsrt/retcode.h" #include "dds/ddsrt/sync.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/threads.h" static int32_t min_fifo_prio = 250; @@ -81,7 +82,7 @@ static uint32_t thread_main(void *ptr) #elif _WIN32 int prio = GetThreadPriority(GetCurrentThread()); if (prio == THREAD_PRIORITY_ERROR_RETURN) - abort(); + ddsrt_abort(); if (prio == attr->schedPriority) { arg->res = 1; } @@ -92,7 +93,7 @@ static uint32_t thread_main(void *ptr) err = pthread_getschedparam(pthread_self(), &policy, &sched); if (err != 0) { - abort(); + ddsrt_abort(); } if (((policy == SCHED_OTHER && attr->schedClass == DDSRT_SCHED_TIMESHARE) || (policy == SCHED_FIFO && attr->schedClass == DDSRT_SCHED_REALTIME)) diff --git a/src/tools/ddsperf/ddsperf.c b/src/tools/ddsperf/ddsperf.c index 8df98517c4..07516a8e75 100644 --- a/src/tools/ddsperf/ddsperf.c +++ b/src/tools/ddsperf/ddsperf.c @@ -391,7 +391,7 @@ static void verrorx (int exitcode, const char *fmt, va_list ap) { vprintf (fmt, ap); fflush (stdout); - exit (exitcode); + ddsrt_exit (exitcode); } static void error2 (const char *fmt, ...) @@ -728,7 +728,7 @@ static uint32_t pubthread (void *varg) { printf ("dds_register_instance failed: %d\n", result); fflush (stdout); - exit (2); + ddsrt_exit (2); } } } @@ -751,7 +751,7 @@ static uint32_t pubthread (void *varg) { printf ("request loan error: %d\n", result); fflush (stdout); - exit (2); + ddsrt_exit (2); } else { @@ -765,7 +765,7 @@ static uint32_t pubthread (void *varg) printf ("write error: %d\n", result); fflush (stdout); if (result != DDS_RETCODE_TIMEOUT) - exit (2); + ddsrt_exit (2); /* retry with original timestamp, it really is just a way of reporting blocking for an exceedingly long time, but do force a fresh time stamp for the next sample */ @@ -976,7 +976,7 @@ static int check_eseq (struct eseq_admin *ea, uint32_t seq, uint32_t keyval, uin if (keyval >= ea->nkeys) { printf ("received key %"PRIu32" >= nkeys %u\n", keyval, ea->nkeys); - exit (3); + ddsrt_exit (3); } ddsrt_mutex_lock (&ea->lock); for (uint32_t i = 0; i < ea->nph; i++) @@ -1970,7 +1970,7 @@ EXAMPLES:\n\ running for 10s\n\ ", argv0, argv0, argv0); fflush (stdout); - exit (3); + ddsrt_exit (3); } struct string_int_map_elem { From 778fedb44255c5de6b46bd286b0afa194b5dffff Mon Sep 17 00:00:00 2001 From: Philip Oetinger Date: Mon, 13 Nov 2023 16:04:31 +0100 Subject: [PATCH 5/9] declare `ddsrt_abort` and `ddsrt_exit` as `noreturn` --- src/ddsrt/include/dds/ddsrt/process.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ddsrt/include/dds/ddsrt/process.h b/src/ddsrt/include/dds/ddsrt/process.h index a9d9be7391..a4b6928e4e 100644 --- a/src/ddsrt/include/dds/ddsrt/process.h +++ b/src/ddsrt/include/dds/ddsrt/process.h @@ -15,6 +15,7 @@ #include "dds/ddsrt/time.h" #include "dds/ddsrt/types.h" #include "dds/ddsrt/retcode.h" +#include "dds/ddsrt/attributes.h" #if DDSRT_WITH_FREERTOS #include @@ -76,7 +77,7 @@ ddsrt_getprocessname(void); * Does not return. Immediately terminates the process. */ DDS_EXPORT void -ddsrt_abort(void); +ddsrt_abort (void) ddsrt_attribute_noreturn; /** * @brief Performs a normal process termination. @@ -85,7 +86,7 @@ ddsrt_abort(void); * @returns The least significant byte of `status` is returned to the parent. */ DDS_EXPORT void -ddsrt_exit(int status); +ddsrt_exit(int status) ddsrt_attribute_noreturn; #if defined (__cplusplus) } From b9d2e79d16ed4fd12c30667c1656db2b064b31a5 Mon Sep 17 00:00:00 2001 From: Philip Oetinger Date: Wed, 13 Dec 2023 20:58:52 +0100 Subject: [PATCH 6/9] change `abort()` -> `ddsrt_abort` in core Signed-off-by: Philip Oetinger --- ports/freertos-posix/src/loader.c | 2 +- src/core/ddsc/src/dds_entity.c | 2 +- src/ddsrt/include/dds/ddsrt/heap.h | 6 +++--- src/ddsrt/src/heap/freertos/heap.c | 6 +++--- src/ddsrt/src/sync/freertos/sync.c | 14 +++++++------- src/ddsrt/src/sync/windows/sync.c | 4 ++-- src/ddsrt/src/threads/windows/threads.c | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ports/freertos-posix/src/loader.c b/ports/freertos-posix/src/loader.c index 7b207151ea..f20534da0d 100644 --- a/ports/freertos-posix/src/loader.c +++ b/ports/freertos-posix/src/loader.c @@ -49,7 +49,7 @@ void vAssertCalled(unsigned long ulLine, const char * const pcFileName) fprintf(stderr, "[ASSERT] %s:%lu"LF, pcFileName, ulLine); } taskEXIT_CRITICAL(); - abort(); + ddsrt_abort(); } void vApplicationMallocFailedHook(void) diff --git a/src/core/ddsc/src/dds_entity.c b/src/core/ddsc/src/dds_entity.c index 39437d4ce9..ff8db5bdc7 100644 --- a/src/core/ddsc/src/dds_entity.c +++ b/src/core/ddsc/src/dds_entity.c @@ -1629,7 +1629,7 @@ dds_return_t dds_return_loan (dds_entity_t entity, void **buf, int32_t bufsz) // bufsz <= 0 is accepted because it allows one to write: // // if (dds_return_loan(rd, buf, dds_take(rd, buf, ...)) < 0) - // abort(); + // ddsrt_abort(); // // with abort only being called if there is a real problem. // diff --git a/src/ddsrt/include/dds/ddsrt/heap.h b/src/ddsrt/include/dds/ddsrt/heap.h index 1c8e207a8c..3d2320847d 100644 --- a/src/ddsrt/include/dds/ddsrt/heap.h +++ b/src/ddsrt/include/dds/ddsrt/heap.h @@ -49,7 +49,7 @@ ddsrt_set_allocator( * * @param[in] size The size, in bytes, of the block of memory to allocate. * - * @returns A pointer to the allocated block of memory. abort() is called if + * @returns A pointer to the allocated block of memory. ddsrt_abort() is called if * not enough free memory was available. */ DDS_EXPORT void * @@ -85,7 +85,7 @@ ddsrt_attribute_alloc_size((1)); * A non-NULL pointer, that must be freed is always returned, even if the sum * @count and @size equals zero. * - * @returns A pointer to the allocated memory. abort() is called if not enough + * @returns A pointer to the allocated memory. ddsrt_abort() is called if not enough * free memory was available. */ DDS_EXPORT void * @@ -123,7 +123,7 @@ ddsrt_attribute_alloc_size((1,2)); * pointed to by memblk and returns a pointer as if ddsrt_malloc_s(0) was * invoked. The returned pointer must be free'd with ddsrt_free. * - * @returns A pointer to reallocated memory. Calls abort() if not enough free + * @returns A pointer to reallocated memory. Calls ddsrt_abort() if not enough free * memory was available. */ DDS_EXPORT void * diff --git a/src/ddsrt/src/heap/freertos/heap.c b/src/ddsrt/src/heap/freertos/heap.c index 399735c33a..4d93af8291 100644 --- a/src/ddsrt/src/heap/freertos/heap.c +++ b/src/ddsrt/src/heap/freertos/heap.c @@ -51,7 +51,7 @@ void *ddsrt_malloc(size_t size) void *ptr; if ((ptr = ddsrt_malloc_s(size)) == NULL) { - abort(); + ddsrt_abort(); } return ptr; @@ -80,7 +80,7 @@ void *ddsrt_calloc(size_t nmemb, size_t size) void *ptr = NULL; if ((ptr = ddsrt_calloc_s(nmemb, size)) == NULL) { - abort(); + ddsrt_abort(); } return ptr; @@ -121,7 +121,7 @@ void *ddsrt_realloc(void *memblk, size_t size) void *ptr = NULL; if ((ptr = ddsrt_realloc_s(memblk, size)) == NULL) { - abort(); + ddsrt_abort(); } return ptr; diff --git a/src/ddsrt/src/sync/freertos/sync.c b/src/ddsrt/src/sync/freertos/sync.c index a25c91f30e..881a203f56 100644 --- a/src/ddsrt/src/sync/freertos/sync.c +++ b/src/ddsrt/src/sync/freertos/sync.c @@ -27,7 +27,7 @@ void ddsrt_mutex_init(ddsrt_mutex_t *mutex) assert(mutex != NULL); if ((sem = xSemaphoreCreateMutex()) == NULL) { - abort(); + ddsrt_abort(); } (void)memset(mutex, 0, sizeof(*mutex)); @@ -136,11 +136,11 @@ void ddsrt_cond_init(ddsrt_cond_t *cond) assert(cond != NULL); if (ddsrt_tasklist_init(&tasks) == -1) { - abort(); + ddsrt_abort(); } if ((sem = xSemaphoreCreateMutex()) == NULL) { ddsrt_tasklist_fini(&tasks); - abort(); + ddsrt_abort(); } (void)memset(cond, 0, sizeof(*cond)); @@ -178,7 +178,7 @@ ddsrt_cond_waitfor( switch ((rc = cond_timedwait(cond, mutex, reltime))) { case DDS_RETCODE_OUT_OF_RESOURCES: - abort(); + ddsrt_abort(); case DDS_RETCODE_TIMEOUT: return false; default: @@ -207,7 +207,7 @@ ddsrt_cond_waituntil( switch ((rc = cond_timedwait(cond, mutex, reltime))) { case DDS_RETCODE_OUT_OF_RESOURCES: - abort(); + ddsrt_abort(); case DDS_RETCODE_TIMEOUT: return false; default: @@ -256,11 +256,11 @@ void ddsrt_rwlock_init(ddsrt_rwlock_t *rwlock) assert(rwlock != NULL); if (ddsrt_tasklist_init(&tasks) == -1) { - abort(); + ddsrt_abort(); } if ((sem = xSemaphoreCreateMutex()) == NULL) { ddsrt_tasklist_fini(&tasks); - abort(); + ddsrt_abort(); } memset(rwlock, 0, sizeof(*rwlock)); diff --git a/src/ddsrt/src/sync/windows/sync.c b/src/ddsrt/src/sync/windows/sync.c index 422b34d486..0e7ac71a79 100644 --- a/src/ddsrt/src/sync/windows/sync.c +++ b/src/ddsrt/src/sync/windows/sync.c @@ -61,7 +61,7 @@ ddsrt_cond_wait(ddsrt_cond_t *cond, ddsrt_mutex_t *mutex) assert(mutex != NULL); if (!SleepConditionVariableSRW(&cond->cond, &mutex->lock, INFINITE, 0)) { - abort(); + ddsrt_abort(); } } @@ -108,7 +108,7 @@ ddsrt_cond_waitfor( if (SleepConditionVariableSRW(&cond->cond, &mutex->lock, msecs, 0)) { return true; } else if (GetLastError() != ERROR_TIMEOUT) { - abort(); + ddsrt_abort(); } return (dds_time() >= abstime) ? false : true; diff --git a/src/ddsrt/src/threads/windows/threads.c b/src/ddsrt/src/threads/windows/threads.c index 9f9aad89a4..f749af6f32 100644 --- a/src/ddsrt/src/threads/windows/threads.c +++ b/src/ddsrt/src/threads/windows/threads.c @@ -457,7 +457,7 @@ void ddsrt_thread_init(uint32_t reason) if (reason != DLL_PROCESS_ATTACH) return; if ((cleanup = TlsAlloc()) == TLS_OUT_OF_INDEXES) - abort(); + ddsrt_abort(); } void ddsrt_thread_fini(uint32_t reason) From a86760a01de35cbabf5b1611107cf3ebc2d0910f Mon Sep 17 00:00:00 2001 From: Philip Oetinger Date: Wed, 13 Dec 2023 21:00:40 +0100 Subject: [PATCH 7/9] remove `ddsrt_exit` From feedback comment, it really is unnecessary. Signed-off-by: Philip Oetinger --- src/core/xtests/symbol_export/symbol_export.c | 1 - src/ddsrt/include/dds/ddsrt/process.h | 9 --------- src/ddsrt/src/process/posix/process.c | 5 ----- src/tools/ddsperf/ddsperf.c | 12 ++++++------ 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/core/xtests/symbol_export/symbol_export.c b/src/core/xtests/symbol_export/symbol_export.c index f9f4fe59ab..ef86d00222 100644 --- a/src/core/xtests/symbol_export/symbol_export.c +++ b/src/core/xtests/symbol_export/symbol_export.c @@ -848,7 +848,6 @@ int main (int argc, char **argv) ddsrt_getpid (); ddsrt_getprocessname (); ddsrt_abort (); - ddsrt_exit(0); // ddsrt/time.h ddsrt_mtime_t mt = { .v = 0}; diff --git a/src/ddsrt/include/dds/ddsrt/process.h b/src/ddsrt/include/dds/ddsrt/process.h index a4b6928e4e..cb38483187 100644 --- a/src/ddsrt/include/dds/ddsrt/process.h +++ b/src/ddsrt/include/dds/ddsrt/process.h @@ -79,15 +79,6 @@ ddsrt_getprocessname(void); DDS_EXPORT void ddsrt_abort (void) ddsrt_attribute_noreturn; -/** - * @brief Performs a normal process termination. - * - * @param status - * @returns The least significant byte of `status` is returned to the parent. - */ -DDS_EXPORT void -ddsrt_exit(int status) ddsrt_attribute_noreturn; - #if defined (__cplusplus) } #endif diff --git a/src/ddsrt/src/process/posix/process.c b/src/ddsrt/src/process/posix/process.c index 9455c21a8e..b80b676ec3 100644 --- a/src/ddsrt/src/process/posix/process.c +++ b/src/ddsrt/src/process/posix/process.c @@ -90,8 +90,3 @@ ddsrt_abort(void) abort(); } -void -ddsrt_exit(int status) -{ - exit(status); -} diff --git a/src/tools/ddsperf/ddsperf.c b/src/tools/ddsperf/ddsperf.c index 07516a8e75..8df98517c4 100644 --- a/src/tools/ddsperf/ddsperf.c +++ b/src/tools/ddsperf/ddsperf.c @@ -391,7 +391,7 @@ static void verrorx (int exitcode, const char *fmt, va_list ap) { vprintf (fmt, ap); fflush (stdout); - ddsrt_exit (exitcode); + exit (exitcode); } static void error2 (const char *fmt, ...) @@ -728,7 +728,7 @@ static uint32_t pubthread (void *varg) { printf ("dds_register_instance failed: %d\n", result); fflush (stdout); - ddsrt_exit (2); + exit (2); } } } @@ -751,7 +751,7 @@ static uint32_t pubthread (void *varg) { printf ("request loan error: %d\n", result); fflush (stdout); - ddsrt_exit (2); + exit (2); } else { @@ -765,7 +765,7 @@ static uint32_t pubthread (void *varg) printf ("write error: %d\n", result); fflush (stdout); if (result != DDS_RETCODE_TIMEOUT) - ddsrt_exit (2); + exit (2); /* retry with original timestamp, it really is just a way of reporting blocking for an exceedingly long time, but do force a fresh time stamp for the next sample */ @@ -976,7 +976,7 @@ static int check_eseq (struct eseq_admin *ea, uint32_t seq, uint32_t keyval, uin if (keyval >= ea->nkeys) { printf ("received key %"PRIu32" >= nkeys %u\n", keyval, ea->nkeys); - ddsrt_exit (3); + exit (3); } ddsrt_mutex_lock (&ea->lock); for (uint32_t i = 0; i < ea->nph; i++) @@ -1970,7 +1970,7 @@ EXAMPLES:\n\ running for 10s\n\ ", argv0, argv0, argv0); fflush (stdout); - ddsrt_exit (3); + exit (3); } struct string_int_map_elem { From 68361f5219c352b909e8eaadf4e059407a018156 Mon Sep 17 00:00:00 2001 From: Philip Oetinger Date: Mon, 22 Apr 2024 14:12:38 +0200 Subject: [PATCH 8/9] use ddsrt_abort in cdrstream part files --- src/core/cdr/include/dds/cdr/dds_cdrstream.h | 1 + src/core/cdr/src/dds_cdrstream_keys.part.c | 14 ++++++------- src/core/cdr/src/dds_cdrstream_write.part.c | 22 ++++++++++---------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/core/cdr/include/dds/cdr/dds_cdrstream.h b/src/core/cdr/include/dds/cdr/dds_cdrstream.h index 861b8e49ba..8bffa747f2 100644 --- a/src/core/cdr/include/dds/cdr/dds_cdrstream.h +++ b/src/core/cdr/include/dds/cdr/dds_cdrstream.h @@ -13,6 +13,7 @@ #include "dds/ddsrt/bswap.h" #include "dds/ddsrt/static_assert.h" +#include "dds/ddsrt/process.h" #include "dds/ddsc/dds_data_type_properties.h" #include "dds/dds.h" diff --git a/src/core/cdr/src/dds_cdrstream_keys.part.c b/src/core/cdr/src/dds_cdrstream_keys.part.c index 906f2cc06a..8238b52820 100644 --- a/src/core/cdr/src/dds_cdrstream_keys.part.c +++ b/src/core/cdr/src/dds_cdrstream_keys.part.c @@ -65,7 +65,7 @@ static void dds_stream_write_keyBO_impl (DDS_OSTREAM_T * __restrict os, const st break; } default: - abort (); + ddsrt_abort (); } break; } @@ -77,7 +77,7 @@ static void dds_stream_write_keyBO_impl (DDS_OSTREAM_T * __restrict os, const st } case DDS_OP_VAL_SEQ: case DDS_OP_VAL_BSQ: case DDS_OP_VAL_UNI: case DDS_OP_VAL_STU: { // FIXME: implement support for sequences and unions as part of the key - abort (); + ddsrt_abort (); break; } } @@ -114,7 +114,7 @@ void dds_stream_write_keyBO (DDS_OSTREAM_T * __restrict os, enum dds_cdr_key_ser break; } default: - abort (); + ddsrt_abort (); break; } } @@ -191,7 +191,7 @@ static const uint32_t *dds_stream_extract_keyBO_from_data_delimited (dds_istream ops++; break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_DLC: case DDS_OP_PLC: case DDS_OP_PLM: - abort (); + ddsrt_abort (); break; } } @@ -290,7 +290,7 @@ static const uint32_t *dds_stream_extract_keyBO_from_data_pl (dds_istream_t * __ msz <<= (lc - 4); break; default: - abort (); + ddsrt_abort (); break; } @@ -332,7 +332,7 @@ static const uint32_t *dds_stream_extract_keyBO_from_data1 (dds_istream_t * __re ops++; break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: - abort (); + ddsrt_abort (); break; case DDS_OP_DLC: ops = dds_stream_extract_keyBO_from_data_delimited (is, os, allocator, op0, ops, mutable_member_or_parent, n_keys, keys_remaining); @@ -411,7 +411,7 @@ static void dds_stream_extract_keyBO_from_key_optimized (dds_istream_t * __restr break; } default: - abort (); + ddsrt_abort (); break; } } diff --git a/src/core/cdr/src/dds_cdrstream_write.part.c b/src/core/cdr/src/dds_cdrstream_write.part.c index a2aeacf762..041fb35e29 100644 --- a/src/core/cdr/src/dds_cdrstream_write.part.c +++ b/src/core/cdr/src/dds_cdrstream_write.part.c @@ -34,7 +34,7 @@ static bool dds_stream_write_enum_valueBO (DDS_OSTREAM_T * __restrict os, const dds_os_put4BO (os, allocator, val); break; default: - abort (); + ddsrt_abort (); } return true; } @@ -72,7 +72,7 @@ static bool dds_stream_write_bitmask_valueBO (DDS_OSTREAM_T * __restrict os, con break; } default: - abort (); + ddsrt_abort (); } return true; } @@ -126,7 +126,7 @@ static bool dds_stream_write_enum_arrBO (DDS_OSTREAM_T * __restrict os, const st } break; default: - abort (); + ddsrt_abort (); } return true; } @@ -176,7 +176,7 @@ static bool dds_stream_write_bitmask_arrBO (DDS_OSTREAM_T * __restrict os, const break; } default: - abort (); + ddsrt_abort (); } return true; } @@ -271,7 +271,7 @@ static const uint32_t *dds_stream_write_seqBO (DDS_OSTREAM_T * __restrict os, co break; } case DDS_OP_VAL_EXT: - abort (); /* op type EXT as sequence subtype not supported */ + ddsrt_abort (); /* op type EXT as sequence subtype not supported */ return NULL; } } @@ -347,7 +347,7 @@ static const uint32_t *dds_stream_write_arrBO (DDS_OSTREAM_T * __restrict os, co break; } case DDS_OP_VAL_EXT: - abort (); /* op type EXT as array subtype not supported */ + ddsrt_abort (); /* op type EXT as array subtype not supported */ break; } @@ -388,7 +388,7 @@ static bool dds_stream_write_union_discriminantBO (DDS_OSTREAM_T * __restrict os return false; break; default: - abort (); + ddsrt_abort (); } return true; } @@ -436,7 +436,7 @@ static const uint32_t *dds_stream_write_uniBO (DDS_OSTREAM_T * __restrict os, co return NULL; break; case DDS_OP_VAL_EXT: - abort (); /* op type EXT as union subtype not supported */ + ddsrt_abort (); /* op type EXT as union subtype not supported */ break; } } @@ -503,7 +503,7 @@ static const uint32_t *dds_stream_write_adrBO (uint32_t insn, DDS_OSTREAM_T * __ ops += jmp ? jmp : 3; break; } - case DDS_OP_VAL_STU: abort (); break; /* op type STU only supported as subtype */ + case DDS_OP_VAL_STU: ddsrt_abort (); break; /* op type STU only supported as subtype */ } return ops; } @@ -578,7 +578,7 @@ static const uint32_t *dds_stream_write_pl_memberlistBO (DDS_OSTREAM_T * __restr break; } default: - abort (); /* other ops not supported at this point */ + ddsrt_abort (); /* other ops not supported at this point */ break; } } @@ -618,7 +618,7 @@ static const uint32_t *dds_stream_write_implBO (DDS_OSTREAM_T * __restrict os, c ops++; break; case DDS_OP_RTS: case DDS_OP_JEQ: case DDS_OP_JEQ4: case DDS_OP_KOF: case DDS_OP_PLM: - abort (); + ddsrt_abort (); break; case DDS_OP_DLC: assert (((struct dds_ostream *)os)->m_xcdr_version == DDSI_RTPS_CDR_ENC_VERSION_2); From ba2766d2502544c3c6c3a4d7aaadd1066429a4ff Mon Sep 17 00:00:00 2001 From: Philip Oetinger Date: Mon, 22 Apr 2024 14:58:38 +0200 Subject: [PATCH 9/9] use `ddsrt_abort` in library tests --- src/core/ddsc/tests/cdr.c | 5 ++- src/core/ddsc/tests/listener.c | 3 +- src/core/ddsc/tests/psmx.c | 3 +- src/core/ddsc/tests/qos_set_match.c | 3 +- src/core/ddsc/tests/test_oneliner.c | 11 ++--- src/core/ddsc/tests/test_oneliner.h | 2 +- src/core/ddsc/tests/time_based_filter.c | 3 +- src/core/ddsc/tests/xtypes_typelookup.c | 2 +- src/core/xtests/initsampledeliv/publisher.c | 3 +- src/core/xtests/initsampledeliv/subscriber.c | 3 +- src/core/xtests/rhc_torture/rhc_torture.c | 44 ++++++++++---------- src/tools/idlc/tests/type_meta.c | 3 +- 12 files changed, 47 insertions(+), 38 deletions(-) diff --git a/src/core/ddsc/tests/cdr.c b/src/core/ddsc/tests/cdr.c index ae0b2f625c..b2e197dd4e 100644 --- a/src/core/ddsc/tests/cdr.c +++ b/src/core/ddsc/tests/cdr.c @@ -17,6 +17,7 @@ #include "dds/ddsrt/bswap.h" #include "dds/ddsrt/environ.h" #include "dds/ddsrt/static_assert.h" +#include "dds/ddsrt/process.h" #include "dds/dds.h" #include "dds/ddsi/ddsi_serdata.h" @@ -374,7 +375,7 @@ static void sd_to_ser (const struct ddsi_serdata *serdata_common, size_t off, si static bool sdx_to_sample (const struct sdx *sd, enum ddsi_serdata_kind kind, struct sampletype *s, void **bufptr, void *buflim) { - if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ + if (bufptr) ddsrt_abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ s->key = dds_realloc (s->key, sd->keysz); memcpy (s->key, sd->data.key, sd->keysz); if (kind == SDK_DATA) @@ -393,7 +394,7 @@ static bool sd_to_sample (const struct ddsi_serdata *serdata_common, void *sampl static bool sdx_untyped_to_sample (const struct sdx *sd, struct sampletype *s, void **bufptr, void *buflim) { - if (bufptr) abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ + if (bufptr) ddsrt_abort(); else { (void)buflim; } /* FIXME: haven't implemented that bit yet! */ s->key = dds_realloc (s->key, sd->keysz); memcpy (s->key, sd->data.key, sd->keysz); return true; diff --git a/src/core/ddsc/tests/listener.c b/src/core/ddsc/tests/listener.c index fa9e617c98..d7d0b67729 100644 --- a/src/core/ddsc/tests/listener.c +++ b/src/core/ddsc/tests/listener.c @@ -16,6 +16,7 @@ #include "dds/ddsrt/heap.h" #include "dds/ddsrt/string.h" #include "dds/ddsrt/environ.h" +#include "dds/ddsrt/process.h" #include "test_common.h" #include "test_oneliner.h" @@ -56,7 +57,7 @@ static void dummy_cb (void) // Used as a listener function in checking merging of listeners, // and for that purpose, casting it to whatever function type is // required is ok. It is not supposed to ever be called. - abort (); + ddsrt_abort (); } #undef DEFINE_STATUS_CALLBACK diff --git a/src/core/ddsc/tests/psmx.c b/src/core/ddsc/tests/psmx.c index e54cd30db5..9ab69d8faf 100644 --- a/src/core/ddsc/tests/psmx.c +++ b/src/core/ddsc/tests/psmx.c @@ -17,6 +17,7 @@ #include "dds/ddsrt/heap.h" #include "dds/ddsrt/bswap.h" #include "dds/ddsrt/environ.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/static_assert.h" #include "dds/dds.h" @@ -280,7 +281,7 @@ static void print (struct tracebuf *tb, const char *fmt, ...) { //return; if (tb->pos >= sizeof (tb->buf)) - abort (); + ddsrt_abort (); va_list ap; va_start (ap, fmt); diff --git a/src/core/ddsc/tests/qos_set_match.c b/src/core/ddsc/tests/qos_set_match.c index 89de54afc9..17e467e17d 100644 --- a/src/core/ddsc/tests/qos_set_match.c +++ b/src/core/ddsc/tests/qos_set_match.c @@ -14,6 +14,7 @@ #include "dds/dds.h" #include "dds/ddsrt/environ.h" +#include "dds/ddsrt/process.h" #include "test_common.h" enum check_mode { @@ -242,7 +243,7 @@ static int32_t resource_limits_cnv (const int v, const int f, const int o) case 0: l = v % 2; break; case 1: l = (v/2) % 2; break; case 2: l = (v/4) % 2; break; - default: abort (); + default: ddsrt_abort (); } // 1000: so resource limits are always greater than what is required for the history settings used in this test // o: offset so we can put in unique values for "resource limits" and "durability service resource limits" diff --git a/src/core/ddsc/tests/test_oneliner.c b/src/core/ddsc/tests/test_oneliner.c index b77e8b04c8..64c19c18c7 100644 --- a/src/core/ddsc/tests/test_oneliner.c +++ b/src/core/ddsc/tests/test_oneliner.c @@ -16,6 +16,7 @@ #include #include "dds/ddsrt/align.h" +#include "dds/ddsrt/process.h" #include "dds/ddsrt/misc.h" #include "dds/ddsrt/sync.h" #include "dds/ddsrt/heap.h" @@ -119,7 +120,7 @@ static void dummy_cb (void) // Used as a listener function in checking merging of listeners, // and for that purpose, casting it to whatever function type is // required is ok. It is not supposed to ever be called. - abort (); + ddsrt_abort (); } #undef DEFINE_STATUS_CALLBACK @@ -176,7 +177,7 @@ static const void *advance (const void *status, size_t *off, char code) align = dds_alignof (dds_sample_rejected_status_kind); size = sizeof (dds_sample_rejected_status_kind); break; default: - abort (); + ddsrt_abort (); } *off = (*off + align - 1) & ~(align - 1); const void *p = (const char *) status + *off; @@ -979,7 +980,7 @@ static void make_entity1 (struct oneliner_ctx *ctx, int ent, dds_listener_t *lis ctx->es[ent] = dds_create_writer (ctx->es[9*domid+2], ctx->tps[domid], ctx->entqos, list); break; default: - abort (); + ddsrt_abort (); } mprintf (ctx, " = %"PRId32, ctx->es[ent]); if (ctx->es[ent] <= 0) @@ -1019,7 +1020,7 @@ static void setlistener (struct oneliner_ctx *ctx, struct oneliner_lex *l, int l case 10: dds_lset_sample_lost (list, sample_lost_cb); break; case 11: dds_lset_sample_rejected (list, sample_rejected_cb); break; case 12: dds_lset_subscription_matched (list, subscription_matched_cb); break; - default: abort (); + default: ddsrt_abort (); } } while (l && (ll = parse_listener1 (l)) >= 0); if (ctx->es[ent] == 0) @@ -1463,7 +1464,7 @@ static int checkstatus (struct oneliner_ctx *ctx, int ll, int ent, struct onelin const char *sep = "("; size_t off = 0; if (nexttok (argl, NULL) != '(') - abort (); + ddsrt_abort (); while (*d) { const void *p = advance (status, &off, *d); diff --git a/src/core/ddsc/tests/test_oneliner.h b/src/core/ddsc/tests/test_oneliner.h index 7fba47f771..9d9f42d138 100644 --- a/src/core/ddsc/tests/test_oneliner.h +++ b/src/core/ddsc/tests/test_oneliner.h @@ -23,7 +23,7 @@ * executes it. Any failures, be it because of error codes coming out of the Cyclone * calls or expected values being wrong cause it to fail the test via CU_ASSERT_FATAL. * While it is doing this, it outputs the test steps to stdout including some actual - * values. An invalid program is mostly reported by calling abort(). It is geared towards + * values. An invalid program is mostly reported by calling ddsrt_abort(). It is geared towards * checking for listener invocations and the effects on statuses. * * Entities in play: diff --git a/src/core/ddsc/tests/time_based_filter.c b/src/core/ddsc/tests/time_based_filter.c index 7d0b5f019d..b06a1b698e 100644 --- a/src/core/ddsc/tests/time_based_filter.c +++ b/src/core/ddsc/tests/time_based_filter.c @@ -17,6 +17,7 @@ #include "ddsi__thread.h" #include "dds/ddsi/ddsi_serdata.h" #include "dds/ddsi/ddsi_tkmap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsc/dds_rhc.h" #include "test_common.h" @@ -97,7 +98,7 @@ static struct ddsi_domaingv *get_gv (dds_entity_t e) struct ddsi_domaingv *gv; dds_entity *x; if (dds_entity_pin (e, &x) < 0) - abort (); + ddsrt_abort (); gv = &x->m_domain->gv; dds_entity_unpin (x); return gv; diff --git a/src/core/ddsc/tests/xtypes_typelookup.c b/src/core/ddsc/tests/xtypes_typelookup.c index 69b14673e2..96f5581707 100644 --- a/src/core/ddsc/tests/xtypes_typelookup.c +++ b/src/core/ddsc/tests/xtypes_typelookup.c @@ -138,7 +138,7 @@ static void get_type (dds_entity_t entity, ddsi_typeid_t **type_id, char **type_ *type_name = ddsrt_strdup (wr->xqos->type_name); } else - abort (); + ddsrt_abort (); ddsi_thread_state_asleep (ddsi_lookup_thread_state ()); dds_entity_unpin (e); } diff --git a/src/core/xtests/initsampledeliv/publisher.c b/src/core/xtests/initsampledeliv/publisher.c index 51db60e1a0..2e0739ac58 100644 --- a/src/core/xtests/initsampledeliv/publisher.c +++ b/src/core/xtests/initsampledeliv/publisher.c @@ -10,6 +10,7 @@ #include "dds/dds.h" #include "dds/ddsrt/atomics.h" +#include "dds/ddsrt/process.h" #include "InitSampleDelivData.h" #include #include @@ -19,7 +20,7 @@ static void oops (const char *file, int line) { fflush (stdout); fprintf (stderr, "%s:%d\n", file, line); - abort (); + ddsrt_abort (); } #define oops() oops(__FILE__, __LINE__) diff --git a/src/core/xtests/initsampledeliv/subscriber.c b/src/core/xtests/initsampledeliv/subscriber.c index 7f38871ee3..d0afed54c1 100644 --- a/src/core/xtests/initsampledeliv/subscriber.c +++ b/src/core/xtests/initsampledeliv/subscriber.c @@ -9,6 +9,7 @@ // SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause #include "dds/dds.h" +#include "dds/ddsrt/process.h" #include "InitSampleDelivData.h" #include #include @@ -20,7 +21,7 @@ static void oops (const char *file, int line) { fflush (stdout); fprintf (stderr, "%s:%d\n", file, line); - abort (); + ddsrt_abort (); } #define oops() oops(__FILE__, __LINE__) diff --git a/src/core/xtests/rhc_torture/rhc_torture.c b/src/core/xtests/rhc_torture/rhc_torture.c index 738c537ea1..190bc1d494 100644 --- a/src/core/xtests/rhc_torture/rhc_torture.c +++ b/src/core/xtests/rhc_torture/rhc_torture.c @@ -146,7 +146,7 @@ static uint64_t store (struct ddsi_tkmap *tkmap, struct dds_rhc *rhc, struct dds char si_u = (sd->statusinfo & DDSI_STATUSINFO_UNREGISTER) ? 'U' : '.'; memset (&d, 0, sizeof (d)); if (!ddsi_serdata_to_sample (sd, &d, NULL, NULL)) - abort (); + ddsrt_abort (); (void) print_tstamp (buf, sizeof (buf), sd->timestamp.v); if (sd->kind == SDK_KEY) printf ("STORE %c%c %16"PRIx64" %16"PRIx64" %2"PRId32" %6s %s\n", si_u, si_d, iid, wr->e.iid, d.k, "_", buf); @@ -338,14 +338,14 @@ static void rdtkcond (struct dds_rhc *rhc, dds_readcond *cond, const struct chec ddsi_thread_state_asleep (ddsi_lookup_thread_state ()); if (max > 0 && cnt > max) { printf ("%s TOO MUCH DATA (%d > %d)\n", opname, cnt, max); - abort (); + ddsrt_abort (); } else if (cnt > 0) { if (print) print_seq (cnt, rres_iseq, rres_mseq); } else if (cnt == 0) { if (print) printf ("(no data)\n"); } else { printf ("%s ERROR %d\n", opname, cnt); - abort (); + ddsrt_abort (); } for (int i = 0; i < cnt; i++) @@ -358,7 +358,7 @@ static void rdtkcond (struct dds_rhc *rhc, dds_readcond *cond, const struct chec if (!rres_iseq[i].valid_data) { if (rres_mseq[i].x != 0 || rres_mseq[i].y != 0 || rres_mseq[i].s != NULL) - abort (); + ddsrt_abort (); } } @@ -370,50 +370,50 @@ static void rdtkcond (struct dds_rhc *rhc, dds_readcond *cond, const struct chec switch (cond->m_sample_states) { case DDS_SST_READ: - if (rres_iseq[i].sample_state != DDS_READ_SAMPLE_STATE) abort (); + if (rres_iseq[i].sample_state != DDS_READ_SAMPLE_STATE) ddsrt_abort (); break; case DDS_SST_NOT_READ: - if (rres_iseq[i].sample_state != DDS_NOT_READ_SAMPLE_STATE) abort (); + if (rres_iseq[i].sample_state != DDS_NOT_READ_SAMPLE_STATE) ddsrt_abort (); break; } switch (cond->m_view_states) { case DDS_VST_NEW: - if (rres_iseq[i].view_state != DDS_NEW_VIEW_STATE) abort (); + if (rres_iseq[i].view_state != DDS_NEW_VIEW_STATE) ddsrt_abort (); break; case DDS_VST_OLD: - if (rres_iseq[i].view_state != DDS_NOT_NEW_VIEW_STATE) abort (); + if (rres_iseq[i].view_state != DDS_NOT_NEW_VIEW_STATE) ddsrt_abort (); break; } switch (cond->m_instance_states) { case DDS_IST_ALIVE: - if (rres_iseq[i].instance_state != DDS_ALIVE_INSTANCE_STATE) abort (); + if (rres_iseq[i].instance_state != DDS_ALIVE_INSTANCE_STATE) ddsrt_abort (); break; case DDS_IST_NOT_ALIVE_NO_WRITERS: - if (rres_iseq[i].instance_state != DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE) abort (); + if (rres_iseq[i].instance_state != DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE) ddsrt_abort (); break; case DDS_IST_NOT_ALIVE_DISPOSED: - if (rres_iseq[i].instance_state != DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE) abort (); + if (rres_iseq[i].instance_state != DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE) ddsrt_abort (); break; case DDS_IST_NOT_ALIVE_NO_WRITERS | DDS_IST_NOT_ALIVE_DISPOSED: if (rres_iseq[i].instance_state != DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE && rres_iseq[i].instance_state != DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE) - abort (); + ddsrt_abort (); break; case DDS_IST_ALIVE | DDS_IST_NOT_ALIVE_NO_WRITERS: if (rres_iseq[i].instance_state != DDS_ALIVE_INSTANCE_STATE && rres_iseq[i].instance_state != DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE) - abort (); + ddsrt_abort (); break; case DDS_IST_ALIVE | DDS_IST_NOT_ALIVE_DISPOSED: if (rres_iseq[i].instance_state != DDS_ALIVE_INSTANCE_STATE && rres_iseq[i].instance_state != DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE) - abort (); + ddsrt_abort (); break; } if (cond->m_query.m_filter) { /* invalid samples don't get the attributes zero'd out in the result, though the keys are guaranteed to be set; maybe I should change that and guarantee that the fields are 0 ... */ if (!cond->m_query.m_filter (&rres_mseq[i])) - abort (); + ddsrt_abort (); } } } @@ -551,7 +551,7 @@ static dds_readcond *get_condaddr (dds_entity_t x) { struct dds_entity *e; if (dds_entity_lock (x, DDS_KIND_DONTCARE, &e) < 0) - abort(); + ddsrt_abort(); assert (dds_entity_kind (e) == DDS_KIND_COND_READ || dds_entity_kind (e) == DDS_KIND_COND_QUERY); dds_entity_unlock (e); return (dds_readcond *) e; @@ -562,7 +562,7 @@ static void print_cond_w_addr (const char *label, dds_entity_t x) char buf[100]; struct dds_entity *e; if (dds_entity_lock (x, DDS_KIND_DONTCARE, &e) < 0) - abort(); + ddsrt_abort(); assert (dds_entity_kind (e) == DDS_KIND_COND_READ || dds_entity_kind (e) == DDS_KIND_COND_QUERY); print_condmask (buf, sizeof (buf), (dds_readcond *) e); printf ("%s: %"PRId32" => %p %s\n", label, x, (void *) e, buf); @@ -580,7 +580,7 @@ static struct ddsi_domaingv *get_gv (dds_entity_t e) struct ddsi_domaingv *gv; dds_entity *x; if (dds_entity_pin (e, &x) < 0) - abort (); + ddsrt_abort (); gv = &x->m_domain->gv; dds_entity_unpin (x); return gv; @@ -603,7 +603,7 @@ static void test_conditions (dds_entity_t pp, dds_entity_t tp, const int count, { struct dds_entity *x; if (dds_entity_lock (rd[i], DDS_KIND_READER, &x) < 0) - abort (); + ddsrt_abort (); dds_reader *rdp = (dds_reader *) x; rhc[i] = rdp->m_rhc; dds_entity_unlock (x); @@ -649,7 +649,7 @@ static void test_conditions (dds_entity_t pp, dds_entity_t tp, const int count, { assert (ci / 32 < (int) (sizeof (rd) / sizeof (rd[0]))); conds[ci] = create_cond (rd[ci / 32], stab[s] | vtab[v] | itab[i], ((ci % 2) == 0) ? filter0 : filter1); - if (conds[ci] <= 0) abort (); + if (conds[ci] <= 0) ddsrt_abort (); rhcconds[ci] = get_condaddr (conds[ci]); if (print) { char buf[19]; @@ -972,7 +972,7 @@ int main (int argc, char **argv) ddsrt_threadattr_t tattr; ddsrt_threadattr_init (&tattr); if (ddsrt_thread_create (&stttid, "stacktracethread", &tattr, stacktracethread, &sttarg) != 0) - abort (); + ddsrt_abort (); } printf ("%"PRId64" prng seed %u first %d count %d print %d xchecks %d\n", dds_time (), seed, first, count, print, xchecks); @@ -996,7 +996,7 @@ int main (int argc, char **argv) assert (ddsrt_atomic_ldvoidp (&mainthread->gv) != NULL); { struct dds_topic *x; - if (dds_topic_pin (tp, &x) < 0) abort(); + if (dds_topic_pin (tp, &x) < 0) ddsrt_abort(); mdtype = ddsi_sertype_ref (x->m_stype); dds_topic_unpin (x); } diff --git a/src/tools/idlc/tests/type_meta.c b/src/tools/idlc/tests/type_meta.c index 686d75f283..1e502a6261 100644 --- a/src/tools/idlc/tests/type_meta.c +++ b/src/tools/idlc/tests/type_meta.c @@ -17,6 +17,7 @@ #include "dds/ddsi/ddsi_xqos.h" #include "dds/ddsi/ddsi_typelib.h" #include "dds/ddsi/ddsi_typewrap.h" +#include "dds/ddsrt/process.h" #include "dds/ddsc/dds_opcodes.h" #include "dds/cdr/dds_cdrstream.h" #include "idl/string.h" @@ -34,7 +35,7 @@ static void *calloc_no_fail (size_t count, size_t size) assert (count > 0 && size > 0); void *p = calloc (count, size); if (p == NULL) - abort (); + ddsrt_abort(); return p; }