summaryrefslogtreecommitdiffstats
path: root/gl/arpa_inet.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/arpa_inet.in.h')
-rw-r--r--gl/arpa_inet.in.h63
1 files changed, 58 insertions, 5 deletions
diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h
index 80e6713f..d7417bfd 100644
--- a/gl/arpa_inet.in.h
+++ b/gl/arpa_inet.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <arpa/inet.h>. 1/* A GNU-like <arpa/inet.h>.
2 2
3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2025 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -49,12 +49,64 @@
49#ifndef _@GUARD_PREFIX@_ARPA_INET_H 49#ifndef _@GUARD_PREFIX@_ARPA_INET_H
50#define _@GUARD_PREFIX@_ARPA_INET_H 50#define _@GUARD_PREFIX@_ARPA_INET_H
51 51
52/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
53#if !_GL_CONFIG_H_INCLUDED
54 #error "Please include config.h first."
55#endif
56
52/* Get all possible declarations of inet_ntop() and inet_pton(). */ 57/* Get all possible declarations of inet_ntop() and inet_pton(). */
53#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \ 58#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
54 && @HAVE_WS2TCPIP_H@ 59 && @HAVE_WS2TCPIP_H@
55# include <ws2tcpip.h> 60# include <ws2tcpip.h>
56#endif 61#endif
57 62
63#if !(@HAVE_DECL_HTONL@ || @HAVE_DECL_HTONS@ || @HAVE_DECL_NTOHL@ || @HAVE_DECL_NTOHS@)
64# include <endian.h>
65#endif
66
67_GL_INLINE_HEADER_BEGIN
68#ifndef _GL_ARPA_INET_INLINE
69# define _GL_ARPA_INET_INLINE _GL_INLINE
70#endif
71
72
73/* Host to network byte order. */
74
75#if !@HAVE_DECL_HTONS@
76_GL_ARPA_INET_INLINE uint16_t
77htons (uint16_t value)
78{
79 return htobe16 (value);
80}
81#endif
82
83#if !@HAVE_DECL_HTONL@
84_GL_ARPA_INET_INLINE uint32_t
85htonl (uint32_t value)
86{
87 return htobe32 (value);
88}
89#endif
90
91/* Network to host byte order. */
92
93#if !@HAVE_DECL_NTOHS@
94_GL_ARPA_INET_INLINE uint16_t
95ntohs (uint16_t value)
96{
97 return htobe16 (value);
98}
99#endif
100
101#if !@HAVE_DECL_NTOHL@
102_GL_ARPA_INET_INLINE uint32_t
103ntohl (uint32_t value)
104{
105 return htobe32 (value);
106}
107#endif
108
109
58/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 110/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
59 111
60/* The definition of _GL_ARG_NONNULL is copied here. */ 112/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -85,7 +137,7 @@
85# endif 137# endif
86_GL_FUNCDECL_RPL (inet_ntop, const char *, 138_GL_FUNCDECL_RPL (inet_ntop, const char *,
87 (int af, const void *restrict src, 139 (int af, const void *restrict src,
88 char *restrict dst, socklen_t cnt) 140 char *restrict dst, socklen_t cnt),
89 _GL_ARG_NONNULL ((2, 3))); 141 _GL_ARG_NONNULL ((2, 3)));
90_GL_CXXALIAS_RPL (inet_ntop, const char *, 142_GL_CXXALIAS_RPL (inet_ntop, const char *,
91 (int af, const void *restrict src, 143 (int af, const void *restrict src,
@@ -94,7 +146,7 @@ _GL_CXXALIAS_RPL (inet_ntop, const char *,
94# if !@HAVE_DECL_INET_NTOP@ 146# if !@HAVE_DECL_INET_NTOP@
95_GL_FUNCDECL_SYS (inet_ntop, const char *, 147_GL_FUNCDECL_SYS (inet_ntop, const char *,
96 (int af, const void *restrict src, 148 (int af, const void *restrict src,
97 char *restrict dst, socklen_t cnt) 149 char *restrict dst, socklen_t cnt),
98 _GL_ARG_NONNULL ((2, 3))); 150 _GL_ARG_NONNULL ((2, 3)));
99# endif 151# endif
100/* Need to cast, because on NonStop Kernel, the fourth parameter is 152/* Need to cast, because on NonStop Kernel, the fourth parameter is
@@ -121,14 +173,14 @@ _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
121# define inet_pton rpl_inet_pton 173# define inet_pton rpl_inet_pton
122# endif 174# endif
123_GL_FUNCDECL_RPL (inet_pton, int, 175_GL_FUNCDECL_RPL (inet_pton, int,
124 (int af, const char *restrict src, void *restrict dst) 176 (int af, const char *restrict src, void *restrict dst),
125 _GL_ARG_NONNULL ((2, 3))); 177 _GL_ARG_NONNULL ((2, 3)));
126_GL_CXXALIAS_RPL (inet_pton, int, 178_GL_CXXALIAS_RPL (inet_pton, int,
127 (int af, const char *restrict src, void *restrict dst)); 179 (int af, const char *restrict src, void *restrict dst));
128# else 180# else
129# if !@HAVE_DECL_INET_PTON@ 181# if !@HAVE_DECL_INET_PTON@
130_GL_FUNCDECL_SYS (inet_pton, int, 182_GL_FUNCDECL_SYS (inet_pton, int,
131 (int af, const char *restrict src, void *restrict dst) 183 (int af, const char *restrict src, void *restrict dst),
132 _GL_ARG_NONNULL ((2, 3))); 184 _GL_ARG_NONNULL ((2, 3)));
133# endif 185# endif
134_GL_CXXALIAS_SYS (inet_pton, int, 186_GL_CXXALIAS_SYS (inet_pton, int,
@@ -145,6 +197,7 @@ _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
145# endif 197# endif
146#endif 198#endif
147 199
200_GL_INLINE_HEADER_END
148 201
149#endif /* _@GUARD_PREFIX@_ARPA_INET_H */ 202#endif /* _@GUARD_PREFIX@_ARPA_INET_H */
150#endif /* _@GUARD_PREFIX@_ARPA_INET_H */ 203#endif /* _@GUARD_PREFIX@_ARPA_INET_H */