diff --git a/include/cmp_io.h b/include/cmp_io.h index 5eb73f3f4f835f5de0ea070b2da68bd37b35b1f2..7ac78803caf1bba7f7907be0e2dd6b231fad47d9 100644 --- a/include/cmp_io.h +++ b/include/cmp_io.h @@ -51,7 +51,7 @@ int cmp_cfg_fo_file(const struct cmp_cfg *cfg, const char *output_prefix, int ve void cmp_cfg_print(const struct cmp_cfg *cfg); int atoui32(const char *dep_str, const char *val_str, uint32_t *red_val); -int cmp_mode_parse(const char *cmp_mode_str, uint32_t *cmp_mode); +int cmp_mode_parse(const char *cmp_mode_str, enum cmp_mode *cmp_mode); enum cmp_data_type string2data_type(const char *data_type_str); const char *data_type2string(enum cmp_data_type data_type); diff --git a/include/my_inttypes.h b/include/my_inttypes.h new file mode 100644 index 0000000000000000000000000000000000000000..97a7f876ecf1be93e7886ee4046fd7515c6be096 --- /dev/null +++ b/include/my_inttypes.h @@ -0,0 +1,55 @@ +/** +* @file my_inttypes.h +* @author Dominik Loidolt (dominik.loidolt@univie.ac.at) +* @date 2021 +* +* @copyright GPLv2 +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* @brief This is a self-created inttypes.h, since the sparc-elf-gcc toolchain +* does not provide one. +* WARNING: Does not fully implement the standard. +*/ + + +#ifndef _MY_INTTYPES_H +#define _MY_INTTYPES_H + +#ifndef __sparc__ +# include <inttypes.h> +#else + +#ifndef PRId32 +# define PRId32 "ld" +#endif /*PRId32*/ + +#ifndef PRIi32 +# define PRIi32 "li" +#endif /*PRIi32*/ + +#ifndef PRIo32 +# define PRIo32 "lo" +#endif /*PRIo32*/ + +#ifndef PRIu32 +# define PRIu32 "lu" +#endif /* PRIu32 */ + +#ifndef PRIx32 +# define PRIx32 "lx" +#endif /*PRIx32*/ + +#ifndef PRIX32 +# define PRIX32 "lX" +#endif /*PRIX32*/ + +#endif /* __sparc__ */ + +#endif /* _MY_INTTYPES_H */ diff --git a/lib/cmp_entity.c b/lib/cmp_entity.c index 3574062e1f4b94e0ca6df5f36c61bca860ebabc1..796d08d96cfd36fe649a10ebdfcbceb255b33392 100644 --- a/lib/cmp_entity.c +++ b/lib/cmp_entity.c @@ -35,6 +35,7 @@ #include <cmp_support.h> #include <cmp_data_types.h> #include <cmp_entity.h> +#include <my_inttypes.h> #ifdef HAS_TIME_H @@ -2404,22 +2405,22 @@ static void cmp_ent_parse_generic_header(struct cmp_entity *ent) printf("Compressed with cmp_tool version: %u.%02u\n", major, minor); } else - printf("ICU ASW Version ID: %u\n", version_id); + printf("ICU ASW Version ID: %" PRIu32 "\n", version_id); cmp_ent_size = cmp_ent_get_size(ent); - printf("Compression Entity Size: %u byte\n", cmp_ent_size); + printf("Compression Entity Size: %" PRIu32 " byte\n", cmp_ent_size); original_size = cmp_ent_get_original_size(ent); - printf("Original Data Size: %u byte\n", original_size); + printf("Original Data Size: %" PRIu32 " byte\n", original_size); start_coarse_time = cmp_ent_get_coarse_start_time(ent); - printf("Compression Coarse Start Time: %u\n", start_coarse_time); + printf("Compression Coarse Start Time: %" PRIu32 "\n", start_coarse_time); start_fine_time = cmp_ent_get_fine_start_time(ent); printf("Compression Fine Start Time: %d\n", start_fine_time); end_coarse_time = cmp_ent_get_coarse_end_time(ent); - printf("Compression Coarse End Time: %u\n", end_coarse_time); + printf("Compression Coarse End Time: %" PRIu32 "\n", end_coarse_time); end_fine_time = cmp_ent_get_fine_end_time(ent); printf("Compression Fine End Time: %d\n", end_fine_time); @@ -2445,22 +2446,22 @@ static void cmp_ent_parse_generic_header(struct cmp_entity *ent) printf("RAW bit in the Data Product Type is%s set\n", raw_bit ? "" : " not"); cmp_mode_used = cmp_ent_get_cmp_mode(ent); - printf("Used Compression Mode: %u\n", cmp_mode_used); + printf("Used Compression Mode: %" PRIu32 "\n", cmp_mode_used); model_value_used = cmp_ent_get_model_value_used(ent); - printf("Used Model Updating Weighing Value: %u\n", model_value_used); + printf("Used Model Updating Weighing Value: %" PRIu32 "\n", model_value_used); model_id = cmp_ent_get_model_id(ent); - printf("Model ID: %u\n", model_id); + printf("Model ID: %" PRIu32 "\n", model_id); model_counter = cmp_ent_get_model_counter(ent); - printf("Model Counter: %u\n", model_counter); + printf("Model Counter: %" PRIu32 "\n", model_counter); max_used_bits_version = cmp_ent_get_max_use_bits_version(ent); - printf("Maximum Used Bits Registry Version: %u\n", max_used_bits_version); + printf("Maximum Used Bits Registry Version: %" PRIu32 "\n", max_used_bits_version); lossy_cmp_par_used = cmp_ent_get_lossy_cmp_par(ent); - printf("Used Lossy Compression Parameters: %u\n", lossy_cmp_par_used); + printf("Used Lossy Compression Parameters: %" PRIu32 "\n", lossy_cmp_par_used); } @@ -2475,10 +2476,10 @@ static void cmp_ent_parese_imagette_header(struct cmp_entity *ent) uint32_t spill_used, golomb_par_used; spill_used = cmp_ent_get_ima_spill(ent); - printf("Used Spillover Threshold Parameter: %u\n", spill_used); + printf("Used Spillover Threshold Parameter: %" PRIu32 "\n", spill_used); golomb_par_used = cmp_ent_get_ima_golomb_par(ent); - printf("Used Golomb Parameter: %u\n", golomb_par_used); + printf("Used Golomb Parameter: %" PRIu32 "\n", golomb_par_used); } @@ -2494,22 +2495,22 @@ static void cmp_ent_parese_adaptive_imagette_header(struct cmp_entity *ent) ap1_golomb_par_used, ap2_spill_used, ap2_golomb_par_used; spill_used = cmp_ent_get_ima_spill(ent); - printf("Used Spillover Threshold Parameter: %u\n", spill_used); + printf("Used Spillover Threshold Parameter: %" PRIu32 "\n", spill_used); golomb_par_used = cmp_ent_get_ima_golomb_par(ent); - printf("Used Golomb Parameter: %u\n", golomb_par_used); + printf("Used Golomb Parameter: %" PRIu32 "\n", golomb_par_used); ap1_spill_used = cmp_ent_get_ima_ap1_spill(ent); - printf("Used Adaptive 1 Spillover Threshold Parameter: %u\n", ap1_spill_used); + printf("Used Adaptive 1 Spillover Threshold Parameter: %" PRIu32 "\n", ap1_spill_used); ap1_golomb_par_used = cmp_ent_get_ima_ap1_golomb_par(ent); - printf("Used Adaptive 1 Golomb Parameter: %u\n", ap1_golomb_par_used); + printf("Used Adaptive 1 Golomb Parameter: %" PRIu32 "\n", ap1_golomb_par_used); ap2_spill_used = cmp_ent_get_ima_ap2_spill(ent); - printf("Used Adaptive 2 Spillover Threshold Parameter: %u\n", ap2_spill_used); + printf("Used Adaptive 2 Spillover Threshold Parameter: %" PRIu32 "\n", ap2_spill_used); ap2_golomb_par_used = cmp_ent_get_ima_ap2_golomb_par(ent); - printf("Used Adaptive 2 Golomb Parameter: %u\n", ap2_golomb_par_used); + printf("Used Adaptive 2 Golomb Parameter: %" PRIu32 "\n", ap2_golomb_par_used); } diff --git a/lib/cmp_guess.c b/lib/cmp_guess.c index 87aec6cd5824f7baa9cde955b9cb44f91fd6042f..86387959a262f857cb44208b65762f7377a48edf 100644 --- a/lib/cmp_guess.c +++ b/lib/cmp_guess.c @@ -23,9 +23,10 @@ #include <stdlib.h> #include <string.h> -#include "cmp_data_types.h" -#include "cmp_icu.h" -#include "cmp_guess.h" +#include <cmp_data_types.h> +#include <cmp_icu.h> +#include <cmp_guess.h> +#include <my_inttypes.h> /* how often the model is updated before it is rested */ @@ -190,7 +191,7 @@ static uint32_t brute_force(struct cmp_cfg *cfg) percent = n_cal_steps*100/max_cal_steps; if (percent > 5+last && percent < 100) { last = percent; - printf("%u%%... ", percent); + printf("%" PRIu32 "%%... ", percent); fflush(stdout); } } diff --git a/lib/cmp_io.c b/lib/cmp_io.c index 6c762e1745756d8507a2dca7b6f922a95e91cfd9..357473049d2c72f2cc7ca6eed61cc73a2ef43bad 100644 --- a/lib/cmp_io.c +++ b/lib/cmp_io.c @@ -31,6 +31,7 @@ #include <rdcu_cmd.h> #include <byteorder.h> #include <cmp_data_types.h> +#include <my_inttypes.h> /* directory to convert from data_type to string */ @@ -468,7 +469,7 @@ const char *data_type2string(enum cmp_data_type data_type) * @returns 0 on success, error otherwise */ -int cmp_mode_parse(const char *cmp_mode_str, uint32_t *cmp_mode) +int cmp_mode_parse(const char *cmp_mode_str, enum cmp_mode *cmp_mode) { size_t j; static const struct { @@ -501,8 +502,10 @@ int cmp_mode_parse(const char *cmp_mode_str, uint32_t *cmp_mode) } return -1; } else { - if (atoui32(cmp_mode_str, cmp_mode_str, cmp_mode)) + uint32_t read_val; + if (atoui32(cmp_mode_str, cmp_mode_str, &read_val)) return -1; + *cmp_mode = read_val; } if (!cmp_mode_is_supported(*cmp_mode)) @@ -1450,7 +1453,7 @@ ssize_t read_file_cmp_entity(const char *file_name, struct cmp_entity *ent, PROGRAM_NAME, file_name); return -1; } - if (size != cmp_ent_get_size(ent)) { + if (size != (ssize_t)cmp_ent_get_size(ent)) { fprintf(stderr, "%s: %s: The size of the compression entity set in the header of the compression entity is not the same size as the read-in file has.\n", PROGRAM_NAME, file_name); return -1; @@ -1586,22 +1589,22 @@ static void write_cfg_internal(FILE *fp, const struct cmp_cfg *cfg) fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Number of samples to compress, length of the data and model buffer\n"); fprintf(fp, "\n"); - fprintf(fp, "samples = %u\n", cfg->samples); + fprintf(fp, "samples = %" PRIu32 "\n", cfg->samples); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Length of the compressed data buffer in number of samples\n"); fprintf(fp, "\n"); - fprintf(fp, "buffer_length = %u\n", cfg->buffer_length); + fprintf(fp, "buffer_length = %" PRIu32 "\n", cfg->buffer_length); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Model weighting parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "model_value = %u\n", cfg->model_value); + fprintf(fp, "model_value = %" PRIu32 "\n", cfg->model_value); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Number of noise bits to be rounded\n"); fprintf(fp, "\n"); - fprintf(fp, "round = %u\n", cfg->round); + fprintf(fp, "round = %" PRIu32 "\n", cfg->round); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); @@ -1612,12 +1615,12 @@ static void write_cfg_internal(FILE *fp, const struct cmp_cfg *cfg) if (cmp_imagette_data_type_is_used(cfg->data_type)) { fprintf(fp, "# Golomb parameter for dictionary selection\n"); fprintf(fp, "\n"); - fprintf(fp, "golomb_par = %u\n", cfg->golomb_par); + fprintf(fp, "golomb_par = %" PRIu32 "\n", cfg->golomb_par); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Spillover threshold for encoding outliers\n"); fprintf(fp, "\n"); - fprintf(fp, "spill = %u\n", cfg->spill); + fprintf(fp, "spill = %" PRIu32 "\n", cfg->spill); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } @@ -1626,42 +1629,42 @@ static void write_cfg_internal(FILE *fp, const struct cmp_cfg *cfg) fprintf(fp, "\n"); fprintf(fp, "# Adaptive 1 Golomb parameter; HW only\n"); fprintf(fp, "\n"); - fprintf(fp, "ap1_golomb_par = %u\n", cfg->ap1_golomb_par); + fprintf(fp, "ap1_golomb_par = %" PRIu32 "\n", cfg->ap1_golomb_par); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Adaptive 1 spillover threshold; HW only\n"); fprintf(fp, "\n"); - fprintf(fp, "ap1_spill = %u\n", cfg->ap1_spill); + fprintf(fp, "ap1_spill = %" PRIu32 "\n", cfg->ap1_spill); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Adaptive 2 Golomb parameter; HW only\n"); fprintf(fp, "\n"); - fprintf(fp, "ap2_golomb_par = %u\n", cfg->ap2_golomb_par); + fprintf(fp, "ap2_golomb_par = %" PRIu32 "\n", cfg->ap2_golomb_par); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Adaptive 2 spillover threshold; HW only\n"); fprintf(fp, "\n"); - fprintf(fp, "ap2_spill = %u\n", cfg->ap2_spill); + fprintf(fp, "ap2_spill = %" PRIu32 "\n", cfg->ap2_spill); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# RDCU data to compress start address, the first data address in the RDCU SRAM; HW only\n"); fprintf(fp, "\n"); - fprintf(fp, "rdcu_data_adr = 0x%06X\n", cfg->rdcu_data_adr); + fprintf(fp, "rdcu_data_adr = 0x%06"PRIX32"\n", cfg->rdcu_data_adr); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# RDCU model start address, the first model address in the RDCU SRAM\n"); fprintf(fp, "\n"); - fprintf(fp, "rdcu_model_adr = 0x%06X\n", cfg->rdcu_model_adr); + fprintf(fp, "rdcu_model_adr = 0x%06"PRIX32"\n", cfg->rdcu_model_adr); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# RDCU updated model start address, the address in the RDCU SRAM where the updated model is stored\n"); fprintf(fp, "\n"); - fprintf(fp, "rdcu_new_model_adr = 0x%06X\n", cfg->rdcu_new_model_adr); + fprintf(fp, "rdcu_new_model_adr = 0x%06"PRIX32"\n", cfg->rdcu_new_model_adr); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# RDCU compressed data start address, the first output data address in the RDCU SRAM\n"); fprintf(fp, "\n"); - fprintf(fp, "rdcu_buffer_adr = 0x%06X\n", cfg->rdcu_buffer_adr); + fprintf(fp, "rdcu_buffer_adr = 0x%06"PRIX32"\n", cfg->rdcu_buffer_adr); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } @@ -1669,33 +1672,33 @@ static void write_cfg_internal(FILE *fp, const struct cmp_cfg *cfg) if (cmp_aux_data_type_is_used(cfg->data_type)) { fprintf(fp, "# mean compression parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_par_mean = %u\n", cfg->cmp_par_mean); + fprintf(fp, "cmp_par_mean = %" PRIu32 "\n", cfg->cmp_par_mean); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# mean spillover threshold parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_mean = %u\n", cfg->spill_mean); + fprintf(fp, "spill_mean = %" PRIu32 "\n", cfg->spill_mean); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# variance compression parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_par_variance = %u\n", cfg->cmp_par_variance); + fprintf(fp, "cmp_par_variance = %" PRIu32 "\n", cfg->cmp_par_variance); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# variance spillover threshold parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_variance = %u\n", cfg->spill_variance); + fprintf(fp, "spill_variance = %" PRIu32 "\n", cfg->spill_variance); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); if (cfg->data_type != DATA_TYPE_OFFSET) { fprintf(fp, "# outlier pixels number compression parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_par_pixels_error = %u\n", cfg->cmp_par_pixels_error); + fprintf(fp, "cmp_par_pixels_error = %" PRIu32 "\n", cfg->cmp_par_pixels_error); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# outlier pixels number spillover threshold parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_pixels_error = %u\n", cfg->spill_pixels_error); + fprintf(fp, "spill_pixels_error = %" PRIu32 "\n", cfg->spill_pixels_error); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } @@ -1710,72 +1713,72 @@ static void write_cfg_internal(FILE *fp, const struct cmp_cfg *cfg) if (needed_pars.exp_flags) { fprintf(fp, "# exposure flags compression parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_par_exp_flags = %u\n", cfg->cmp_par_exp_flags); + fprintf(fp, "cmp_par_exp_flags = %" PRIu32 "\n", cfg->cmp_par_exp_flags); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# exposure flags spillover threshold parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_exp_flags = %u\n", cfg->spill_exp_flags); + fprintf(fp, "spill_exp_flags = %" PRIu32 "\n", cfg->spill_exp_flags); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } if (needed_pars.fx) { fprintf(fp, "# normal light flux compression parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_par_fx = %u\n", cfg->cmp_par_fx); + fprintf(fp, "cmp_par_fx = %" PRIu32 "\n", cfg->cmp_par_fx); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# normal light flux spillover threshold parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_fx = %u\n", cfg->spill_fx); + fprintf(fp, "spill_fx = %" PRIu32 "\n", cfg->spill_fx); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } if (needed_pars.ncob) { fprintf(fp, "# normal center of brightness compression parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_par_ncob = %u\n", cfg->cmp_par_ncob); + fprintf(fp, "cmp_par_ncob = %" PRIu32 "\n", cfg->cmp_par_ncob); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# normal center of brightness spillover threshold parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_nocb = %u\n", cfg->spill_ncob); + fprintf(fp, "spill_nocb = %" PRIu32 "\n", cfg->spill_ncob); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } if (needed_pars.efx) { fprintf(fp, "# extended light flux compression parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_par_efx = %u\n", cfg->cmp_par_efx); + fprintf(fp, "cmp_par_efx = %" PRIu32 "\n", cfg->cmp_par_efx); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# extended light flux spillover threshold parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_efx = %u\n", cfg->spill_efx); + fprintf(fp, "spill_efx = %" PRIu32 "\n", cfg->spill_efx); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } if (needed_pars.ecob) { fprintf(fp, "# extended center of brightness compression parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_par_ecob = %u\n", cfg->cmp_par_ecob); + fprintf(fp, "cmp_par_ecob = %" PRIu32 "\n", cfg->cmp_par_ecob); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# extended center of brightness spillover threshold parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_ecob = %u\n", cfg->spill_ecob); + fprintf(fp, "spill_ecob = %" PRIu32 "\n", cfg->spill_ecob); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } if (needed_pars.fx_cob_variance) { fprintf(fp, "# flux/COB variance compression parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_par_fx_cob_variance = %u\n", cfg->cmp_par_fx_cob_variance); + fprintf(fp, "cmp_par_fx_cob_variance = %" PRIu32 "\n", cfg->cmp_par_fx_cob_variance); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# flux/COB variance spillover threshold parameter\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_fx_cob_variance = %u\n", cfg->spill_fx_cob_variance); + fprintf(fp, "spill_fx_cob_variance = %" PRIu32 "\n", cfg->spill_fx_cob_variance); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } @@ -1858,27 +1861,27 @@ int cmp_info_to_file(const struct cmp_info *info, const char *output_prefix, fprintf(fp, "# 3: model mode with multi escape symbol mechanism\n"); fprintf(fp, "# 4: 1d differencing mode without input model multi escape symbol mechanism\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_mode_used = %u\n", info->cmp_mode_used); + fprintf(fp, "cmp_mode_used = %" PRIu32 "\n", info->cmp_mode_used); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Number of samples used, measured in 16 bit units, length of the data and model buffer\n"); fprintf(fp, "\n"); - fprintf(fp, "samples_used = %u\n", info->samples_used); + fprintf(fp, "samples_used = %" PRIu32 "\n", info->samples_used); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Compressed data size; measured in bits\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_size = %u\n", info->cmp_size); + fprintf(fp, "cmp_size = %" PRIu32 "\n", info->cmp_size); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Golomb parameter used\n"); fprintf(fp, "\n"); - fprintf(fp, "golomb_par_used = %u\n", info->golomb_par_used); + fprintf(fp, "golomb_par_used = %" PRIu32 "\n", info->golomb_par_used); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Spillover threshold used\n"); fprintf(fp, "\n"); - fprintf(fp, "spill_used = %u\n", info->spill_used); + fprintf(fp, "spill_used = %" PRIu32 "\n", info->spill_used); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Model weighting parameter used\n"); @@ -1900,22 +1903,22 @@ int cmp_info_to_file(const struct cmp_info *info, const char *output_prefix, fprintf(fp, "\n"); fprintf(fp, "# Adaptive compressed data size 1; measured in bits\n"); fprintf(fp, "\n"); - fprintf(fp, "ap1_cmp_size = %u\n", info->ap1_cmp_size); + fprintf(fp, "ap1_cmp_size = %" PRIu32 "\n", info->ap1_cmp_size); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Adaptive compressed data size 2; measured in bits\n"); fprintf(fp, "\n"); - fprintf(fp, "ap2_cmp_size = %u\n", info->ap2_cmp_size); + fprintf(fp, "ap2_cmp_size = %" PRIu32 "\n", info->ap2_cmp_size); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Updated model info start address used\n"); fprintf(fp, "\n"); - fprintf(fp, "rdcu_new_model_adr_used = 0x%06X\n", info->rdcu_new_model_adr_used); + fprintf(fp, "rdcu_new_model_adr_used = 0x%06"PRIX32"\n", info->rdcu_new_model_adr_used); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, " #RDCU compressed data start address\n"); fprintf(fp, "\n"); - fprintf(fp, "rdcu_cmp_adr_used = 0x%06X\n", info->rdcu_cmp_adr_used); + fprintf(fp, "rdcu_cmp_adr_used = 0x%06"PRIX32"\n", info->rdcu_cmp_adr_used); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); } diff --git a/lib/cmp_rdcu.c b/lib/cmp_rdcu.c index 6a7354573e94d64a5e5b982c01ac71f979e5a6ee..b7893397b4a87ca4b950b1c37368bb1d7336160c 100644 --- a/lib/cmp_rdcu.c +++ b/lib/cmp_rdcu.c @@ -36,6 +36,7 @@ #include <cmp_data_types.h> #include <rdcu_ctrl.h> #include <rdcu_rmap.h> +#include <my_inttypes.h> #define IMA_SAM2BYT \ @@ -111,13 +112,13 @@ static int rdcu_cfg_gen_par_is_invalid(const struct cmp_cfg *cfg) } if (cfg->model_value > MAX_MODEL_VALUE) { - debug_print("Error: selected model_value: %u is invalid. Largest supported value is: %u.\n", + debug_print("Error: selected model_value: %" PRIu32 " is invalid. Largest supported value is: %u.\n", cfg->model_value, MAX_MODEL_VALUE); cfg_invalid++; } if (cfg->round > MAX_RDCU_ROUND) { - debug_print("Error: selected round parameter: %u is not supported. Largest supported value is: %u.\n", + debug_print("Error: selected round parameter: %" PRIu32 " is not supported. Largest supported value is: %u.\n", cfg->round, MAX_RDCU_ROUND); cfg_invalid++; } @@ -415,57 +416,57 @@ static int rdcu_cfg_imagette_is_invalid(const struct cmp_cfg *cfg) if (cfg->golomb_par < MIN_IMA_GOLOMB_PAR || cfg->golomb_par > MAX_IMA_GOLOMB_PAR) { - debug_print("Error: The selected Golomb parameter: %u is not supported. The Golomb parameter has to be between [%u, %u].\n", + debug_print("Error: The selected Golomb parameter: %" PRIu32 " is not supported. The Golomb parameter has to be between [%u, %u].\n", cfg->golomb_par, MIN_IMA_GOLOMB_PAR, MAX_IMA_GOLOMB_PAR); cfg_invalid++; } if (cfg->ap1_golomb_par < MIN_IMA_GOLOMB_PAR || cfg->ap1_golomb_par > MAX_IMA_GOLOMB_PAR) { - debug_print("Error: The selected adaptive 1 Golomb parameter: %u is not supported. The Golomb parameter has to be between [%u, %u].\n", + debug_print("Error: The selected adaptive 1 Golomb parameter: %" PRIu32 " is not supported. The Golomb parameter has to be between [%u, %u].\n", cfg->ap1_golomb_par, MIN_IMA_GOLOMB_PAR, MAX_IMA_GOLOMB_PAR); cfg_invalid++; } if (cfg->ap2_golomb_par < MIN_IMA_GOLOMB_PAR || cfg->ap2_golomb_par > MAX_IMA_GOLOMB_PAR) { - debug_print("Error: The selected adaptive 2 Golomb parameter: %u is not supported. The Golomb parameter has to be between [%u, %u].\n", + debug_print("Error: The selected adaptive 2 Golomb parameter: %" PRIu32 " is not supported. The Golomb parameter has to be between [%u, %u].\n", cfg->ap2_golomb_par, MIN_IMA_GOLOMB_PAR, MAX_IMA_GOLOMB_PAR); cfg_invalid++; } if (cfg->spill < MIN_IMA_SPILL) { - debug_print("Error: The selected spillover threshold value: %u is too small. Smallest possible spillover value is: %u.\n", + debug_print("Error: The selected spillover threshold value: %" PRIu32 " is too small. Smallest possible spillover value is: %u.\n", cfg->spill, MIN_IMA_SPILL); cfg_invalid++; } if (cfg->spill > cmp_ima_max_spill(cfg->golomb_par)) { - debug_print("Error: The selected spillover threshold value: %u is too large for the selected Golomb parameter: %u, the largest possible spillover value is: %u.\n", + debug_print("Error: The selected spillover threshold value: %" PRIu32 " is too large for the selected Golomb parameter: %" PRIu32 ", the largest possible spillover value is: %" PRIu32 ".\n", cfg->spill, cfg->golomb_par, cmp_ima_max_spill(cfg->golomb_par)); cfg_invalid++; } if (cfg->ap1_spill < MIN_IMA_SPILL) { - debug_print("Error: The selected adaptive 1 spillover threshold value: %u is too small. Smallest possible spillover value is: %u.\n", + debug_print("Error: The selected adaptive 1 spillover threshold value: %" PRIu32 " is too small. Smallest possible spillover value is: %u.\n", cfg->ap1_spill, MIN_IMA_SPILL); cfg_invalid++; } if (cfg->ap1_spill > cmp_ima_max_spill(cfg->ap1_golomb_par)) { - debug_print("Error: The selected adaptive 1 spillover threshold value: %u is too large for the selected adaptive 1 Golomb parameter: %u, the largest possible adaptive 1 spillover value is: %u.\n", + debug_print("Error: The selected adaptive 1 spillover threshold value: %" PRIu32 " is too large for the selected adaptive 1 Golomb parameter: %" PRIu32 ", the largest possible adaptive 1 spillover value is: %" PRIu32 ".\n", cfg->ap1_spill, cfg->ap1_golomb_par, cmp_ima_max_spill(cfg->ap1_golomb_par)); cfg_invalid++; } if (cfg->ap2_spill < MIN_IMA_SPILL) { - debug_print("Error: The selected adaptive 2 spillover threshold value: %u is too small. Smallest possible spillover value is: %u.\n", + debug_print("Error: The selected adaptive 2 spillover threshold value: %" PRIu32 " is too small. Smallest possible spillover value is: %u.\n", cfg->ap2_spill, MIN_IMA_SPILL); cfg_invalid++; } if (cfg->ap2_spill > cmp_ima_max_spill(cfg->ap2_golomb_par)) { - debug_print("Error: The selected adaptive 2 spillover threshold value: %u is too large for the selected adaptive 2 Golomb parameter: %u, the largest possible adaptive 2 spillover value is: %u.\n", + debug_print("Error: The selected adaptive 2 spillover threshold value: %" PRIu32 " is too large for the selected adaptive 2 Golomb parameter: %" PRIu32 ", the largest possible adaptive 2 spillover value is: %" PRIu32 ".\n", cfg->ap2_spill, cfg->ap2_golomb_par, cmp_ima_max_spill(cfg->ap2_golomb_par)); cfg_invalid++; } diff --git a/lib/cmp_support.c b/lib/cmp_support.c index 49e56d1cb64332e3110c0064c10a765bcf1e3c8f..ce497e7ba764a767d2adf7a3382db1ce567c23b4 100644 --- a/lib/cmp_support.c +++ b/lib/cmp_support.c @@ -20,6 +20,7 @@ #include <cmp_support.h> #include <cmp_debug.h> +#include <my_inttypes.h> /** @@ -466,14 +467,14 @@ int cmp_cfg_icu_gen_par_is_invalid(const struct cmp_cfg *cfg) if (model_mode_is_used(cfg->cmp_mode)) { if (cfg->model_value > MAX_MODEL_VALUE) { - debug_print("Error: selected model_value: %u is invalid. Largest supported value is: %u.\n", + debug_print("Error: selected model_value: %" PRIu32 " is invalid. Largest supported value is: %u.\n", cfg->model_value, MAX_MODEL_VALUE); cfg_invalid++; } } if (cfg->round > MAX_ICU_ROUND) { - debug_print("Error: selected lossy parameter: %u is not supported. Largest supported value is: %u.\n", + debug_print("Error: selected lossy parameter: %" PRIu32 " is not supported. Largest supported value is: %u.\n", cfg->round, MAX_ICU_ROUND); cfg_invalid++; } @@ -604,17 +605,17 @@ static int cmp_pars_are_invalid(uint32_t cmp_par, uint32_t spill, enum cmp_mode case CMP_MODE_MODEL_ZERO: case CMP_MODE_MODEL_MULTI: if (cmp_par < min_golomb_par || cmp_par > max_golomb_par) { - debug_print("Error: The selected %s compression parameter: %u is not supported. The compression parameter has to be between [%u, %u].\n", + debug_print("Error: The selected %s compression parameter: %" PRIu32 " is not supported. The compression parameter has to be between [%" PRIu32 ", %" PRIu32 "].\n", par_name, cmp_par, min_golomb_par, max_golomb_par); cfg_invalid++; } if (spill < min_spill) { - debug_print("Error: The selected %s spillover threshold value: %u is too small. Smallest possible spillover value is: %u.\n", + debug_print("Error: The selected %s spillover threshold value: %" PRIu32 " is too small. Smallest possible spillover value is: %" PRIu32 ".\n", par_name, spill, min_spill); cfg_invalid++; } if (spill > max_spill) { - debug_print("Error: The selected %s spillover threshold value: %u is too large for the selected %s compression parameter: %u, the largest possible spillover value in the selected compression mode is: %u.\n", + debug_print("Error: The selected %s spillover threshold value: %" PRIu32 " is too large for the selected %s compression parameter: %" PRIu32 ", the largest possible spillover value in the selected compression mode is: %" PRIu32 ".\n", par_name, spill, par_name, cmp_par, max_spill); cfg_invalid++; } @@ -622,7 +623,7 @@ static int cmp_pars_are_invalid(uint32_t cmp_par, uint32_t spill, enum cmp_mode break; case CMP_MODE_STUFF: if (cmp_par > MAX_STUFF_CMP_PAR) { - debug_print("Error: The selected %s stuff mode compression parameter: %u is too large, the largest possible value in the selected compression mode is: %u.\n", + debug_print("Error: The selected %s stuff mode compression parameter: %" PRIu32 " is too large, the largest possible value in the selected compression mode is: %u.\n", par_name, cmp_par, MAX_STUFF_CMP_PAR); cfg_invalid++; } @@ -896,15 +897,15 @@ void print_cmp_info(const struct cmp_info *info) return; } - debug_print("cmp_mode_used: %u\n", info->cmp_mode_used); - debug_print("spill_used: %u\n", info->spill_used); - debug_print("golomb_par_used: %u\n", info->golomb_par_used); - debug_print("samples_used: %u\n", info->samples_used); - debug_print("cmp_size: %u\n", info->cmp_size); - debug_print("ap1_cmp_size: %u\n", info->ap1_cmp_size); - debug_print("ap2_cmp_size: %u\n", info->ap2_cmp_size); - debug_print("rdcu_new_model_adr_used: 0x%06X\n", info->rdcu_new_model_adr_used); - debug_print("rdcu_cmp_adr_used: 0x%06X\n", info->rdcu_cmp_adr_used); + debug_print("cmp_mode_used: %" PRIu32 "\n", info->cmp_mode_used); + debug_print("spill_used: %" PRIu32 "\n", info->spill_used); + debug_print("golomb_par_used: %" PRIu32 "\n", info->golomb_par_used); + debug_print("samples_used: %" PRIu32 "\n", info->samples_used); + debug_print("cmp_size: %" PRIu32 "\n", info->cmp_size); + debug_print("ap1_cmp_size: %" PRIu32 "\n", info->ap1_cmp_size); + debug_print("ap2_cmp_size: %" PRIu32 "\n", info->ap2_cmp_size); + debug_print("rdcu_new_model_adr_used: 0x%06"PRIX32"\n", info->rdcu_new_model_adr_used); + debug_print("rdcu_cmp_adr_used: 0x%06"PRIX32"\n", info->rdcu_cmp_adr_used); debug_print("model_value_used: %u\n", info->model_value_used); debug_print("round_used: %u\n", info->round_used); debug_print("cmp_err: %#X\n", info->cmp_err); diff --git a/lib/rmap.c b/lib/rmap.c index 703add595bb907340be3399759178229afa6db89..06f7263805475db067bd17032fd49e25e3854425 100644 --- a/lib/rmap.c +++ b/lib/rmap.c @@ -25,9 +25,7 @@ #include <stdio.h> #include <rmap.h> - - - +#include <my_inttypes.h> /** @@ -585,7 +583,7 @@ struct rmap_pkt *rmap_pkt_from_buffer(uint8_t *buf, uint32_t len) if (pkt->data_len) { if (len < RMAP_DATA_START + n + pkt->data_len + 1) { /* +1 for data CRC */ - printf("buffer len is smaller than the contained RMAP packet; buf len: %u bytes vs RMAP: %zu bytes needed\n", + printf("buffer len is smaller than the contained RMAP packet; buf len: %" PRIu32 " bytes vs RMAP: %lu bytes needed\n", len, RMAP_DATA_START + n + pkt->data_len); goto error; } diff --git a/sparc-efl-gcc.txt b/sparc-efl-gcc.txt new file mode 100644 index 0000000000000000000000000000000000000000..817f1154e803ca79b4ef05357b6a64d3e49d3c32 --- /dev/null +++ b/sparc-efl-gcc.txt @@ -0,0 +1,24 @@ +[binaries] +c = 'sparc-elf-gcc' +cpp = 'sparc-elf-g++' +objc = 'sparc-elf-gcc' +ar = 'sparc-elf-ar' +strip = 'sparc-elf-strip' +ld = 'sparc-elf-ld' + +# pkgconfig = ['false'] +# cmake = ['false'] + +[built-in options] +# use sparcv8 +c_args = ['-mcpu=v8'] +b_staticpic = 'false' + +[properties] + + +[host_machine] +system = 'none' +cpu_family = 'sparc' +cpu = 'leon' +endian = 'big'