Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux POSIX support #4118

Merged
merged 35 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c0521c6
Add linux support for errno.
andradei Aug 21, 2024
ef06cd9
Initial implementation of linux-specifig dirent struct.
andradei Aug 21, 2024
1adea2f
Merge branch 'master' of github.com:odin-lang/Odin into posix-linux
andradei Aug 24, 2024
90aa7df
Add POSIX dirent struct for Linux.
andradei Aug 24, 2024
9c06898
Add comma to last dirent struct member.
andradei Aug 24, 2024
d8e4a1b
Fix comment typo on POSIX ENOTSUP constant.
andradei Aug 24, 2024
2794eb3
On Linux POSIX, ENOTSUP and EOPNOTSUPP have the same value.
andradei Aug 24, 2024
e0b7847
Fix else when clause.
andradei Aug 24, 2024
7d94810
Fix ino_t and ino_t32 types for POSIX linux.
andradei Aug 27, 2024
4532202
Merge branch 'master' of github.com:odin-lang/Odin into posix-linux
andradei Aug 28, 2024
f0e631c
Use native types on linux POSIX structs.
andradei Aug 29, 2024
4577d54
Add contants RTLD contants on os_linux and posix (dlfcn).
andradei Aug 29, 2024
3557955
Align the dirent struct for linux
andradei Aug 30, 2024
575aedc
Implement POSIX support for Linux for the following facilities:
andradei Aug 31, 2024
186565b
Simplify the implementation of POSIX langinfo for Linux:
andradei Aug 31, 2024
a248d49
Add Linux support for POSIX limits.
andradei Sep 2, 2024
35f961d
Add POSIX Linux support for net_if and netdb.
andradei Sep 2, 2024
f072136
Implement POSIX linux support for poll and netinet_tcp. Incomplete su…
andradei Sep 3, 2024
d93f55c
Reuse POSIX netinet_in constants for linux.
andradei Sep 3, 2024
9e4b45f
Add linux to OS check.
andradei Sep 3, 2024
92ff046
Fix some compilation errors on POSIX linux.
andradei Sep 10, 2024
ff82396
Add Linux support for POSIX sys ipc, mman, time, utsname.
andradei Sep 10, 2024
1632f19
In-progress support for POSIX on Linux for sys/socket.
andradei Sep 11, 2024
55a9ba1
Finish sys/socket POSIX support for Linux.
andradei Sep 12, 2024
af94c4a
Add initial POSIX support for Linux for wordexp.
andradei Sep 14, 2024
aa91479
Fix O_NOFOLLOW typo. Add Linux support for POSIX fcntl.
andradei Sep 14, 2024
8616842
Implement Linux POSIX compliance for poll, sched, sys/select. Fix enu…
andradei Sep 15, 2024
97e06cb
Fix bit flags on fcntl linux POSIX implemention. Add sys/sem linux im…
andradei Sep 16, 2024
10702f1
Implement POSIX pthread, signal, sys/resource, unistd for Linux.
andradei Sep 22, 2024
5162c6c
Rename sigaction duplicate type to sigaction_t on linux, following ot…
andradei Sep 22, 2024
c68d847
Satisfy the compiler.
andradei Sep 22, 2024
04c08c2
Resolve bit set differences between linux and other platforms in posi…
andradei Sep 22, 2024
cc60725
Move bit set creation to compiler guard. Fix indentation on posix/sys…
andradei Sep 22, 2024
c1a67f3
Fix O_Flag_Bits.EXEC for non Linux platforms on posix/fcntl.
andradei Sep 22, 2024
5cd1784
review/correct/cleanup posix linux PR
laytan Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions core/os/os_linux.odin
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,13 @@ F_SETFL: int : 4 /* Set file flags */

// NOTE(zangent): These are OS specific!
// Do not mix these up!
RTLD_LAZY :: 0x001
RTLD_NOW :: 0x002
RTLD_BINDING_MASK :: 0x3
RTLD_GLOBAL :: 0x100
RTLD_LAZY :: 0x0001
RTLD_NOW :: 0x0002
RTLD_BINDING_MASK :: 0x0003
RTLD_GLOBAL :: 0x0100
RTLD_NOLOAD :: 0x0004
RTLD_DEEPBIND :: 0x0008
RTLD_NODELETE :: 0x1000

socklen_t :: c.int

