diff --git a/time/mktime.c b/time/mktime.c
index fca0b62d76..c95805c37c 100644
--- a/time/mktime.c
+++ b/time/mktime.c
@@ -101,8 +101,8 @@ my_tzset (void)
   tzset ();
 # endif
 }
-# undef __tzset
-# define __tzset() my_tzset ()
+# undef tzset
+# define tzset() my_tzset ()
 #endif
 
 #if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL
@@ -554,18 +554,19 @@ __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset)
 __time64_t
 __mktime64 (struct tm *tp)
 {
-# if defined _LIBC || NEED_MKTIME_WORKING
   __libc_lock_lock (__tzset_lock);
   __tzset_unlocked ();
+
+# if defined _LIBC || NEED_MKTIME_WORKING
   static mktime_offset_t localtime_offset;
   __time64_t result = __mktime_internal (tp, true, &localtime_offset);
-  __libc_lock_unlock (__tzset_lock);
-  return result;
 # else
-  __tzset ();
 #  undef mktime
-  return mktime (tp);
+  __time64_t result = mktime (tp);
 # endif
+
+  __libc_lock_unlock (__tzset_lock);
+  return result;
 }
 #endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */
 
