[git commit future 1/1] utent.c, wtent.c: move functions from utxent.c

Peter S. Mazinger ps.m at gmx.net
Tue Mar 15 05:45:33 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=05e6c9db2a3a1282799abdbc19bcbc4837771383
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future

before the change (threads enabled)
   text	   data	    bss	    dec	    hex	filename
   1107	      8	    408	   1523	    5f3	libc/misc/utmp/utent.os
    152	      0	      0	    152	     98	libc/misc/utmp/wtent.os
    240	      0	      0	    240	     f0	libc/misc/utmp/utxent.os
after the change
   text	   data	    bss	    dec	    hex	filename
   1072	      8	    408	   1488	    5d0	libc/misc/utmp/utent.os
    157	      0	      0	    157	     9d	libc/misc/utmp/wtent.os
    200	      0	      0	    200	     c8	libc/misc/utmp/utxent.os

The smaller size on utent.os is unexpected, could be due to better inlining/not inlining

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
 include/utmp.h          |    8 -----
 libc/misc/utmp/utent.c  |   74 ++++++++++++++++++++++++++++++++++++----------
 libc/misc/utmp/utxent.c |    4 ++-
 libc/misc/utmp/wtent.c  |   14 +++++++-
 4 files changed, 73 insertions(+), 27 deletions(-)