Expand Down
20 changes: 15 additions & 5 deletions core/sys/posix/dirent.odin
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,23 @@ when ODIN_OS == .Darwin {
} else when ODIN_OS == .NetBSD {

dirent :: struct {
d_ino: ino_t, /* [PSX] file number of entry */
d_reclen: c.uint16_t, /* length of this record */
d_namelen: c.uint16_t, /* length of string in d_name */
d_type: D_Type, /* file type */
d_name: [512]c.char `fmt:"s,0"`, /* [PSX] entry name */
d_ino: ino_t, /* [PSX] file number of entry */
d_reclen: c.uint16_t, /* length of this record */
d_namelen: c.uint16_t, /* length of string in d_name */
d_type: D_Type, /* file type */
d_name: [512]c.char `fmt:"s,0"`, /* [PSX] entry name */
}

} else when ODIN_OS == .Linux {

dirent :: struct {
andradei marked this conversation as resolved.
Show resolved Hide resolved
d_ino: u64, /* [PSX] file number of entry */
d_off: i64, /* directory offset of the next entry */
d_reclen: u16, /* length of this record */
d_type: D_Type, /* file type */
d_name: [256]c.char `fmt:"s,0"`, /* [PSX] entry name */
}

} else {
#panic("posix is unimplemented for the current target")
}
9 changes: 9 additions & 0 deletions core/sys/posix/dlfcn.odin
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ when ODIN_OS == .Darwin {

RTLD_LOCAL :: RTLD_Flags{RTLD_Flag_Bits(log2(_RTLD_LOCAL))}

} else when ODIN_OS == .Linux {

RTLD_LAZY :: 0x001
RTLD_NOW :: 0x002
RTLD_GLOBAL :: 0x100

_RTLD_LOCAL :: 0
RTLD_LOCAL :: RTLD_Flags{}

} else {
#panic("posix is unimplemented for the current target")
}
Expand Down
101 changes: 95 additions & 6 deletions core/sys/posix/errno.odin
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ when ODIN_OS == .Darwin {
EMLINK :: 31
EPIPE :: 32
EAGAIN :: 35
EWOULDBLOCK :: 35
EWOULDBLOCK :: EAGAIN
EINPROGRESS :: 36
EALREADY :: 37
ENOTSOCK :: 38
Expand All @@ -151,7 +151,7 @@ when ODIN_OS == .Darwin {
ENOPROTOOPT :: 42
EPROTONOSUPPORT :: 43
ENOTSUP :: 45
EOPNOTSUPP :: 45
EOPNOTSUPP :: ENOTSUP
EAFNOSUPPORT :: 47
EADDRINUSE :: 48
EADDRNOTAVAIL :: 49
Expand Down Expand Up @@ -220,7 +220,7 @@ when ODIN_OS == .Darwin {
EMLINK :: 31
EPIPE :: 32
EAGAIN :: 35
EWOULDBLOCK :: 35
EWOULDBLOCK :: EAGAIN
EINPROGRESS :: 36
EALREADY :: 37
ENOTSOCK :: 38
Expand All @@ -230,7 +230,7 @@ when ODIN_OS == .Darwin {
ENOPROTOOPT :: 42
EPROTONOSUPPORT :: 43
ENOTSUP :: 45
EOPNOTSUPP :: 45
EOPNOTSUPP :: ENOTSUP
EAFNOSUPPORT :: 47
EADDRINUSE :: 48
EADDRNOTAVAIL :: 49
Expand Down Expand Up @@ -301,7 +301,7 @@ when ODIN_OS == .Darwin {
EMLINK :: 31
EPIPE :: 32
EAGAIN :: 35
EWOULDBLOCK :: 35
EWOULDBLOCK :: EAGAIN
EINPROGRESS :: 36
EALREADY :: 37
ENOTSOCK :: 38
Expand All @@ -311,7 +311,7 @@ when ODIN_OS == .Darwin {
ENOPROTOOPT :: 42
EPROTONOSUPPORT :: 43
ENOTSUP :: 45
EOPNOTSUPP :: 45
EOPNOTSUPP :: ENOTSUP
EAFNOSUPPORT :: 47
EADDRINUSE :: 48
EADDRNOTAVAIL :: 49
Expand Down Expand Up @@ -367,6 +367,95 @@ when ODIN_OS == .Darwin {
ETIME :: -1
}

} else when ODIN_OS == .Linux {
EPERM :: 1
ENOENT :: 2
ESRCH :: 3
EINTR :: 4
EIO :: 5
ENXIO :: 6
E2BIG :: 7
ENOEXEC :: 8
EBADF :: 9
ECHILD :: 10
EAGAIN :: 11
EWOULDBLOCK :: EAGAIN
ENOMEM :: 12
EACCES :: 13
EFAULT :: 14
EBUSY :: 16
EEXIST :: 17
EXDEV :: 18
ENODEV :: 19
ENOTDIR :: 20
EISDIR :: 21
EINVAL :: 22
ENFILE :: 23
EMFILE :: 24
ENOTTY :: 25
ETXTBSY :: 26
EFBIG :: 27
ENOSPC :: 28
ESPIPE :: 29
EROFS :: 30
EMLINK :: 31
EPIPE :: 32

EDEADLK :: 35
ENAMETOOLONG :: 36
ENOLCK :: 37
ENOSYS :: 38
ENOTEMPTY :: 39
ELOOP :: 40
ENOMSG :: 42
EIDRM :: 43

ENOSTR :: 60
ENODATA :: 61
ETIME :: 62
ENOSR :: 63

ENOLINK :: 67

EPROTO :: 71
EMULTIHOP :: 72
EBADMSG :: 74
EOVERFLOW :: 75

ENOTSOCK :: 88
EDESTADDRREQ :: 89
EMSGSIZE :: 90
EPROTOTYPE :: 91
ENOPROTOOPT :: 92
EPROTONOSUPPORT :: 93

EOPNOTSUPP :: 95
ENOTSUP :: EOPNOTSUPP
EAFNOSUPPORT :: 97
EADDRINUSE :: 98
EADDRNOTAVAIL :: 99
ENETDOWN :: 100
ENETUNREACH :: 101
ENETRESET :: 102
ECONNABORTED :: 103
ECONNRESET :: 104
ENOBUFS :: 105
EISCONN :: 106
ENOTCONN :: 107

ETIMEDOUT :: 110
ECONNREFUSED :: 111

EHOSTUNREACH :: 113
EALREADY :: 114
EINPROGRESS :: 115
ESTALE :: 116

EDQUOT :: 122
ECANCELED :: 125

EOWNERDEAD :: 130
ENOTRECOVERABLE :: 131
} else {
#panic("posix is unimplemented for the current target")
}
Expand Down
Loading
Loading