Skip to content

Commit 7f3184a

Browse files
admlckdgibson
authored andcommitted
libfdt: Remove old MacOS strnlen workaround
The check for the MacOS X version (10.7) is problematic, because it fails unless _DARWIN_C_SOURCE is defined if also _POSIX_C_SOURCE or _XOPEN_SOURCE is defined, as then the Darwin version defines are not defined. We cannot force _DARWIN_C_SOURCE reliably in the header either, because we cannot be sure that the libfdt_env.h has not already been included by another source before. The check is also only for very old versions of Mac OS X. In the interest of not replacing strnlen arbitrarily for sources using libfdt and considering that the last version of OS X 10.6 was released in 2011 I propose to remove the workaround for that system. We noticed as compiling fdt_strnlen in C++ environments fails (missing cast for memchr). Signed-off-by: Adam Lackorzynski <adam@l4re.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
1 parent 9197f1c commit 7f3184a

1 file changed

Lines changed: 0 additions & 27 deletions

File tree

libfdt/libfdt_env.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,4 @@ static inline fdt64_t cpu_to_fdt64(uint64_t x)
6666
#undef CPU_TO_FDT16
6767
#undef EXTRACT_BYTE
6868

69-
#ifdef __APPLE__
70-
#include <AvailabilityMacros.h>
71-
72-
/* strnlen() is not available on Mac OS < 10.7 */
73-
# if !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED < \
74-
MAC_OS_X_VERSION_10_7)
75-
76-
#define strnlen fdt_strnlen
77-
78-
/*
79-
* fdt_strnlen: returns the length of a string or max_count - which ever is
80-
* smallest.
81-
* Input 1 string: the string whose size is to be determined
82-
* Input 2 max_count: the maximum value returned by this function
83-
* Output: length of the string or max_count (the smallest of the two)
84-
*/
85-
static inline size_t fdt_strnlen(const char *string, size_t max_count)
86-
{
87-
const char *p = memchr(string, 0, max_count);
88-
return p ? p - string : max_count;
89-
}
90-
91-
#endif /* !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED <
92-
MAC_OS_X_VERSION_10_7) */
93-
94-
#endif /* __APPLE__ */
95-
9669
#endif /* LIBFDT_ENV_H */

0 commit comments

Comments
 (0)