X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fnetdb.h;fp=src%2Fcommon%2Fcompat%2Fnetdb.h;h=477058bad65559474248eb3f2ead3db3f887184d;hp=0000000000000000000000000000000000000000;hb=507af6fc151b69a9b7c243e30387da303c5b83cc;hpb=d1f721c52e3810dcb38429cb3beec9f80043aa57 diff --git a/src/common/compat/netdb.h b/src/common/compat/netdb.h new file mode 100644 index 000000000..477058bad --- /dev/null +++ b/src/common/compat/netdb.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2015 Michael Jeanson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _COMPAT_NETDB_H +#define _COMPAT_NETDB_H + +#include + +#ifdef HAVE_GETHOSTBYNAME2 +static inline +struct hostent *lttng_gethostbyname2(const char *name, int af) { + return gethostbyname2(name, af); +} +#elif HAVE_GETIPNODEBYNAME +static inline +struct hostent *lttng_gethostbyname2(const char *name, int af) { + int unused; + + return getipnodebyname(name, af, AI_DEFAULT, &unused); +} +#else +# error "Missing compat for gethostbyname2()" +#endif + +#endif /* _COMPAT_NETDB_H */