Define strnlen when it is not in libc

Chi-Hua Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 16:11:19 PST 2016


Joerg,

On Mon, Nov 28, 2016 at 1:56 PM, Duncan P. N. Exon Smith
<dexonsmith at apple.com> wrote:
>
>> On 2016-Nov-28, at 10:55, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
>>
>>
>>> On 2016-Nov-24, at 11:10, Joerg Sonnenberger via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>>>
>>> On Thu, Nov 24, 2016 at 02:06:55PM -0500, Chi-Hua Chen via llvm-commits wrote:
>>>> Some older platforms, e.g. Mac 10.6.8, do not have strnlen. Define one
>>>> in Support when necessary.
>>>
>>> Personally, I'd prefer to just avoid it in first place. It is not really
>>> much simpler than just using memchr.
>>
>> `StringRef(...).find('\0')` seems cleaner.
>
> But I'm fine with the original patch as well, since it avoids people introducing more uses of strnlen in the future... assuming we actually support building on 10.6?  (There weren't any buildbot failures...)

If you don't have any objections, I'd like to commit the original
patch. It will be easier that way if people add more strnlen. And if
llvm ever decide to stop supporting these old platforms, we can just
drop the compat implementation.

- Chi-Hua


More information about the llvm-commits mailing list