static int __map_queue_memory(RT_QUEUE *q, RT_QUEUE_PLACEHOLDER * php) { int err, heapfd; /* Open the heap device to share the message pool memory with the in-kernel skin and bound clients. */ heapfd = __real_open(XNHEAP_DEV_NAME, O_RDWR); if (heapfd < 0) return -ENOENT; /* Bind this file instance to the shared heap. */ err = __real_ioctl(heapfd, 0, php->opaque2); if (err) goto close_and_exit; /* Map the heap memory into our address space. */ php->mapbase = (caddr_t) __real_mmap(NULL, php->mapsize, PROT_READ | PROT_WRITE, MAP_SHARED, heapfd, 0L); if (php->mapbase != MAP_FAILED) /* Copy back a complete placeholder only if all is ok. */ *q = *php; else err = -ENOMEM; close_and_exit: __real_close(heapfd); return err; }
// Emulated ioctl implementation VISIBLE long ioctl(int fd, int cmd, void* arg) { IOCTL_STEP(handle_filio(fd, cmd, arg, &retval)); IOCTL_STEP(handle_termios(fd, cmd, arg, &retval)); run_ioctl: return __real_ioctl(fd, cmd, arg); }
int __wrap_ioctl(int fd, unsigned long int request, ...) { va_list ap; void *arg; va_start(ap, request); arg = va_arg(ap, void *); va_end(ap); if (fd >= __pse51_rtdm_fd_start) return set_errno(XENOMAI_SKINCALL3(__pse51_rtdm_muxid, __rtdm_ioctl, fd - __pse51_rtdm_fd_start, request, arg)); else return __real_ioctl(fd, request, arg); }