summaryrefslogtreecommitdiff
path: root/portable/system.h
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2010-02-09 15:32:54 -0800
committerRuss Allbery <rra@stanford.edu>2010-02-09 15:32:54 -0800
commitccf1cd7efa90bdcbe834e0d4ca144289cca97fd7 (patch)
treea3f791ef91920da7a1857e2e95bab3ecdf9aa4a7 /portable/system.h
parentce6c27ef04783e21baf44549ff9e361e0c0f148e (diff)
Update portability code to rra-c-util 3.0
Add replacements for mkstemp and setenv, since we now use them when obtaining credentials in the client. Fix the bool type with Sun Studio 12 on Solaris 10.
Diffstat (limited to 'portable/system.h')
-rw-r--r--portable/system.h38
1 files changed, 27 insertions, 11 deletions
diff --git a/portable/system.h b/portable/system.h
index b899d08..461601b 100644
--- a/portable/system.h
+++ b/portable/system.h
@@ -1,6 +1,9 @@
/*
+ * Standard system includes and portability adjustments.
+ *
* Declarations of routines and variables in the C library. Including this
- * file is the equivalent of including all of the following headers, portably:
+ * file is the equivalent of including all of the following headers,
+ * portably:
*
* #include <sys/types.h>
* #include <stdarg.h>
@@ -12,8 +15,8 @@
* #include <string.h>
* #include <unistd.h>
*
- * Missing functions are provided via #define or prototyped if available.
- * Also provides some standard #defines.
+ * Missing functions are provided via #define or prototyped if available from
+ * the portable helper library. Also provides some standard #defines.
*
* Written by Russ Allbery <rra@stanford.edu>
* This work is hereby placed in the public domain by its author.
@@ -55,13 +58,17 @@
BEGIN_DECLS
+/* Default to a hidden visibility for all portability functions. */
+#pragma GCC visibility push(hidden)
+
/*
* Provide prototypes for functions not declared in system headers. Use the
- * HAVE_DECL macros for those functions that may be prototyped but
- * implemented incorrectly or implemented without a prototype.
+ * HAVE_DECL macros for those functions that may be prototyped but implemented
+ * incorrectly or implemented without a prototype.
*/
#if !HAVE_ASPRINTF
-extern int asprintf(char **, const char *, ...);
+extern int asprintf(char **, const char *, ...)
+ __attribute__((__format__(printf, 2, 3)));
extern int vasprintf(char **, const char *, va_list);
#endif
#if !HAVE_DECL_SNPRINTF
@@ -71,6 +78,12 @@ extern int snprintf(char *, size_t, const char *, ...)
#if !HAVE_DECL_VSNPRINTF
extern int vsnprintf(char *, size_t, const char *, va_list);
#endif
+#if !HAVE_MKSTEMP
+extern int mkstemp(char *);
+#endif
+#if !HAVE_SETENV
+extern int setenv(const char *, const char *, int);
+#endif
#if !HAVE_STRLCAT
extern size_t strlcat(char *, const char *, size_t);
#endif
@@ -78,6 +91,9 @@ extern size_t strlcat(char *, const char *, size_t);
extern size_t strlcpy(char *, const char *, size_t);
#endif
+/* Undo default visibility change. */
+#pragma GCC visibility pop
+
END_DECLS
/* Windows provides snprintf under a different name. */
@@ -90,9 +106,9 @@ END_DECLS
* been defined, all the rest almost certainly have.
*/
#ifndef STDIN_FILENO
-# define STDIN_FILENO 0
-# define STDOUT_FILENO 1
-# define STDERR_FILENO 2
+# define STDIN_FILENO 0
+# define STDOUT_FILENO 1
+# define STDERR_FILENO 2
#endif
/*
@@ -101,9 +117,9 @@ END_DECLS
*/
#ifndef va_copy
# ifdef __va_copy
-# define va_copy(d, s) __va_copy((d), (s))
+# define va_copy(d, s) __va_copy((d), (s))
# else
-# define va_copy(d, s) memcpy(&(d), &(s), sizeof(va_list))
+# define va_copy(d, s) memcpy(&(d), &(s), sizeof(va_list))
# endif
#endif