+#endif
+
+ return err;
+}
+
+/* Lock the lock file named LFNAME.
+ If FORCE, do so even if it is already locked.
+ Return true if successful. */
+
+static bool
+lock_file_1 (char *lfname, bool force)
+{
+ int err;
+ int symlink_errno;
+ USE_SAFE_ALLOCA;
+
+ /* Call this first because it can GC. */
+ printmax_t boot = get_boot_time ();
+
+ Lisp_Object luser_name = Fuser_login_name (Qnil);
+ char const *user_name = STRINGP (luser_name) ? SSDATA (luser_name) : "";
+ Lisp_Object lhost_name = Fsystem_name ();
+ char const *host_name = STRINGP (lhost_name) ? SSDATA (lhost_name) : "";
+ ptrdiff_t lock_info_size = (strlen (user_name) + strlen (host_name)
+ + 2 * INT_STRLEN_BOUND (printmax_t)
+ + sizeof "@.:");
+ char *lock_info_str = SAFE_ALLOCA (lock_info_size);
+ printmax_t pid = getpid ();
+
+ esprintf (lock_info_str, boot ? "%s@%s.%"pMd":%"pMd : "%s@%s.%"pMd,
+ user_name, host_name, pid, boot);
+ err = create_lock_file (lfname, lock_info_str, force);