[sgen] Add parallel copying infrastructure
[mono-project.git] / mono / utils / networking-missing.c
blob8c8c75b5a1012ffdaab66fdac3d976abb6c76cea
1 /*
2 * networking-missing.c: Implements missing standard socket functions.
4 * Author:
5 * Rodrigo Kumpera (kumpera@gmail.com)
7 * (C) 2015 Xamarin
8 */
10 #include <mono/utils/networking.h>
11 #include <mono/utils/mono-compiler.h>
12 #include <glib.h>
14 #ifdef HAVE_NETDB_H
15 #include <netdb.h>
16 #endif
18 #ifndef HAVE_INET_PTON
20 int
21 inet_pton (int family, const char *address, void *inaddrp)
23 if (family == AF_INET) {
24 #ifdef HAVE_INET_ATON
25 struct in_addr inaddr;
27 if (!inet_aton (address, &inaddr))
28 return 0;
30 memcpy (inaddrp, &inaddr, sizeof (struct in_addr));
31 return 1;
32 #else
33 /* assume the system has inet_addr(), if it doesn't
34 have that we're pretty much screwed... */
35 guint32 inaddr;
37 if (!strcmp (address, "255.255.255.255")) {
38 /* special-case hack */
39 inaddr = 0xffffffff;
40 } else {
41 inaddr = inet_addr (address);
42 #ifndef INADDR_NONE
43 #define INADDR_NONE ((in_addr_t) -1)
44 #endif
45 if (inaddr == INADDR_NONE)
46 return 0;
49 memcpy (inaddrp, &inaddr, sizeof (guint32));
50 return 1;
51 #endif /* HAVE_INET_ATON */
54 return -1;
57 #else /* !HAVE_INET_PTON */
59 MONO_EMPTY_SOURCE_FILE (networking_missing);
60 #endif /* !HAVE_INET_PTON */