Skip to content

Commit f23a3f1

Browse files
committed
Added interfaces to access functions.
1 parent df3146c commit f23a3f1

File tree

4 files changed

+48
-9
lines changed

4 files changed

+48
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ tested on:
4040

4141
Preprocessor macros are used to achieve platform-independent interoperability.
4242
Therefore, your Fortran compiler has to support at least GNU preprocessor
43-
conditionals (`#ifdef` …).
43+
conditionals.
4444

4545
## Build Instructions
4646

src/unix_fcntl.F90

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ module unix_fcntl
1010

1111
#if defined (__linux__)
1212

13+
integer(kind=c_int), parameter, public :: AT_EACCESS = int(z'200')
14+
integer(kind=c_int), parameter, public :: AT_SYMLINK_NOFOLLOW = int(z'100')
15+
integer(kind=c_int), parameter, public :: AT_SYMLINK_FOLLOW = int(z'400')
16+
integer(kind=c_int), parameter, public :: AT_REMOVEDIR = int(z'200')
17+
integer(kind=c_int), parameter, public :: AT_EMPTY_PATH = int(z'1000')
18+
1319
integer(kind=c_int), parameter, public :: O_ACCMODE = int(o'0003')
1420
integer(kind=c_int), parameter, public :: O_RDONLY = int(o'00')
1521
integer(kind=c_int), parameter, public :: O_WRONLY = int(o'01')
@@ -29,6 +35,12 @@ module unix_fcntl
2935

3036
#elif defined (__FreeBSD__)
3137

38+
integer(kind=c_int), parameter, public :: AT_EACCESS = int(z'0100') ! Check access using effective user and group ID.
39+
integer(kind=c_int), parameter, public :: AT_SYMLINK_NOFOLLOW = int(z'0200') ! Do not follow symbolic links.
40+
integer(kind=c_int), parameter, public :: AT_SYMLINK_FOLLOW = int(z'0400') ! Follow symbolic link.
41+
integer(kind=c_int), parameter, public :: AT_REMOVEDIR = int(z'0800') ! Remove directory instead of file.
42+
integer(kind=c_int), parameter, public :: AT_EMPTY_PATH = int(z'4000') ! Operate on dirfd if path is empty.
43+
3244
integer(kind=c_int), parameter, public :: O_RDONLY = int(z'0000') ! Open for reading only.
3345
integer(kind=c_int), parameter, public :: O_WRONLY = int(z'0001') ! Open for writing only.
3446
integer(kind=c_int), parameter, public :: O_RDWR = int(z'0002') ! Open for reading and writing.

src/unix_types.F90

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ module unix_types
99

1010
#if defined (__flang__)
1111

12+
public :: c_uint16_t
13+
public :: c_uint32_t
14+
public :: c_uint64_t
15+
1216
public :: c_unsigned
1317
public :: c_unsigned_char
1418
public :: c_unsigned_short
1519
public :: c_unsigned_long
1620

17-
public :: c_uint16_t
18-
public :: c_uint32_t
19-
public :: c_uint64_t
20-
2121
#else
2222

23+
integer, parameter, public :: c_uint16_t = c_int16_t
24+
integer, parameter, public :: c_uint32_t = c_int32_t
25+
integer, parameter, public :: c_uint64_t = c_int64_t
26+
2327
integer, parameter, public :: c_unsigned = c_int
2428
integer, parameter, public :: c_unsigned_char = c_signed_char
2529
integer, parameter, public :: c_unsigned_short = c_short
2630
integer, parameter, public :: c_unsigned_long = c_long
2731

28-
integer, parameter, public :: c_uint16_t = c_int16_t
29-
integer, parameter, public :: c_uint32_t = c_int32_t
30-
integer, parameter, public :: c_uint64_t = c_int64_t
31-
3232
#endif
3333

3434
#if defined (__linux__)

src/unix_unistd.F90

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ module unix_unistd
1212
integer(kind=c_int), parameter, public :: STDOUT_FILENO = 1
1313
integer(kind=c_int), parameter, public :: STDERR_FILENO = 2
1414

15+
integer(kind=c_int), parameter, public :: F_OK = 0 ! Test for existence of file.
16+
integer(kind=c_int), parameter, public :: X_OK = int(z'01') ! Test for execute or search permission.
17+
integer(kind=c_int), parameter, public :: W_OK = int(z'02') ! Test for write permission.
18+
integer(kind=c_int), parameter, public :: R_OK = int(z'04') ! Test for read permission.
19+
20+
public :: c_access
1521
public :: c_chdir
1622
public :: c_close
1723
public :: c_dup
1824
public :: c_dup2
1925
public :: c_execl
26+
public :: c_faccessat
2027
public :: c_fork
2128
public :: c_getpid
2229
public :: c_pipe
@@ -27,6 +34,15 @@ module unix_unistd
2734
public :: c_write
2835

2936
interface
37+
! int access(const char *path, int mode)
38+
function c_access(path, mode) bind(c, name='access')
39+
import :: c_char, c_int
40+
implicit none
41+
character(kind=c_char), intent(in) :: path
42+
integer(kind=c_int), intent(in), value :: mode
43+
integer(kind=c_int) :: c_access
44+
end function c_access
45+
3046
! int chdir(const char *path)
3147
function c_chdir(path) bind(c, name='chdir')
3248
import :: c_int, c_char
@@ -72,6 +88,17 @@ function c_execl(path, arg1, arg2, arg3, ptr) bind(c, name='c_execl')
7288
integer(kind=c_int) :: c_execl
7389
end function c_execl
7490

91+
! int faccessat(int dirfd, const char *path, int mode, int flags)
92+
function c_faccessat(dirfd, path, mode, flags) bind(c, name='faccessat')
93+
import :: c_char, c_int
94+
implicit none
95+
integer(kind=c_int), intent(in), value :: dirfd
96+
character(kind=c_char), intent(in) :: path
97+
integer(kind=c_int), intent(in), value :: mode
98+
integer(kind=c_int), intent(in), value :: flags
99+
integer(kind=c_int) :: c_faccessat
100+
end function c_faccessat
101+
75102
! pid_t fork(void)
76103
function c_fork() bind(c, name='fork')
77104
import :: c_pid_t

0 commit comments

Comments
 (0)