Skip to content

Commit 161a35d

Browse files
committed
Improve compatibility with non-glibc libc
1 parent 797799d commit 161a35d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

getdents/_getdents.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <stddef.h>
55
#include <stdbool.h>
66
#include <stdio.h>
7+
#include <limits.h>
78
#include <unistd.h>
89
#include <stdlib.h>
910
#include <sys/stat.h>
@@ -32,7 +33,11 @@ struct getdents_state {
3233
#endif
3334

3435
#ifndef MIN_GETDENTS_BUFF_SIZE
35-
# define MIN_GETDENTS_BUFF_SIZE (MAXNAMLEN + sizeof(struct linux_dirent64))
36+
# ifdef NAME_MAX
37+
# define MIN_GETDENTS_BUFF_SIZE (NAME_MAX + sizeof(struct linux_dirent64))
38+
# else
39+
# define MIN_GETDENTS_BUFF_SIZE (MAXNAMLEN + sizeof(struct linux_dirent64))
40+
# endif
3641
#endif
3742

3843
static PyObject *

0 commit comments

Comments
 (0)