Changeset 4e5f848 in rtems


Ignore:
Timestamp:
Oct 26, 2017, 1:13:46 AM (19 months ago)
Author:
John Arbuckle <programmingkidx@…>
Branches:
master
Children:
c13e400
Parents:
42f1b37
git-author:
John Arbuckle <programmingkidx@…> (10/26/17 01:13:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/19/18 05:01:11)
Message:

implement strnlen for systems that need it

Prior the Mac OS 10.7, the function strnlen() was not available. This patch
implements strnlen() on Mac OS X versions that are below 10.7.

Signed-off-by: John Arbuckle <programmingkidx@…>
Signed-off-by: David Gibson <david@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/libfdt_env.h

    r42f1b37 r4e5f848  
    110110#undef EXTRACT_BYTE
    111111
     112#ifdef __APPLE__
     113#include <AvailabilityMacros.h>
     114
     115/* strnlen() is not available on Mac OS < 10.7 */
     116# if !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED < \
     117                                         MAC_OS_X_VERSION_10_7)
     118
     119#define strnlen fdt_strnlen
     120
     121/*
     122 * fdt_strnlen: returns the length of a string or max_count - which ever is
     123 * smallest.
     124 * Input 1 string: the string whose size is to be determined
     125 * Input 2 max_count: the maximum value returned by this function
     126 * Output: length of the string or max_count (the smallest of the two)
     127 */
     128static inline size_t fdt_strnlen(const char *string, size_t max_count)
     129{
     130    const char *p = memchr(string, 0, max_count);
     131    return p ? p - string : max_count;
     132}
     133
     134#endif /* !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED <
     135          MAC_OS_X_VERSION_10_7) */
     136
     137#endif /* __APPLE__ */
     138
    112139#endif /* LIBFDT_ENV_H */
Note: See TracChangeset for help on using the changeset viewer.