To allocate HPS memory, the application calls sysctl() as follows:
int mib[4];
unsigned long ptrs[15];
size_t ptrslen;
int ret;
mib[0] = CTL_OS2;
mib[1] = PF_INET;
mib[2] = IPPROTO_IP;
mib[3] = OS2_MEMMAPIO;
memset(ptr, 0, sizeof(ptrs));
ptrslen = sizeof(ptrs);
ret = sysctl(mib, sizeof(mib) / sizeof(mib[0]), ptrs,
&ptrslen, NULL, 0);
The TCP/IP stack will allocate 60K bytes of memory and return 15 pointers to 4K byte blocks. These must be passed on subsequent send calls with the MSG_MAPIO flag.
To allocate memory and attach a shared-event semaphore to each block as well, the application should initialize the ptrs array with the shared-event semaphore handles before calling sysctl():
int mib[4];
unsigned long ptrs[15];
size_t ptrslen;
int i;
APIRET rc;
int ret;
mib[0] = CTL_OS2;
mib[1] = PF_INET;
mib[2] = IPPROTO_IP;
mib[3] = OS2_MEMMAPIO;
for (i = 0; i < sizeof(ptrs) / sizeof(ptrs[0]); i++) {
rc = DosCreateEventSemaphore(NULL, &ptrs[i], DC_SEM_SHARED, FALSE);
if (rc != NO_ERROR)
exit(1);
}
ptrslen = sizeof(ptrs);
ret = sysctl(mib, sizeof(mib) / sizeof(mib[0]), ptrs, &ptrslen, NULL, 0);