summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/io/NativeC.java
blob: 7dbf4015bcf4e6fcd62358f2936d840fec6f883f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.yahoo.io;

import com.sun.jna.LastErrorException;
import com.sun.jna.Native;
import com.sun.jna.Platform;

class NativeC {
    private final static Throwable initException = loadLibrary();
    private static Throwable loadLibrary() {
        if (Platform.isLinux()) {
            try {
                Native.register(Platform.C_LIBRARY_NAME);
            } catch (Throwable e) {
                return e;
            }
        } else {
            return new RuntimeException("Platform is unsúpported. Only supported on linux.");
        }
        return null;
    }
    static Throwable init() {
        return initException;
    }
    static native int posix_fadvise(int fd, long offset, long len, int flag) throws LastErrorException;
}