From 02cb8b45af2f771816a0ee83aa6f0f2369aea44d Mon Sep 17 00:00:00 2001
From: Florian Kaltenberger <florian.kaltenberger@eurecom.fr>
Date: Wed, 1 Apr 2015 11:09:36 +0000
Subject: [PATCH] more 64bit compatibility fixes

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6968 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair1/EMOS/LTE/IMPORT_FILTER/dump_size.c   | 20 ++++++-------
 .../IMPORT_FILTER/load_estimates_lte_new.m    | 28 ++++++-------------
 .../LTE/IMPORT_FILTER/struct_template_new.m   | 28 +++++++++++--------
 3 files changed, 35 insertions(+), 41 deletions(-)

diff --git a/openair1/EMOS/LTE/IMPORT_FILTER/dump_size.c b/openair1/EMOS/LTE/IMPORT_FILTER/dump_size.c
index 5d73bb2d71f..e54b2cf17a9 100644
--- a/openair1/EMOS/LTE/IMPORT_FILTER/dump_size.c
+++ b/openair1/EMOS/LTE/IMPORT_FILTER/dump_size.c
@@ -31,15 +31,15 @@
 
 int main(void)
 {
-  printf("MAX_CQI_BITS = %d;\n",MAX_CQI_BITS);
-  printf("PHY_measurements_size = %d;\n",sizeof(PHY_MEASUREMENTS));
-  printf("PHY_measurements_eNb_size = %d;\n",sizeof(PHY_MEASUREMENTS_eNB));
-  //printf("UCI_data_t_size = %d;\n",sizeof(UCI_DATA_t));
-  //printf("DCI_alloc_t_size = %d;\n",sizeof(DCI_ALLOC_t));
-  printf("eNb_UE_stats_size = %d;\n",sizeof(LTE_eNB_UE_stats));
-  printf("fifo_dump_emos_UE_size = %d;\n",sizeof(fifo_dump_emos_UE));
-  printf("fifo_dump_emos_eNb_size = %d;\n",sizeof(fifo_dump_emos_eNB));
-  printf("gps_fix_t_size = %d;\n",sizeof(struct gps_fix_t));
-
+  printf("MAX_CQI_BITS = %zu;\n",MAX_CQI_BITS);
+  printf("PHY_measurements_size = %zu;\n",sizeof(PHY_MEASUREMENTS));
+  printf("PHY_measurements_eNb_size = %zu;\n",sizeof(PHY_MEASUREMENTS_eNB));
+  //printf("UCI_data_t_size = %zu;\n",sizeof(UCI_DATA_t));
+  //printf("DCI_alloc_t_size = %zu;\n",sizeof(DCI_ALLOC_t));
+  printf("eNb_UE_stats_size = %zu;\n",sizeof(LTE_eNB_UE_stats));
+  printf("fifo_dump_emos_UE_size = %zu;\n",sizeof(fifo_dump_emos_UE));
+  printf("fifo_dump_emos_eNb_size = %zu;\n",sizeof(fifo_dump_emos_eNB));
+  printf("gps_fix_t_size = %zu;\n",sizeof(struct gps_fix_t));
+  printf("align = %zu;\n",sizeof(void*));
   return(0);
 }
diff --git a/openair1/EMOS/LTE/IMPORT_FILTER/load_estimates_lte_new.m b/openair1/EMOS/LTE/IMPORT_FILTER/load_estimates_lte_new.m
index 82447d01a13..b7ecc79112b 100644
--- a/openair1/EMOS/LTE/IMPORT_FILTER/load_estimates_lte_new.m
+++ b/openair1/EMOS/LTE/IMPORT_FILTER/load_estimates_lte_new.m
@@ -1,9 +1,9 @@
-function [estimates, NFrames, gps_data, H] = load_estimates_lte_new(filename, NFrames_max, decimation, is_eNb, EMOS_CHANNEL)
+function [estimates, NFrames, gps_data, H] = load_estimates_lte_new(filename, NFrames_max, decimation, is_eNb, EMOS_CHANNEL, align)
 % 
 % EMOS Single User Import Filter
 %
 % [estimates, NFrames] = 
-%       load_estimates_lte(filename, NFrames_max, decimation, is_eNb, EMOS_CHANNEL)
+%       load_estimates_lte(filename, NFrames_max, decimation, is_eNb, EMOS_CHANNEL, align)
 %
 % Parameters:
 % filename          - filename(s) of the EMOS data file
