summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--built_in.h8
-rw-r--r--curvetun.h2
-rw-r--r--netsniff-ng.c2
-rw-r--r--pcap_mm.c2
-rw-r--r--pcap_sg.c4
-rw-r--r--ring.h2
-rw-r--r--ring_rx.c4
-rw-r--r--ring_tx.c4
8 files changed, 13 insertions, 15 deletions
diff --git a/built_in.h b/built_in.h
index 8dd1824..c3ff2b5 100644
--- a/built_in.h
+++ b/built_in.h
@@ -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)
diff --git a/curvetun.h b/curvetun.h
index 46a3d4b..2274124 100644
--- a/curvetun.h
+++ b/curvetun.h
@@ -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) {
diff --git a/pcap_mm.c b/pcap_mm.c
index 0c4114e..5b3cfcb 100644
--- a/pcap_mm.c
+++ b/pcap_mm.c
@@ -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)
diff --git a/pcap_sg.c b/pcap_sg.c
index 7a2bfb0..9d07656 100644
--- a/pcap_sg.c
+++ b/pcap_sg.c
@@ -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);
diff --git a/ring.h b/ring.h
index 9522410..d3ccc04 100644
--- a/ring.h
+++ b/ring.h
@@ -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,
diff --git a/ring_rx.c b/ring_rx.c
index 355d10c..59cafd3 100644
--- a/ring_rx.c
+++ b/ring_rx.c
@@ -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 :
diff --git a/ring_tx.c b/ring_tx.c
index 9fef7f0..17d5f26 100644
--- a/ring_tx.c
+++ b/ring_tx.c
@@ -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 :