+#ifdef HAVE_STRUCT_FLOCK
+int
+Mono_Posix_FromFlock (struct Mono_Posix_Flock *from, struct flock *to)
+{
+ _cnm_return_val_if_overflow (off_t, from->l_start, -1);
+ _cnm_return_val_if_overflow (off_t, from->l_len, -1);
+ _cnm_return_val_if_overflow (pid_t, from->l_pid, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ if (Mono_Posix_FromLockType (from->l_type, &to->l_type) != 0) {
+ return -1;
+ }
+ if (Mono_Posix_FromSeekFlags (from->l_whence, &to->l_whence) != 0) {
+ return -1;
+ }
+ to->l_start = from->l_start;
+ to->l_len = from->l_len;
+ to->l_pid = from->l_pid;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_FLOCK */
+
+
+#ifdef HAVE_STRUCT_FLOCK
+int
+Mono_Posix_ToFlock (struct flock *from, struct Mono_Posix_Flock *to)
+{
+ _cnm_return_val_if_overflow (gint64, from->l_start, -1);
+ _cnm_return_val_if_overflow (gint64, from->l_len, -1);
+ _cnm_return_val_if_overflow (int, from->l_pid, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ if (Mono_Posix_ToLockType (from->l_type, &to->l_type) != 0) {
+ return -1;
+ }
+ if (Mono_Posix_ToSeekFlags (from->l_whence, &to->l_whence) != 0) {
+ return -1;
+ }
+ to->l_start = from->l_start;
+ to->l_len = from->l_len;
+ to->l_pid = from->l_pid;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_FLOCK */
+
+