Skip to content

Commit 547ae0e

Browse files
committed
C library: support inet_* redefinitions as found on FreeBSD
FreeBSD redefines various inet_* function names to __inet_*.
1 parent 28df9ae commit 547ae0e

File tree

2 files changed

+93
-8
lines changed

2 files changed

+93
-8
lines changed

src/ansi-c/library/inet.c

+92-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* FUNCTION: inet_addr */
1+
/* FUNCTION: __inet_addr */
22

33
#ifndef _WIN32
44

@@ -9,7 +9,7 @@
99

1010
in_addr_t __VERIFIER_nondet_in_addr_t(void);
1111

12-
in_addr_t inet_addr(const char *cp)
12+
in_addr_t __inet_addr(const char *cp)
1313
{
1414
__CPROVER_HIDE:;
1515
#ifdef __CPROVER_STRING_ABSTRACTION
@@ -24,7 +24,28 @@ in_addr_t inet_addr(const char *cp)
2424

2525
#endif
2626

27-
/* FUNCTION: inet_aton */
27+
/* FUNCTION: inet_addr */
28+
29+
#ifndef _WIN32
30+
31+
# ifndef __CPROVER_INET_H_INCLUDED
32+
# include <arpa/inet.h>
33+
# define __CPROVER_INET_H_INCLUDED
34+
# endif
35+
36+
# undef inet_addr
37+
38+
in_addr_t __inet_addr(const char *cp);
39+
40+
in_addr_t inet_addr(const char *cp)
41+
{
42+
__CPROVER_HIDE:;
43+
return __inet_addr(cp);
44+
}
45+
46+
#endif
47+
48+
/* FUNCTION: __inet_aton */
2849

2950
#ifndef _WIN32
3051

@@ -35,7 +56,7 @@ in_addr_t inet_addr(const char *cp)
3556

3657
int __VERIFIER_nondet_int(void);
3758

38-
int inet_aton(const char *cp, struct in_addr *pin)
59+
int __inet_aton(const char *cp, struct in_addr *pin)
3960
{
4061
__CPROVER_HIDE:;
4162
#ifdef __CPROVER_STRING_ABSTRACTION
@@ -51,7 +72,28 @@ int inet_aton(const char *cp, struct in_addr *pin)
5172

5273
#endif
5374

54-
/* FUNCTION: inet_ntoa */
75+
/* FUNCTION: inet_aton */
76+
77+
#ifndef _WIN32
78+
79+
# ifndef __CPROVER_INET_H_INCLUDED
80+
# include <arpa/inet.h>
81+
# define __CPROVER_INET_H_INCLUDED
82+
# endif
83+
84+
# undef inet_aton
85+
86+
int __inet_aton(const char *cp, struct in_addr *pin);
87+
88+
int inet_aton(const char *cp, struct in_addr *pin)
89+
{
90+
__CPROVER_HIDE:;
91+
return __inet_aton(cp, pin);
92+
}
93+
94+
#endif
95+
96+
/* FUNCTION: __inet_ntoa */
5597

5698
#ifndef _WIN32
5799

@@ -62,7 +104,7 @@ int inet_aton(const char *cp, struct in_addr *pin)
62104

63105
char __inet_ntoa_buffer[16];
64106

65-
char *inet_ntoa(struct in_addr in)
107+
char *__inet_ntoa(struct in_addr in)
66108
{
67109
__CPROVER_HIDE:;
68110
(void)in;
@@ -73,7 +115,28 @@ __CPROVER_HIDE:;
73115

74116
#endif
75117

76-
/* FUNCTION: inet_network */
118+
/* FUNCTION: inet_ntoa */
119+
120+
#ifndef _WIN32
121+
122+
# ifndef __CPROVER_INET_H_INCLUDED
123+
# include <arpa/inet.h>
124+
# define __CPROVER_INET_H_INCLUDED
125+
# endif
126+
127+
# undef inet_ntoa
128+
129+
char *__inet_ntoa(struct in_addr in);
130+
131+
char *inet_ntoa(struct in_addr in)
132+
{
133+
__CPROVER_HIDE:;
134+
return __inet_ntoa(in);
135+
}
136+
137+
#endif
138+
139+
/* FUNCTION: __inet_network */
77140

78141
#ifndef _WIN32
79142

@@ -84,7 +147,7 @@ __CPROVER_HIDE:;
84147

85148
in_addr_t __VERIFIER_nondet_in_addr_t(void);
86149

87-
in_addr_t inet_network(const char *cp)
150+
in_addr_t __inet_network(const char *cp)
88151
{
89152
__CPROVER_HIDE:;
90153
#ifdef __CPROVER_STRING_ABSTRACTION
@@ -99,6 +162,27 @@ in_addr_t inet_network(const char *cp)
99162

100163
#endif
101164

165+
/* FUNCTION: inet_network */
166+
167+
#ifndef _WIN32
168+
169+
# ifndef __CPROVER_INET_H_INCLUDED
170+
# include <arpa/inet.h>
171+
# define __CPROVER_INET_H_INCLUDED
172+
# endif
173+
174+
# undef inet_network
175+
176+
in_addr_t __inet_network(const char *cp);
177+
178+
in_addr_t inet_network(const char *cp)
179+
{
180+
__CPROVER_HIDE:;
181+
return __inet_network(cp);
182+
}
183+
184+
#endif
185+
102186
/* FUNCTION: htonl */
103187

104188
#ifndef __CPROVER_STDINT_H_INCLUDED

src/ansi-c/library_check.sh

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ perl -p -i -e 's/^_munmap\n//' __functions # mumap, macOS
3737
perl -p -i -e 's/^_pipe\n//' __functions # pipe, macOS
3838
perl -p -i -e 's/^_setjmp\n//' __functions # pipe, macOS
3939
perl -p -i -e 's/^_time(32|64)\n//' __functions # time, Windows
40+
perl -p -i -e 's/^__inet_(addr|aton|ntoa|network)\n//' __functions # inet_*, FreeBSD
4041
perl -p -i -e 's/^__isoc99_v?fscanf\n//' __functions # fscanf, Linux
4142
perl -p -i -e 's/^__isoc99_v?scanf\n//' __functions # scanf, Linux
4243
perl -p -i -e 's/^__isoc99_v?sscanf\n//' __functions # sscanf, Linux

0 commit comments

Comments
 (0)