diff --git a/common/utils/LOG/log.h b/common/utils/LOG/log.h index 46c73427c1..9a2c92bb10 100644 --- a/common/utils/LOG/log.h +++ b/common/utils/LOG/log.h @@ -346,7 +346,7 @@ typedef struct { @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) @param multiVec create new file or append to existing (useful for writing multiple vectors to same file. Just call the function multiple times with same file name and with this parameter set to 1) */ -#define MATLAB_RAW (1<<31) +#define MATLAB_RAW (1U<<31) #define MATLAB_SHORT 0 #define MATLAB_CSHORT 1 #define MATLAB_INT 2 diff --git a/openair1/PHY/CODING/crc_byte.c b/openair1/PHY/CODING/crc_byte.c index 7e37abcf81..9ad18cc1a6 100644 --- a/openair1/PHY/CODING/crc_byte.c +++ b/openair1/PHY/CODING/crc_byte.c @@ -72,10 +72,10 @@ unsigned int crcbit (unsigned char * inputptr, unsigned int i, crc = 0, c; while (octetlen-- > 0) { - c = (*inputptr++) << 24; + c = ((unsigned int)(*inputptr++)) << 24; for (i = 8; i != 0; i--) { - if ((1 << 31) & (c ^ crc)) + if ((1U << 31) & (c ^ crc)) crc = (crc << 1) ^ poly; else crc <<= 1; diff --git a/openair1/PHY/NR_REFSIG/nr_gold_ue.c b/openair1/PHY/NR_REFSIG/nr_gold_ue.c index 623b86edfb..e949faeaf0 100644 --- a/openair1/PHY/NR_REFSIG/nr_gold_ue.c +++ b/openair1/PHY/NR_REFSIG/nr_gold_ue.c @@ -64,7 +64,7 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue, reset = 1; x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; - x2 = (x2tmp0+(nid<<1))%(1<<31); //cinit + x2 = (x2tmp0+(nid<<1))%(1U<<31); //cinit for (n=0; nnr_gold_pdcch[0][ns][l][n] = lte_gold_generic(&x1, &x2, reset); @@ -95,7 +95,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue, reset = 1; x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; - x2 = (x2tmp0+(nid<<1)+nscid)%(1<<31); //cinit + x2 = (x2tmp0+(nid<<1)+nscid)%(1U<<31); //cinit LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid); for (n=0; ndlsch_channel_estimation_stats); // computing channel estimation for selected best ssb - const int estimateSz=7*2*sizeof(int)*frame_parms->ofdm_symbol_size; - struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz]; - struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz]; + const int estimateSz=7*2*frame_parms->ofdm_symbol_size; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz]; for(int i=pbch_initial_symbol; ii_ssb,temp_ptr->n_hf); diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c index 0073e8344d..c06dec7fcb 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_pbch.c @@ -457,6 +457,7 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, struct complex16 rxdataF_comp[frame_parms->nb_antennas_rx][nb_re]; //was dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) ); struct complex16 dl_ch_estimates_ext[frame_parms->nb_antennas_rx][20*12*4]; + memset(dl_ch_estimates_ext,0, sizeof dl_ch_estimates_ext); nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, estimateSz, dl_ch_estimates, @@ -540,7 +541,9 @@ printf("pbch rx llr %d\n",*(pbch_e_rx+cnt)); nr_pbch_unscrambling(nr_ue_pbch_vars,pbch_e_rx,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0, pbch_a_prime, &pbch_a_interleaved); //polar decoding de-rate matching const t_nrPolar_params *currentPtr = nr_polar_params( NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL,1,&ue->polarList); - decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&pbch_a_prime,0,currentPtr); +uint64_t tmp=pbch_a_prime; +decoderState = polar_decoder_int16(pbch_e_rx,&tmp,0,currentPtr); +pbch_a_prime=tmp; if(decoderState) return(decoderState); diff --git a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c index 28b6677b2c..0b1f374a52 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pss_nr.c @@ -883,7 +883,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain /* perform correlation of rx data and pss sequence ie it is a dot product */ result = dot_product64((short*)primary_synchro_time_nr[pss_index], - (short*) &(rxdata[ar][n+is*frame_parms->samples_per_frame]), + (short*)&(rxdata[ar][n+is*frame_parms->samples_per_frame]), frame_parms->ofdm_symbol_size, shift); pss_corr_ue[pss_index][n] += abs64(result); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 12a8ce0d08..bbf4617207 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1404,8 +1404,8 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); const int estimateSz=7*2*sizeof(int)*fp->ofdm_symbol_size; - struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; - struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][estimateSz]; for (int i=1; i<4; i++) { nr_slot_fep(ue, diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 692d1bac20..a314f7b397 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -430,13 +430,14 @@ int main(int argc, char **argv) printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL); - RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *)); + RC.gNB = (PHY_VARS_gNB**) calloc(sizeof(PHY_VARS_gNB *),1); RC.gNB[0] = malloc(sizeof(PHY_VARS_gNB)); gNB = RC.gNB[0]; gNB->ofdm_offset_divisor = UINT_MAX; frame_parms = &gNB->frame_parms; //to be initialized I suppose (maybe not necessary for PBCH) frame_parms->nb_antennas_tx = n_tx; frame_parms->nb_antennas_rx = n_rx; + frame_parms->nb_antenna_ports_gNB=n_rx; frame_parms->N_RB_DL = N_RB_DL; frame_parms->Nid_cell = Nid_cell; frame_parms->nushift = Nid_cell%4; @@ -522,23 +523,17 @@ int main(int argc, char **argv) s_im = malloc(2*sizeof(double*)); r_re = malloc(2*sizeof(double*)); r_im = malloc(2*sizeof(double*)); - txdata = malloc(2*sizeof(int*)); + txdata = calloc(2,sizeof(int*)); for (i=0; i<2; i++) { - s_re[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(s_re[i],frame_length_complex_samples*sizeof(double)); - s_im[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(s_im[i],frame_length_complex_samples*sizeof(double)); - - r_re[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(r_re[i],frame_length_complex_samples*sizeof(double)); - r_im[i] = malloc(frame_length_complex_samples*sizeof(double)); - bzero(r_im[i],frame_length_complex_samples*sizeof(double)); + s_re[i] = calloc(frame_length_complex_samples, sizeof(double)); + s_im[i] = calloc(frame_length_complex_samples, sizeof(double)); + r_re[i] = calloc(frame_length_complex_samples, sizeof(double)); + r_im[i] = calloc(frame_length_complex_samples, sizeof(double)); printf("Allocating %d samples for txdata\n",frame_length_complex_samples); - txdata[i] = malloc(frame_length_complex_samples*sizeof(int)); - bzero(r_re[i],frame_length_complex_samples*sizeof(int)); + txdata[i] = calloc(frame_length_complex_samples, sizeof(int)); } if (pbch_file_fd!=NULL) { @@ -547,8 +542,8 @@ int main(int argc, char **argv) //configure UE - UE = malloc(sizeof(PHY_VARS_NR_UE)); - memcpy(&UE->frame_parms,frame_parms,sizeof(NR_DL_FRAME_PARMS)); + UE = calloc(1,sizeof(*UE)); + memcpy(&UE->frame_parms,frame_parms,sizeof(*frame_parms)); //phy_init_nr_top(UE); //called from init_nr_ue_signal if (run_initial_sync==1) UE->is_synchronized = 0; else UE->is_synchronized = 1; @@ -721,8 +716,8 @@ int main(int argc, char **argv) UE->rx_offset=0; uint8_t ssb_index = 0; const int estimateSz=7*2*sizeof(int)*frame_parms->ofdm_symbol_size; - struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz]; - struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz]; + __attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz]; while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms,ssb_index); diff --git a/openair2/UTIL/LISTS/list.c b/openair2/UTIL/LISTS/list.c index 65f70c0786..578833edba 100644 --- a/openair2/UTIL/LISTS/list.c +++ b/openair2/UTIL/LISTS/list.c @@ -43,7 +43,7 @@ list_init (list_t * listP, char *nameP) { //----------------------------------------------------------------------------- if (nameP) { - strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR ); + strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 ); listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string } diff --git a/openair2/UTIL/LISTS/list2.c b/openair2/UTIL/LISTS/list2.c index 3f0a59df53..d9aa1b6a90 100644 --- a/openair2/UTIL/LISTS/list2.c +++ b/openair2/UTIL/LISTS/list2.c @@ -53,7 +53,7 @@ list2_init (list2_t * listP, char *nameP) { //----------------------------------------------------------------------------- if (nameP) { - strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR ); + strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 ); listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string }