From 652cf94f7c538ff028aa458f5a813a7c9a470102 Mon Sep 17 00:00:00 2001 From: cpickett Date: Tue, 30 Dec 2008 02:17:15 +0000 Subject: [PATCH] * use HAVE_DECL_FUNCTION instead of HAVE_FUNCTION * add bodies for all lib/ .c files * rely on libcompat.h to provide common #includes git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@482 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- lib/fileno.c | 7 +++++++ lib/libcompat.h | 39 ++++++++++++++++++++++----------------- lib/localtime_r.c | 6 ++++++ lib/malloc.c | 3 --- lib/realloc.c | 3 --- lib/setenv.c | 6 ++++++ lib/sleep.c | 3 --- lib/strdup.c | 8 +------- lib/strsignal.c | 5 ----- lib/unsetenv.c | 5 +++++ 10 files changed, 47 insertions(+), 38 deletions(-) diff --git a/lib/fileno.c b/lib/fileno.c index e69de29..35ced77 100644 --- a/lib/fileno.c +++ b/lib/fileno.c @@ -0,0 +1,7 @@ +#include "libcompat.h" + +int fileno(FILE *stream CK_ATTRIBUTE_UNUSED) +{ + return 0; +} + diff --git a/lib/libcompat.h b/lib/libcompat.h index 18cd5bb..280e389 100644 --- a/lib/libcompat.h +++ b/lib/libcompat.h @@ -7,14 +7,10 @@ /* defines size_t */ #include -#if !HAVE_FILENO -int fileno(FILE *stream); -#endif /* !HAVE_FILENO */ - -#if !HAVE_LOCALTIME_R -struct tm *localtime_r(const time_t *clock, struct tm *result); -#endif /* !HAVE_LOCALTIME_R */ +/* defines FILE */ +#include +/* replacement functions for broken originals */ #if !HAVE_MALLOC void *rpl_malloc (size_t n); #endif /* !HAVE_MALLOC */ @@ -23,25 +19,34 @@ void *rpl_malloc (size_t n); void *rpl_realloc (void *p, size_t n); #endif /* !HAVE_REALLOC */ -#if !HAVE_SETENV +/* functions that may be undeclared */ +#if !HAVE_DECL_FILENO +int fileno(FILE *stream); +#endif /* !HAVE_DECL_FILENO */ + +#if !HAVE_DECL_LOCALTIME_R +struct tm *localtime_r(const time_t *clock, struct tm *result); +#endif /* !HAVE_DECL_LOCALTIME_R */ + +#if !HAVE_DECL_SETENV int setenv(const char *name, const char *value, int overwrite); -#endif /* !HAVE_SETENV */ +#endif /* !HAVE_DECL_SETENV */ -#if !HAVE_SLEEP +#if !HAVE_DECL_SLEEP unsigned int sleep (unsigned int seconds); -#endif /* !HAVE_SLEEP */ +#endif /* !HAVE_DECL_SLEEP */ -#if !HAVE_STRDUP +#if !HAVE_DECL_STRDUP char *strdup (const char *str); -#endif /* !HAVE_STRDUP */ +#endif /* !HAVE_DECL_STRDUP */ -#if !HAVE_STRSIGNAL +#if !HAVE_DECL_STRSIGNAL const char *strsignal(int sig); -#endif /* !HAVE_STRSIGNAL */ +#endif /* !HAVE_DECL_STRSIGNAL */ -#if !HAVE_UNSETENV +#if !HAVE_DECL_UNSETENV void unsetenv(const char *name); -#endif /* !HAVE_UNSETENV */ +#endif /* !HAVE_DECL_UNSETENV */ /* silence warnings about an empty library */ void ck_do_nothing (void); diff --git a/lib/localtime_r.c b/lib/localtime_r.c index e69de29..aaa5edf 100644 --- a/lib/localtime_r.c +++ b/lib/localtime_r.c @@ -0,0 +1,6 @@ +#include "libcompat.h" + +struct tm *localtime_r (const time_t *clock CK_ATTRIBUTE_UNUSED, struct tm *result CK_ATTRIBUTE_UNUSED) +{ + return NULL; +} diff --git a/lib/malloc.c b/lib/malloc.c index c9a685b..39b11e9 100644 --- a/lib/malloc.c +++ b/lib/malloc.c @@ -6,9 +6,6 @@ /* malloc has been defined to rpl_malloc, so first undo that */ #undef malloc -/* defines size_t */ -#include - /* this gives us the real malloc to use below */ void *malloc (size_t n); diff --git a/lib/realloc.c b/lib/realloc.c index e72a7fc..bbf51bb 100644 --- a/lib/realloc.c +++ b/lib/realloc.c @@ -7,9 +7,6 @@ /* realloc has been defined to rpl_realloc, so first undo that */ #undef realloc -/* defines size_t */ -#include - /* this gives us the real realloc to use below */ void *realloc (void *p, size_t n); diff --git a/lib/setenv.c b/lib/setenv.c index e69de29..988c815 100644 --- a/lib/setenv.c +++ b/lib/setenv.c @@ -0,0 +1,6 @@ +#include "libcompat.h" + +int setenv (const char *name CK_ATTRIBUTE_UNUSED, const char *value CK_ATTRIBUTE_UNUSED, int overwrite CK_ATTRIBUTE_UNUSED) +{ + return 0; +} diff --git a/lib/sleep.c b/lib/sleep.c index 90bd8ea..4699029 100644 --- a/lib/sleep.c +++ b/lib/sleep.c @@ -1,6 +1,3 @@ -/* This file gets included if AC_REPLACE_FUNCS([sleep]) cannot find - the function. */ - #include "libcompat.h" unsigned int diff --git a/lib/strdup.c b/lib/strdup.c index 3db2cda..80d068e 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -1,13 +1,7 @@ -/* This file gets included if AC_REPLACE_FUNCS([strdup]) cannot - find the function. */ - #include "libcompat.h" -#include -/* Note that Gnulib has a much more advanced version of strdup */ char * -strdup (const char *str) +strdup (const char *str CK_ATTRIBUTE_UNUSED) { - /* FIXME: obviously this is broken */ return NULL; } diff --git a/lib/strsignal.c b/lib/strsignal.c index 1f1a9d7..62dd140 100644 --- a/lib/strsignal.c +++ b/lib/strsignal.c @@ -1,10 +1,5 @@ -/* This file gets included if AC_REPLACE_FUNCS([strsignal]) cannot - find the function. */ - #include "libcompat.h" -#include -/* Note that Gnulib has a much more advanced version of strsignal */ const char * strsignal (int sig) { diff --git a/lib/unsetenv.c b/lib/unsetenv.c index e69de29..8456eb1 100644 --- a/lib/unsetenv.c +++ b/lib/unsetenv.c @@ -0,0 +1,5 @@ +#include "libcompat.h" + +void unsetenv (const char *name CK_ATTRIBUTE_UNUSED) +{ +} -- 2.40.0