similarity index 100%
rename from sysdeps/gnu/bits/struct_utmpx.h
rename to bits/types/struct_utmpx.h
similarity index 98%
rename from sysdeps/gnu/bits/utmpx.h
rename to bits/utmpx.h
@@ -51,7 +51,7 @@ struct __exit_status
};
-#include <bits/struct_utmpx.h>
+#include <bits/types/struct_utmpx.h>
/* Values for the `ut_type' field of a `struct utmpx'. */
new file mode 100644
@@ -0,0 +1 @@
+#include <login/utmpx.h>
@@ -26,7 +26,7 @@ include ../Makeconfig
headers := utmp.h bits/utmp.h lastlog.h pty.h \
bits/types/struct_lastlog.h \
bits/types/struct_utmp.h \
- bits/struct_utmpx.h
+ bits/types/struct_utmpx.h
routines := getlogin getlogin_r setlogin getlogin_r_chk \
getutent getutent_r getutid getutline getutid_r getutline_r \
@@ -17,17 +17,47 @@
#include <string.h>
#include <utmp.h>
+#include <stddef.h>
+#define getutmpx __redirect_getutmpx
#include <utmpx.h>
+#undef getutmpx
+
+#define CHECK_SIZE_AND_OFFSET(field) \
+ _Static_assert (sizeof ((struct utmp){0}.field) \
+ == sizeof ((struct utmpx){0}.field), \
+ "sizeof ((struct utmp){0}." #field " != " \
+ "sizeof ((struct utmpx){0}" #field); \
+ _Static_assert (offsetof (struct utmp, field) \
+ == offsetof (struct utmpx, field), \
+ "offsetof (struct utmp, " #field ") != " \
+ "offsetof (struct utmpx, " #field ")");
+
+/* This ensure the getutmp to getutmpx alias is valid. */
+_Static_assert (sizeof (struct utmp) == sizeof (struct utmpx),
+ "sizeof (struct utmp) != sizeof (struct utmpx)");
+CHECK_SIZE_AND_OFFSET (ut_type)
+CHECK_SIZE_AND_OFFSET (ut_pid)
+CHECK_SIZE_AND_OFFSET (ut_line)
+CHECK_SIZE_AND_OFFSET (ut_user)
+CHECK_SIZE_AND_OFFSET (ut_id)
+CHECK_SIZE_AND_OFFSET (ut_host)
+CHECK_SIZE_AND_OFFSET (ut_tv)
+
/* Copy the information in UTMPX to UTMP. */
void
-getutmp (const struct utmpx *utmpx, struct utmp *utmp)
+__getutmp (const struct utmpx *utmpx, struct utmp *utmp)
{
+ memset (utmp, 0, sizeof (struct utmpx));
utmp->ut_type = utmpx->ut_type;
utmp->ut_pid = utmpx->ut_pid;
memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line));
memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user));
memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id));
memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host));
- utmp->ut_tv = utmpx->ut_tv;
+ utmp->ut_tv.tv_sec = utmpx->ut_tv.tv_sec;
+ utmp->ut_tv.tv_usec = utmpx->ut_tv.tv_usec;
}
+
+weak_alias (__getutmp, getutmp)
+strong_alias (__getutmp, getutmpx)
@@ -1,34 +1 @@
-/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <string.h>
-#include <utmp.h>
-#include <utmpx.h>
-
-/* Copy the information in UTMP to UTMPX. */
-void
-getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
-{
- memset (utmpx, 0, sizeof (struct utmpx));
- utmpx->ut_type = utmp->ut_type;
- utmpx->ut_pid = utmp->ut_pid;
- memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line));
- memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user));
- memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id));
- memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host));
- utmpx->ut_tv = utmp->ut_tv;
-}
+/* Implemented by getutmp.c. */
@@ -17,11 +17,20 @@
<https://www.gnu.org/licenses/>. */
#include <utmp.h>
+#include <string.h>
+#include <unistd.h>
#include "utmp-private.h"
#ifndef TRANSFORM_UTMP_FILE_NAME
-# define TRANSFORM_UTMP_FILE_NAME(file_name) (file_name)
+# define TRANSFORM_UTMP_FILE_NAME(file_name) \
+ ((strcmp (file_name, _PATH_UTMP "x") == 0 \
+ && __access (_PATH_UTMP "x", F_OK) != 0) \
+ ? _PATH_UTMP \
+ : ((strcmp (file_name, _PATH_WTMP "x") == 0 \
+ && __access (_PATH_WTMP "x", F_OK) != 0) \
+ ? _PATH_WTMP \
+ : file_name))
#endif
void
similarity index 100%
rename from sysdeps/gnu/utmpx.h
rename to login/utmpx.h
deleted file mode 100644
@@ -1,34 +0,0 @@
-/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <assert.h>
-#include <string.h>
-#include <utmp.h>
-#ifndef _UTMPX_H
-/* This is an ugly hack but we must not see the getutmpx declaration. */
-# define getutmpx XXXgetutmpx
-# include <utmpx.h>
-# undef getutmpx
-#endif
-
-void
-getutmp (const struct utmpx *utmpx, struct utmp *utmp)
-{
- assert (sizeof (struct utmp) == sizeof (struct utmpx));
- memcpy (utmp, utmpx, sizeof (struct utmp));
-}
-strong_alias (getutmp, getutmpx)
deleted file mode 100644
@@ -1 +0,0 @@
-/* We don't need a separate version. it is the same as getutmp(). */
deleted file mode 100644
@@ -1,31 +0,0 @@
-/* Copyright (C) 1998-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1998.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <string.h>
-#include <unistd.h>
-
-#define TRANSFORM_UTMP_FILE_NAME(file_name) \
- ((strcmp (file_name, _PATH_UTMP "x") == 0 \
- && __access (_PATH_UTMP "x", F_OK) != 0) \
- ? _PATH_UTMP \
- : ((strcmp (file_name, _PATH_WTMP "x") == 0 \
- && __access (_PATH_WTMP "x", F_OK) != 0) \
- ? _PATH_WTMP \
- : file_name))
-
-#include <login/updwtmp.c>
@@ -16,22 +16,15 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <string.h>
-#include <utmp.h>
-/* This is an ugly hack but we must not see the getutmpx declaration. */
-#define getutmpx XXXgetutmpx
-#include <utmpx.h>
-#undef getutmpx
+#undef weak_alias
+#define weak_alias(a, b)
+#undef strong_alias
+#define strong_alias(a, b)
-#include "utmp-compat.h"
+#include <login/getutmp.c>
-#undef weak_alias
-#define weak_alias(n,a)
-#define getutmp __getutmp
-#define getutmpx __getutmpx
-#include "sysdeps/gnu/getutmp.c"
-#undef getutmp
-#undef getutmpx
+#include "utmp-compat.h"
default_symbol_version (__getutmp, getutmp, UTMP_COMPAT_BASE);
+_strong_alias (__getutmp, __getutmpx)
default_symbol_version (__getutmpx, getutmpx, UTMP_COMPAT_BASE);
@@ -25,7 +25,7 @@
# undef weak_alias
# define weak_alias(n,a)
#endif
-#include "sysdeps/gnu/updwtmp.c"
+#include <login/updwtmp.c>
#if defined SHARED
default_symbol_version (__updwtmp, updwtmp, UTMP_COMPAT_BASE);