chiark
/
gitweb
/
~mdw
/
disorder
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
038f45a
)
disorder.h: more consistent approach to function attributes
author
Richard Kettlewell
<rjk@greenend.org.uk>
Sun, 22 Dec 2013 11:17:42 +0000
(11:17 +0000)
committer
Richard Kettlewell
<rjk@greenend.org.uk>
Sun, 22 Dec 2013 11:17:42 +0000
(11:17 +0000)
lib/disorder.h
patch
|
blob
|
blame
|
history
diff --git
a/lib/disorder.h
b/lib/disorder.h
index cb0c070e8ca7562f67b2509cfb4ca8c8f28cf888..9fde2d8e397e00c3c6dd4f8f4610f57558835e67 100644
(file)
--- a/
lib/disorder.h
+++ b/
lib/disorder.h
@@
-25,6
+25,12
@@
extern "C" {
#endif
extern "C" {
#endif
+#ifdef __GNUC__
+# define DISORDER_IFGNUC(x) x
+#else
+# define DISORDER_IFGNUC(x)
+#endif
+
/* memory allocation **********************************************************/
void *disorder_malloc(size_t);
/* memory allocation **********************************************************/
void *disorder_malloc(size_t);
@@
-47,34
+53,24
@@
char *disorder_strndup(const char *, size_t);
* {xmalloc,xrealloc}_noptr don't promise to clear the new space
*/
* {xmalloc,xrealloc}_noptr don't promise to clear the new space
*/
-#ifdef __GNUC__
-
int disorder_snprintf(char buffer[], size_t bufsize, const char *fmt, ...)
int disorder_snprintf(char buffer[], size_t bufsize, const char *fmt, ...)
-
__attribute__((format (printf, 3, 4
)));
+
DISORDER_IFGNUC(__attribute__((format (printf, 3, 4)
)));
/* like snprintf */
int disorder_asprintf(char **rp, const char *fmt, ...)
/* like snprintf */
int disorder_asprintf(char **rp, const char *fmt, ...)
- __attribute__((format (printf, 2, 3)));
-/* like asprintf but uses xmalloc_noptr() */
-
-#else
-
-int disorder_snprintf(char buffer[], size_t bufsize, const char *fmt, ...);
-/* like snprintf */
-
-int disorder_asprintf(char **rp, const char *fmt, ...);
+ DISORDER_IFGNUC(__attribute__((format (printf, 2, 3))));
/* like asprintf but uses xmalloc_noptr() */
/* like asprintf but uses xmalloc_noptr() */
-#endif
-
-
/* logging ********************************************************************/
/* logging ********************************************************************/
-void disorder_error(int errno_value, const char *fmt, ...);
+void disorder_error(int errno_value, const char *fmt, ...)
+ DISORDER_IFGNUC(__attribute__((format (printf, 2, 3))));
/* report an error. If errno_value is nonzero then the errno string
* is included. */
/* report an error. If errno_value is nonzero then the errno string
* is included. */
-void disorder_fatal(int errno_value, const char *fmt, ...);
+void disorder_fatal(int errno_value, const char *fmt, ...)
+ DISORDER_IFGNUC(__attribute__((noreturn))
+ __attribute__((format (printf, 2, 3))));
/* report an error and terminate. If errno_value is nonzero then the
* errno string is included. This is the only safe way to terminate
* the process. */
/* report an error and terminate. If errno_value is nonzero then the
* errno string is included. This is the only safe way to terminate
* the process. */