<commit_before>// -*- c++ -*-
#ifndef REGEXBENCH_SESSION_H
#define REGEXBENCH_SESSION_H

#include <netinet/in.h>
#include <stddef.h>
#include <sys/types.h>

#include <net/ethernet.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/ip_icmp.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <unordered_map>

#include "PcapSource.h"

namespace regexbench {
#ifndef __linux__
constexpr
#endif
    inline uint16_t
    EXT_SPORT(const char* pkt, uint16_t size_iphdr)
{
  return ntohs(
      *reinterpret_cast<const uint16_t*>(pkt + size_iphdr + ETHER_HDR_LEN +
#ifdef __linux__
                                         offsetof(struct tcphdr, source)
#else
                                         offsetof(struct tcphdr, th_sport)
#endif
                                             ));
}

#ifndef __linux__
constexpr
#endif
    inline uint16_t
    EXT_DPORT(const char* pkt, uint16_t size_iphdr)
{
  return ntohs(*reinterpret_cast<const uint16_t*>(pkt + size_iphdr +
                                                  ETHER_HDR_LEN +
#ifdef __linux__
                                                  offsetof(struct tcphdr, dest)
#else
                                                  offsetof(struct tcphdr,
                                                           th_dport)
#endif
                                                      ));
}

#ifndef __linux__
constexpr
#endif
    inline uint32_t
    EXT_SIP(const char* pkt)
{
  return ntohl(*reinterpret_cast<const uint16_t*>(pkt + ETHER_HDR_LEN +
                                                  offsetof(struct ip, ip_src)));
}

#ifndef __linux__
constexpr
#endif
    inline uint32_t
    EXT_DIP(const char* pkt)
{
  return ntohl(*reinterpret_cast<const uint16_t*>(pkt + ETHER_HDR_LEN +
                                                  offsetof(struct ip, ip_dst)));
}

inline const struct ip6_addr* EXT_SIP6(const char* pkt)
{
  return reinterpret_cast<const struct ip6_addr*>(
      pkt + ETHER_HDR_LEN + offsetof(struct ip6_hdr, ip6_src));
}

inline const struct ip6_addr* EXT_DIP6(const char* pkt)
{
  return reinterpret_cast<const struct ip6_addr*>(
      pkt + ETHER_HDR_LEN + offsetof(struct ip6_hdr, ip6_dst));
}
<commit_msg>In FreeBSD conditional inclusion of constexpr specifier causes error<commit_after>// -*- c++ -*-
#ifndef REGEXBENCH_SESSION_H
#define REGEXBENCH_SESSION_H

#include <netinet/in.h>
#include <stddef.h>
#include <sys/types.h>

#include <net/ethernet.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/ip_icmp.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <unordered_map>

#include "PcapSource.h"

namespace regexbench {
inline uint16_t EXT_SPORT(const char* pkt, uint16_t size_iphdr)
{
  return ntohs(
      *reinterpret_cast<const uint16_t*>(pkt + size_iphdr + ETHER_HDR_LEN +
#ifdef __linux__
                                         offsetof(struct tcphdr, source)
#else
                                         offsetof(struct tcphdr, th_sport)
#endif
                                             ));
}

inline uint16_t EXT_DPORT(const char* pkt, uint16_t size_iphdr)
{
  return ntohs(*reinterpret_cast<const uint16_t*>(pkt + size_iphdr +
                                                  ETHER_HDR_LEN +
#ifdef __linux__
                                                  offsetof(struct tcphdr, dest)
#else
                                                  offsetof(struct tcphdr,
                                                           th_dport)
#endif
                                                      ));
}

inline uint32_t EXT_SIP(const char* pkt)
{
  return ntohl(*reinterpret_cast<const uint16_t*>(pkt + ETHER_HDR_LEN +
                                                  offsetof(struct ip, ip_src)));
}

inline uint32_t EXT_DIP(const char* pkt)
{
  return ntohl(*reinterpret_cast<const uint16_t*>(pkt + ETHER_HDR_LEN +
                                                  offsetof(struct ip, ip_dst)));
}

inline const struct ip6_addr* EXT_SIP6(const char* pkt)
{
  return reinterpret_cast<const struct ip6_addr*>(
      pkt + ETHER_HDR_LEN + offsetof(struct ip6_hdr, ip6_src));
}

inline const struct ip6_addr* EXT_DIP6(const char* pkt)
{
  return reinterpret_cast<const struct ip6_addr*>(
      pkt + ETHER_HDR_LEN + offsetof(struct ip6_hdr, ip6_dst));
}

{'fraction_non_alphanumeric': 0.09364397195204704, 'fraction_numerical': 0.014023976475910428, 'mean_word_length': 1.9421157684630739, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7268402', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1408, 'n_words': 294}