Changeset 777 for soft


Ignore:
Timestamp:
Feb 4, 2016, 6:25:22 PM (9 years ago)
Author:
meunier
Message:
  • Ajout de quelques fonction dans la lib math
  • Déplacement de certaines fonctions de stdlib vers string
Location:
soft/giet_vm
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/Makefile

    r776 r777  
    130130                build/libs/math/s_copysign.o   \
    131131                build/libs/math/s_fabs.o       \
     132                build/libs/math/fmod.o       \
    132133                build/libs/math/s_finite.o     \
    133134                build/libs/math/s_floor.o      \
     135                build/libs/math/s_ceil.o       \
    134136                build/libs/math/s_isnan.o      \
    135137                build/libs/math/sqrt.o         \
  • soft/giet_vm/applications/rosenfeld/include/ecc_generation.h

    r772 r777  
    1414void generate_granularity_density_float(uint8 **X, int i0, int i1, int j0, int j1, int granularity, float density, int seed);
    1515   
    16 void generate_size_granularity_name            (char *name, int size, int granularity,                               char *filename);
    17 void generate_granularity_density_name         (char *name,           int granularity, int density,                  char *filename);
    18 void generate_granularity_density_ext_name     (char *name,           int granularity, int density, char *extension, char *filename);
     16void generate_size_granularity_name            (char *name, int size, int granularity,                               char *filename, int maxlen);
     17void generate_granularity_density_name         (char *name,           int granularity, int density,                  char *filename, int maxlen);
     18void generate_granularity_density_ext_name     (char *name,           int granularity, int density, char *extension, char *filename, int maxlen);
    1919   
    20 void generate_size_granularity_density_name    (char *name, int size, int granularity, int density,                  char *filename);
    21 void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename);
     20void generate_size_granularity_density_name    (char *name, int size, int granularity, int density,                  char *filename, int maxlen);
     21void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename, int maxlen);
    2222
    23 void generate_name100(char *name, int granularity, float density, char *filename);
     23void generate_name100(char *name, int granularity, float density, char *filename, int maxlen);
    2424
    2525int test_generation(int argc, char* argv[]);
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio0.h

    r772 r777  
    2020#endif
    2121
    22 IMAGE_EXPORT(void) generate_filename_k_ndigit          (char *filename, int k, int ndigit,                  char *complete_filename);
    23 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename);
     22IMAGE_EXPORT(void) generate_filename_k_ndigit          (char *filename, int k, int ndigit,                  char *complete_filename, int maxlen);
     23IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen);
    2424
    25 IMAGE_EXPORT(void) generate_path_filename                     (char *path, char *filename,                                            char *complete_filename);
    26 IMAGE_EXPORT(void) generate_path_filename_extension           (char *path, char *filename,                           char *extension, char *complete_filename);
    27 IMAGE_EXPORT(void) generate_path_filename_suffix_extension    (char *path, char *filename, char *suffix,             char *extension, char *complete_filename);
    28 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension  (char *path, char *filename, int k, int ndigit,        char *extension, char *complete_filename);
    29 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename);
     25IMAGE_EXPORT(void) generate_path_filename                     (char *path, char *filename,                                            char *complete_filename, int maxlen);
     26IMAGE_EXPORT(void) generate_path_filename_extension           (char *path, char *filename,                           char *extension, char *complete_filename, int maxlen);
     27IMAGE_EXPORT(void) generate_path_filename_suffix_extension    (char *path, char *filename, char *suffix,             char *extension, char *complete_filename, int maxlen);
     28IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension  (char *path, char *filename, int k, int ndigit,        char *extension, char *complete_filename, int maxlen);
     29IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename, int maxlen);
    3030
    3131void select_display_positive_parameters(int iformat, char **format, char **str);
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio0.c

    r772 r777  
    2626
    2727/* --------------------------------------------------------------------------------------------------- */
    28 IMAGE_EXPORT(void) generate_filename_k_ndigit(char *filename, int k, int ndigit, char *complete_filename)
     28IMAGE_EXPORT(void) generate_filename_k_ndigit(char *filename, int k, int ndigit, char *complete_filename, int maxlen)
    2929/* --------------------------------------------------------------------------------------------------- */
    3030{
     
    4343    case 9 : format = "%s%09d.txt"; break;
    4444  }
    45   sprintf(complete_filename, format, filename, k);
     45  snprintf(complete_filename, maxlen, format, filename, k);
    4646}
    47 /* ------------------------------------------------------------------------------------------------------------------------------ */
    48 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename)
    49 /* ------------------------------------------------------------------------------------------------------------------------------ */
     47/* ------------------------------------------------------------------------------------------------------------------------------------------ */
     48IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen)
     49/* ------------------------------------------------------------------------------------------------------------------------------------------ */
    5050{
    5151  char *format = "%s%d.%s";
     
    6363    case 9 : format = "%s%09d.%s"; break;
    6464  }
    65   sprintf(complete_filename, format, filename, k, extension);
     65  snprintf(complete_filename, maxlen, format, filename, k, extension);
    6666}
    67 /* ---------------------------------------------------------------------------------------- */
    68 IMAGE_EXPORT(void) generate_path_filename(char *path, char *filename, char *complete_filename)
    69 /* ---------------------------------------------------------------------------------------- */
     67/* ---------------------------------------------------------------------------------------------------- */
     68IMAGE_EXPORT(void) generate_path_filename(char *path, char *filename, char *complete_filename, int maxlen)
     69/* ---------------------------------------------------------------------------------------------------- */
    7070{
    71   sprintf(complete_filename, "%s%s", path, filename);
     71  snprintf(complete_filename, maxlen, "%s%s", path, filename);
    7272}
    73 /* ------------------------------------------------------------------------------------------------------------------- */
    74 IMAGE_EXPORT(void) generate_path_filename_extension(char *path, char *filename, char *extension, char *complete_filename)
    75 /* ------------------------------------------------------------------------------------------------------------------- */
     73/* ------------------------------------------------------------------------------------------------------------------------------- */
     74IMAGE_EXPORT(void) generate_path_filename_extension(char *path, char *filename, char *extension, char *complete_filename, int maxlen)
     75/* ------------------------------------------------------------------------------------------------------------------------------- */
    7676{
    77   sprintf(complete_filename, "%s%s.%s", path, filename, extension);
     77  snprintf(complete_filename, maxlen, "%s%s.%s", path, filename, extension);
    7878}
    79 /* ---------------------------------------------------------------------------------------------------------------------------------------- */
    80 IMAGE_EXPORT(void) generate_path_filename_suffix_extension(char *path, char *filename, char *suffix, char *extension, char *complete_filename)
    81 /* ---------------------------------------------------------------------------------------------------------------------------------------- */
     79/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
     80IMAGE_EXPORT(void) generate_path_filename_suffix_extension(char *path, char *filename, char *suffix, char *extension, char *complete_filename, int maxlen)
     81/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
    8282{
    83     sprintf(complete_filename, "%s%s%s.%s", path, filename, suffix, extension);
     83    snprintf(complete_filename, maxlen, "%s%s%s.%s", path, filename, suffix, extension);
    8484}
    85 /* ----------------------------------------------------------------------------------------------------------------------------------------------- */
    86 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension(char *path, char *filename, int k, int ndigit, char *extension, char *complete_filename)
    87 /* ----------------------------------------------------------------------------------------------------------------------------------------------- */
     85/* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */
     86IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension(char *path, char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen)
     87/* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */
    8888{
    8989  char *format = "%s%s%d.%s";
     
    101101    case 9 : format = "%s%s%09d.%s"; break;
    102102  }
    103   sprintf(complete_filename, format, path, filename, k, extension);
     103  snprintf(complete_filename, maxlen, format, path, filename, k, extension);
    104104}
    105 /* -------------------------------------------------------------------------------------------------------------------------------------------------------- */
    106 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename)
    107 /* -------------------------------------------------------------------------------------------------------------------------------------------------------- */
     105/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
     106IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename, int maxlen)
     107/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
    108108{
    109109  char *format = "%s%s%d_%d.%s";
     
    121121    case 9 : format = "%s%s%09d_%09d.%s"; break;
    122122  }
    123   sprintf(complete_filename, format, path, filename, k, l, extension);
     123  snprintf(complete_filename, maxlen, format, path, filename, k, l, extension);
    124124}
    125125// ----------------------------------------------------------------------------
  • soft/giet_vm/applications/rosenfeld/src/ecc_common.c

    r772 r777  
    55#include <stdio.h>
    66#include <stdlib.h>
     7#include <string.h>
    78#include <math.h>
    89
     
    310311    char complete_filename[64];
    311312   
    312     sprintf(complete_filename, "%s.dot", filename);
     313    snprintf(complete_filename, 64, "%s.dot", filename);
    313314   
    314315    fd = open(complete_filename, O_CREAT | O_TRUNC);
     
    330331    char complete_filename[64];
    331332   
    332     sprintf(complete_filename, "%s.dot", filename);
     333    snprintf(complete_filename, 64, "%s.dot", filename);
    333334   
    334335   
     
    351352    char complete_filename[64];
    352353   
    353     sprintf(complete_filename, "%s.dot", filename);
     354    snprintf(complete_filename, 64, "%s.dot", filename);
    354355   
    355356   
     
    403404    char complete_filename[64];
    404405   
    405     sprintf(complete_filename, "%s.dot", filename);
     406    snprintf(complete_filename, 64, "%s.dot", filename);
    406407   
    407408   
  • soft/giet_vm/applications/rosenfeld/src/ecc_generation.c

    r772 r777  
    5858    generate_granularity_density_float(X, i0, i1, j0, j1, granularity, (float) density, seed);
    5959}
    60 // ---------------------------------------------------------------------------------------------
    61 void generate_granularity_density_name(char *name, int granularity, int density, char *filename)
    62 // ---------------------------------------------------------------------------------------------
    63 {
    64     sprintf(filename, "%s_%02d_%03d.pgm", name, granularity, density);
    65 }
    66 // ------------------------------------------------------------------------------------------------------------------
    67 void generate_granularity_density_ext_name(char *name, int granularity, int density, char *extension, char *filename)
    68 // ------------------------------------------------------------------------------------------------------------------
    69 {
    70     sprintf(filename, "%s_%02d_%03d.%s", name, granularity, density, extension);
    71 }
    72 // ------------------------------------------------------------------------------------------------------------
    73 void generate_size_granularity_density_name(char *name, int size, int granularity, int density, char *filename)
    74 // ------------------------------------------------------------------------------------------------------------
    75 {
    76     sprintf(filename, "%s_%d_%02d_%03d.pgm", name, size, granularity, density);
    77 }
    78 // ---------------------------------------------------------------------------------------------------------------------------------
    79 void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename)
    80 // ---------------------------------------------------------------------------------------------------------------------------------
    81 {
    82     sprintf(filename, "%s_%d_%02d_%03d.%s", name, size, granularity, density, extension);
    83 }
    84 // ---------------------------------------------------------------------------------------
    85 void generate_size_granularity_name(char *name, int size, int granularity, char *filename)
    86 // ---------------------------------------------------------------------------------------
    87 {
    88     sprintf(filename, "%s_%d_%02d.pgm", name, size, granularity);
    89 }// ------------------------------------------------------------------------------
    90 void generate_name100(char *name, int granularity, float density, char *filename)
    91 // ------------------------------------------------------------------------------
     60// ---------------------------------------------------------------------------------------------------------
     61void generate_granularity_density_name(char *name, int granularity, int density, char *filename, int maxlen)
     62// ---------------------------------------------------------------------------------------------------------
     63{
     64    snprintf(filename, maxlen, "%s_%02d_%03d.pgm", name, granularity, density);
     65}
     66// ------------------------------------------------------------------------------------------------------------------------------
     67void generate_granularity_density_ext_name(char *name, int granularity, int density, char *extension, char *filename, int maxlen)
     68// ------------------------------------------------------------------------------------------------------------------------------
     69{
     70    snprintf(filename, maxlen, "%s_%02d_%03d.%s", name, granularity, density, extension);
     71}
     72// ------------------------------------------------------------------------------------------------------------------------
     73void generate_size_granularity_density_name(char *name, int size, int granularity, int density, char *filename, int maxlen)
     74// ------------------------------------------------------------------------------------------------------------------------
     75{
     76    snprintf(filename, maxlen, "%s_%d_%02d_%03d.pgm", name, size, granularity, density);
     77}
     78// ---------------------------------------------------------------------------------------------------------------------------------------------
     79void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename, int maxlen)
     80// ---------------------------------------------------------------------------------------------------------------------------------------------
     81{
     82    snprintf(filename, maxlen, "%s_%d_%02d_%03d.%s", name, size, granularity, density, extension);
     83}
     84// ---------------------------------------------------------------------------------------------------
     85void generate_size_granularity_name(char *name, int size, int granularity, char *filename, int maxlen)
     86// ---------------------------------------------------------------------------------------------------
     87{
     88    snprintf(filename, maxlen, "%s_%d_%02d.pgm", name, size, granularity);
     89}// -----------------------------------------------------------------------------------------
     90void generate_name100(char *name, int granularity, float density, char *filename, int maxlen)
     91// ------------------------------------------------------------------------------------------
    9292{
    9393    // density en pourcentage: 0:100
    9494    // mais aussi <1, par exe 0.01
    9595    int d = (int) ceil(100 * density);
    96     sprintf(filename, "%s_%02d_%05d.pgm", name, granularity, d);
     96    snprintf(filename, maxlen, "%s_%02d_%05d.pgm", name, granularity, d);
    9797}
    9898// ----------------------------------------
     
    128128        for(d=dmin; d<=dmax; d+=dstep) {
    129129            generate_granularity_density_int(X, 0, n-1, 0, n-1, g, d, seed);
    130             generate_granularity_density_name("I", g, d, filename);
     130            generate_granularity_density_name("I", g, d, filename, 32);
    131131            printf(filename);
    132132            bin2gray_ui8matrix(X, 0, n-1, 0, n-1, X255);
     
    256256    X255 = ui8matrix(0, h-1, 0, w-1);
    257257   
    258     sprintf(filename, "spirale_simple_%d.pgm", n);
     258    snprintf(filename, 128, "spirale_simple_%d.pgm", n);
    259259    spirale_simple(X, h, w);
    260260    bin2gray_ui8matrix(X,   0, h-1, 0, w-1, X255);
    261261    SavePGM_ui8matrix(X255, 0, h-1, 0, w-1, filename);
    262262   
    263     sprintf(filename, "spirale_double_%d.pgm", n);
     263    snprintf(filename, 128, "spirale_double_%d.pgm", n);
    264264    spirale_double(X, h, w);
    265265    bin2gray_ui8matrix(X,   0, h-1, 0, w-1, X255);
     
    306306
    307307    generate_granularity_density_float(X, 0, h-1, 0, w-1, g, d, seed);
    308     generate_granularity_density_name("HGH", g, d, filename);
     308    generate_granularity_density_name("HGH", g, d, filename, 32);
    309309    printf(filename);
    310310    bin2gray_ui8matrix(X,   0, h-1, 0, w-1, X255);
  • soft/giet_vm/applications/rosenfeld/src/ecc_main_rosenfeld_sa.c

    r772 r777  
    105105    binarisation_ui8matrix(X0, i0, i1, j0, j1, 1, 1, X);    // pour le traitement
    106106    binarisation_ui8matrix(X0, i0, i1, j0, j1, 1, 255, X0); // pour la verif visuelle
    107     generate_path_filename(dst_path, "verif.pgm", complete_filename);
     107    generate_path_filename(dst_path, "verif.pgm", complete_filename, 1024);
    108108    SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename);
    109109    display_ui8matrix_positive(X, i0, i1, j0, j1, 3, "X");
     
    131131    // traitement: desactiver FlattenL dans Rosenfeld
    132132    // pour voir l'image d'etiquettes  sans re-etiquetage
    133     na = Rosenfeld_UF_Org1_4C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org1_4C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
    134 
    135 
    136     na = Rosenfeld_UF_Org1_8C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org1_8C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
    137 
    138 
    139     na = Rosenfeld_UF_Org2_4C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org2_4C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
     133    na = Rosenfeld_UF_Org1_4C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org1_4C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename, 1024); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
     134
     135
     136    na = Rosenfeld_UF_Org1_8C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org1_8C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename, 1024); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
     137
     138
     139    na = Rosenfeld_UF_Org2_4C(X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org2_4C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(dst_path, filename, complete_filename, 1024); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); display_ui32matrix_positive(E32,i0, i1, j0, j1, 3, "E1"); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);
    140140   
    141141    // free
     
    188188   
    189189    Palette_18ColorsBW(palette);
    190     generate_path_filename(pathSrc, filename, complete_filename);
     190    generate_path_filename(pathSrc, filename, complete_filename, 1024);
    191191
    192192    // chargement d'une image depuis le disque
     
    206206    binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 1, X); // pour le traitement
    207207    binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 255, X0); // pour la verif visuelle
    208     generate_path_filename(pathDst, "verif.pgm", complete_filename);
     208    generate_path_filename(pathDst, "verif.pgm", complete_filename, 1024);
    209209    SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename);
    210210
     
    236236    filename = "Rosenfeld_UF_Org1_8C.bmp";
    237237    mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8);
    238     generate_path_filename(pathDst, filename, complete_filename);
     238    generate_path_filename(pathDst, filename, complete_filename, 1024);
    239239    SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename);
    240240    zero_ui32matrix(E32, i0 - border, i1 + border, j0 - border, j1 + border);
  • soft/giet_vm/applications/rosenfeld/src/str_ext.c

    r772 r777  
    99#include <stdio.h>
    1010#include <stdlib.h>
     11#include <string.h>
    1112
    1213#include "nrc_os_config.h"
  • soft/giet_vm/giet_libs/malloc.c

    r709 r777  
    88#include "malloc.h"
    99#include "stdio.h"
     10#include "stdlib.h"
    1011#include "giet_config.h"
    1112
     
    214215
    215216////////////////////////////////////////
    216 void * remote_malloc( unsigned int size,
     217void * remote_malloc( int size,
    217218                      unsigned int x,
    218219                      unsigned int y )
     
    278279#endif
    279280
    280     return (void*)base;
     281    return (void*) base;
    281282
    282283} // end remote_malloc()
     
    284285
    285286//////////////////////////////////
    286 void * malloc( unsigned int size )
     287void * malloc( int size )
    287288{
    288289    // get cluster coordinates
    289     unsigned int    x;
    290     unsigned int    y;
    291     unsigned int    lpid;
     290    unsigned int x;
     291    unsigned int y;
     292    unsigned int lpid;
    292293    giet_proc_xyp( &x, &y, &lpid );
    293294
    294295    return remote_malloc( size, x, y );
    295296}
     297
     298
     299////////////////////////////////////
     300void * calloc ( int nbmem, int size )
     301{
     302    void * a = malloc( nbmem * size );
     303    memset( a, 0, nbmem * size );
     304    return a;
     305}
    296306
    297307///////////////////////////////////////////
  • soft/giet_vm/giet_libs/malloc.h

    r709 r777  
    9393                       unsigned int y );
    9494
    95 extern void* malloc( unsigned int size );
     95extern void * malloc( int size );
     96extern void * calloc( int nbmem,
     97                      int size );
    9698
    97 extern void* remote_malloc( unsigned int size,
    98                             unsigned int x,
    99                             unsigned int y );
     99extern void * remote_malloc( int size,
     100                             unsigned int x,
     101                             unsigned int y );
    100102
    101103extern void free(void * ptr);
  • soft/giet_vm/giet_libs/math.h

    r667 r777  
    77
    88double  fabs    (double x);
     9double  fmod    (double x, double y);
    910double  floor   (double x);
     11double  ceil    (double x);
    1012double  sin             (double x);
    1113double  cos             (double x);
    1214double  pow             (double x, double y);
     15double  exp     (double x);
    1316int             isnan   (double x);
    1417int             isfinite(double x);
  • soft/giet_vm/giet_libs/math/e_pow.c

    r682 r777  
    103103        int32_t i,j,k,yisint,n;
    104104        int32_t hx,hy,ix,iy;
    105         u_int32_t lx,ly;
     105        uint32_t lx,ly;
    106106
    107107        EXTRACT_WORDS(hx,lx,x);
     
    180180
    181181    /* (x<0)**(non-int) is NaN */
    182         if(((((u_int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x);
     182        if(((((uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x);
    183183
    184184    /* |y| is huge */
     
    251251
    252252        s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
    253         if(((((u_int32_t)hx>>31)-1)|(yisint-1))==0)
     253        if(((((uint32_t)hx>>31)-1)|(yisint-1))==0)
    254254            s = -one;/* (-ve)**(odd int) */
    255255
     
    312312{
    313313        double z = __ieee754_pow(x, y);
    314         if (isnan(y))
     314        if (isnan(y)) {
    315315                return z;
     316    }
    316317        if (isnan(x)) {
    317318                if (y == 0.0) {
     
    322323        if (x == 0.0) {
    323324                if (y == 0.0) {
    324                         return 0; /* pow(0.0,0.0) */
     325            return 0; /* pow(0.0,0.0) */
    325326                }
    326327                if (isfinite(y) && y < 0.0) {
     
    332333                if (isfinite(x) && isfinite(y)) {
    333334                        if (isnan(z)) {
    334                                 return 0.0/0.0; /* pow neg**non-int */
     335                                return 0.0 / 0.0; /* pow neg**non-int */
    335336                        }
    336337                        {
    337338                                double ret = huge;
    338339                                y *= 0.5;
    339                                 if(x<zero&&rint(y)!=y) ret = -huge;
     340                                if (x < zero && rint(y) !=y ) {
     341                    ret = -huge;
     342                }
    340343                                return ret;
    341344                        }
     
    347350        return z;
    348351}
     352
     353/*
     354 * Pseudo exp function (QM)
     355 * There probably is a better implementation
     356 */
     357double exp(double x)
     358{
     359    const double e = 2.71828182846;
     360    return pow(e, x);
     361}
     362
  • soft/giet_vm/giet_libs/math/e_rem_pio2.c

    r581 r777  
    7575        double tx[3];
    7676        int32_t e0,i,j,nx,n,ix,hx;
    77         u_int32_t low;
     77        uint32_t low;
    7878
    7979        GET_HIGH_WORD(hx,x);            /* high word of x */
     
    115115                y[0] = r-w;     /* quick check no cancellation */
    116116            } else {
    117                 u_int32_t high;
     117                uint32_t high;
    118118                j  = ix>>20;
    119119                y[0] = r-w;
  • soft/giet_vm/giet_libs/math/e_sqrt.c

    r581 r777  
    9393        int32_t sign = (int)0x80000000;
    9494        int32_t ix0,s0,q,m,t,i;
    95         u_int32_t r,t1,s1,ix1,q1;
     95        uint32_t r,t1,s1,ix1,q1;
    9696
    9797        EXTRACT_WORDS(ix0,ix1,x);
     
    168168            if (z>=one) {
    169169                z = one+tiny;
    170                 if (q1==(u_int32_t)0xffffffff) { q1=0; q += 1;}
     170                if (q1==(uint32_t)0xffffffff) { q1=0; q += 1;}
    171171                else if (z>one) {
    172                     if (q1==(u_int32_t)0xfffffffe) q+=1;
     172                    if (q1==(uint32_t)0xfffffffe) q+=1;
    173173                    q1+=2;
    174174                } else
  • soft/giet_vm/giet_libs/math/math_private.h

    r588 r777  
    1616#define _MATH_PRIVATE_H_
    1717
    18 typedef unsigned int u_int32_t;
    19 
     18typedef unsigned int uint32_t;
    2019typedef int          int32_t;
     20typedef unsigned long long int uint64_t;
     21typedef long long int int64_t;
    2122
    2223/* The original fdlibm code used statements like:
     
    5152  struct
    5253  {
    53     u_int32_t msw;
    54     u_int32_t lsw;
     54    uint32_t msw;
     55    uint32_t lsw;
    5556  } parts;
    5657} ieee_double_shape_type;
     
    6465  struct
    6566  {
    66     u_int32_t lsw;
    67     u_int32_t msw;
     67    uint32_t lsw;
     68    uint32_t msw;
    6869  } parts;
    6970} ieee_double_shape_type;
  • soft/giet_vm/giet_libs/math/s_copysign.c

    r581 r777  
    2424double copysign(double x, double y)
    2525{
    26         u_int32_t hx,hy;
     26        uint32_t hx,hy;
    2727        GET_HIGH_WORD(hx,x);
    2828        GET_HIGH_WORD(hy,y);
  • soft/giet_vm/giet_libs/math/s_fabs.c

    r581 r777  
    2222double fabs(double x)
    2323{
    24         u_int32_t high;
     24        uint32_t high;
    2525        GET_HIGH_WORD(high,x);
    2626        SET_HIGH_WORD(x,high&0x7fffffff);
  • soft/giet_vm/giet_libs/math/s_finite.c

    r581 r777  
    2323int isfinite(double x)
    2424{
    25         u_int32_t hx;
     25        uint32_t hx;
    2626
    2727        GET_HIGH_WORD(hx, x);
  • soft/giet_vm/giet_libs/math/s_floor.c

    r581 r777  
    1111
    1212/* Modified for GIET-VM static OS at UPMC, France 2015.
    13  */
     13*/
    1414
    1515/*
     
    2828double floor(double x)
    2929{
    30         int32_t i0,i1,j0;
    31         u_int32_t i,j;
    32         EXTRACT_WORDS(i0,i1,x);
    33         j0 = ((i0>>20)&0x7ff)-0x3ff;
    34         if(j0<20) {
    35             if(j0<0) {  /* raise inexact if x != 0 */
    36                 if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
    37                     if(i0>=0) {i0=i1=0;}
    38                     else if(((i0&0x7fffffff)|i1)!=0)
    39                         { i0=0xbff00000;i1=0;}
    40                 }
    41             } else {
    42                 i = (0x000fffff)>>j0;
    43                 if(((i0&i)|i1)==0) return x; /* x is integral */
    44                 if(huge+x>0.0) {        /* raise inexact flag */
    45                     if(i0<0) i0 += (0x00100000)>>j0;
    46                     i0 &= (~i); i1=0;
    47                 }
    48             }
    49         } else if (j0>51) {
    50             if(j0==0x400) return x+x;   /* inf or NaN */
    51             else return x;              /* x is integral */
    52         } else {
    53             i = ((u_int32_t)(0xffffffff))>>(j0-20);
    54             if((i1&i)==0) return x;     /* x is integral */
    55             if(huge+x>0.0) {            /* raise inexact flag */
    56                 if(i0<0) {
    57                     if(j0==20) i0+=1;
    58                     else {
    59                         j = i1+(1<<(52-j0));
    60                         if(j<i1) i0 +=1 ;       /* got a carry */
    61                         i1=j;
    62                     }
    63                 }
    64                 i1 &= (~i);
    65             }
    66         }
    67         INSERT_WORDS(x,i0,i1);
    68         return x;
     30    int32_t i0, i1, j0;
     31    uint32_t i, j;
     32    EXTRACT_WORDS(i0, i1, x);
     33    j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
     34    if (j0 < 20) {
     35        if (j0 < 0) {   /* raise inexact if x != 0 */
     36            if (huge + x > 0.0) {/* return 0*sign(x) if |x|<1 */
     37                if (i0 >= 0) {
     38                    i0 = i1 = 0;
     39                }
     40                else if (((i0 & 0x7fffffff) | i1) != 0) {
     41                    i0 = 0xbff00000;
     42                    i1 = 0;
     43                }
     44            }
     45        }
     46        else {
     47            i = (0x000fffff) >> j0;
     48            if (((i0 & i) | i1) == 0) {
     49                return x; /* x is integral */
     50            }
     51            if (huge + x > 0.0) {       /* raise inexact flag */
     52                if (i0 < 0) {
     53                    i0 += (0x00100000) >> j0;
     54                }
     55                i0 &= (~i);
     56                i1 = 0;
     57            }
     58        }
     59    }
     60    else if (j0 > 51) {
     61        if (j0 == 0x400) {
     62            return x + x;       /* inf or NaN */
     63        }
     64        else {
     65            return x;           /* x is integral */
     66        }
     67    }
     68    else {
     69        i = ((uint32_t) (0xffffffff)) >> (j0 - 20);
     70        if ((i1 & i)== 0) {
     71            return x;   /* x is integral */
     72        }
     73        if (huge + x > 0.0) {           /* raise inexact flag */
     74            if (i0 < 0) {
     75                if (j0 == 20) {
     76                    i0 += 1;
     77                }
     78                else {
     79                    j = i1 + (1 << (52 - j0));
     80                    if (j < i1) {
     81                        i0 += 1 ;       /* got a carry */
     82                    }
     83                    i1 = j;
     84                }
     85            }
     86            i1 &= (~i);
     87        }
     88    }
     89    INSERT_WORDS(x, i0, i1);
     90    return x;
    6991}
    7092
  • soft/giet_vm/giet_libs/math/s_isnan.c

    r581 r777  
    2626        EXTRACT_WORDS(hx,lx,x);
    2727        hx &= 0x7fffffff;
    28         hx |= (u_int32_t)(lx|(-lx))>>31;
     28        hx |= (uint32_t)(lx|(-lx))>>31;
    2929        hx = 0x7ff00000 - hx;
    30         return (int)(((u_int32_t)hx)>>31);
     30        return (int)(((uint32_t)hx)>>31);
    3131}
  • soft/giet_vm/giet_libs/math/s_rint.c

    r581 r777  
    3535{
    3636        int32_t i0, j0, sx;
    37         u_int32_t i,i1;
     37        uint32_t i,i1;
    3838        double t;
    3939        /* We use w = x + 2^52; t = w - 2^52; trick to round x to integer.
     
    4747        EXTRACT_WORDS(i0,i1,x);
    4848        /* Unbiased exponent */
    49         j0 = ((((u_int32_t)i0) >> 20)&0x7ff)-0x3ff;
     49        j0 = ((((uint32_t)i0) >> 20)&0x7ff)-0x3ff;
    5050
    5151        if (j0 > 51) {
     
    5757
    5858        /* Sign */
    59         sx = ((u_int32_t)i0) >> 31;
     59        sx = ((uint32_t)i0) >> 31;
    6060
    6161        if (j0<20) {
     
    8181            }
    8282        } else {
    83             i = ((u_int32_t)(0xffffffff))>>(j0-20);
     83            i = ((uint32_t)(0xffffffff))>>(j0-20);
    8484            if ((i1&i)==0) return x;    /* x is integral */
    8585            i>>=1;
  • soft/giet_vm/giet_libs/stdlib.c

    r772 r777  
    110110    }
    111111    return dst;
    112 }
    113 
    114 ///////////////////////////////////
    115 int strlen( const char* string )
    116 {
    117     unsigned int i = 0;
    118     while ( string[i] != 0 ) i++;
    119     return i;
    120 }
    121 
    122 ///////////////////////////////
    123 int strcmp( const char * s1,
    124             const char * s2 )
    125 {
    126     while (1)
    127     {
    128         if (*s1 != *s2) return 1;
    129         if (*s1 == 0)   break;
    130         s1++, s2++;
    131     }
    132     return 0;
    133 }
    134 
    135 /////////////////////////
    136 char* strcpy( char* dest,
    137               const char* source )
    138 {
    139     if (!dest || !source) return dest;
    140 
    141     while (*source)
    142     {
    143         *(dest) = *(source);
    144         dest++;
    145         source++;
    146     }
    147     *dest = 0;
    148     return dest;
    149112}
    150113
  • soft/giet_vm/giet_libs/stdlib.h

    r772 r777  
    4141              unsigned int size );
    4242
    43 ////////////////////////////////////////////////////////////////////////////////////////
    44 // This function returns the number of characters in a string.
    45 // The terminating NUL character is not taken into account.
    46 ////////////////////////////////////////////////////////////////////////////////////////
    47 int strlen( const char* string );
    48 
    49 ////////////////////////////////////////////////////////////////////////////////////////
    50 // This function compare the two s1 & s2 strings.
    51 // It returns 0 if strings are identical (including the terminating NUL character).
    52 // It returns 1 if they are not.
    53 ////////////////////////////////////////////////////////////////////////////////////////
    54 int strcmp( const char* s1,
    55             const char* s2 );
    56 
    57 ////////////////////////////////////////////////////////////////////////////////////////
    58 // This function copies the source string to the dest string.
    59 // It returns a pointer on the dest string.
    60 ////////////////////////////////////////////////////////////////////////////////////////
    61 char* strcpy( char* dest,
    62               const char* source );
    6343
    6444///////////////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_libs/string.c

    r607 r777  
    77
    88///////////////////////////////////////////////////////////////////////////////////
    9 // char * strcpy ( char * destination, const char * source )
     9// char * strcpy (char * destination, const char * source)
    1010///////////////////////////////////////////////////////////////////////////////////
    11 char * strcpy ( char * destination, const char * source )
     11char * strcpy (char * destination, const char * source)
    1212{
    13     if (!destination || !source)
     13    if (!destination || !source) {
    1414        return destination;
     15    }
    1516
    16     while (*source)
     17    while (*source) {
    1718        *(destination++) = *(source++);
     19    }
    1820
    1921    return destination;
    2022}
    2123
     24
    2225///////////////////////////////////////////////////////////////////////////////////
    23 // int strcmp ( const char * str1, const char * str2 )
     26// char * strncpy (char * destination, const char * source, int maxlen)
    2427///////////////////////////////////////////////////////////////////////////////////
    25 int strcmp ( const char * str1, const char * str2 )
     28char * strncpy(char * dest, const char * src, int n)
    2629{
    27     if (!str1 || !str2)
     30    int i;
     31    for (i = 0; i < n && src[i] != '\0'; i++) {
     32        dest[i] = src[i];
     33    }
     34    for (; i < n ; i++) {
     35        dest[i] = '\0';
     36    }
     37    return dest;
     38}
     39
     40
     41///////////////////////////////////////////////////////////////////////////////////
     42// int strcmp (const char * str1, const char * str2)
     43///////////////////////////////////////////////////////////////////////////////////
     44int strcmp (const char * str1, const char * str2)
     45{
     46    if (!str1 || !str2) {
    2847        return -123456; // return a value out of the char's bounds
     48    }
    2949
    30     while (*str1 && *str1 == *str2)
    31     {
     50    while (*str1 && *str1 == *str2) {
    3251        str1++;
    3352        str2++;
     
    4059// int strlen ( const char * str )
    4160///////////////////////////////////////////////////////////////////////////////////
    42 int strlen ( const char * str )
     61int strlen (const char * str)
    4362{
    44     const char *s = str;
     63    const char * s = str;
    4564
    46     while (*s)
     65    while (*s) {
    4766        s++;
    48 
     67    }
    4968    return (s - str);
    5069}
     70
     71
     72///////////////////////////////////////////////////////////////////////////////////
     73// char * strchr(const char * str)
     74///////////////////////////////////////////////////////////////////////////////////
     75char * strchr(const char * str, int c)
     76{
     77    const char * s = str;
     78    const char ch = c;
     79    while (*s != ch && *s != '\0') {
     80        s++;
     81    }
     82
     83    return (char *) s;
     84}
     85
    5186
    5287// Local Variables:
  • soft/giet_vm/giet_libs/string.h

    r607 r777  
    99#define _STRING_H
    1010
    11 char * strcpy ( char * destination, const char * source );
    12 int strcmp ( const char * str1, const char * str2 );
    13 int strlen ( const char * str );
     11////////////////////////////////////////////////////////////////////////////////////////
     12// This function copies the source string to the dest string.
     13// It returns a pointer on the dest string.
     14////////////////////////////////////////////////////////////////////////////////////////
     15char * strcpy(char * destination, const char * source);
     16
     17////////////////////////////////////////////////////////////////////////////////////////
     18// The strncpy() function is similar to strcpy, except that at most n bytes of src
     19// are copied. If there is no null byte among the first n bytes of src, the string
     20// placed in dest will not be null terminated.
     21////////////////////////////////////////////////////////////////////////////////////////
     22char * strncpy(char * dest, const char * src, int n);
     23
     24////////////////////////////////////////////////////////////////////////////////////////
     25//The strcmp() function compares the two strings s1 and s2.  It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2.
     26////////////////////////////////////////////////////////////////////////////////////////
     27int strcmp(const char * str1, const char * str2);
     28
     29////////////////////////////////////////////////////////////////////////////////////////
     30// This function returns the number of characters in a string.
     31// The terminating NULL character is not taken into account.
     32////////////////////////////////////////////////////////////////////////////////////////
     33int strlen(const char * str);
     34
     35////////////////////////////////////////////////////////////////////////////////////////
     36// The strchr() function returns a pointer to the first occurrence of the character c
     37// in the string s.
     38////////////////////////////////////////////////////////////////////////////////////////
     39char * strchr(const char * str, int c);
    1440
    1541#endif
Note: See TracChangeset for help on using the changeset viewer.