Commit e9933255d4234a7d16f5e2f261376dd10747d469

Guillem Jover 2013-05-25T17:11:53

Make setproctitle() available in 0.2 and 0.5 version nodes Make the 0.5 version the default, so that code wanting the actual implemented version can get a proper versioned depdendency. For code linked against the old version, make it available as an alias.

diff --git a/configure.ac b/configure.ac
index 1644510..2fcd511 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,7 @@ AC_CHECK_HEADERS([sys/ndir.h sys/dir.h dir.h dirent.h])
 # Checks for typedefs, structures, and compiler characteristics.
 AC_TYPE_UID_T
 AC_C_INLINE
+AC_C_TYPEOF
 AC_TYPE_INT64_T
 AC_TYPE_MODE_T
 AC_TYPE_OFF_T
diff --git a/src/libbsd.map b/src/libbsd.map
index e900ee3..4067e2c 100644
--- a/src/libbsd.map
+++ b/src/libbsd.map
@@ -73,8 +73,6 @@ LIBBSD_0.2 {
     pidfile_close;
     pidfile_remove;
 
-    setproctitle;
-
     arc4random_buf;
     arc4random_uniform;
 } LIBBSD_0.1;
@@ -99,6 +97,9 @@ LIBBSD_0.5 {
     fgetwln;
     fparseln;
 
+    /* Introduced in 0.2 as a stub, implemented in 0.5. */
+    setproctitle;
+
     strnstr;
 
     wcslcat;
diff --git a/src/setproctitle.c b/src/setproctitle.c
index 969f266..60b6484 100644
--- a/src/setproctitle.c
+++ b/src/setproctitle.c
@@ -191,7 +191,7 @@ spt_init(int argc, char *argv[], char *envp[])
 #endif
 
 void
-setproctitle(const char *fmt, ...)
+setproctitle_impl(const char *fmt, ...)
 {
 	/* Use buffer in case argv[0] is passed. */
 	char buf[SPT_MAXTITLE + 1];
@@ -243,3 +243,13 @@ setproctitle(const char *fmt, ...)
 		*++nul = '\0';
 	}
 }
+__asm__(".symver setproctitle_impl,setproctitle@@LIBBSD_0.5");
+
+#ifdef HAVE_TYPEOF
+/* The original function introduced in 0.2 was a stub, it only got implemented
+ * in 0.5, make the implementation available in the old version as an alias
+ * for code linking against that version, and change the default to use the
+ * new version, so that new code depends on the implemented version. */
+extern typeof(setproctitle_impl) setproctitle_stub __attribute__((alias("setproctitle_impl")));
+__asm__(".symver setproctitle_stub,setproctitle@LIBBSD_0.2");
+#endif