+void sysv_shm_lock_init(void);
+
+static __inline__ time_t
+sysv_shmtime(void)
+{
+ struct timeval tv;
+ microtime(&tv);
+ return (tv.tv_sec);
+}
+
+/*
+ * This conversion is safe, since if we are converting for a 32 bit process,
+ * then it's value of (struct shmid_ds)->shm_segsz will never exceed 4G.
+ *
+ * NOTE: Source and target may *NOT* overlap! (target is smaller)
+ */
+static void
+shmid_ds_64to32(struct user_shmid_ds *in, struct user32_shmid_ds *out)
+{
+ out->shm_perm = in->shm_perm;
+ out->shm_segsz = in->shm_segsz;
+ out->shm_lpid = in->shm_lpid;
+ out->shm_cpid = in->shm_cpid;
+ out->shm_nattch = in->shm_nattch;
+ out->shm_atime = in->shm_atime;
+ out->shm_dtime = in->shm_dtime;
+ out->shm_ctime = in->shm_ctime;
+ out->shm_internal = CAST_DOWN_EXPLICIT(int,in->shm_internal);
+}
+
+/*
+ * NOTE: Source and target may are permitted to overlap! (source is smaller);
+ * this works because we copy fields in order from the end of the struct to
+ * the beginning.
+ */
+static void
+shmid_ds_32to64(struct user32_shmid_ds *in, struct user_shmid_ds *out)
+{
+ out->shm_internal = in->shm_internal;
+ out->shm_ctime = in->shm_ctime;
+ out->shm_dtime = in->shm_dtime;
+ out->shm_atime = in->shm_atime;
+ out->shm_nattch = in->shm_nattch;
+ out->shm_cpid = in->shm_cpid;
+ out->shm_lpid = in->shm_lpid;
+ out->shm_segsz = in->shm_segsz;
+ out->shm_perm = in->shm_perm;
+}
+
+