summaryrefslogtreecommitdiffstats
path: root/ctdb/lib/replace/replace.h
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2013-05-29 14:44:03 +1000
committerAmitay Isaacs <amitay@gmail.com>2013-05-29 17:47:16 +1000
commit4c1dc871b9ebdb9a83ab7b4714d89e451ea0783a (patch)
tree340462070c256ce4f33bf0ccf344725c16270e17 /ctdb/lib/replace/replace.h
parentfe1fc55c616f175a3ebdd8edb64dca0430c149d7 (diff)
downloadsamba-4c1dc871b9ebdb9a83ab7b4714d89e451ea0783a.tar.gz
samba-4c1dc871b9ebdb9a83ab7b4714d89e451ea0783a.tar.xz
samba-4c1dc871b9ebdb9a83ab7b4714d89e451ea0783a.zip
replace: Sync to latest replace from upstream
The latest commits affecting lib/replace remove autoconf build from Samba tree. So using following commit as a sync point. commit 9ddfd7d8784e6f546628f48990b69ee2850be52d Author: Andrew Bartlett <abartlet@samba.org> Date: Wed May 22 17:23:30 2013 +1000 Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 506b27c944b4031e8a325816bd12abddd442a0bb)
Diffstat (limited to 'ctdb/lib/replace/replace.h')
-rw-r--r--ctdb/lib/replace/replace.h137
1 files changed, 117 insertions, 20 deletions
diff --git a/ctdb/lib/replace/replace.h b/ctdb/lib/replace/replace.h
index c081f23c26..c0b799763a 100644
--- a/ctdb/lib/replace/replace.h
+++ b/ctdb/lib/replace/replace.h
@@ -46,18 +46,22 @@
#endif
-#ifdef HAVE_STDINT_H
+#ifdef HAVE_INTTYPES_H
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+#elif HAVE_STDINT_H
#include <stdint.h>
/* force off HAVE_INTTYPES_H so that roken doesn't try to include both,
which causes a warning storm on irix */
#undef HAVE_INTTYPES_H
-#elif HAVE_INTTYPES_H
-#define __STDC_FORMAT_MACROS
-#include <inttypes.h>
+#endif
+
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
#endif
#ifndef __PRI64_PREFIX
-# if __WORDSIZE == 64
+# if __WORDSIZE == 64 && ! defined __APPLE__
# define __PRI64_PREFIX "l"
# else
# define __PRI64_PREFIX "ll"
@@ -104,6 +108,53 @@
# define PRIu64 __PRI64_PREFIX "u"
#endif
+#ifndef SCNd8
+# define SCNd8 "hhd"
+#endif
+#ifndef SCNd16
+# define SCNd16 "hd"
+#endif
+#ifndef SCNd32
+# define SCNd32 "d"
+#endif
+#ifndef SCNd64
+# define SCNd64 __PRI64_PREFIX "d"
+#endif
+
+#ifndef SCNi8
+# define SCNi8 "hhi"
+#endif
+#ifndef SCNi16
+# define SCNi16 "hi"
+#endif
+#ifndef SCNi32
+# define SCNi32 "i"
+#endif
+#ifndef SCNi64
+# define SCNi64 __PRI64_PREFIX "i"
+#endif
+
+#ifndef SCNu8
+# define SCNu8 "hhu"
+#endif
+#ifndef SCNu16
+# define SCNu16 "hu"
+#endif
+#ifndef SCNu32
+# define SCNu32 "u"
+#endif
+#ifndef SCNu64
+# define SCNu64 __PRI64_PREFIX "u"
+#endif
+
+#ifdef HAVE_BSD_STRING_H
+#include <bsd/string.h>
+#endif
+
+#ifdef HAVE_BSD_UNISTD_H
+#include <bsd/unistd.h>
+#endif
+
#ifdef HAVE_STRING_H
#include <string.h>
#endif
@@ -116,6 +167,10 @@
#include <sys/types.h>
#endif
+#ifdef HAVE_SETPROCTITLE_H
+#include <setproctitle.h>
+#endif
+
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
@@ -153,6 +208,11 @@ void *rep_memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
#endif
+#ifndef HAVE_MEMALIGN
+#define memalign rep_memalign
+void *rep_memalign(size_t boundary, size_t size);
+#endif
+
#ifndef HAVE_MKTIME
#define mktime rep_mktime
/* prototype is in "system/time.h" */
@@ -355,16 +415,6 @@ int rep_dlclose(void *handle);
/* prototype is in system/network.h */
#endif
-#ifndef HAVE_VDPRINTF
-#define vdprintf rep_vdprintf
-int rep_vdprintf(int fd, const char *format, va_list ap);
-#endif
-
-#ifndef HAVE_DPRINTF
-#define dprintf rep_dprintf
-int rep_dprintf(int fd, const char *format, ...);
-#endif
-
#ifndef PRINTF_ATTRIBUTE
#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
/** Use gcc attribute to check printf fns. a1 is the 1-based index of
@@ -385,7 +435,17 @@ int rep_dprintf(int fd, const char *format, ...);
#endif
#endif
-#ifndef HAVE_VASPRINTF
+#if !defined(HAVE_VDPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+#define vdprintf rep_vdprintf
+int rep_vdprintf(int fd, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
+#endif
+
+#if !defined(HAVE_DPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+#define dprintf rep_dprintf
+int rep_dprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
+#endif
+
+#if !defined(HAVE_VASPRINTF) || !defined(HAVE_C99_VSNPRINTF)
#define vasprintf rep_vasprintf
int rep_vasprintf(char **ptr, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
#endif
@@ -400,11 +460,29 @@ int rep_snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
int rep_vsnprintf(char *,size_t ,const char *, va_list ap) PRINTF_ATTRIBUTE(3,0);
#endif
-#ifndef HAVE_ASPRINTF
+#if !defined(HAVE_ASPRINTF) || !defined(HAVE_C99_VSNPRINTF)
#define asprintf rep_asprintf
int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
#endif
+#if !defined(HAVE_C99_VSNPRINTF)
+#ifdef REPLACE_BROKEN_PRINTF
+/*
+ * We do not redefine printf by default
+ * as it breaks the build if system headers
+ * use __attribute__((format(printf, 3, 0)))
+ * instead of __attribute__((format(__printf__, 3, 0)))
+ */
+#define printf rep_printf
+#endif
+int rep_printf(const char *, ...) PRINTF_ATTRIBUTE(1,2);
+#endif
+
+#if !defined(HAVE_C99_VSNPRINTF)
+#define fprintf rep_fprintf
+int rep_fprintf(FILE *stream, const char *, ...) PRINTF_ATTRIBUTE(2,3);
+#endif
+
#ifndef HAVE_VSYSLOG
#ifdef HAVE_SYSLOG
#define vsyslog rep_vsyslog
@@ -434,7 +512,7 @@ void rep_vsyslog (int facility_priority, const char *format, va_list arglist) PR
typedef int (*comparison_fn_t)(const void *, const void *);
#endif
-#ifdef REPLACE_STRPTIME
+#ifndef HAVE_WORKING_STRPTIME
#define strptime rep_strptime
struct tm;
char *rep_strptime(const char *buf, const char *format, struct tm *tm);
@@ -531,8 +609,7 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
char *rep_get_current_dir_name(void);
#endif
-#if !defined(HAVE_STRERROR_R) || !defined(STRERROR_R_PROTO_COMPATIBLE)
-#undef strerror_r
+#ifndef HAVE_STRERROR_R
#define strerror_r rep_strerror_r
int rep_strerror_r(int errnum, char *buf, size_t buflen);
#endif
@@ -569,6 +646,10 @@ int rep_strerror_r(int errnum, char *buf, size_t buflen);
#define UINT64_MAX ((uint64_t)-1)
#endif
+#ifndef INT64_MAX
+#define INT64_MAX 9223372036854775807LL
+#endif
+
#ifndef CHAR_BIT
#define CHAR_BIT 8
#endif
@@ -802,4 +883,20 @@ int fdatasync(int );
/* prototype is in "system/network.h" */
#endif
+#ifndef HAVE_GETPEEREID
+#define getpeereid rep_getpeereid
+int rep_getpeereid(int s, uid_t *uid, gid_t *gid);
+#endif
+
+#ifndef HAVE_USLEEP
+#define usleep rep_usleep
+typedef long useconds_t;
+int usleep(useconds_t);
+#endif
+
+#ifndef HAVE_SETPROCTITLE
+#define setproctitle rep_setproctitle
+void rep_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
+#endif
+
#endif /* _LIBREPLACE_REPLACE_H */