~bigbes/tarantool

tarantool-protobuf

956bf2a2a4baf60a231a5e0377b418860a47cd32 — Eugene Blikh 2 months ago 52e4752
c-accel: fix strdup on glibc with -std=c99

strdup is POSIX, not ISO C99, so glibc's <string.h> only exposes it when
_POSIX_C_SOURCE >= 200809. With -std=c99 (strict mode) gcc otherwise
treats strdup as an implicit-int function, which on 64-bit Linux
truncates the returned pointer to int and yields warnings + likely
crashes. macOS happens to declare strdup unconditionally so the issue
only surfaces on the srht.bigb.es Ubuntu builder.

Define _POSIX_C_SOURCE at the top of c_runtime.c before any include.
1 files changed, 6 insertions(+), 0 deletions(-)

M runtime/pb/c/c_runtime.c
M runtime/pb/c/c_runtime.c => runtime/pb/c/c_runtime.c +6 -0
@@ 10,6 10,12 @@
 * Conventions follow docs/specs/c_accel_strategy.md.
 */

/* strdup is POSIX, not C99; declare we want the POSIX surface from
 * <string.h> before any system header pulls it in. */
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include <module.h>
#include <lauxlib.h>