|
请做EFI的大侠&前辈指点一下,红色标记的那个宏怎么解释?; w% z) n- z T& R5 Y
我调试发现他是取得那个字段的地址。2 K( k7 w* y2 R( `3 B1 P
大侠能详细解释一下吗?/ O' j+ g, T8 O
' R2 q* ] l: P* \
这段是我Debug的用例。
J' t7 R, M) |/ q! Q
/ P4 `& C) O$ s7 s* e' d#include "stdio.h"
4 z P5 L T: s' ?#include "stdlib.h"
% W* V' ?+ j: i! g: {% P#include "string.h"& R9 X& D$ z( z- |
3 S1 T2 Y' x7 }( ?#define CHAR8 unsigned char
% ^9 r. r& Y& T3 r, o2 m4 u t. ], e0 z! P, t' _% a
typedef struct _tagjany+ \4 K3 u% G7 @
{
, V5 N/ t7 B& j0 n char name[8];* B' f- m h8 d' c" y$ k
int age;
$ P3 q t0 n7 S+ D* g6 x, F}JANY, *PJANY;9 j/ Y, c9 O- Y1 T: k+ G
& {8 a6 m5 O9 |5 @typedef struct _tagowen
# X' S) g: e/ e- p' D{1 D& V `. E3 ~# o* ?
JANY jy;4 L* t: K2 N: w* j& R. x
char home[5];* G+ I! ^) |7 Z( X$ q) L5 l+ O/ }( |
}OWEN, *POWEN;
3 G+ j$ }' Z5 s" X
* h+ X% m# Q X/ X#define PEI_CORE_HANDLE_SIGNATURE "owen.lu"
. b! ~" G0 N+ w+ E% Q9 C; y3 E* [
#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
$ d/ t$ V2 ^/ Z8 R* K) u
6 Z2 y) a3 ^/ J! q& d! H$ p3 |! o#define PEI_CR(Record, TYPE, Field, Signature) \( Q! P( J7 _# {! T4 O- e
_CR(Record, TYPE, Field) ! K$ |5 c# p* m, z4 z
1 E& h. B; m7 O7 ^! K#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
/ z7 ^, L7 U( T$ J7 a (PEI_CR(a, JANY, name, PEI_CORE_HANDLE_SIGNATURE))
9 t2 f2 T; e& `
/ R0 n! s% g$ R; pvoid main()
0 N& X" F; k; ]) c( R{/ x: G/ _) M G4 W
PJANY jany;
2 C6 G+ n9 b* B POWEN owen;
0 _% _. e7 v8 n* \$ K$ n! ]3 ? jany = malloc(sizeof(JANY));
- Y& W! w/ u: ]$ T owen = malloc(sizeof(OWEN));1 t& z6 m- I: F. Z+ x' U _
jany = PEI_CORE_INSTANCE_FROM_PS_THIS(owen);
) m0 ^4 t& y. i; {3 g% g! T) v free(owen);, v( J$ y) i+ W2 I7 e- |
free(jany);
$ E' K8 g% S9 G+ k return; ( F5 P0 k1 N4 a+ S+ b9 q
} |
|