int shmget(key_t key, size_t size, int flags) { char name[NAME_MAX + 1]; int oflag = 0; struct shm_info info; if (flags & IPC_CREAT) { oflag |= O_CREAT; } if (flags & IPC_EXCL) { oflag |= O_EXCL; } if (flags & SHM_R) { if (flags & SHM_W) { oflag |= O_RDWR; } else { oflag |= O_RDONLY; } } info.shmid = shm_open(keytoname(key, name), oflag, MODE); if (info.shmid != -1) { info.key = key; info.size = size; info.addr = NULL; if (shm_putinfo(&info) == -1) { close(info.shmid); if ((oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) { shm_unlink(name); } return -1; } } ltrunc(info.shmid, size, SEEK_SET); return info.shmid; }
inline T modf(const T& v, long* ipart, const Policy& pol) { *ipart = ltrunc(v, pol); return v - *ipart; }
inline long ltrunc(const T& v) { return ltrunc(v, policies::policy<>()); }
inline long ltrunc(__gmp_expr<T,U> const& x, const Policy& pol) { return ltrunc(static_cast<mpfr_class>(x), pol); }