diff options
-rw-r--r-- | built_in.h | 8 | ||||
-rw-r--r-- | curvetun.h | 2 | ||||
-rw-r--r-- | netsniff-ng.c | 2 | ||||
-rw-r--r-- | pcap_mm.c | 2 | ||||
-rw-r--r-- | pcap_sg.c | 4 | ||||
-rw-r--r-- | ring.h | 2 | ||||
-rw-r--r-- | ring_rx.c | 4 | ||||
-rw-r--r-- | ring_tx.c | 4 |
8 files changed, 13 insertions, 15 deletions
@@ -178,11 +178,9 @@ typedef uint8_t u8; # define bug() assert(0) #endif -#ifndef PAGE_SIZE -# define PAGE_SIZE (getpagesize()) -#endif -#define PAGE_MASK (~(PAGE_SIZE - 1)) -#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) +#define RUNTIME_PAGE_SIZE (getpagesize()) +#define PAGE_MASK (~(RUNTIME_PAGE_SIZE - 1)) +#define PAGE_ALIGN(addr) (((addr) + RUNTIME_PAGE_SIZE - 1) & PAGE_MASK) #if __BYTE_ORDER == __LITTLE_ENDIAN static inline uint64_t htonll(uint64_t x) @@ -22,7 +22,7 @@ struct ct_proto { } __attribute__((packed)); /* FIXME: think up sth better */ -#define TUNBUFF_SIZ (3 * getpagesize()) +#define TUNBUFF_SIZ (3 * RUNTIME_PAGE_SIZE) #define MAX_EPOLL_SIZE 10000 #define THREADS_PER_CPU 2 diff --git a/netsniff-ng.c b/netsniff-ng.c index 6a83702..1e9d6f9 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -580,7 +580,7 @@ static void read_pcap(struct ctx *ctx) dissector_init_all(ctx->print_mode); - out_len = round_up(1024 * 1024, PAGE_SIZE); + out_len = round_up(1024 * 1024, RUNTIME_PAGE_SIZE); out = xmalloc_aligned(out_len, CO_CACHE_LINE_SIZE); if (ctx->device_out) { @@ -91,7 +91,7 @@ static inline off_t ____get_map_size(bool jumbo) { int allocsz = jumbo ? 16 : 3; - return PAGE_ALIGN(sizeof(struct pcap_filehdr) + (PAGE_SIZE * allocsz) * 1024); + return PAGE_ALIGN(sizeof(struct pcap_filehdr) + (RUNTIME_PAGE_SIZE * allocsz) * 1024); } static void __pcap_mm_prepare_access_wr(int fd, bool jumbo) @@ -156,8 +156,8 @@ static int pcap_sg_prepare_access(int fd, enum pcap_mode mode, bool jumbo) size_t i, len = 0; iov_slot = 0; - len = jumbo ? (PAGE_SIZE * 16) /* 64k max */ : - (PAGE_SIZE * 3) /* 12k max */; + len = jumbo ? (RUNTIME_PAGE_SIZE * 16) /* 64k max */ : + (RUNTIME_PAGE_SIZE * 3) /* 12k max */; for (i = 0; i < array_size(iov); ++i) { iov[i].iov_base = xzmalloc_aligned(len, 64); @@ -100,7 +100,7 @@ static inline void ring_verify_layout(struct ring *ring) { bug_on(ring->layout.tp_block_size < ring->layout.tp_frame_size); bug_on((ring->layout.tp_block_size % ring->layout.tp_frame_size) != 0); - bug_on((ring->layout.tp_block_size % getpagesize()) != 0); + bug_on((ring->layout.tp_block_size % RUNTIME_PAGE_SIZE) != 0); } static inline void tpacket_hdr_clone(struct tpacket2_hdr *thdrd, @@ -46,8 +46,8 @@ void setup_rx_ring_layout(int sock, struct ring *ring, unsigned int size, fmemset(&ring->layout, 0, sizeof(ring->layout)); ring->layout.tp_block_size = (jumbo_support ? - getpagesize() << 4 : - getpagesize() << 2); + RUNTIME_PAGE_SIZE << 4 : + RUNTIME_PAGE_SIZE << 2); ring->layout.tp_frame_size = (jumbo_support ? TPACKET_ALIGNMENT << 12 : @@ -51,8 +51,8 @@ void setup_tx_ring_layout(int sock, struct ring *ring, unsigned int size, fmemset(&ring->layout, 0, sizeof(ring->layout)); ring->layout.tp_block_size = (jumbo_support ? - getpagesize() << 4 : - getpagesize() << 2); + RUNTIME_PAGE_SIZE << 4 : + RUNTIME_PAGE_SIZE << 2); ring->layout.tp_frame_size = (jumbo_support ? TPACKET_ALIGNMENT << 12 : |