Kernel calls and macros for sigvals
The sigval data type is a union of an integer and a pointer, so its size depends on whether you compile for a 32- or 64-bit architecture, There are some other implications:
- In 32-bit architectures, you can send a pointer in a pulse by passing the pointer as the value
argument to
MsgSendPulse(),
but this won't work with 64-bit pointers, so there's a
MsgSendPulsePtr()
kernel call:
int MsgSendPulsePtr(int coid, int priority, int code, void *value);When you receive a pulse, you need to extract the value from the correct field: integers from sival_int, pointers from sival_ptr.
- There's also
SignalKillSigval(),
which lets you send a pointer as the value for a signal:
int SignalKillSigval(uint32_t nd, pid_t pid, int tid, int signo, union sigval *sigval);It's the kernel call under the POSIX sigqueue() function, and you aren't likely to use it directly.
- We provide the following macros for initializing the sigval that's part of a
sigevent:
- SIGEV_PULSE_INT_INIT()
- SIGEV_PULSE_PTR_INIT()
- SIGEV_SIGNAL_CODE_INT_INIT()
- SIGEV_SIGNAL_CODE_PTR_INIT()
- SIGEV_SIGNAL_VALUE_INT_INIT()
- SIGEV_SIGNAL_VALUE_PTR_INIT()
The original initialization macros (e.g., SIGEV_PULSE_INIT()) store the value in sigev_value.sival_ptr, as do the SIGEV_*_PTR_INIT() macros. The SIGEV_*_INT_INIT() macros store the value in sigev_value.sival_int and set the hidden SIGEV_FLAG_SIVAL_INT bit in sigev_notify.
Page updated:
