jnr.posix.LinuxSocketMacros Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cassandra-driver Show documentation
Show all versions of cassandra-driver Show documentation
Shaded version of DataStax Java Driver for Apache Cassandra
The newest version!
package jnr.posix;
import jnr.ffi.*;
import jnr.ffi.Runtime;
/**
* @author Bob McWhirter
*/
public class LinuxSocketMacros implements SocketMacros {
public static final LinuxSocketMacros INSTANCE = new LinuxSocketMacros();
public int CMSG_ALIGN(int len) {
int sizeof_size_t = Runtime.getSystemRuntime().findType(TypeAlias.size_t).size();
return (len + sizeof_size_t - 1) & ~(sizeof_size_t - 1);
}
public int CMSG_SPACE(int l) {
return CMSG_ALIGN(l) + CMSG_ALIGN(LinuxCmsgHdr.layout.size());
}
public int CMSG_LEN(int l) {
return CMSG_ALIGN( LinuxCmsgHdr.layout.size() + l );
}
public Pointer CMSG_DATA(Pointer cmsg) {
return cmsg.slice(CMSG_ALIGN(LinuxCmsgHdr.layout.size()));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy