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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
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