Changeset 777
- Timestamp:
- Feb 4, 2016, 6:25:22 PM (9 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/Makefile
r776 r777 130 130 build/libs/math/s_copysign.o \ 131 131 build/libs/math/s_fabs.o \ 132 build/libs/math/fmod.o \ 132 133 build/libs/math/s_finite.o \ 133 134 build/libs/math/s_floor.o \ 135 build/libs/math/s_ceil.o \ 134 136 build/libs/math/s_isnan.o \ 135 137 build/libs/math/sqrt.o \ -
soft/giet_vm/applications/rosenfeld/include/ecc_generation.h
r772 r777 14 14 void generate_granularity_density_float(uint8 **X, int i0, int i1, int j0, int j1, int granularity, float density, int seed); 15 15 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 );16 void generate_size_granularity_name (char *name, int size, int granularity, char *filename, int maxlen); 17 void generate_granularity_density_name (char *name, int granularity, int density, char *filename, int maxlen); 18 void generate_granularity_density_ext_name (char *name, int granularity, int density, char *extension, char *filename, int maxlen); 19 19 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 );20 void generate_size_granularity_density_name (char *name, int size, int granularity, int density, char *filename, int maxlen); 21 void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename, int maxlen); 22 22 23 void generate_name100(char *name, int granularity, float density, char *filename );23 void generate_name100(char *name, int granularity, float density, char *filename, int maxlen); 24 24 25 25 int test_generation(int argc, char* argv[]); -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrio0.h
r772 r777 20 20 #endif 21 21 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 );22 IMAGE_EXPORT(void) generate_filename_k_ndigit (char *filename, int k, int ndigit, char *complete_filename, int maxlen); 23 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen); 24 24 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 );25 IMAGE_EXPORT(void) generate_path_filename (char *path, char *filename, char *complete_filename, int maxlen); 26 IMAGE_EXPORT(void) generate_path_filename_extension (char *path, char *filename, char *extension, char *complete_filename, int maxlen); 27 IMAGE_EXPORT(void) generate_path_filename_suffix_extension (char *path, char *filename, char *suffix, char *extension, char *complete_filename, int maxlen); 28 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension (char *path, char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen); 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, int maxlen); 30 30 31 31 void select_display_positive_parameters(int iformat, char **format, char **str); -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio0.c
r772 r777 26 26 27 27 /* --------------------------------------------------------------------------------------------------- */ 28 IMAGE_EXPORT(void) generate_filename_k_ndigit(char *filename, int k, int ndigit, char *complete_filename )28 IMAGE_EXPORT(void) generate_filename_k_ndigit(char *filename, int k, int ndigit, char *complete_filename, int maxlen) 29 29 /* --------------------------------------------------------------------------------------------------- */ 30 30 { … … 43 43 case 9 : format = "%s%09d.txt"; break; 44 44 } 45 s printf(complete_filename, format, filename, k);45 snprintf(complete_filename, maxlen, format, filename, k); 46 46 } 47 /* ------------------------------------------------------------------------------------------------------------------------------ */48 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename )49 /* ------------------------------------------------------------------------------------------------------------------------------ */47 /* ------------------------------------------------------------------------------------------------------------------------------------------ */ 48 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen) 49 /* ------------------------------------------------------------------------------------------------------------------------------------------ */ 50 50 { 51 51 char *format = "%s%d.%s"; … … 63 63 case 9 : format = "%s%09d.%s"; break; 64 64 } 65 s printf(complete_filename, format, filename, k, extension);65 snprintf(complete_filename, maxlen, format, filename, k, extension); 66 66 } 67 /* ---------------------------------------------------------------------------------------- */68 IMAGE_EXPORT(void) generate_path_filename(char *path, char *filename, char *complete_filename )69 /* ---------------------------------------------------------------------------------------- */67 /* ---------------------------------------------------------------------------------------------------- */ 68 IMAGE_EXPORT(void) generate_path_filename(char *path, char *filename, char *complete_filename, int maxlen) 69 /* ---------------------------------------------------------------------------------------------------- */ 70 70 { 71 s printf(complete_filename, "%s%s", path, filename);71 snprintf(complete_filename, maxlen, "%s%s", path, filename); 72 72 } 73 /* ------------------------------------------------------------------------------------------------------------------- */74 IMAGE_EXPORT(void) generate_path_filename_extension(char *path, char *filename, char *extension, char *complete_filename )75 /* ------------------------------------------------------------------------------------------------------------------- */73 /* ------------------------------------------------------------------------------------------------------------------------------- */ 74 IMAGE_EXPORT(void) generate_path_filename_extension(char *path, char *filename, char *extension, char *complete_filename, int maxlen) 75 /* ------------------------------------------------------------------------------------------------------------------------------- */ 76 76 { 77 s printf(complete_filename, "%s%s.%s", path, filename, extension);77 snprintf(complete_filename, maxlen, "%s%s.%s", path, filename, extension); 78 78 } 79 /* ---------------------------------------------------------------------------------------------------------------------------------------- */80 IMAGE_EXPORT(void) generate_path_filename_suffix_extension(char *path, char *filename, char *suffix, char *extension, char *complete_filename )81 /* ---------------------------------------------------------------------------------------------------------------------------------------- */79 /* ---------------------------------------------------------------------------------------------------------------------------------------------------- */ 80 IMAGE_EXPORT(void) generate_path_filename_suffix_extension(char *path, char *filename, char *suffix, char *extension, char *complete_filename, int maxlen) 81 /* ---------------------------------------------------------------------------------------------------------------------------------------------------- */ 82 82 { 83 s printf(complete_filename, "%s%s%s.%s", path, filename, suffix, extension);83 snprintf(complete_filename, maxlen, "%s%s%s.%s", path, filename, suffix, extension); 84 84 } 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 /* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */ 86 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension(char *path, char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen) 87 /* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */ 88 88 { 89 89 char *format = "%s%s%d.%s"; … … 101 101 case 9 : format = "%s%s%09d.%s"; break; 102 102 } 103 s printf(complete_filename, format, path, filename, k, extension);103 snprintf(complete_filename, maxlen, format, path, filename, k, extension); 104 104 } 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 /* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 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, int maxlen) 107 /* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ 108 108 { 109 109 char *format = "%s%s%d_%d.%s"; … … 121 121 case 9 : format = "%s%s%09d_%09d.%s"; break; 122 122 } 123 s printf(complete_filename, format, path, filename, k, l, extension);123 snprintf(complete_filename, maxlen, format, path, filename, k, l, extension); 124 124 } 125 125 // ---------------------------------------------------------------------------- -
soft/giet_vm/applications/rosenfeld/src/ecc_common.c
r772 r777 5 5 #include <stdio.h> 6 6 #include <stdlib.h> 7 #include <string.h> 7 8 #include <math.h> 8 9 … … 310 311 char complete_filename[64]; 311 312 312 s printf(complete_filename, "%s.dot", filename);313 snprintf(complete_filename, 64, "%s.dot", filename); 313 314 314 315 fd = open(complete_filename, O_CREAT | O_TRUNC); … … 330 331 char complete_filename[64]; 331 332 332 s printf(complete_filename, "%s.dot", filename);333 snprintf(complete_filename, 64, "%s.dot", filename); 333 334 334 335 … … 351 352 char complete_filename[64]; 352 353 353 s printf(complete_filename, "%s.dot", filename);354 snprintf(complete_filename, 64, "%s.dot", filename); 354 355 355 356 … … 403 404 char complete_filename[64]; 404 405 405 s printf(complete_filename, "%s.dot", filename);406 snprintf(complete_filename, 64, "%s.dot", filename); 406 407 407 408 -
soft/giet_vm/applications/rosenfeld/src/ecc_generation.c
r772 r777 58 58 generate_granularity_density_float(X, i0, i1, j0, j1, granularity, (float) density, seed); 59 59 } 60 // --------------------------------------------------------------------------------------------- 61 void generate_granularity_density_name(char *name, int granularity, int density, char *filename )62 // --------------------------------------------------------------------------------------------- 63 { 64 s printf(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 s printf(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 s printf(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 s printf(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 s printf(filename, "%s_%d_%02d.pgm", name, size, granularity);89 }// ------------------------------------------------------------------------------ 90 void generate_name100(char *name, int granularity, float density, char *filename )91 // ------------------------------------------------------------------------------ 60 // --------------------------------------------------------------------------------------------------------- 61 void 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 // ------------------------------------------------------------------------------------------------------------------------------ 67 void 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 // ------------------------------------------------------------------------------------------------------------------------ 73 void 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 // --------------------------------------------------------------------------------------------------------------------------------------------- 79 void 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 // --------------------------------------------------------------------------------------------------- 85 void 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 }// ----------------------------------------------------------------------------------------- 90 void generate_name100(char *name, int granularity, float density, char *filename, int maxlen) 91 // ------------------------------------------------------------------------------------------ 92 92 { 93 93 // density en pourcentage: 0:100 94 94 // mais aussi <1, par exe 0.01 95 95 int d = (int) ceil(100 * density); 96 s printf(filename, "%s_%02d_%05d.pgm", name, granularity, d);96 snprintf(filename, maxlen, "%s_%02d_%05d.pgm", name, granularity, d); 97 97 } 98 98 // ---------------------------------------- … … 128 128 for(d=dmin; d<=dmax; d+=dstep) { 129 129 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); 131 131 printf(filename); 132 132 bin2gray_ui8matrix(X, 0, n-1, 0, n-1, X255); … … 256 256 X255 = ui8matrix(0, h-1, 0, w-1); 257 257 258 s printf(filename, "spirale_simple_%d.pgm", n);258 snprintf(filename, 128, "spirale_simple_%d.pgm", n); 259 259 spirale_simple(X, h, w); 260 260 bin2gray_ui8matrix(X, 0, h-1, 0, w-1, X255); 261 261 SavePGM_ui8matrix(X255, 0, h-1, 0, w-1, filename); 262 262 263 s printf(filename, "spirale_double_%d.pgm", n);263 snprintf(filename, 128, "spirale_double_%d.pgm", n); 264 264 spirale_double(X, h, w); 265 265 bin2gray_ui8matrix(X, 0, h-1, 0, w-1, X255); … … 306 306 307 307 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); 309 309 printf(filename); 310 310 bin2gray_ui8matrix(X, 0, h-1, 0, w-1, X255); -
soft/giet_vm/applications/rosenfeld/src/ecc_main_rosenfeld_sa.c
r772 r777 105 105 binarisation_ui8matrix(X0, i0, i1, j0, j1, 1, 1, X); // pour le traitement 106 106 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); 108 108 SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename); 109 109 display_ui8matrix_positive(X, i0, i1, j0, j1, 3, "X"); … … 131 131 // traitement: desactiver FlattenL dans Rosenfeld 132 132 // 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); 140 140 141 141 // free … … 188 188 189 189 Palette_18ColorsBW(palette); 190 generate_path_filename(pathSrc, filename, complete_filename );190 generate_path_filename(pathSrc, filename, complete_filename, 1024); 191 191 192 192 // chargement d'une image depuis le disque … … 206 206 binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 1, X); // pour le traitement 207 207 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); 209 209 SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename); 210 210 … … 236 236 filename = "Rosenfeld_UF_Org1_8C.bmp"; 237 237 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); 239 239 SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); 240 240 zero_ui32matrix(E32, i0 - border, i1 + border, j0 - border, j1 + border); -
soft/giet_vm/applications/rosenfeld/src/str_ext.c
r772 r777 9 9 #include <stdio.h> 10 10 #include <stdlib.h> 11 #include <string.h> 11 12 12 13 #include "nrc_os_config.h" -
soft/giet_vm/giet_libs/malloc.c
r709 r777 8 8 #include "malloc.h" 9 9 #include "stdio.h" 10 #include "stdlib.h" 10 11 #include "giet_config.h" 11 12 … … 214 215 215 216 //////////////////////////////////////// 216 void * remote_malloc( unsignedint size,217 void * remote_malloc( int size, 217 218 unsigned int x, 218 219 unsigned int y ) … … 278 279 #endif 279 280 280 return (void*) base;281 return (void*) base; 281 282 282 283 } // end remote_malloc() … … 284 285 285 286 ////////////////////////////////// 286 void * malloc( unsignedint size )287 void * malloc( int size ) 287 288 { 288 289 // get cluster coordinates 289 unsigned int 290 unsigned int 291 unsigned int 290 unsigned int x; 291 unsigned int y; 292 unsigned int lpid; 292 293 giet_proc_xyp( &x, &y, &lpid ); 293 294 294 295 return remote_malloc( size, x, y ); 295 296 } 297 298 299 //////////////////////////////////// 300 void * calloc ( int nbmem, int size ) 301 { 302 void * a = malloc( nbmem * size ); 303 memset( a, 0, nbmem * size ); 304 return a; 305 } 296 306 297 307 /////////////////////////////////////////// -
soft/giet_vm/giet_libs/malloc.h
r709 r777 93 93 unsigned int y ); 94 94 95 extern void* malloc( unsigned int size ); 95 extern void * malloc( int size ); 96 extern void * calloc( int nbmem, 97 int size ); 96 98 97 extern void * remote_malloc( unsignedint size,98 unsigned int x,99 unsigned int y );99 extern void * remote_malloc( int size, 100 unsigned int x, 101 unsigned int y ); 100 102 101 103 extern void free(void * ptr); -
soft/giet_vm/giet_libs/math.h
r667 r777 7 7 8 8 double fabs (double x); 9 double fmod (double x, double y); 9 10 double floor (double x); 11 double ceil (double x); 10 12 double sin (double x); 11 13 double cos (double x); 12 14 double pow (double x, double y); 15 double exp (double x); 13 16 int isnan (double x); 14 17 int isfinite(double x); -
soft/giet_vm/giet_libs/math/e_pow.c
r682 r777 103 103 int32_t i,j,k,yisint,n; 104 104 int32_t hx,hy,ix,iy; 105 u _int32_t lx,ly;105 uint32_t lx,ly; 106 106 107 107 EXTRACT_WORDS(hx,lx,x); … … 180 180 181 181 /* (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); 183 183 184 184 /* |y| is huge */ … … 251 251 252 252 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) 254 254 s = -one;/* (-ve)**(odd int) */ 255 255 … … 312 312 { 313 313 double z = __ieee754_pow(x, y); 314 if (isnan(y)) 314 if (isnan(y)) { 315 315 return z; 316 } 316 317 if (isnan(x)) { 317 318 if (y == 0.0) { … … 322 323 if (x == 0.0) { 323 324 if (y == 0.0) { 324 325 return 0; /* pow(0.0,0.0) */ 325 326 } 326 327 if (isfinite(y) && y < 0.0) { … … 332 333 if (isfinite(x) && isfinite(y)) { 333 334 if (isnan(z)) { 334 return 0.0 /0.0; /* pow neg**non-int */335 return 0.0 / 0.0; /* pow neg**non-int */ 335 336 } 336 337 { 337 338 double ret = huge; 338 339 y *= 0.5; 339 if(x<zero&&rint(y)!=y) ret = -huge; 340 if (x < zero && rint(y) !=y ) { 341 ret = -huge; 342 } 340 343 return ret; 341 344 } … … 347 350 return z; 348 351 } 352 353 /* 354 * Pseudo exp function (QM) 355 * There probably is a better implementation 356 */ 357 double 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 75 75 double tx[3]; 76 76 int32_t e0,i,j,nx,n,ix,hx; 77 u _int32_t low;77 uint32_t low; 78 78 79 79 GET_HIGH_WORD(hx,x); /* high word of x */ … … 115 115 y[0] = r-w; /* quick check no cancellation */ 116 116 } else { 117 u _int32_t high;117 uint32_t high; 118 118 j = ix>>20; 119 119 y[0] = r-w; -
soft/giet_vm/giet_libs/math/e_sqrt.c
r581 r777 93 93 int32_t sign = (int)0x80000000; 94 94 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; 96 96 97 97 EXTRACT_WORDS(ix0,ix1,x); … … 168 168 if (z>=one) { 169 169 z = one+tiny; 170 if (q1==(u _int32_t)0xffffffff) { q1=0; q += 1;}170 if (q1==(uint32_t)0xffffffff) { q1=0; q += 1;} 171 171 else if (z>one) { 172 if (q1==(u _int32_t)0xfffffffe) q+=1;172 if (q1==(uint32_t)0xfffffffe) q+=1; 173 173 q1+=2; 174 174 } else -
soft/giet_vm/giet_libs/math/math_private.h
r588 r777 16 16 #define _MATH_PRIVATE_H_ 17 17 18 typedef unsigned int u_int32_t; 19 18 typedef unsigned int uint32_t; 20 19 typedef int int32_t; 20 typedef unsigned long long int uint64_t; 21 typedef long long int int64_t; 21 22 22 23 /* The original fdlibm code used statements like: … … 51 52 struct 52 53 { 53 u _int32_t msw;54 u _int32_t lsw;54 uint32_t msw; 55 uint32_t lsw; 55 56 } parts; 56 57 } ieee_double_shape_type; … … 64 65 struct 65 66 { 66 u _int32_t lsw;67 u _int32_t msw;67 uint32_t lsw; 68 uint32_t msw; 68 69 } parts; 69 70 } ieee_double_shape_type; -
soft/giet_vm/giet_libs/math/s_copysign.c
r581 r777 24 24 double copysign(double x, double y) 25 25 { 26 u _int32_t hx,hy;26 uint32_t hx,hy; 27 27 GET_HIGH_WORD(hx,x); 28 28 GET_HIGH_WORD(hy,y); -
soft/giet_vm/giet_libs/math/s_fabs.c
r581 r777 22 22 double fabs(double x) 23 23 { 24 u _int32_t high;24 uint32_t high; 25 25 GET_HIGH_WORD(high,x); 26 26 SET_HIGH_WORD(x,high&0x7fffffff); -
soft/giet_vm/giet_libs/math/s_finite.c
r581 r777 23 23 int isfinite(double x) 24 24 { 25 u _int32_t hx;25 uint32_t hx; 26 26 27 27 GET_HIGH_WORD(hx, x); -
soft/giet_vm/giet_libs/math/s_floor.c
r581 r777 11 11 12 12 /* Modified for GIET-VM static OS at UPMC, France 2015. 13 13 */ 14 14 15 15 /* … … 28 28 double floor(double x) 29 29 { 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; 69 91 } 70 92 -
soft/giet_vm/giet_libs/math/s_isnan.c
r581 r777 26 26 EXTRACT_WORDS(hx,lx,x); 27 27 hx &= 0x7fffffff; 28 hx |= (u _int32_t)(lx|(-lx))>>31;28 hx |= (uint32_t)(lx|(-lx))>>31; 29 29 hx = 0x7ff00000 - hx; 30 return (int)(((u _int32_t)hx)>>31);30 return (int)(((uint32_t)hx)>>31); 31 31 } -
soft/giet_vm/giet_libs/math/s_rint.c
r581 r777 35 35 { 36 36 int32_t i0, j0, sx; 37 u _int32_t i,i1;37 uint32_t i,i1; 38 38 double t; 39 39 /* We use w = x + 2^52; t = w - 2^52; trick to round x to integer. … … 47 47 EXTRACT_WORDS(i0,i1,x); 48 48 /* Unbiased exponent */ 49 j0 = ((((u _int32_t)i0) >> 20)&0x7ff)-0x3ff;49 j0 = ((((uint32_t)i0) >> 20)&0x7ff)-0x3ff; 50 50 51 51 if (j0 > 51) { … … 57 57 58 58 /* Sign */ 59 sx = ((u _int32_t)i0) >> 31;59 sx = ((uint32_t)i0) >> 31; 60 60 61 61 if (j0<20) { … … 81 81 } 82 82 } else { 83 i = ((u _int32_t)(0xffffffff))>>(j0-20);83 i = ((uint32_t)(0xffffffff))>>(j0-20); 84 84 if ((i1&i)==0) return x; /* x is integral */ 85 85 i>>=1; -
soft/giet_vm/giet_libs/stdlib.c
r772 r777 110 110 } 111 111 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;149 112 } 150 113 -
soft/giet_vm/giet_libs/stdlib.h
r772 r777 41 41 unsigned int size ); 42 42 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 );63 43 64 44 /////////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_libs/string.c
r607 r777 7 7 8 8 /////////////////////////////////////////////////////////////////////////////////// 9 // char * strcpy ( char * destination, const char * source)9 // char * strcpy (char * destination, const char * source) 10 10 /////////////////////////////////////////////////////////////////////////////////// 11 char * strcpy ( char * destination, const char * source)11 char * strcpy (char * destination, const char * source) 12 12 { 13 if (!destination || !source) 13 if (!destination || !source) { 14 14 return destination; 15 } 15 16 16 while (*source) 17 while (*source) { 17 18 *(destination++) = *(source++); 19 } 18 20 19 21 return destination; 20 22 } 21 23 24 22 25 /////////////////////////////////////////////////////////////////////////////////// 23 // int strcmp ( const char * str1, const char * str2)26 // char * strncpy (char * destination, const char * source, int maxlen) 24 27 /////////////////////////////////////////////////////////////////////////////////// 25 int strcmp ( const char * str1, const char * str2)28 char * strncpy(char * dest, const char * src, int n) 26 29 { 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 /////////////////////////////////////////////////////////////////////////////////// 44 int strcmp (const char * str1, const char * str2) 45 { 46 if (!str1 || !str2) { 28 47 return -123456; // return a value out of the char's bounds 48 } 29 49 30 while (*str1 && *str1 == *str2) 31 { 50 while (*str1 && *str1 == *str2) { 32 51 str1++; 33 52 str2++; … … 40 59 // int strlen ( const char * str ) 41 60 /////////////////////////////////////////////////////////////////////////////////// 42 int strlen ( const char * str)61 int strlen (const char * str) 43 62 { 44 const char * s = str;63 const char * s = str; 45 64 46 while (*s) 65 while (*s) { 47 66 s++; 48 67 } 49 68 return (s - str); 50 69 } 70 71 72 /////////////////////////////////////////////////////////////////////////////////// 73 // char * strchr(const char * str) 74 /////////////////////////////////////////////////////////////////////////////////// 75 char * 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 51 86 52 87 // Local Variables: -
soft/giet_vm/giet_libs/string.h
r607 r777 9 9 #define _STRING_H 10 10 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 //////////////////////////////////////////////////////////////////////////////////////// 15 char * 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 //////////////////////////////////////////////////////////////////////////////////////// 22 char * 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 //////////////////////////////////////////////////////////////////////////////////////// 27 int 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 //////////////////////////////////////////////////////////////////////////////////////// 33 int 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 //////////////////////////////////////////////////////////////////////////////////////// 39 char * strchr(const char * str, int c); 14 40 15 41 #endif
Note: See TracChangeset
for help on using the changeset viewer.