-Add the restrict required by IEEE Std 1003.1-2001 in form

of our __restrict macro to the prototypes and function
   definitions of inet_pton and inet_ntop.
 - Use ANSI-C function argument lists.
 - Adjust the prototypes in the manual page.
This commit is contained in:
Robert Drehmel 2002-08-14 20:40:35 +00:00
parent 0054a46d1d
commit b7dbaf7b46
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=101880
4 changed files with 12 additions and 27 deletions

View File

@ -139,8 +139,9 @@ uint16_t ntohs(uint16_t);
in_addr_t inet_addr(const char *); in_addr_t inet_addr(const char *);
char *inet_ntoa(struct in_addr); char *inet_ntoa(struct in_addr);
const char *inet_ntop(int, const void *, char *, socklen_t); const char *inet_ntop(int, const void *__restrict, char *__restrict,
int inet_pton(int, const char *, void *); socklen_t);
int inet_pton(int, const char *__restrict, void *__restrict);
#if __BSD_VISIBLE #if __BSD_VISIBLE
int ascii2addr(int, const char *, void *); int ascii2addr(int, const char *, void *);

View File

@ -62,9 +62,9 @@
.Ft char * .Ft char *
.Fn inet_ntoa "struct in_addr in" .Fn inet_ntoa "struct in_addr in"
.Ft const char * .Ft const char *
.Fn inet_ntop "int af" "const void *src" "char *dst" "socklen_t size" .Fn inet_ntop "int af" "const void *restrict src" "char *restrict dst" "socklen_t size"
.Ft int .Ft int
.Fn inet_pton "int af" "const char *src" "void *dst" .Fn inet_pton "int af" "const char *restrict src" "void *restrict dst"
.Ft struct in_addr .Ft struct in_addr
.Fn inet_makeaddr "in_addr_t net" "in_addr_t lna" .Fn inet_makeaddr "in_addr_t net" "in_addr_t lna"
.Ft in_addr_t .Ft in_addr_t

View File

@ -49,11 +49,8 @@ static const char *inet_ntop6(const u_char *src, char *dst, socklen_t size);
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
const char * const char *
inet_ntop(af, src, dst, size) inet_ntop(int af, const void *__restrict src, char *__restrict dst,
int af; socklen_t size)
const void *src;
char *dst;
socklen_t size;
{ {
switch (af) { switch (af) {
case AF_INET: case AF_INET:
@ -79,10 +76,7 @@ inet_ntop(af, src, dst, size)
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static const char * static const char *
inet_ntop4(src, dst, size) inet_ntop4(const u_char *src, char *dst, socklen_t size)
const u_char *src;
char *dst;
socklen_t size;
{ {
static const char fmt[] = "%u.%u.%u.%u"; static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"]; char tmp[sizeof "255.255.255.255"];
@ -102,10 +96,7 @@ inet_ntop4(src, dst, size)
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static const char * static const char *
inet_ntop6(src, dst, size) inet_ntop6(const u_char *src, char *dst, socklen_t size)
const u_char *src;
char *dst;
socklen_t size;
{ {
/* /*
* Note that int32_t and int16_t need only be "at least" large enough * Note that int32_t and int16_t need only be "at least" large enough

View File

@ -48,10 +48,7 @@ static int inet_pton6(const char *src, u_char *dst);
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
int int
inet_pton(af, src, dst) inet_pton(int af, const char *__restrict src, void *__restrict dst)
int af;
const char *src;
void *dst;
{ {
switch (af) { switch (af) {
case AF_INET: case AF_INET:
@ -76,9 +73,7 @@ inet_pton(af, src, dst)
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static int static int
inet_pton4(src, dst) inet_pton4(const char *src, u_char *dst)
const char *src;
u_char *dst;
{ {
static const char digits[] = "0123456789"; static const char digits[] = "0123456789";
int saw_digit, octets, ch; int saw_digit, octets, ch;
@ -130,9 +125,7 @@ inet_pton4(src, dst)
* Paul Vixie, 1996. * Paul Vixie, 1996.
*/ */
static int static int
inet_pton6(src, dst) inet_pton6(const char *src, u_char *dst)
const char *src;
u_char *dst;
{ {
static const char xdigits_l[] = "0123456789abcdef", static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF"; xdigits_u[] = "0123456789ABCDEF";