Skip to contentSkip to conversation

portability of getpagesize() in libmnl.h

libmnl Applied Markus Teich 3 participants 4 messages Feb 24, 2015 – Mar 2, 2015 netfilter

lore
Share & tools
lore
#0 lore raw

Heyho,

the getpagesize() call in line

#define MNL_SOCKET_BUFFER_SIZE (getpagesize() < 8192L ? getpagesize() : 8192L)

of libmnl.h seems to be less portable than sysconf(_SC_PAGESIZE) as suggested by the getpagesize man page. getpagesize() needs e.g. _BSD_SOURCE while sysconf() does not.

Would you consider fixing this or should I write a patch?

(I'm not on the list, so please leave me a CC)

--Markus

#1 lore raw
Quoted 11 lines · Markus Teich

Heyho,

the getpagesize() call in line

#define MNL_SOCKET_BUFFER_SIZE (getpagesize() < 8192L ? getpagesize() : 8192L)

of libmnl.h seems to be less portable than sysconf(_SC_PAGESIZE) as suggested by the getpagesize man page. getpagesize() needs e.g. _BSD_SOURCE while sysconf() does not.

Would you consider fixing this or should I write a patch?

Go send a patch that I can apply via 'git am'. Thanks.

#2 lore raw

PATCH 1/1 header: use sysconf() instead of getpagesize()

The sysconf(_SC_PAGESIZE) call is more portable since it does not need _BSD_SOURCE defined.

---
 include/libmnl/libmnl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/libmnl/libmnl.h +1 -1
index 0de6678..3a589bc 100644
@@ -17,7 +17,7 @@ extern "C" {
  */
 
 #define MNL_SOCKET_AUTOPID	0
-#define MNL_SOCKET_BUFFER_SIZE (getpagesize() < 8192L ? getpagesize() : 8192L)
+#define MNL_SOCKET_BUFFER_SIZE (sysconf(_SC_PAGESIZE) < 8192L ? sysconf(_SC_PAGESIZE) : 8192L)
 
 struct mnl_socket;
 
Signature · 1 line
2.0.5
maintainer Applied
#3 lore raw

Re: [PATCH] header: use sysconf() instead of getpagesize()

Quoted 2 lines · Markus Teich

The sysconf(_SC_PAGESIZE) call is more portable since it does not need _BSD_SOURCE defined.

Applied, thanks.