<commit_before>#ifndef __mpoe_hal_h__
#define __mpoe_hal_h__

#include "mpoe_checks.h"

#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/vmalloc.h>

/* FIXME: useless now */
#ifdef MPOE_SKB_LINEARIZE_HAS_GFP
#define mpoe_skb_linearize(skb) skb_linearize(skb, GFP_ATOMIC)
#else
#define mpoe_skb_linearize skb_linearize
#endif

#ifdef MPOE_HAVE_NETDEV_ALLOC_SKB
#define mpoe_netdev_alloc_skb netdev_alloc_skb
#else /* MPOE_HAVE_NETDEV_ALLOC_SKB */
static inline struct sk_buff *
mpoe_netdev_alloc_skb(struct net_device * dev, unsigned length)
{
	struct sk_buff * skb = dev_alloc_skb(length);
	if (likely(skb))
		skb->dev = dev;
	return skb;
}
#endif /* MPOE_HAVE_NETDEV_ALLOC_SKB */

#ifdef MPOE_HAVE_REMAP_VMALLOC_RANGE
#define mpoe_vmalloc_user vmalloc_user
#define mpoe_remap_vmalloc_range remap_vmalloc_range
#else /* MPOE_HAVE_REMAP_VMALLOC_RANGE */
static inline void *
mpoe_vmalloc_user(unsigned long size)
{
	return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
}

static inline int
mpoe_remap_vmalloc_range(struct vm_area_struct *vma, void *addr, unsigned long pgoff)
{
	unsigned long uaddr = vma->vm_start;
	unsigned long usize = vma->vm_end - vma->vm_start;
	int ret;

	addr += pgoff << PAGE_SHIFT;
	do {
		struct page *page = vmalloc_to_page(addr);
		ret = vm_insert_page(vma, uaddr, page);
		if (ret)
			return ret;

		uaddr += PAGE_SIZE;
		addr += PAGE_SIZE;
		usize -= PAGE_SIZE;
	} while (usize > 0);

	/* Prevent "things" like memory migration? VM_flags need a cleanup... */
	vma->vm_flags |= VM_RESERVED;

	return ret;
}
#endif /* MPOE_HAVE_REMAP_VMALLOC_RANGE */

#ifdef MPOE_HAVE_FOR_EACH_NETDEV
#define mpoe_for_each_netdev(_ifp) for_each_netdev(_ifp)
#else /* MPOE_HAVE_FOR_EACH_NETDEV */
#define mpoe_for_each_netdev(_ifp) for ((_ifp) = dev_base; (_ifp) != NULL; (_ifp) = (_ifp)->next)
#endif /* MPOE_HAVE_FOR_EACH_NETDEV */

#ifdef MPOE_HAVE_SKB_HEADERS
#define mpoe_skb_reset_mac_header skb_reset_mac_header
#define mpoe_skb_reset_network_header skb_reset_network_header
#define mpoe_hdr(skb) (struct mpoe_hdr *) skb_mac_header(skb)
#else /* MPOE_HAVE_SKB_HEADERS */
#define mpoe_skb_reset_mac_header(skb) skb->mac.raw = skb->data
#define mpoe_skb_reset_network_header(skb) skb->nh.raw = skb->mac.raw
#define mpoe_hdr(skb) (struct mpoe_hdr *) skb->mac.raw
#endif /* MPOE_HAVE_SKB_HEADERS */

#endif /* __mpoe_hal_h__ */

/*
 * Local variables:
 *  tab-width: 8
 *  c-basic-offset: 8
 *  c-indent-level: 8
 * End:
 */<commit_msg>guard parentheses around mpoe_hdr macro definition<commit_after>#ifndef __mpoe_hal_h__
#define __mpoe_hal_h__

#include "mpoe_checks.h"

#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/vmalloc.h>

/* FIXME: useless now */
#ifdef MPOE_SKB_LINEARIZE_HAS_GFP
#define mpoe_skb_linearize(skb) skb_linearize(skb, GFP_ATOMIC)
#else
#define mpoe_skb_linearize skb_linearize
#endif

#ifdef MPOE_HAVE_NETDEV_ALLOC_SKB
#define mpoe_netdev_alloc_skb netdev_alloc_skb
#else /* MPOE_HAVE_NETDEV_ALLOC_SKB */
static inline struct sk_buff *
mpoe_netdev_alloc_skb(struct net_device * dev, unsigned length)
{
	struct sk_buff * skb = dev_alloc_skb(length);
	if (likely(skb))
		skb->dev = dev;
	return skb;
}
#endif /* MPOE_HAVE_NETDEV_ALLOC_SKB */

#ifdef MPOE_HAVE_REMAP_VMALLOC_RANGE
#define mpoe_vmalloc_user vmalloc_user
#define mpoe_remap_vmalloc_range remap_vmalloc_range
#else /* MPOE_HAVE_REMAP_VMALLOC_RANGE */
static inline void *
mpoe_vmalloc_user(unsigned long size)
{
	return __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
}

static inline int
mpoe_remap_vmalloc_range(struct vm_area_struct *vma, void *addr, unsigned long pgoff)
{
	unsigned long uaddr = vma->vm_start;
	unsigned long usize = vma->vm_end - vma->vm_start;
	int ret;

	addr += pgoff << PAGE_SHIFT;
	do {
		struct page *page = vmalloc_to_page(addr);
		ret = vm_insert_page(vma, uaddr, page);
		if (ret)
			return ret;

		uaddr += PAGE_SIZE;
		addr += PAGE_SIZE;
		usize -= PAGE_SIZE;
	} while (usize > 0);

	/* Prevent "things" like memory migration? VM_flags need a cleanup... */
	vma->vm_flags |= VM_RESERVED;

	return ret;
}
#endif /* MPOE_HAVE_REMAP_VMALLOC_RANGE */

#ifdef MPOE_HAVE_FOR_EACH_NETDEV
#define mpoe_for_each_netdev(_ifp) for_each_netdev(_ifp)
#else /* MPOE_HAVE_FOR_EACH_NETDEV */
#define mpoe_for_each_netdev(_ifp) for ((_ifp) = dev_base; (_ifp) != NULL; (_ifp) = (_ifp)->next)
#endif /* MPOE_HAVE_FOR_EACH_NETDEV */

#ifdef MPOE_HAVE_SKB_HEADERS
#define mpoe_skb_reset_mac_header skb_reset_mac_header
#define mpoe_skb_reset_network_header skb_reset_network_header
#define mpoe_hdr(skb) ((struct mpoe_hdr *) skb_mac_header(skb))
#else /* MPOE_HAVE_SKB_HEADERS */
#define mpoe_skb_reset_mac_header(skb) skb->mac.raw = skb->data
#define mpoe_skb_reset_network_header(skb) skb->nh.raw = skb->mac.raw
#define mpoe_hdr(skb) ((struct mpoe_hdr *) skb->mac.raw)
#endif /* MPOE_HAVE_SKB_HEADERS */

#endif /* __mpoe_hal_h__ */

/*
 * Local variables:
 *  tab-width: 8
 *  c-basic-offset: 8
 *  c-indent-level: 8
 * End:
 */
{'fraction_non_alphanumeric': 0.11078022632519356, 'fraction_numerical': 0.0015882469724042088, 'mean_word_length': 5.771505376344086, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5594662', 'n_tokens_mistral': 2113, 'n_tokens_neox': 2061, 'n_words': 399}