git: 10f1b536ad71 - main - libc: move __getosreldate to libsys

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Mon, 05 Feb 2024 20:38:40 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=10f1b536ad71fddc725da58d9e30a42fa66d183c

commit 10f1b536ad71fddc725da58d9e30a42fa66d183c
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-11-17 20:13:40 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2024-02-05 20:34:56 +0000

    libc: move __getosreldate to libsys
    
    Reviewed by:    kib, emaste, imp
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/908
---
 lib/libc/gen/Makefile.inc                 |  2 +-
 lib/libsys/Makefile.sys                   |  1 +
 lib/{libc/gen => libsys}/__getosreldate.c | 15 +--------------
 3 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 6d1f98c241d4..bbd090e46b27 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -6,7 +6,7 @@ CONFS+=	group master.passwd shells
 CONFSMODE_master.passwd=	600
 CONFSPACKAGE=   runtime
 
-SRCS+=	__getosreldate.c \
+SRCS+= \
 	__pthread_mutex_init_calloc_cb_stub.c \
 	__xuname.c \
 	_pthread_stubs.c \
diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys
index e299396585b9..f7fd08f1702d 100644
--- a/lib/libsys/Makefile.sys
+++ b/lib/libsys/Makefile.sys
@@ -32,6 +32,7 @@ PSEUDO+= _clock_gettime.o _gettimeofday.o
 # Sources common to both syscall interfaces:
 SRCS+=	\
 	__error.c \
+	__getosreldate.c \
 	_once_stub.c \
 	getpagesize.c \
 	getpagesizes.c \
diff --git a/lib/libc/gen/__getosreldate.c b/lib/libsys/__getosreldate.c
similarity index 83%
rename from lib/libc/gen/__getosreldate.c
rename to lib/libsys/__getosreldate.c
index 053ec4c94a9b..0bb2efd2ba6a 100644
--- a/lib/libc/gen/__getosreldate.c
+++ b/lib/libsys/__getosreldate.c
@@ -44,23 +44,10 @@ int
 __getosreldate(void)
 {
 	static int osreldate;
-	size_t len;
-	int oid[2];
-	int error, osrel;
 
 	if (osreldate != 0)
 		return (osreldate);
 
-	error = _elf_aux_info(AT_OSRELDATE, &osreldate, sizeof(osreldate));
-	if (error == 0 && osreldate != 0)
-		return (osreldate);
-
-	oid[0] = CTL_KERN;
-	oid[1] = KERN_OSRELDATE;
-	osrel = 0;
-	len = sizeof(osrel);
-	error = sysctl(oid, 2, &osrel, &len, NULL, 0);
-	if (error == 0 && osrel > 0 && len == sizeof(osrel))
-		osreldate = osrel;
+	(void)_elf_aux_info(AT_OSRELDATE, &osreldate, sizeof(osreldate));
 	return (osreldate);
 }