diff options
author | Andrew Tridgell <tridge@samba.org> | 2008-01-05 17:41:01 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2008-01-05 17:41:01 +1100 |
commit | 370779a1bb0218f31d02f0976e143d4b5d84b3d4 (patch) | |
tree | fd466f27d5334c23eff9dbb61c304e014e868ae9 /ctdb/lib/replace/replace.h | |
parent | 67d2b14d908498b28bf19febc958cbf5f91cc1ec (diff) | |
download | samba-370779a1bb0218f31d02f0976e143d4b5d84b3d4.tar.gz samba-370779a1bb0218f31d02f0976e143d4b5d84b3d4.tar.xz samba-370779a1bb0218f31d02f0976e143d4b5d84b3d4.zip |
update from Samba4
(This used to be ctdb commit 298118c41bd33acd1a34a35a71a28451a45390c5)
Diffstat (limited to 'ctdb/lib/replace/replace.h')
-rw-r--r-- | ctdb/lib/replace/replace.h | 127 |
1 files changed, 81 insertions, 46 deletions
diff --git a/ctdb/lib/replace/replace.h b/ctdb/lib/replace/replace.h index 06173bd84b..f8a89a7213 100644 --- a/ctdb/lib/replace/replace.h +++ b/ctdb/lib/replace/replace.h @@ -1,15 +1,16 @@ -/* +/* Unix SMB/CIFS implementation. macros to go along with the lib/replace/ portability layer code Copyright (C) Andrew Tridgell 2005 Copyright (C) Jelmer Vernooij 2006 + Copyright (C) Jeremy Allison 2007. ** NOTE! The following LGPL license applies to the replace ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -44,13 +45,6 @@ #include "win32_replace.h" #endif -#ifdef __COMPAR_FN_T -#define QSORT_CAST (__compar_fn_t) -#endif - -#ifndef QSORT_CAST -#define QSORT_CAST (int (*)(const void *, const void *)) -#endif #ifdef HAVE_STDINT_H #include <stdint.h> @@ -78,29 +72,6 @@ #include <stddef.h> #endif -/** - this is a warning hack. The idea is to use this everywhere that we - get the "discarding const" warning from gcc. That doesn't actually - fix the problem of course, but it means that when we do get to - cleaning them up we can do it by searching the code for - discard_const. - - It also means that other error types aren't as swamped by the noise - of hundreds of const warnings, so we are more likely to notice when - we get new errors. - - Please only add more uses of this macro when you find it - _really_ hard to fix const warnings. Our aim is to eventually use - this function in only a very few places. - - Also, please call this via the discard_const_p() macro interface, as that - makes the return type safe. -*/ -#define discard_const(ptr) ((void *)((intptr_t)(ptr))) - -/** Type-safe version of discard_const */ -#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) - #ifndef HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] @@ -120,19 +91,14 @@ char *rep_strdup(const char *s); void *rep_memmove(void *dest,const void *src,int size); #endif -#if !defined(HAVE_MKTIME) || !defined(HAVE_TIMEGM) -#include "system/time.h" -#endif - #ifndef HAVE_MKTIME #define mktime rep_mktime -time_t rep_mktime(struct tm *t); +/* prototype is in "system/time.h" */ #endif #ifndef HAVE_TIMEGM -struct tm; #define timegm rep_timegm -time_t rep_timegm(struct tm *tm); +/* prototype is in "system/time.h" */ #endif #ifndef HAVE_STRLCPY @@ -168,7 +134,7 @@ int setenv(const char *name, const char *value, int overwrite); #ifndef HAVE_UNSETENV #define unsetenv rep_unsetenv -int rep_unsetenv(const char *name); +int rep_unsetenv(const char *name); #endif #ifndef HAVE_SETEUID @@ -192,7 +158,7 @@ char *rep_strcasestr(const char *haystack, const char *needle); #endif #ifndef HAVE_STRTOK_R -#define strtok_r rep_strtok_r +#define strtok_r rep_strtok_r char *rep_strtok_r(char *s, const char *delim, char **save_ptr); #endif @@ -359,10 +325,39 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset); ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset); #endif +#ifdef REPLACE_INET_NTOA +#define inet_ntoa rep_inet_ntoa +/* prototype is in "system/network.h" */ +#endif + +#ifndef HAVE_INET_PTON +#define inet_pton rep_inet_pton +/* prototype is in "system/network.h" */ +#endif + +#ifndef HAVE_INET_NTOP +#define inet_ntop rep_inet_ntop +/* prototype is in "system/network.h" */ +#endif + +#ifndef HAVE_GETIFADDRS +#define getifaddrs rep_getifaddrs +/* prototype is in "system/network.h" */ +#endif + +#ifndef HAVE_FREEIFADDRS +#define freeifaddrs rep_freeifaddrs +/* prototype is in "system/network.h" */ +#endif + #ifdef HAVE_LIMITS_H #include <limits.h> #endif +#ifdef HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif + /* The extra casts work around common compiler bugs. */ #define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) /* The outer cast is needed to work around a bug in Cray C 5.0.3.0. @@ -372,7 +367,15 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset) #define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t))) #ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 64 +#define HOST_NAME_MAX 255 +#endif + +/* + * Some older systems seem not to have MAXHOSTNAMELEN + * defined. + */ +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN HOST_NAME_MAX #endif #ifndef UINT16_MAX @@ -450,9 +453,6 @@ typedef int bool; #endif #endif -#ifdef HAVE_SYS_PARAM_H -#include <sys/param.h> -#endif #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -462,11 +462,38 @@ typedef int bool; #define MAX(a,b) ((a)>(b)?(a):(b)) #endif +#if !defined(HAVE_VOLATILE) +#define volatile +#endif + +/** + this is a warning hack. The idea is to use this everywhere that we + get the "discarding const" warning from gcc. That doesn't actually + fix the problem of course, but it means that when we do get to + cleaning them up we can do it by searching the code for + discard_const. + + It also means that other error types aren't as swamped by the noise + of hundreds of const warnings, so we are more likely to notice when + we get new errors. + + Please only add more uses of this macro when you find it + _really_ hard to fix const warnings. Our aim is to eventually use + this function in only a very few places. + + Also, please call this via the discard_const_p() macro interface, as that + makes the return type safe. +*/ +#define discard_const(ptr) ((void *)((intptr_t)(ptr))) + +/** Type-safe version of discard_const */ +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) + #ifndef __STRING #define __STRING(x) #x #endif -#ifndef _STRINGSTRING +#ifndef __STRINGSTRING #define __STRINGSTRING(x) __STRING(x) #endif @@ -511,4 +538,12 @@ typedef int bool; #undef HAVE_MMAP #endif +#ifdef __COMPAR_FN_T +#define QSORT_CAST (__compar_fn_t) +#endif + +#ifndef QSORT_CAST +#define QSORT_CAST (int (*)(const void *, const void *)) +#endif + #endif /* _LIBREPLACE_REPLACE_H */ |