mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-13 04:46:15 +01:00
Merge branch 'mgl-fix-build' into 'master'
Fix build on old libc that does not define _SC_HOST_NAME_MAX See merge request GNOME/glib!1231
This commit is contained in:
commit
653d3e2c5d
@ -993,6 +993,7 @@ g_get_host_name (void)
|
|||||||
const gsize size_large = (gsize) 256 * 256;
|
const gsize size_large = (gsize) 256 * 256;
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
|
|
||||||
|
#ifdef _SC_HOST_NAME_MAX
|
||||||
max = sysconf (_SC_HOST_NAME_MAX);
|
max = sysconf (_SC_HOST_NAME_MAX);
|
||||||
if (max > 0 && max <= G_MAXSIZE - 1)
|
if (max > 0 && max <= G_MAXSIZE - 1)
|
||||||
size = (gsize) max + 1;
|
size = (gsize) max + 1;
|
||||||
@ -1001,8 +1002,11 @@ g_get_host_name (void)
|
|||||||
size = HOST_NAME_MAX + 1;
|
size = HOST_NAME_MAX + 1;
|
||||||
#else
|
#else
|
||||||
size = _POSIX_HOST_NAME_MAX + 1;
|
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);
|
tmp = g_malloc (size);
|
||||||
failed = (gethostname (tmp, size) == -1);
|
failed = (gethostname (tmp, size) == -1);
|
||||||
if (failed && size < size_large)
|
if (failed && size < size_large)
|
||||||
|
Loading…
Reference in New Issue
Block a user