|
请做EFI的大侠&前辈指点一下,红色标记的那个宏怎么解释?
& D$ E( S- f8 Q% z( o4 j我调试发现他是取得那个字段的地址。
K; A: i& d, }8 j. G$ z大侠能详细解释一下吗?
4 }4 Q1 @" t; @* N, R" ~1 D& h v j X) q( o8 {! n
这段是我Debug的用例。1 K) {$ s. Q. h* ?7 M8 f
6 f- L/ G. N' V+ n5 L- j
#include "stdio.h"
3 j s! K; `0 D; U) g0 {- d#include "stdlib.h"
1 z6 w, Y6 t0 ]/ e, ~#include "string.h"( V- N% P" r6 D) B7 t
' e4 ]; y7 y- D; ~' w- t) i
#define CHAR8 unsigned char
2 J: S5 E+ ~+ C0 `5 M0 |4 r
. P" l5 l# \ I, ztypedef struct _tagjany
! E$ ^' X- J- e6 {* e9 k- t{6 I1 }1 m) Y/ A4 k4 W
char name[8];
& _. z1 C1 N% j0 R) ` int age;) a( ]' h/ }( m
}JANY, *PJANY;( ?2 M- e; B% N! D: h g
( ?9 K, R! B7 `3 }typedef struct _tagowen
# T5 t) ^0 }1 i# i{+ V7 M% S, t( b6 k% A. o
JANY jy;# [ n6 N$ w# f5 ?! I& c7 i: r; H
char home[5];% G) M2 O# o7 G( ?9 R
}OWEN, *POWEN;* A3 n: d2 w3 G- O
; @& K: M5 o( L+ `
#define PEI_CORE_HANDLE_SIGNATURE "owen.lu"
. t7 o; d7 x3 {% m+ u E5 e; j0 q, d0 c9 {1 ?: k/ F
#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
: o; T5 l# [% V' T" Q
$ H8 t; a/ g% K ^1 W% }#define PEI_CR(Record, TYPE, Field, Signature) \
% Y( R, y) T$ m$ o5 e& u& u; P _CR(Record, TYPE, Field) 2 P# @7 v$ w* \! t1 k
Z2 E) F! i, [; g v' ^. _* L5 r
#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \3 v+ e# y& _1 M) d# S
(PEI_CR(a, JANY, name, PEI_CORE_HANDLE_SIGNATURE))+ C. O' N% i- C$ g, ~- p
& H: o; d* c) Rvoid main()
+ m8 }" w; B* {' T* t8 g- T( p c" f7 b{1 p( p a5 I/ j2 t
PJANY jany;* h( L$ A, f% o& t' { p
POWEN owen;
% ]: _% C- ~2 F2 j0 T jany = malloc(sizeof(JANY));6 v3 u n% V+ \4 h L/ e
owen = malloc(sizeof(OWEN));
" U1 T" Y7 S2 {+ T( Y$ B jany = PEI_CORE_INSTANCE_FROM_PS_THIS(owen);
& w. }8 b5 U$ V7 `+ T- L free(owen);
8 B9 |( X% \2 P, M free(jany);9 Z. z& r# O9 w. A
return; 6 f' R2 z' ~) i- G9 l( `! \
} |
|