aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface
diff options
context:
space:
mode:
authorCalvin <[email protected]>2019-05-29 07:43:26 -0400
committerCalvin <[email protected]>2019-05-29 07:43:26 -0400
commite414c818360911ab759cef6a08b3ed133f3208ae (patch)
tree12d39abebfbdc7ab53310e000eb1d020a24b915d /lib/erl_interface
parent8a0c0ae7defd1e9f5d41a88de8c3dc8a544a7c73 (diff)
downloadotp-e414c818360911ab759cef6a08b3ed133f3208ae.tar.gz
otp-e414c818360911ab759cef6a08b3ed133f3208ae.tar.bz2
otp-e414c818360911ab759cef6a08b3ed133f3208ae.zip
Attempt at fixing AIX while keeping API compatibility
erl_interface has a function in a struct, and AIX headers, when you use C instead of C++, pollute the global namespace with definitions that override socket functions, and end up clobbering names of things Erlang/OTP uses. The new socket interface of R22 was one of the victims. I had previously tied to fix it for erl_interface, but the change broke API public surface. What this does is replace the name with a define, that defines to the same name on non-AIX, but uses a "mangled" name on AIX instead. This means internal uses of this function in the struct need to use the preprocessor define instead of the "normal" name, and likewise external users too, but those can be dealt with one-at-a-time on AIX instead of breaking everyone else.
Diffstat (limited to 'lib/erl_interface')
-rw-r--r--lib/erl_interface/include/ei.h13
-rw-r--r--lib/erl_interface/src/misc/ei_portio.c2
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/erl_interface/include/ei.h b/lib/erl_interface/include/ei.h
index ca235e2cd1..7d39043bb2 100644
--- a/lib/erl_interface/include/ei.h
+++ b/lib/erl_interface/include/ei.h
@@ -323,13 +323,24 @@ typedef struct {
#define EI_SCLBK_FLG_FULL_IMPL (1 << 0)
+/*
+ * HACK: AIX defines many socket functions like accept to be naccept, which
+ * pollutes the global namespace. Set up an ugly ifdef for consumers of this
+ * API here so they get a mangled name for AIX and the sane name elsewhere.
+ */
+#ifdef _AIX
+#define EI_ACCEPT_NAME accept_ei
+#else
+#define EI_ACCEPT_NAME accept
+#endif
+
typedef struct {
int flags;
int (*socket)(void **ctx, void *setup_ctx);
int (*close)(void *ctx);
int (*listen)(void *ctx, void *addr, int *len, int backlog);
- int (*accept_ei)(void **ctx, void *addr, int *len, unsigned tmo);
+ int (*EI_ACCEPT_NAME)(void **ctx, void *addr, int *len, unsigned tmo);
int (*connect)(void *ctx, void *addr, int len, unsigned tmo);
int (*writev)(void *ctx, const void *iov, int iovcnt, ssize_t *len, unsigned tmo);
int (*write)(void *ctx, const char *buf, ssize_t *len, unsigned tmo);
diff --git a/lib/erl_interface/src/misc/ei_portio.c b/lib/erl_interface/src/misc/ei_portio.c
index caa3d270a8..bfe67a732c 100644
--- a/lib/erl_interface/src/misc/ei_portio.c
+++ b/lib/erl_interface/src/misc/ei_portio.c
@@ -622,7 +622,7 @@ int ei_accept_ctx_t__(ei_socket_callbacks *cbs, void **ctx,
} while (error == EINTR);
}
do {
- error = cbs->accept_ei(ctx, addr, len, ms);
+ error = cbs->EI_ACCEPT_NAME(ctx, addr, len, ms);
} while (error == EINTR);
return error;
}