Skip to content

Commit

Permalink
Merge pull request #174 from headius/new_varargs
Browse files Browse the repository at this point in the history
Use Variadic annotation to support more platforms
  • Loading branch information
headius authored Jan 6, 2022
2 parents d4dcb18 + ce6e2b7 commit 3bf952c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.2.10</version>
<version>2.2.11-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/jnr/posix/LibC.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ public interface LibC {
int dup(int fd);
int dup2(int oldFd, int newFd);

@Variadic(fixedCount = 2)
int fcntl(int fd, int fnctl, Flock arg);
@Variadic(fixedCount = 2)
int fcntl(int fd, int fnctl, Pointer arg);
@Variadic(fixedCount = 2)
int fcntl(int fd, int fnctl);
int fcntl(int fd, int fnctl, int arg);
@Variadic(fixedCount = 2)
int fcntl(int fd, int fnctl, @u_int64_t int arg);
@Deprecated
int fcntl(int fd, int fnctl, int... arg);
int access(CharSequence path, int amode);
Expand Down Expand Up @@ -164,7 +168,8 @@ public interface LibCSignalHandler {

int flock(int fd, int mode);
int unlink(CharSequence path);
int open(CharSequence path, int flags, int perm);
@Variadic(fixedCount = 2)
int open(CharSequence path, int flags, @u_int32_t int perm);
int pipe(@Out int[] fds);
int truncate(CharSequence path, long length);
int ftruncate(int fd, long offset);
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/jnr/posix/FileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,15 @@ public void openTest() throws Throwable {

result = posix.close(fd);
assertEquals(-1, result);

fd = posix.open("jnr-posix-filetest.txt", OpenFlags.O_CREAT.intValue() | OpenFlags.O_RDWR.intValue(), 0600);

assertEquals(0600, posix.stat("jnr-posix-filetest.txt").mode() & 0777);

result = posix.close(fd);
assertEquals(0, result);

new File("jnr-posix-filetest.txt").delete();
}

@Test
Expand Down

0 comments on commit 3bf952c

Please sign in to comment.