From a25a060c358358d61d683dc8e9aa9df91e877a35 Mon Sep 17 00:00:00 2001
From: Arjun Shankar <arjun@redhat.com>
Date: Mon, 2 Oct 2023 14:55:24 +0200
Subject: [PATCH] Move 'protocols' routines from 'inet' into 'nss'

The getprotoby* and getprotoent* routines are entry points for nss
functionality.  This commit moves them from the 'inet' subdirectory to
'nss'.
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
---
 inet/Makefile                |  8 --------
 inet/Versions                |  5 +----
 nss/Makefile                 | 15 +++++++++++++++
 nss/Versions                 |  3 +++
 {inet => nss}/getproto.c     |  0
 {inet => nss}/getproto_r.c   |  0
 {inet => nss}/getprtent.c    |  0
 {inet => nss}/getprtent_r.c  |  0
 {inet => nss}/getprtname.c   |  0
 {inet => nss}/getprtname_r.c |  0
 10 files changed, 19 insertions(+), 12 deletions(-)
 rename {inet => nss}/getproto.c (100%)
 rename {inet => nss}/getproto_r.c (100%)
 rename {inet => nss}/getprtent.c (100%)
 rename {inet => nss}/getprtent_r.c (100%)
 rename {inet => nss}/getprtname.c (100%)
 rename {inet => nss}/getprtname_r.c (100%)

diff --git a/inet/Makefile b/inet/Makefile
index 776cbfa0fd..dab7182a11 100644
--- a/inet/Makefile
+++ b/inet/Makefile
@@ -48,12 +48,6 @@ routines := \
   ether_ntoa_r \
   getipv4sourcefilter \
   getnameinfo \
-  getproto \
-  getproto_r \
-  getprtent \
-  getprtent_r \
-  getprtname \
-  getprtname_r \
   getrpcbyname \
   getrpcbyname_r \
   getrpcbynumber \
@@ -142,8 +136,6 @@ CFLAGS-getrpcent_r.c += -fexceptions
 CFLAGS-getrpcent.c += -fexceptions
 CFLAGS-getservent_r.c += -fexceptions
 CFLAGS-getservent.c += -fexceptions
-CFLAGS-getprtent_r.c += -fexceptions
-CFLAGS-getprtent.c += -fexceptions
 CFLAGS-either_ntoh.c += -fexceptions
 CFLAGS-either_hton.c += -fexceptions
 CFLAGS-in6_addr.c += $(config-cflags-wno-ignored-attributes)
diff --git a/inet/Versions b/inet/Versions
index 051b305e48..c0c64e1543 100644
--- a/inet/Versions
+++ b/inet/Versions
@@ -15,8 +15,6 @@ libc {
 
     # g*
     getdomainname;
-    getprotobyname; getprotobyname_r; getprotobynumber;
-    getprotobynumber_r; getprotoent; getprotoent_r;
     getservbyname; getservbyname_r; getservbyport;
     getservbyport_r; getservent; getservent_r;
 
@@ -48,8 +46,7 @@ libc {
     # g*
     getaliasbyname_r; getaliasent_r; gethostbyaddr_r; gethostbyname2_r;
     gethostbyname_r; gethostent_r; getnetbyaddr_r; getnetbyname_r;
-    getnetent_r; getprotobyname_r; getprotobynumber_r;
-    getprotoent_r; getservbyname_r;
+    getnetent_r; getservbyname_r;
     getservbyport_r;
     getservent_r;
   }
diff --git a/nss/Makefile b/nss/Makefile
index 023a11fa4b..df22d3655c 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -178,6 +178,21 @@ CFLAGS-getnetent.c += -fexceptions
 CFLAGS-getnetent_r.c += -fexceptions
 endif
 
+# protocols routines:
+routines += \
+  getproto \
+  getproto_r \
+  getprtent \
+  getprtent_r \
+  getprtname \
+  getprtname_r \
+  # routines
+
+ifeq ($(have-thread-library),yes)
+CFLAGS-getprtent_r.c += -fexceptions
+CFLAGS-getprtent.c += -fexceptions
+endif
+
 # pwd routines:
 routines += \
   fgetpwent \
diff --git a/nss/Versions b/nss/Versions
index 95219f0fc7..c5de97fb53 100644
--- a/nss/Versions
+++ b/nss/Versions
@@ -27,6 +27,8 @@ libc {
     getnetgrent; getnetgrent_r;
     getnetbyaddr; getnetbyaddr_r; getnetbyname; getnetbyname_r;
     getnetent; getnetent_r;
+    getprotobyname; getprotobyname_r; getprotobynumber;
+    getprotobynumber_r; getprotoent; getprotoent_r;
     getpw; getpwent; getpwent_r; getpwnam; getpwnam_r; getpwuid; getpwuid_r;
     getspent; getspent_r; getspnam; getspnam_r;
 
@@ -58,6 +60,7 @@ libc {
     # g*
     getgrent_r; getgrgid_r; getgrnam_r;
     getnetgrent_r;
+    getprotobyname_r; getprotobynumber_r; getprotoent_r;
     getpwent_r; getpwuid_r; getpwnam_r;
     getspent_r; getspnam_r;
   }
diff --git a/inet/getproto.c b/nss/getproto.c
similarity index 100%
rename from inet/getproto.c
rename to nss/getproto.c
diff --git a/inet/getproto_r.c b/nss/getproto_r.c
similarity index 100%
rename from inet/getproto_r.c
rename to nss/getproto_r.c
diff --git a/inet/getprtent.c b/nss/getprtent.c
similarity index 100%
rename from inet/getprtent.c
rename to nss/getprtent.c
diff --git a/inet/getprtent_r.c b/nss/getprtent_r.c
similarity index 100%
rename from inet/getprtent_r.c
rename to nss/getprtent_r.c
diff --git a/inet/getprtname.c b/nss/getprtname.c
similarity index 100%
rename from inet/getprtname.c
rename to nss/getprtname.c
diff --git a/inet/getprtname_r.c b/nss/getprtname_r.c
similarity index 100%
rename from inet/getprtname_r.c
rename to nss/getprtname_r.c