sys/un.h: define SUN_LEN
SUN_LEN is not in the POSIX <sys/un.h> spec but is a long-standing BSD/glibc extension that portable AF_UNIX socket code depends on. KWin's src/helpers/wayland_wrapper/wl-socket.c calls it directly and fails with error: implicit declaration of function 'SUN_LEN' Definition matches glibc: offset of sun_path plus strlen of the pathname it holds, i.e. the byte count to pass to bind()/connect() for an AF_UNIX address. Pulls in <string.h> for strlen.
This commit is contained in:
@@ -4,6 +4,22 @@
|
||||
# - "The <sys/un.h> header shall define the sa_family_t type as described in <sys/socket.h>."
|
||||
after_includes = """
|
||||
#include <bits/safamily-t.h> // for sa_family_t from sys/socket.h
|
||||
#include <string.h> // for strlen() used by SUN_LEN
|
||||
|
||||
/*
|
||||
* SUN_LEN() is not in the POSIX <sys/un.h> spec, but it is a long-standing
|
||||
* BSD/glibc extension that portable Wayland/X11 socket code relies on:
|
||||
* KWin's src/helpers/wayland_wrapper/wl-socket.c calls it directly and
|
||||
* otherwise fails with
|
||||
* error: implicit declaration of function 'SUN_LEN'
|
||||
* The definition matches glibc's: offset of sun_path plus the length of the
|
||||
* pathname it holds, giving the number of bytes to pass to bind()/connect()
|
||||
* for an AF_UNIX address.
|
||||
*/
|
||||
#ifndef SUN_LEN
|
||||
#define SUN_LEN(ptr) \\
|
||||
((size_t)(((struct sockaddr_un *)0)->sun_path) + strlen((ptr)->sun_path))
|
||||
#endif
|
||||
"""
|
||||
include_guard = "_RELIBC_SYS_UN_H"
|
||||
language = "C"
|
||||
|
||||
Reference in New Issue
Block a user