FreeBSD 13 : wrong kernel version and size of kevent_t

eugene dee0xeed at gmail.com
Tue Dec 21 18:22:52 UTC 2021


On Tuesday, 21 December 2021 at 17:32:44 UTC, rempas wrote:
> Please eugene use LDC2 and check confirm that the behavior is 
> the same there.

Phobos that shipped with LDC, does not have 
core.sys.freebsd.config
So

```d
import std.stdio;
//import core.sys.freebsd.config;
import core.sys.freebsd.sys.event;

void main(string[] args) {
//        writefln("FreeBSD_version = %s", __FreeBSD_version);
         writefln("sizeof(kevent_t) = %s", kevent_t.sizeof);
}
```

and

```
@bsd:~/d> ldc2 freebsdver.d
@bsd:~/d> ./freebsdver
sizeof(kevent_t) = 32
```

As you see, sizeof struct kevent_t is also wrong, must be 64:

exerpt from /usr/include/sys/event.h

```c
struct kevent {
         __uintptr_t     ident;          // identifier for this 
event
         short           filter;         // filter for event
         unsigned short  flags;          // action flags for kqueue
         unsigned int    fflags;         // filter flag value
         __int64_t       data;           // filter data value
         void            *udata;         // opaque user data 
identifier
         __uint64_t      ext[4];         // extensions
};

#if defined(_WANT_FREEBSD11_KEVENT)
// Older structure used in FreeBSD 11.x and older.
struct kevent_freebsd11 {
         __uintptr_t     ident;          // identifier for this 
event
         short           filter;         // filter for event
         unsigned short  flags;
         unsigned int    fflags;
         __intptr_t      data;
         void            *udata;         // opaque user data 
identifier
};
#endif
```



More information about the Digitalmars-d-learn mailing list