aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/nativec/GLibcVersion.java
blob: f179f6e506e1c48ee8e2c62fa6b0b4d9bb4d9d8b (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
26
27
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.nativec;

/**
 * Gives access to the C library version.
 *
 * @author baldersheim
 */
public class GLibcVersion {
    private final static Throwable initException = NativeC.loadLibrary(GLibcVersion.class);
    public static Throwable init() {
        return initException;
    }
    private final String version;
    private final int major;
    private final int minor;
    public GLibcVersion() {
        version = gnu_get_libc_version();
        String [] parts = version.split("\\.");
        major = parts.length > 0 ? Integer.valueOf(parts[0]) : -1;
        minor = parts.length > 1 ? Integer.valueOf(parts[1]) : -1;
    }
    private native static String gnu_get_libc_version();
    public String version() { return version; }
    public int major() { return major; }
    public int minor() { return minor; }
}