> On Dec 3, 2014, at 10:01 PM, [email protected] wrote:
> 
> Revision: 16474
>          http://sourceforge.net/p/edk2/code/16474
> Author:   jyao1
> Date:     2014-12-04 06:01:15 +0000 (Thu, 04 Dec 2014)
> Log Message:
> -----------
> properly support GCC - pass 'I' (int) rather than 'L' (long) to struct.unpack.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: "Yao, Jiewen" <[email protected]>
> Reviewed-by: "Rangarajan, Ravi P" <[email protected]>
> Reviewed-by: "Ma, Maurice" <[email protected]>
> Reviewed-by: "Mudusuru, Giri P" <[email protected]>
> 
> Modified Paths:
> --------------
>    trunk/edk2/IntelFspPkg/Tools/GenCfgOpt.py
> 
> Modified: trunk/edk2/IntelFspPkg/Tools/GenCfgOpt.py
> ===================================================================
> --- trunk/edk2/IntelFspPkg/Tools/GenCfgOpt.py 2014-12-04 01:18:04 UTC (rev 
> 16473)
> +++ trunk/edk2/IntelFspPkg/Tools/GenCfgOpt.py 2014-12-04 06:01:15 UTC (rev 
> 16474)
> @@ -615,7 +615,7 @@
>                 BinFd = open(BinFile, "rb")
>                 IdStr    = BinFd.read(0x08)
>                 ImageId  = struct.unpack('Q', IdStr)
> -                ImageRev = struct.unpack('L', BinFd.read(0x04))
> +                ImageRev = struct.unpack('I', BinFd.read(0x04))

I’ve been hit by this issue and done some research….

I would recommend not using native types/endian with struct in Python to 
describe well defined data. 

It is better to specify little-endian, and then use the “Standard size” from 
the chart. 

In this case both, ‘<I’ and ‘<L’, would work. 

The default being native size (and alignment) means by default the standard 
sizes are not used, and if you just look at the table you get confused (I know 
I did).  


Character       Byte order      Size    Alignment
@       native  native  native
=       native  standard        none
<       little-endian   standard        none
>       big-endian      standard        none
!       network (= big-endian)  standard        none



Format  C Type  Python type     Standard size   Notes
x       pad byte        no value                 
c       char    string of length 1      1        
b       signed char     integer 1       (3)
B       unsigned char   integer 1       (3)
?       _Bool   bool    1       (1)
h       short   integer 2       (3)
H       unsigned short  integer 2       (3)
i       int     integer 4       (3)
I       unsigned int    integer 4       (3)
l       long    integer 4       (3)
L       unsigned long   integer 4       (3)
q       long long       integer 8       (2), (3)
Q       unsigned long long      integer 8       (2), (3)
f       float   float   4       (4)
d       double  float   8       (4)
s       char[]  string           
p       char[]  string           
P       void *  integer         (5), (3)


Thanks,

Andrew Fish

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Andrew Fish <[email protected]>


>                 BinFd.close()
> 
>                 HeaderFd.write("#define VPD_IMAGE_ID    0x%016X        /* 
> '%s' */\n" % (ImageId[0], IdStr))
> 
> 
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-commits mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-commits

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to