third_party_libbpf/include/tools/libc_compat.h
Yonghong Song 66684189f0 initial commit
This initial commit added the following files
from bpf-next repository:
  src:
    <files from linux:tools/lib/bpf>
    bpf.c bpf.h btf.c btf.h libbpf.c libbpf.h
    libbpf_errno.c netlink.c nlattr.c nlattr.h
    str_error.c str_error.h
  include:
    <files from linux:tools/include/uapi/linux>
    uapi/linux/{bpf.h, btf.h}

    <files from linux:tools/include/tools>
    tools/libc_compat.h

The following files are also added:
  include/linux/{err.h, kernel.h, list.h, overflow.h, types.h}
These files are customized headers to satisfy compilation.
Their original counterparts are at linux:tools/include/linux
directory.

Signed-off-by: Yonghong Song <yhs@fb.com>
2018-10-09 21:56:40 -07:00

21 lines
453 B
C

// SPDX-License-Identifier: (LGPL-2.0+ OR BSD-2-Clause)
/* Copyright (C) 2018 Netronome Systems, Inc. */
#ifndef __TOOLS_LIBC_COMPAT_H
#define __TOOLS_LIBC_COMPAT_H
#include <stdlib.h>
#include <linux/overflow.h>
#ifdef COMPAT_NEED_REALLOCARRAY
static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
{
size_t bytes;
if (unlikely(check_mul_overflow(nmemb, size, &bytes)))
return NULL;
return realloc(ptr, bytes);
}
#endif
#endif