aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-09-21 12:00:05 +0200
committerMicael Karlberg <[email protected]>2018-09-21 12:00:05 +0200
commit37704e1eccc60e2077be13ec0a4c3344d9c04b30 (patch)
tree27ab001d9cf0e0dfbf73824765804e603bdf1668
parente3ace52f8e7d893d170ff5eb60d22c27ab9ec1e5 (diff)
downloadotp-37704e1eccc60e2077be13ec0a4c3344d9c04b30.tar.gz
otp-37704e1eccc60e2077be13ec0a4c3344d9c04b30.tar.bz2
otp-37704e1eccc60e2077be13ec0a4c3344d9c04b30.zip
[socket-nif] More constant if-def and header include moving
-rw-r--r--erts/emulator/nifs/common/net_nif.c40
-rw-r--r--erts/emulator/nifs/common/socket_nif.c17
2 files changed, 40 insertions, 17 deletions
diff --git a/erts/emulator/nifs/common/net_nif.c b/erts/emulator/nifs/common/net_nif.c
index 9905d99a04..f7eeee45ac 100644
--- a/erts/emulator/nifs/common/net_nif.c
+++ b/erts/emulator/nifs/common/net_nif.c
@@ -47,7 +47,6 @@
#include <ctype.h>
#include <sys/types.h>
#include <errno.h>
-#include <netinet/ip.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
@@ -121,6 +120,7 @@
#include <rpc/types.h>
#endif
+#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <arpa/inet.h>
@@ -698,37 +698,53 @@ ERL_NIF_TERM ngetnameinfo(ErlNifEnv* env,
}
break;
+#if defined(EAI_AGAIN)
case EAI_AGAIN:
result = esock_make_error(env, esock_atom_eagain);
break;
+#endif
+#if defined(EAI_BADFLAGS)
case EAI_BADFLAGS:
result = esock_make_error(env, atom_ebadflags);
break;
+#endif
+#if defined(EAI_FAIL)
case EAI_FAIL:
result = esock_make_error(env, atom_efail);
break;
+#endif
+#if defined(EAI_FAMILY)
case EAI_FAMILY:
result = esock_make_error(env, atom_efamily);
break;
+#endif
+#if defined(EAI_MEMORY)
case EAI_MEMORY:
result = esock_make_error(env, atom_emem);
break;
+#endif
+#if defined(EAI_NONAME)
case EAI_NONAME:
result = esock_make_error(env, atom_enoname);
break;
+#endif
+#if defined(EAI_OVERFLOW)
case EAI_OVERFLOW:
result = esock_make_error(env, atom_eoverflow);
break;
+#endif
+#if defined(EAI_SYSTEM)
case EAI_SYSTEM:
result = esock_make_error_errno(env, get_errno());
break;
+#endif
default:
result = esock_make_error(env, esock_atom_einval);
@@ -842,49 +858,71 @@ ERL_NIF_TERM ngetaddrinfo(ErlNifEnv* env,
}
break;
+#if defined(EAI_ADDRFAMILY)
case EAI_ADDRFAMILY:
result = esock_make_error(env, atom_eaddrfamily);
break;
+#endif
+#if defined(EAI_AGAIN)
case EAI_AGAIN:
result = esock_make_error(env, esock_atom_eagain);
break;
+#endif
+#if defined(EAI_BADFLAGS)
case EAI_BADFLAGS:
result = esock_make_error(env, atom_ebadflags);
break;
+#endif
+#if defined(EAI_FAIL)
case EAI_FAIL:
result = esock_make_error(env, atom_efail);
break;
+#endif
+#if defined(EAI_FAMILY)
case EAI_FAMILY:
result = esock_make_error(env, atom_efamily);
break;
+#endif
+#if defined(EAI_MEMORY)
case EAI_MEMORY:
result = esock_make_error(env, atom_emem);
break;
+#endif
+#if defined(EAI_NODATA)
case EAI_NODATA:
result = esock_make_error(env, atom_enodata);
break;
+#endif
+#if defined(EAI_NONAME)
case EAI_NONAME:
result = esock_make_error(env, atom_enoname);
break;
+#endif
+#if defined(EAI_SERVICE)
case EAI_SERVICE:
result = esock_make_error(env, atom_eservice);
break;
+#endif
+#if defined(EAI_SOCKTYPE)
case EAI_SOCKTYPE:
result = esock_make_error(env, atom_esocktype);
break;
+#endif
+#if defined(EAI_SYSTEM)
case EAI_SYSTEM:
result = esock_make_error(env, atom_esystem);
break;
+#endif
default:
result = esock_make_error(env, esock_atom_einval);
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index c98ab1e514..6564c3c82f 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -25,21 +25,6 @@
#define STATIC_ERLANG_NIF 1
-/* #include <stdio.h> */
-/* #include <stdlib.h> */
-/* #include <stdarg.h> */
-/* #include <string.h> */
-/* #include <unistd.h> */
-/* #include <errno.h> */
-/* #include <netdb.h> */
-/* #include <sys/types.h> */
-/* #include <sys/wait.h> */
-/* #include <sys/socket.h> */
-/* #include <netinet/in.h> */
-/* #include <arpa/inet.h> */
-/* #include <sys/time.h> */
-/* #include <fcntl.h> */
-
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -61,7 +46,6 @@
#include <ctype.h>
#include <sys/types.h>
#include <errno.h>
-#include <netinet/ip.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
@@ -135,6 +119,7 @@
#include <rpc/types.h>
#endif
+#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <arpa/inet.h>