@@ -11,8 +11,9 @@ function [estimates, NFrames, gps_data, H] = load_estimates_lte_new(filename, NF
 %                     maximum file contents
 % decimation        - read every 'decimation' frame
 % is_eNb            - if ~= 0 we load data from an eNb
-% EMOS_CHANNEL      - if the measurement contains the full channel
-%                     estimate, set this to 1
+% EMOS_CHANNEL      - if the measurement contains the full channel estimate, set this to 1
+% align             - alignment of the data structures. If data was recorded on a 64bit 
+%                     machine set this to 8, for 32bit use 4.
 %
 % Returns:
 % estimates         - A structure array containing timestamp, etc
@@ -26,6 +27,9 @@ function [estimates, NFrames, gps_data, H] = load_estimates_lte_new(filename, NF
 %   Date      Version   Comment
 %   20100317  0.1       Created based on load_estimates
 
+if nargin < 6
+  align=4;
+end
 if nargin < 5
     EMOS_CHANNEL = 0;
 end
@@ -42,20 +46,6 @@ end
 % Logfile structure: 
 %  - 100 entries of type fifo_dump_emos (defined in phy_procedures_emos.h)
 
-if exist('dump_size','file') && isunix
-    [dummy,result] = system('./dump_size');
-    eval(result);
-else
-    warning('File dump_size.c has to be compiled to enable error checking of sizes');
-    %PHY_measurements_size = 1120;
-    %UCI_data_t_size = 49;
-    %DCI_alloc_t_size = 16;
-    %eNb_UE_stats_size = 20;
-    %fifo_dump_emos_UE_size = 33492;
-    %fifo_dump_emos_eNb_size = 36980;
-    %gps_fix_t_size = 108;
-end
-
 struct_template_new;
 
 gps_fix_t_size = gps_data_struct_a.size;
@@ -87,7 +77,7 @@ for n=1:NFiles
     info_file = dir(filename{n});
     NFrames_file(n) = floor(info_file.bytes/CHANNEL_BUFFER_SIZE)*NO_ESTIMATES_DISK;
     if (mod(info_file.bytes,CHANNEL_BUFFER_SIZE) ~= 0)
-        warning('File size not a multiple of buffer size. File might be corrupt or is_eNb flag is wrong.');
+        warning('File size not a multiple of buffer size. File might be corrupt or is_eNb flag or alignment is wrong.');
     end
 end
 NFrames = min(sum(NFrames_file), NFrames_max);
diff --git a/openair1/EMOS/LTE/IMPORT_FILTER/struct_template_new.m b/openair1/EMOS/LTE/IMPORT_FILTER/struct_template_new.m
index b0800f1f384..bcd5e90abbf 100644
--- a/openair1/EMOS/LTE/IMPORT_FILTER/struct_template_new.m
+++ b/openair1/EMOS/LTE/IMPORT_FILTER/struct_template_new.m
@@ -33,10 +33,14 @@ NB_ANTENNAS_TX = 2;
 MAX_CQI_BITS = 40;
 MAX_DCI_SIZE_BITS = 45;
 
-% EMOS_CHANNEL = 0;
+%EMOS_CHANNEL = 0;
 
 % enable this line to enable error checking
-get_dump_size
+if isunix
+  get_dump_size
+else
+  warning('Error checking of sizes only possible in Linux');
+end
 
 phy_measurements_struct = struct(...
     'rssi',                 uint32(0),...
@@ -80,7 +84,7 @@ phy_measurements_struct = struct(...
     'nb_antennas_rx',       uint8(0));
 
 
-phy_measurements_struct_a = cstruct(phy_measurements_struct,[],4);
+phy_measurements_struct_a = cstruct(phy_measurements_struct,[],align);
 if (exist('PHY_measurements_size','var') && (phy_measurements_struct_a.size ~= PHY_measurements_size))
     warning('PHY_measurements_size does not match');
 end
@@ -108,7 +112,7 @@ phy_measurements_eNb_struct = struct(...
     'subband_cqi_dB',       int32(zeros(N_RB_UL_EMOS,NB_ANTENNAS_RX,NUMBER_OF_UE_MAX)),...
     'subband_cqi_tot_dB',   int32(zeros(N_RB_UL_EMOS,NUMBER_OF_UE_MAX)));
 
-phy_measurements_eNb_struct_a = cstruct(phy_measurements_eNb_struct,[],4);
+phy_measurements_eNb_struct_a = cstruct(phy_measurements_eNb_struct,[],align);
 if (exist('PHY_measurements_eNb_size','var') && (phy_measurements_eNb_struct_a.size ~= PHY_measurements_eNb_size))
     warning('PHY_measurements_eNb_size does not match');
 end
@@ -121,7 +125,7 @@ uci_data_struct = struct(...
     'o_ACK',uint8(zeros(1,4)),...
     'O_ACK',uint8(0));
 
-uci_data_struct_a = cstruct(uci_data_struct,[],4);
+uci_data_struct_a = cstruct(uci_data_struct,[],align);
 if (exist('UCI_data_t_size','var') && (uci_data_struct_a.size ~= UCI_data_t_size))
     warning('UCI_data_t_size does not match');
 end
@@ -156,7 +160,7 @@ dci_alloc_struct = struct(...
 %     'rv2',logical(zeros(1,2)),...
 %     'padding',logical(zeros(1,6)));
 
-dci_alloc_struct_a = cstruct(dci_alloc_struct,[],4);
+dci_alloc_struct_a = cstruct(dci_alloc_struct,[],align);
 if (exist('DCI_alloc_t_size','var') && (dci_alloc_struct_a.size ~= DCI_alloc_t_size))
     warning('DCI_alloc_t_size does not match');
 end
@@ -204,7 +208,7 @@ eNb_UE_stats_struct = struct(...
 );
 
 
-eNb_UE_stats_struct_a = cstruct(eNb_UE_stats_struct,[],4);
+eNb_UE_stats_struct_a = cstruct(eNb_UE_stats_struct,[],align);
 if (exist('eNb_UE_stats_size','var') && (eNb_UE_stats_struct_a.size ~= eNb_UE_stats_size))
     warning('eNb_UE_stats_size does not match');
 end
@@ -245,7 +249,7 @@ if (EMOS_CHANNEL)
     fifo_dump_emos_struct_UE.channel=int16(zeros(2*NUMBER_OF_OFDM_CARRIERS_EMOS*N_PILOTS_DL_EMOS*N_SLOTS_DL_EMOS,NB_ANTENNAS_TX_EMOS,NB_ANTENNAS_RX_EMOS));
 end
 
-fifo_dump_emos_struct_UE_a = cstruct(fifo_dump_emos_struct_UE,[],4);
+fifo_dump_emos_struct_UE_a = cstruct(fifo_dump_emos_struct_UE,[],align);
 if (exist('fifo_dump_emos_UE_size','var') && (fifo_dump_emos_struct_UE_a.size ~= fifo_dump_emos_UE_size))
     warning('fifo_dump_emos_UE_size does not match');
 end
@@ -261,7 +265,7 @@ if (EMOS_CHANNEL)
   fifo_dump_emos_struct_eNb.channel = int16(zeros(2*N_RB_UL_EMOS*12*N_PILOTS_UL_EMOS*N_SUBFRAMES_UL_EMOS,NB_ANTENNAS_RX_EMOS));
 end
 
-fifo_dump_emos_struct_eNb_a = cstruct(fifo_dump_emos_struct_eNb,[],4);
+fifo_dump_emos_struct_eNb_a = cstruct(fifo_dump_emos_struct_eNb,[],align);
 if (exist('fifo_dump_emos_eNb_size','var') && (fifo_dump_emos_struct_eNb_a.size ~= fifo_dump_emos_eNb_size))
     warning('fifo_dump_emos_eNb_size does not match');
 end
@@ -284,7 +288,7 @@ gps_data_struct = struct(...
     'climb',double(0),...
     'epc',double(0));
 
-gps_data_struct_a = cstruct(gps_data_struct,[],4);
+gps_data_struct_a = cstruct(gps_data_struct,[],align);
 if (exist('gps_fix_t_size','var') && (gps_data_struct_a.size ~= gps_fix_t_size))
     warning('gps_data_struct_size does not match');
 end
@@ -304,7 +308,7 @@ min_estimates_struct = struct(...
     'dlsch_errors',uint32(0),...
     'mimo_mode',uint8(0),...
     'eNb_id',uint8(0));
-min_estimates_struct_a = cstruct(min_estimates_struct,[],4);
+min_estimates_struct_a = cstruct(min_estimates_struct,[],align);
 
 min_estimates_struct_eNb = struct(...
     'mcs',double(0),...
@@ -317,7 +321,7 @@ min_estimates_struct_eNb = struct(...
     'ulsch_errors',uint32(0),...
     'mimo_mode',uint8(0),...
     'eNb_id',uint8(0));
-min_estimates_struct_eNb_a = cstruct(min_estimates_struct,[],4);
+min_estimates_struct_eNb_a = cstruct(min_estimates_struct,[],align);
 
 
 
-- 
GitLab