Merge remote-tracking branch 'origin/enhance-rfsim' into integration_2021_wk08
This commit is contained in:
@@ -331,9 +331,10 @@ void end_configmodule(void) {
|
||||
printf ("[CONFIG] free %u config value pointers\n",cfgptr->numptrs);
|
||||
|
||||
for(int i=0; i<cfgptr->numptrs ; i++) {
|
||||
if (cfgptr->ptrs[i] != NULL) {
|
||||
if (cfgptr->ptrs[i] != NULL && cfgptr->ptrsAllocated[i] == true) {
|
||||
free(cfgptr->ptrs[i]);
|
||||
cfgptr->ptrs[i]=NULL;
|
||||
cfgptr->ptrsAllocated[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "common/config/config_paramdesc.h"
|
||||
#include "common/utils/T/T.h"
|
||||
#define CONFIG_MAX_OOPT_PARAMS 10 // maximum number of parameters in the -O option (-O <cfgmode>:P1:P2...
|
||||
@@ -74,6 +76,7 @@ typedef struct configmodule_interface {
|
||||
uint32_t numptrs;
|
||||
uint32_t rtflags;
|
||||
char *ptrs[CONFIG_MAX_ALLOCATEDPTRS];
|
||||
bool ptrsAllocated[CONFIG_MAX_ALLOCATEDPTRS];
|
||||
} configmodule_interface_t;
|
||||
|
||||
#ifdef CONFIG_LOADCONFIG_MAIN
|
||||
|
||||
@@ -62,6 +62,7 @@ char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) {
|
||||
|
||||
if ( (cfgoptions->paramflags & PARAMFLAG_NOFREE) == 0) {
|
||||
config_get_if()->ptrs[config_get_if()->numptrs] = (char *)ptr;
|
||||
config_get_if()->ptrsAllocated[config_get_if()->numptrs] = true;
|
||||
config_get_if()->numptrs++;
|
||||
}
|
||||
} else {
|
||||
@@ -82,7 +83,9 @@ char *config_check_valptr(paramdef_t *cfgoptions, char **ptr, int length) {
|
||||
}
|
||||
|
||||
if (*ptr == NULL) {
|
||||
*ptr = malloc(length>40?length:40); // LTS: dummy fix, waiting Francois full fix in 4G branch
|
||||
*ptr = malloc(length>40?length:40);
|
||||
// LTS: dummy fix, waiting Francois full fix in 4G branch
|
||||
// the issue is we don't know at this point the size we will get
|
||||
|
||||
if ( *ptr != NULL) {
|
||||
memset(*ptr,0,length);
|
||||
|
||||
@@ -346,6 +346,7 @@ int config_libconfig_init(char *cfgP[], int numP) {
|
||||
libconfig_privdata.configfile = strdup((char *)cfgP[0]);
|
||||
config_get_if()->numptrs=0;
|
||||
memset(config_get_if()->ptrs,0,sizeof(void *) * CONFIG_MAX_ALLOCATEDPTRS);
|
||||
memset(config_get_if()->ptrsAllocated, 0, sizeof(config_get_if()->ptrsAllocated));
|
||||
|
||||
/* Read the file. If there is an error, report it and exit. */
|
||||
if(! config_read_file(&(libconfig_privdata.cfg), libconfig_privdata.configfile)) {
|
||||
|
||||
+32
-1
@@ -88,16 +88,19 @@ int write_file_matlab(const char *fname,
|
||||
void *data,
|
||||
int length,
|
||||
int dec,
|
||||
char format)
|
||||
unsigned int format)
|
||||
{
|
||||
FILE *fp=NULL;
|
||||
int i;
|
||||
|
||||
AssertFatal((format&~MATLAB_RAW) <16,"");
|
||||
|
||||
if (data == NULL)
|
||||
return -1;
|
||||
|
||||
//printf("Writing %d elements of type %d to %s\n",length,format,fname);
|
||||
|
||||
|
||||
if (format == 10 || format ==11 || format == 12 || format == 13 || format == 14) {
|
||||
fp = fopen(fname,"a+");
|
||||
} else if (format != 10 && format !=11 && format != 12 && format != 13 && format != 14) {
|
||||
@@ -109,6 +112,32 @@ int write_file_matlab(const char *fname,
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if ( (format&MATLAB_RAW) == MATLAB_RAW ) {
|
||||
int sz[16]={sizeof(short), 2*sizeof(short),
|
||||
sizeof(int), 2*sizeof(int),
|
||||
sizeof(char), 2*sizeof(char),
|
||||
sizeof(long long),
|
||||
sizeof(double), 2*sizeof(double),
|
||||
sizeof(unsigned char),
|
||||
sizeof(short),
|
||||
sizeof(short),
|
||||
sizeof(short),
|
||||
sizeof(short),
|
||||
sizeof(short),
|
||||
sizeof(short)
|
||||
};
|
||||
int eltSz= sz[format&~MATLAB_RAW];
|
||||
if (dec==1)
|
||||
fwrite(data, eltSz, length, fp);
|
||||
else
|
||||
for (i=0; i<length; i+=dec)
|
||||
fwrite(data+i*eltSz, eltSz, 1, fp);
|
||||
|
||||
fclose(fp);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
if (format != 10 && format !=11 && format != 12 && format != 13 && format != 14)
|
||||
fprintf(fp,"%s = [",vname);
|
||||
|
||||
@@ -214,6 +243,8 @@ int write_file_matlab(const char *fname,
|
||||
case 12 : // case eren for log2_maxh real unsigned 8 bit
|
||||
fprintf(fp,"%d \n",((unsigned char *)&data)[0]);
|
||||
break;
|
||||
default:
|
||||
AssertFatal(false, "unknown dump format: %d\n", format);
|
||||
}
|
||||
|
||||
if (format != 10 && format !=11 && format !=12 && format != 13 && format != 15) {
|
||||
|
||||
+19
-1
@@ -336,7 +336,25 @@ typedef struct {
|
||||
@param dec decimation level
|
||||
@param format data format (0 = real 16-bit, 1 = complex 16-bit,2 real 32-bit, 3 complex 32-bit,4 = real 8-bit, 5 = complex 8-bit)
|
||||
*/
|
||||
int32_t write_file_matlab(const char *fname, const char *vname, void *data, int length, int dec, char format);
|
||||
#define MATLAB_RAW (1<<31)
|
||||
#define MATLAB_SHORT 0
|
||||
#define MATLAB_CSHORT 1
|
||||
#define MATLAB_INT 2
|
||||
#define MATLAB_CINT 3
|
||||
#define MATLAB_INT8 4
|
||||
#define MATLAB_CINT8 5
|
||||
#define MATLAB_LLONG 6
|
||||
#define MATLAB_DOUBLE 7
|
||||
#define MATLAB_CDOUBLE 8
|
||||
#define MATLAB_UINT8 9
|
||||
#define MATLEB_EREN1 10
|
||||
#define MATLEB_EREN2 11
|
||||
#define MATLEB_EREN3 12
|
||||
#define MATLAB_CSHORT_BRACKET1 13
|
||||
#define MATLAB_CSHORT_BRACKET2 14
|
||||
#define MATLAB_CSHORT_BRACKET3 15
|
||||
|
||||
int32_t write_file_matlab(const char *fname, const char *vname, void *data, int length, int dec, unsigned int format);
|
||||
|
||||
/*----------------macro definitions for reading log configuration from the config module */
|
||||
#define CONFIG_STRING_LOG_PREFIX "log_config"
|
||||
|
||||
Reference in New Issue
Block a user