GCC_NEED_DECLARATION used to prevent (maintainer-only) GCC warnings. bp_sms9110
authorshort <>
Mon, 6 Sep 1999 15:28:39 +0000 (15:28 +0000)
committershort <>
Mon, 6 Sep 1999 15:28:39 +0000 (15:28 +0000)
acconfig.h
autogen.sh
configure.in
need-declaration.m4 [new file with mode: 0644]

index 6d7a2b0..c20241f 100644 (file)
 
 /* snprintf(3) unsafe emulation */
 #undef HAVE_SNPRINTF
-#ifdef HAVE_SNPRINTF
-#define VARPRINTF(v,f,d) snprintf((v),sizeof((v)),f,(d))
-#else
-#define VARPRINTF(v,f,d) sprintf((v),f,(d))
-#endif
 
 /* vsnprintf(3) unsafe emulation */
 #undef HAVE_VSNPRINTF
-#ifdef HAVE_VSNPRINTF
-#define VARVPRINTF(v,f,d) vsnprintf((v),sizeof((v)),f,(d))
-#else
-#define VARVPRINTF(v,f,d) vsprintf((v),f,(d))
-#endif
 
 /* printf family accepts %m */
 #undef PRINTF_WORKS_PM
 /* how to declare __atribute__ ((__unused__)) */
 #undef ATTR_UNUSED
 
+@BOTTOM@
+/* Declaration for gethostname(3)? */
+#undef NEED_DECLARATION_GETHOSTNAME
+#ifdef NEED_DECLARATION_GETHOSTNAME
+#include <unistd.h>
+int gethostname(char *name, size_t len);
+#endif
+
+/* Declaration for kill(2)? */
+#undef NEED_DECLARATION_KILL
+#ifdef NEED_DECLARATION_KILL
+#include <sys/types.h>
+#include <signal.h>
+int kill(pid_t pid, int sig);
+#endif
+
+/* Declaration for snprintf(3)? */
+#undef NEED_DECLARATION_SNPRINTF
+#ifdef NEED_DECLARATION_SNPRINTF
+#include <stdio.h>
+int snprintf(char *str, size_t n, const char *format, ...);
+#endif
+
+/* Declaration for vsnprintf(3)? */
+#undef NEED_DECLARATION_VSNPRINTF
+#ifdef NEED_DECLARATION_VSNPRINTF
+#include <stdio.h>
+#include <stdarg.h>
+int vsnprintf(char *str, size_t n, const char *format, va_list ap);
+#endif
+
+/* Declaration for strdup(3)? */
+#undef NEED_DECLARATION_STRDUP
+#ifdef NEED_DECLARATION_STRDUP
+#include <string.h>
+char *strdup(const char *s);
+#endif
+
+/* Declaration for usleep(3)? */
+#undef NEED_DECLARATION_USLEEP
+#ifdef NEED_DECLARATION_USLEEP
+#include <unistd.h>
+void usleep(unsigned long usec);
+#endif
+
+/* snprintf(3) unsafe emulation */
+#ifdef HAVE_SNPRINTF
+#define VARPRINTF(v,f,d) snprintf((v),sizeof((v)),f,(d))
+#else
+#define VARPRINTF(v,f,d) sprintf((v),f,(d))
+#endif
+
+/* vsnprintf(3) unsafe emulation */
+#ifdef HAVE_VSNPRINTF
+#define VARVPRINTF(v,f,d) vsnprintf((v),sizeof((v)),f,(d))
+#else
+#define VARVPRINTF(v,f,d) vsprintf((v),f,(d))
+#endif
+
index e5791fa..deb107a 100755 (executable)
@@ -42,7 +42,7 @@ rm -r -f \
 if [ "$1" = clean ];then exit;fi
 
 cp ../getopt/getopt{1.c,.{c,h}} .
-aclocal
+aclocal -I .
 autoheader
 touch ChangeLog
 automake --gnu -c --add-missing
index db61cf3..979a463 100644 (file)
@@ -152,6 +152,15 @@ AC_TRY_RUN([int main() { char s[100];
        return(!(strcmp(s,"m") && strcmp(s,"%m")));
        }],AC_DEFINE(PRINTF_WORKS_PM) AC_MSG_RESULT(yes),AC_MSG_RESULT(no),AC_MSG_RESULT(avoiding))
 
+GCC_NEED_DECLARATION(gethostname, [#include <unistd.h>])
+GCC_NEED_DECLARATION(kill,        [#include <sys/types.h>
+#include <signal.h>])
+GCC_NEED_DECLARATION(snprintf,    [#include <stdio.h>])
+GCC_NEED_DECLARATION(vsnprintf,   [#include <stdio.h>
+#include <stdarg.h>])
+GCC_NEED_DECLARATION(strdup,      [#include <string.h>])
+GCC_NEED_DECLARATION(usleep,      [#include <unistd.h>])
+
 # Final output.
 
 AC_SUBST(LIBOBJS)
diff --git a/need-declaration.m4 b/need-declaration.m4
new file mode 100644 (file)
index 0000000..d5b7bc6
--- /dev/null
@@ -0,0 +1,42 @@
+dnl See whether we need a declaration for a function.
+dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
+AC_DEFUN(GCC_NEED_DECLARATION,
+[AC_MSG_CHECKING([whether $1 must be declared])
+AC_CACHE_VAL(gcc_cv_decl_needed_$1,
+[AC_TRY_COMPILE([
+#include <stdio.h>
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+$2],
+[char *(*pfn) = (char *(*)) $1],
+eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
+if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
+  AC_MSG_RESULT(yes)
+  gcc_need_declarations="$gcc_need_declarations $1"
+  gcc_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  AC_DEFINE_UNQUOTED($gcc_tr_decl)
+else
+  AC_MSG_RESULT(no)
+fi
+])dnl
+
+dnl Check multiple functions to see whether each needs a declaration.
+dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
+AC_DEFUN(GCC_NEED_DECLARATIONS,
+[for ac_func in $1
+do
+GCC_NEED_DECLARATION($ac_func, $2)
+done
+]
+)