The structure of _DISPATCHER_HEADER will be added later. After modification, it can finally be passed when FB is compiled into .exe. But it can't pass when compiling into a driver, maybe the FB translator can't translate perfectly. The error is as follows:
MainDrivers.c:16:47: error: size of array '__$fb_structsizecheck' is negative
16 | #define __FB_STATIC_ASSERT( expr ) extern int __$fb_structsizecheck[(expr) ? 1 : -1]
| ^~~~~~~~~~~~~~~~~~~~~
MainDrivers.c:860:1: note: in expansion of macro '__FB_STATIC_ASSERT'
860 | __FB_STATIC_ASSERT( sizeof( struct $11_KSEMAPHORE ) == 32 );
VC
________________________________
Code: Select all
typedef struct _DISPATCHER_HEADER {
union {
union {
volatile LONG Lock;
LONG LockNV;
} DUMMYUNIONNAME;
struct { // Events, Semaphores, Gates, etc.
UCHAR Type; // All (accessible via KOBJECT_TYPE)
UCHAR Signalling;
UCHAR Size;
UCHAR Reserved1;
} DUMMYSTRUCTNAME;
struct { // Timer
UCHAR TimerType;
union {
UCHAR TimerControlFlags;
struct {
UCHAR Absolute : 1;
UCHAR Wake : 1;
UCHAR EncodedTolerableDelay : TIMER_TOLERABLE_DELAY_BITS;
} DUMMYSTRUCTNAME;
};
UCHAR Hand;
union {
UCHAR TimerMiscFlags;
struct {
#if !defined(KENCODED_TIMER_PROCESSOR)
UCHAR Index : TIMER_EXPIRED_INDEX_BITS;
#else
UCHAR Index : 1;
UCHAR Processor : TIMER_PROCESSOR_INDEX_BITS;
#endif
UCHAR Inserted : 1;
volatile UCHAR Expired : 1;
} DUMMYSTRUCTNAME;
} DUMMYUNIONNAME;
} DUMMYSTRUCTNAME2;
struct { // Timer2
UCHAR Timer2Type;
union {
UCHAR Timer2Flags;
struct {
UCHAR Timer2Inserted : 1;
UCHAR Timer2Expiring : 1;
UCHAR Timer2CancelPending : 1;
UCHAR Timer2SetPending : 1;
UCHAR Timer2Running : 1;
UCHAR Timer2Disabled : 1;
UCHAR Timer2ReservedFlags : 2;
} DUMMYSTRUCTNAME;
} DUMMYUNIONNAME;
UCHAR Timer2ComponentId;
UCHAR Timer2RelativeId;
} DUMMYSTRUCTNAME3;
struct { // Queue
UCHAR QueueType;
union {
UCHAR QueueControlFlags;
struct {
UCHAR Abandoned : 1;
UCHAR DisableIncrement : 1;
UCHAR QueueReservedControlFlags : 6;
} DUMMYSTRUCTNAME;
} DUMMYUNIONNAME;
UCHAR QueueSize;
UCHAR QueueReserved;
} DUMMYSTRUCTNAME4;
struct { // Thread
UCHAR ThreadType;
UCHAR ThreadReserved;
union {
UCHAR ThreadControlFlags;
struct {
UCHAR CycleProfiling : 1;
UCHAR CounterProfiling : 1;
UCHAR GroupScheduling : 1;
UCHAR AffinitySet : 1;
UCHAR Tagged : 1;
UCHAR EnergyProfiling: 1;
#if !defined(_X86_)
UCHAR ThreadReservedControlFlags : 2;
#else
UCHAR Instrumented : 1;
UCHAR ThreadReservedControlFlags : 1;
#endif
} DUMMYSTRUCTNAME;
} DUMMYUNIONNAME;
union {
UCHAR DebugActive;
#if !defined(_X86_)
struct {
BOOLEAN ActiveDR7 : 1;
BOOLEAN Instrumented : 1;
BOOLEAN Minimal : 1;
BOOLEAN Reserved4 : 3;
BOOLEAN UmsScheduled : 1;
BOOLEAN UmsPrimary : 1;
} DUMMYSTRUCTNAME;
#endif
} DUMMYUNIONNAME2;
} DUMMYSTRUCTNAME5;
struct { // Mutant
UCHAR MutantType;
UCHAR MutantSize;
BOOLEAN DpcActive;
UCHAR MutantReserved;
} DUMMYSTRUCTNAME6;
} DUMMYUNIONNAME;
LONG SignalState; // Object lock
LIST_ENTRY WaitListHead; // Object lock
} DISPATCHER_HEADER, *PDISPATCHER_HEADER;
FB
________________________________________________________
Code: Select all
#define TIMER_TOLERABLE_DELAY_BITS 6
#define TIMER_EXPIRED_INDEX_BITS 6
#define TIMER_PROCESSOR_INDEX_BITS 5
type _DISPATCHER_HEADER
union
union
Lock as LONG
LockNV as LONG
end union
type 'Events, Semaphores, Gates, etc.
Type as UCHAR 'All (accessible via KOBJECT_TYPE)
Signalling as UCHAR
Size as UCHAR
Reserved1 as UCHAR
end type
type 'Timer
TimerType as UCHAR
union
TimerControlFlags as UCHAR
type
Absolute:1 as UCHAR
Wake:1 as UCHAR
EncodedTolerableDelay:TIMER_TOLERABLE_DELAY_BITS as UCHAR
end type
end union
Hand as UCHAR
union
TimerMiscFlags as UCHAR
type
#Ifdef __FB_64BIT__
TIndex:TIMER_EXPIRED_INDEX_BITS as UCHAR
#Else
Index:1 as UCHAR
Processor:TIMER_PROCESSOR_INDEX_BITS as UCHAR
#EndIf
Inserted:1 as UCHAR
Expired:1 as UCHAR
end type
end union
end type
type 'Timer2
Timer2Type as UCHAR
union
Timer2Flags as UCHAR
type
Timer2Inserted:1 as UCHAR
Timer2Expiring:1 as UCHAR
Timer2CancelPending:1 as UCHAR
Timer2SetPending:1 as UCHAR
Timer2Running:1 as UCHAR
Timer2Disabled:1 as UCHAR
Timer2ReservedFlags:2 as UCHAR
end type
end union
Timer2ComponentId as UCHAR
Timer2RelativeId as UCHAR
end type
type 'Queue
QueueType as UCHAR
union
QueueControlFlags as UCHAR
type
Abandoned:1 as UCHAR
DisableIncrement:1 as UCHAR
QueueReservedControlFlags:6 as UCHAR
end type
end union
QueueSize as UCHAR
QueueReserved as UCHAR
end type
type 'Thread
ThreadType as UCHAR
ThreadReserved as UCHAR
union
ThreadControlFlags as UCHAR
type
CycleProfiling:1 as UCHAR
CounterProfiling:1 as UCHAR
GroupScheduling:1 as UCHAR
AffinitySet:1 as UCHAR
Tagged:1 as UCHAR
EnergyProfiling:1 as UCHAR
#Ifdef __FB_64BIT__
ThreadReservedControlFlags:2 as UCHAR
#Else
Instrumented:1 as UCHAR
ThreadReservedControlFlags:1 as UCHAR
#EndIf
end type
end union
union
DebugActive as UCHAR
#Ifdef __FB_64BIT__
type
ActiveDR7:1 as BOOLEAN
Instrumented:1 as BOOLEAN
Minimal:1 as BOOLEAN
Reserved4:3 as BOOLEAN
UmsScheduled:1 as BOOLEAN
UmsPrimary:1 as BOOLEAN
end type
#EndIf
end union
end type
type 'Mutant
MutantType as UCHAR
MutantSize as UCHAR
DpcActive as BOOLEAN
MutantReserved as UCHAR
end type
end union
SignalState as LONG 'Object lock
WaitListHead as LIST_ENTRY 'Object lock
end type
type DISPATCHER_HEADER as _DISPATCHER_HEADER
type PDISPATCHER_HEADER as _DISPATCHER_HEADER ptr