diff --git a/include/utmp.h b/include/utmp.h
index 10b75c9..cb8e08f 100644
--- a/include/utmp.h
+++ b/include/utmp.h
@@ -57,37 +57,29 @@ extern void logwtmp (__const char *__ut_line, __const char *__ut_name,
 /* Append entry UTMP to the wtmp-like file WTMP_FILE.  */
 extern void updwtmp (__const char *__wtmp_file, __const struct utmp *__utmp)
      __THROW;
-libc_hidden_proto(updwtmp)
 
 /* Change name of the utmp file to be examined.  */
 extern int utmpname (__const char *__file) __THROW;
-libc_hidden_proto(utmpname)
 
 /* Read next entry from a utmp-like file.  */
 extern struct utmp *getutent (void) __THROW;
-libc_hidden_proto(getutent)
 
 /* Reset the input stream to the beginning of the file.  */
 extern void setutent (void) __THROW;
-libc_hidden_proto(setutent)
 
 /* Close the current open file.  */
 extern void endutent (void) __THROW;
-libc_hidden_proto(endutent)
 
 /* Search forward from the current point in the utmp file until the
    next entry with a ut_type matching ID->ut_type.  */
 extern struct utmp *getutid (__const struct utmp *__id) __THROW;
-libc_hidden_proto(getutid)
 
 /* Search forward from the current point in the utmp file until the
    next entry with a ut_line matching LINE->ut_line.  */
 extern struct utmp *getutline (__const struct utmp *__line) __THROW;
-libc_hidden_proto(getutline)
 
 /* Write out entry pointed to by UTMP_PTR into the utmp file.  */
 extern struct utmp *pututline (__const struct utmp *__utmp_ptr) __THROW;
-libc_hidden_proto(pututline)
 
 
 #if 0 /* def	__USE_MISC */
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index 07ca44e..136ac69 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -19,6 +19,9 @@
 #include <errno.h>
 #include <string.h>
 #include <utmp.h>
+#ifdef __UCLIBC_HAS_UTMPX__
+# include <utmpx.h>
+#endif
 #include <not-cancel.h>
 
 #include <bits/uClibc_mutex.h>
@@ -31,7 +34,7 @@ static const char default_file_name[] = _PATH_UTMP;
 static const char *static_ut_name = default_file_name;
 
 /* This function must be called with the LOCK held */
-static void __setutent(void)
+static void __setutent_nolock(void)
 {
     if (static_fd < 0) {
 	static_fd = open_not_cancel_2(static_ut_name, O_RDWR | O_CLOEXEC);
@@ -50,19 +53,24 @@ static void __setutent(void)
     lseek(static_fd, 0, SEEK_SET);
 }
 #if defined __UCLIBC_HAS_THREADS__
-void setutent(void)
+static void __setutent(void)
 {
     __UCLIBC_MUTEX_LOCK(utmplock);
-    __setutent();
+    __setutent_nolock();
     __UCLIBC_MUTEX_UNLOCK(utmplock);
 }
 #else
+static void __setutent(void);
+strong_alias(__setutent_nolock,__setutent)
+#endif
 strong_alias(__setutent,setutent)
+
+#ifdef __UCLIBC_HAS_UTMPX__
+strong_alias(__setutent,setutxent)
 #endif
-libc_hidden_def(setutent)
 
 /* This function must be called with the LOCK held */
-static struct utmp *__getutent(void)
+static struct utmp *__getutent_lock(void)
 {
     if (static_fd < 0) {
 	__setutent();
@@ -78,19 +86,27 @@ static struct utmp *__getutent(void)
     return NULL;
 }
 #if defined __UCLIBC_HAS_THREADS__
-struct utmp *getutent(void)
+static struct utmp *__getutent(void)
 {
     struct utmp *ret;
 
     __UCLIBC_MUTEX_LOCK(utmplock);
-    ret = __getutent();
+    ret = __getutent_lock();
     __UCLIBC_MUTEX_UNLOCK(utmplock);
     return ret;
 }
 #else
+static struct utmp *__getutent(void);
+strong_alias(__getutent_lock,__getutent)
+#endif
 strong_alias(__getutent,getutent)
+
+#ifdef __UCLIBC_HAS_UTMPX__
+struct utmpx *getutxent(void)
+{
+	return (struct utmpx *) __getutent ();
+}
 #endif
-libc_hidden_def(getutent)
 
 static void __endutent(void)
 {
@@ -101,10 +117,13 @@ static void __endutent(void)
     __UCLIBC_MUTEX_UNLOCK(utmplock);
 }
 strong_alias(__endutent,endutent)
-libc_hidden_def(endutent)
+
+#ifdef __UCLIBC_HAS_UTMPX__
+strong_alias(__endutent,endutxent)
+#endif
 
 /* This function must be called with the LOCK held */
-static struct utmp *__getutid(const struct utmp *utmp_entry)
+static struct utmp *__getutid_lock(const struct utmp *utmp_entry)
 {
     struct utmp *lutmp;
     unsigned type;
@@ -128,19 +147,27 @@ static struct utmp *__getutid(const struct utmp *utmp_entry)
     return NULL;
 }
 #if defined __UCLIBC_HAS_THREADS__
-struct utmp *getutid(const struct utmp *utmp_entry)
+static struct utmp *__getutid(const struct utmp *utmp_entry)
 {
     struct utmp *ret;
 
     __UCLIBC_MUTEX_LOCK(utmplock);
-    ret = __getutid(utmp_entry);
+    ret = __getutid_lock(utmp_entry);
     __UCLIBC_MUTEX_UNLOCK(utmplock);
     return ret;
 }
 #else
+static struct utmp *__getutid(const struct utmp *utmp_entry);
+strong_alias(__getutid_lock,__getutid)
+#endif
 strong_alias(__getutid,getutid)
+
+#ifdef __UCLIBC_HAS_UTMPX__
+struct utmpx *getutxid(const struct utmpx *utmp_entry)
+{
+	return (struct utmpx *) __getutid ((const struct utmp *) utmp_entry);
+}
 #endif
-libc_hidden_def(getutid)
 
 static struct utmp *__getutline(const struct utmp *utmp_entry)
 {
@@ -158,7 +185,13 @@ static struct utmp *__getutline(const struct utmp *utmp_entry)
     return lutmp;
 }
 strong_alias(__getutline,getutline)
-libc_hidden_def(getutline)
+
+#ifdef __UCLIBC_HAS_UTMPX__
+struct utmpx *getutxline(const struct utmpx *utmp_entry)
+{
+	return (struct utmpx *) __getutline ((const struct utmp *) utmp_entry);
+}
+#endif
 
 static struct utmp *__pututline(const struct utmp *utmp_entry)
 {
@@ -178,7 +211,13 @@ static struct utmp *__pututline(const struct utmp *utmp_entry)
     return (struct utmp *)utmp_entry;
 }
 strong_alias(__pututline,pututline)
-libc_hidden_def(pututline)
+
+#ifdef __UCLIBC_HAS_UTMPX__
+struct utmpx *pututxline (const struct utmpx *utmp_entry)
+{
+	return (struct utmpx *) __pututline ((const struct utmp *) utmp_entry);
+}
+#endif
 
 static int __utmpname(const char *new_ut_name)
 {
@@ -202,4 +241,7 @@ static int __utmpname(const char *new_ut_name)
     return 0; /* or maybe return -(static_ut_name != new_ut_name)? */
 }
 strong_alias(__utmpname,utmpname)
-libc_hidden_def(utmpname)
+
+#ifdef __UCLIBC_HAS_UTMPX__
+strong_alias(__utmpname,utmpxname)
+#endif
diff --git a/libc/misc/utmp/utxent.c b/libc/misc/utmp/utxent.c
index a0e80a6..71157cc 100644
--- a/libc/misc/utmp/utxent.c
+++ b/libc/misc/utmp/utxent.c
@@ -13,6 +13,7 @@
 #include <utmpx.h>
 #include <utmp.h>
 
+#if 0 /* moved to utent.c */
 void setutxent(void)
 {
 	setutent ();
@@ -48,10 +49,12 @@ int utmpxname (const char *new_ut_name)
 	return utmpname (new_ut_name);
 }
 
+/* moved to wtent.c */
 void updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx)
 {
 	updwtmp (wtmpx_file, (const struct utmp *) utmpx);
 }
+#endif
 
 /* Copy the information in UTMPX to UTMP. */
 void getutmp (const struct utmpx *utmpx, struct utmp *utmp)
@@ -104,4 +107,3 @@ void getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
 	utmpx->ut_time = utmp->ut_time;
 #endif
 }
-
diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c
index c97f89c..9725426 100644
--- a/libc/misc/utmp/wtent.c
+++ b/libc/misc/utmp/wtent.c
@@ -11,6 +11,9 @@
 #include <time.h>
 #include <unistd.h>
 #include <utmp.h>
+#ifdef __UCLIBC_HAS_UTMPX__
+# include <utmpx.h>
+#endif
 #include <fcntl.h>
 #include <sys/file.h>
 #include <not-cancel.h>
@@ -33,7 +36,7 @@ void logwtmp (const char *line, const char *name, const char *host)
 }
 #endif
 
-void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
+static void __updwtmp(const char *wtmp_file, const struct utmp *lutmp)
 {
     int fd;
 
@@ -46,4 +49,11 @@ void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
 	}
     }
 }
-libc_hidden_def(updwtmp)
+strong_alias(__updwtmp,updwtmp)
+
+#ifdef __UCLIBC_HAS_UTMPX__
+void updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx)
+{
+	__updwtmp (wtmpx_file, (const struct utmp *) utmpx);
+}
+#endif
-- 
1.7.3.4



More information about the uClibc-cvs mailing list