mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
Fix build on old libc that does not define _SC_HOST_NAME_MAX
Bionic (Android's libc) only added that symbol in Nov 2014, can't find in which NDK release it got released.
This commit is contained in:
parent
b8f4c3596c
commit
de79958295
@ -993,6 +993,7 @@ g_get_host_name (void)
|
||||
const gsize size_large = (gsize) 256 * 256;
|
||||
gchar *tmp;
|
||||
|
||||
#ifdef _SC_HOST_NAME_MAX
|
||||
max = sysconf (_SC_HOST_NAME_MAX);
|
||||
if (max > 0 && max <= G_MAXSIZE - 1)
|
||||
size = (gsize) max + 1;
|
||||
@ -1001,8 +1002,11 @@ g_get_host_name (void)
|
||||
size = HOST_NAME_MAX + 1;
|
||||
#else
|
||||
size = _POSIX_HOST_NAME_MAX + 1;
|
||||
#endif
|
||||
|
||||
#endif /* HOST_NAME_MAX */
|
||||
#else
|
||||
/* Fallback to some reasonable value */
|
||||
size = 256;
|
||||
#endif /* _SC_HOST_NAME_MAX */
|
||||
tmp = g_malloc (size);
|
||||
failed = (gethostname (tmp, size) == -1);
|
||||
if (failed && size < size_large)
|
||||
|
Loading…
Reference in New Issue
Block a user