|
|
请做EFI的大侠&前辈指点一下,红色标记的那个宏怎么解释?8 F& u" N6 s2 X9 @$ ?
我调试发现他是取得那个字段的地址。
0 Q8 G+ r5 p) R \( m& U大侠能详细解释一下吗?
& e4 d6 ], {& ^$ E, q- `5 G0 I+ X# Z7 C
这段是我Debug的用例。
: F2 t7 \6 x( f/ S% Q" i- L" t* G9 S; U( M! {' W1 o# a1 c5 ]+ o
#include "stdio.h"+ V u) o1 T6 U8 `, ?
#include "stdlib.h"
! \0 D# Z& C; v: }7 d* @) |+ R' u#include "string.h"
; }* x' M9 g! i$ e( Y/ p3 h5 c* r j1 D2 C) w
#define CHAR8 unsigned char
) O8 X3 |# z R/ N- m! @& h- H7 U6 d5 \
typedef struct _tagjany
/ o" F% `/ s3 O" k{
) [. o& ]8 H6 X4 @& W% g( C) p char name[8];, p8 q4 r3 |% Z: {! E" S3 h5 Y5 T
int age;7 A8 B5 g1 n; Q C( p" h
}JANY, *PJANY;
/ I/ o: t; s0 [. q4 H* C
8 Y+ R. S% @( i3 v. D2 D- Htypedef struct _tagowen5 e& I1 S2 h7 x6 Y+ L
{* G% @( [0 |/ I% s+ g: I
JANY jy;
! l* m* U9 y& U) y% G( n char home[5];: M9 n, {8 t+ V" T; V5 `! g* c, P
}OWEN, *POWEN;# f7 u' z7 i J4 o
' Q( f, s3 }0 P
#define PEI_CORE_HANDLE_SIGNATURE "owen.lu"
. U4 {+ o9 ]3 m/ w, [- R- s( k X+ V) t. n( B# S
#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field))) h0 U) l( m6 ?6 H- N1 [
- q% I- |5 V5 [/ i; Y/ [# R2 W' b
#define PEI_CR(Record, TYPE, Field, Signature) \
7 x; d3 u$ ?: S9 m$ K# f _CR(Record, TYPE, Field)
0 g5 W6 N, V: W) x0 v a6 E3 }
0 d3 a5 l7 u) ~2 }#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \7 y* j" F2 F, u$ ?7 y
(PEI_CR(a, JANY, name, PEI_CORE_HANDLE_SIGNATURE))
3 Z+ j- @# ^8 m+ d! f3 Q% ?
# E: O. y4 |0 }+ N4 [8 C. |0 ?void main()1 l. u9 P! V% _8 M
{ s$ i: R3 Q7 e3 H8 ^4 e
PJANY jany;# m2 a6 Y# j5 F2 K- X5 |9 C, O
POWEN owen;
+ a3 a, ~2 f# N jany = malloc(sizeof(JANY));
# g1 S* @2 F7 t, V9 h) R3 {/ S' G owen = malloc(sizeof(OWEN));( b* k. }& @" n: K
jany = PEI_CORE_INSTANCE_FROM_PS_THIS(owen);7 F5 R+ d# Y$ l- H" S& Y$ r4 Q2 r' p
free(owen);0 \7 S- q3 F6 }& _9 f" O( \
free(jany);0 Q r1 Y* k' \# G* D
return;
1 A7 V" m8 {% X} |
|