Native library bindings for standard C library @author leJOS, Jakub Vaněk @since 2.4.7
| 11 | * @since 2.4.7 |
| 12 | */ |
| 13 | public class NativeLibc implements ILibc { |
| 14 | private static boolean initialized = false; |
| 15 | |
| 16 | public NativeLibc() { |
| 17 | synchronized (NativeLibc.class) { |
| 18 | if (!initialized) { |
| 19 | try { |
| 20 | Native.register(Platform.C_LIBRARY_NAME); |
| 21 | initialized = true; |
| 22 | } catch (Exception e) { |
| 23 | throw new IllegalArgumentException("native libc load failed", e); |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | // file descriptor operations |
| 30 | native public int fcntl(int fd, int cmd, int arg) throws LastErrorException; |
| 31 | |
| 32 | // ioctls |
| 33 | native public int ioctl(int fd, int cmd, int arg) throws LastErrorException; |
| 34 | |
| 35 | native public int ioctl(int fd, int cmd, Pointer arg) throws LastErrorException; |
| 36 | |
| 37 | // open/close |
| 38 | native public int open(String path, int flags, int mode) throws LastErrorException; |
| 39 | |
| 40 | native public int close(int fd) throws LastErrorException; |
| 41 | |
| 42 | // read/write |
| 43 | native public int write(int fd, Buffer buffer, int count) throws LastErrorException; |
| 44 | |
| 45 | native public int read(int fd, Buffer buffer, int count) throws LastErrorException; |
| 46 | |
| 47 | // map/unmap |
| 48 | native public Pointer mmap(Pointer addr, NativeLong len, int prot, int flags, int fd, NativeLong off) throws LastErrorException; |
| 49 | |
| 50 | native public int munmap(Pointer addr, NativeLong len) throws LastErrorException; |
| 51 | |
| 52 | native public int msync(Pointer addr, NativeLong len, int flags) throws LastErrorException; |
| 53 | } |
nothing calls this directly
no outgoing calls
no test coverage detected