diff options
author | Martin Baulig <martin@home-of-linux.org> | 1999-02-18 08:57:03 +0000 |
---|---|---|
committer | Martin Baulig <martin@src.gnome.org> | 1999-02-18 08:57:03 +0000 |
commit | 00f0791ebdf380c5b728d22fe5920528a25b79a7 (patch) | |
tree | 5b4b349ce5ce70258984cdd7a769902bb4b1ea88 | |
parent | ad7aca6105c888de20524ae8677ea7c810d51351 (diff) | |
download | libgtop-00f0791ebdf380c5b728d22fe5920528a25b79a7.tar.gz |
Define them as G_INLINE_FUNC in <glibtop/errno.h> if possible.
1999-02-18 Martin Baulig <martin@home-of-linux.org>
* sysdeps/common/error.c (glibtop_error_r, glibtop_warn_r): Define
them as G_INLINE_FUNC in <glibtop/errno.h> if possible.
(glibtop_error_io_r, glibtop_warn_io_r): Likewise.
(glibtop_error_vr, glibtop_warn_vr): New functions taking a va_list.
(glibtop_error_io_vr, glibtop_warn_io_vr): New functions taking an
errno an a va_list.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | include/glibtop/error.h | 102 | ||||
-rw-r--r-- | sysdeps/common/error.c | 88 |
3 files changed, 157 insertions, 42 deletions
@@ -1,3 +1,12 @@ +1999-02-18 Martin Baulig <martin@home-of-linux.org> + + * sysdeps/common/error.c (glibtop_error_r, glibtop_warn_r): Define + them as G_INLINE_FUNC in <glibtop/errno.h> if possible. + (glibtop_error_io_r, glibtop_warn_io_r): Likewise. + (glibtop_error_vr, glibtop_warn_vr): New functions taking a va_list. + (glibtop_error_io_vr, glibtop_warn_io_vr): New functions taking an + errno an a va_list. + 1999-02-17 Martin Baulig <martin@home-of-linux.org> Released LibGTop 0.99.8. diff --git a/include/glibtop/error.h b/include/glibtop/error.h index 8305430a..5806d351 100644 --- a/include/glibtop/error.h +++ b/include/glibtop/error.h @@ -23,13 +23,65 @@ #define __GLIBTOP_ERROR_H__ #include <glibtop.h> +#include <glib.h> __BEGIN_DECLS -/* - * FIXME: varargs macros only supported on gcc. - * Breaks Sun CC, maybe others. - */ +extern void glibtop_error_vr __P((glibtop *, char *, va_list)); +extern void glibtop_warn_vr __P((glibtop *, char *, va_list)); + +extern void glibtop_error_io_vr __P((glibtop *, char *, gint, va_list)); +extern void glibtop_warn_io_vr __P((glibtop *, char *, gint, va_list)); + +G_INLINE_FUNC void glibtop_error_r __P((glibtop *, char *, ...)); +G_INLINE_FUNC void glibtop_warn_r __P((glibtop *, char *, ...)); + +G_INLINE_FUNC void glibtop_error_io_r __P((glibtop *, char *, ...)); +G_INLINE_FUNC void glibtop_warn_io_r __P((glibtop *, char *, ...)); + +#ifdef G_CAN_INLINE +G_INLINE_FUNC void +glibtop_error_r (glibtop *server, char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_error_vr (server, format, args); + va_end (args); +} + +G_INLINE_FUNC void +glibtop_warn_r (glibtop *server, char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_warn_vr (server, format, args); + va_end (args); +} + +G_INLINE_FUNC void +glibtop_error_io_r (glibtop *server, char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_error_io_vr (server, format, errno, args); + va_end (args); +} + +G_INLINE_FUNC void +glibtop_warn_io_r (glibtop *server, char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_warn_io_vr (server, format, errno, args); + va_end (args); +} +#endif + +#ifdef __GNUC__ #define glibtop_error(p1, args...) glibtop_error_r(glibtop_global_server , p1 , ## args) #define glibtop_warn(p1, args...) glibtop_warn_r(glibtop_global_server , p1 , ## args) @@ -37,11 +89,45 @@ __BEGIN_DECLS #define glibtop_error_io(p1, args...) glibtop_error_io_r(glibtop_global_server , p1 , ## args) #define glibtop_warn_io(p1, args...) glibtop_warn_io_r(glibtop_global_server , p1 , ## args) -extern void glibtop_error_r __P((glibtop *, char *, ...)); -extern void glibtop_warn_r __P((glibtop *, char *, ...)); +#else /* no __GNUC__ */ + +static void +glibtop_error (char *format, ...) +{ + va_list args; + va_start (args, format); + glibtop_error_vr (glibtop_global_server, format, args); + va_end (args); +} + +static void +glibtop_warn (char *format, ...) +{ + va_list args; + va_start (args, format); + glibtop_warn_vr (glibtop_global_server, format, args); + va_end (args); +} + +static void +glibtop_error_io (char *format, ...) +{ + va_list args; + va_start (args, format); + glibtop_error_io_vr (glibtop_global_server, format, errno, args); + va_end (args); +} + +static void +glibtop_warn_io (char *format, ...) +{ + va_list args; + va_start (args, format); + glibtop_warn_io_vr (glibtop_global_server, format, errno, args); + va_end (args); +} -extern void glibtop_error_io_r __P((glibtop *, char *, ...)); -extern void glibtop_warn_io_r __P((glibtop *, char *, ...)); +#endif /* no __GNUC__ */ __END_DECLS diff --git a/sysdeps/common/error.c b/sysdeps/common/error.c index 2ddd7dd9..f7772675 100644 --- a/sysdeps/common/error.c +++ b/sysdeps/common/error.c @@ -34,17 +34,11 @@ print_server_name (glibtop *server) } void -glibtop_error_r (glibtop *server, char *format, ...) +glibtop_error_vr (glibtop *server, char *format, va_list args) { - va_list ap; - - va_start (ap, format); - print_server_name (server); - vfprintf (stderr, format, ap); + vfprintf (stderr, format, args); fprintf (stderr, "\n"); - - va_end (ap); #ifdef LIBGTOP_ENABLE_DEBUG abort (); @@ -54,17 +48,11 @@ glibtop_error_r (glibtop *server, char *format, ...) } void -glibtop_error_io_r (glibtop *server, char *format, ...) +glibtop_error_io_vr (glibtop *server, char *format, gint error, va_list args) { - va_list ap; - - va_start (ap, format); - print_server_name (server); - vfprintf (stderr, format, ap); - fprintf (stderr, ": %s\n", strerror (errno)); - - va_end (ap); + vfprintf (stderr, format, args); + fprintf (stderr, ": %s\n", strerror (error)); #ifdef LIBGTOP_ENABLE_DEBUG abort (); @@ -74,17 +62,11 @@ glibtop_error_io_r (glibtop *server, char *format, ...) } void -glibtop_warn_r (glibtop *server, char *format, ...) +glibtop_warn_vr (glibtop *server, char *format, va_list args) { - va_list ap; - - va_start (ap, format); - print_server_name (server); - vfprintf (stderr, format, ap); + vfprintf (stderr, format, args); fprintf (stderr, "\n"); - - va_end (ap); #ifdef LIBGTOP_FATAL_WARNINGS abort (); @@ -92,19 +74,57 @@ glibtop_warn_r (glibtop *server, char *format, ...) } void -glibtop_warn_io_r (glibtop *server, char *format, ...) +glibtop_warn_io_vr (glibtop *server, char *format, gint error, va_list args) { - va_list ap; - - va_start (ap, format); - print_server_name (server); - vfprintf (stderr, format, ap); - fprintf (stderr, ": %s\n", strerror (errno)); - - va_end (ap); + vfprintf (stderr, format, args); + fprintf (stderr, ": %s\n", strerror (error)); #ifdef LIBGTOP_FATAL_WARNINGS abort (); #endif } + +#ifndef G_CAN_INLINE + +G_INLINE_FUNC void +glibtop_error_r (glibtop *server, char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_error_vr (server, format, args); + va_end (args); +} + +G_INLINE_FUNC void +glibtop_warn_r (glibtop *server, char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_warn_vr (server, format, args); + va_end (args); +} + +G_INLINE_FUNC void +glibtop_error_io_r (glibtop *server, char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_error_io_vr (server, format, errno, args); + va_end (args); +} + +G_INLINE_FUNC void +glibtop_warn_io_r (glibtop *server, char *format, ...) +{ + va_list args; + + va_start (args, format); + glibtop_warn_io_vr (server, format, errno, args); + va_end (args); +} + +#endif /* not G_CAN_INLINE */ |