Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Limkilde Svendsen
relibc
Commits
55e618d8
Verified
Commit
55e618d8
authored
6 years ago
by
jD91mZM2
Browse files
Options
Downloads
Patches
Plain Diff
Add the last socket functions on linux; leave unimplemented on redox
parent
6d923cbd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/platform/src/linux/mod.rs
+39
-2
39 additions, 2 deletions
src/platform/src/linux/mod.rs
src/platform/src/redox/mod.rs
+46
-0
46 additions, 0 deletions
src/platform/src/redox/mod.rs
src/sys_socket/src/lib.rs
+7
-7
7 additions, 7 deletions
src/sys_socket/src/lib.rs
with
92 additions
and
9 deletions
src/platform/src/linux/mod.rs
+
39
−
2
View file @
55e618d8
...
@@ -124,7 +124,7 @@ pub fn getgid() -> gid_t {
...
@@ -124,7 +124,7 @@ pub fn getgid() -> gid_t {
}
}
pub
unsafe
fn
getpeername
(
socket
:
c_int
,
address
:
*
mut
sockaddr
,
address_len
:
*
mut
socklen_t
)
->
c_int
{
pub
unsafe
fn
getpeername
(
socket
:
c_int
,
address
:
*
mut
sockaddr
,
address_len
:
*
mut
socklen_t
)
->
c_int
{
e
(
unsafe
{
syscall!
(
GETPEERNAME
,
socket
,
address
,
address_len
)
}
)
as
c_int
e
(
syscall!
(
GETPEERNAME
,
socket
,
address
,
address_len
))
as
c_int
}
}
pub
fn
getpgid
(
pid
:
pid_t
)
->
pid_t
{
pub
fn
getpgid
(
pid
:
pid_t
)
->
pid_t
{
...
@@ -140,7 +140,17 @@ pub fn getppid() -> pid_t {
...
@@ -140,7 +140,17 @@ pub fn getppid() -> pid_t {
}
}
pub
unsafe
fn
getsockname
(
socket
:
c_int
,
address
:
*
mut
sockaddr
,
address_len
:
*
mut
socklen_t
)
->
c_int
{
pub
unsafe
fn
getsockname
(
socket
:
c_int
,
address
:
*
mut
sockaddr
,
address_len
:
*
mut
socklen_t
)
->
c_int
{
e
(
unsafe
{
syscall!
(
GETSOCKNAME
,
socket
,
address
,
address_len
)
})
as
c_int
e
(
syscall!
(
GETSOCKNAME
,
socket
,
address
,
address_len
))
as
c_int
}
pub
fn
getsockopt
(
socket
:
c_int
,
level
:
c_int
,
option_name
:
c_int
,
option_value
:
*
mut
c_void
,
option_len
:
*
mut
socklen_t
,
)
->
c_int
{
e
(
unsafe
{
syscall!
(
GETSOCKOPT
,
socket
,
level
,
option_name
,
option_value
,
option_len
)
})
as
c_int
}
}
pub
fn
getuid
()
->
uid_t
{
pub
fn
getuid
()
->
uid_t
{
...
@@ -159,6 +169,10 @@ pub fn link(path1: *const c_char, path2: *const c_char) -> c_int {
...
@@ -159,6 +169,10 @@ pub fn link(path1: *const c_char, path2: *const c_char) -> c_int {
e
(
unsafe
{
syscall!
(
LINKAT
,
AT_FDCWD
,
path1
,
AT_FDCWD
,
path2
,
0
)
})
as
c_int
e
(
unsafe
{
syscall!
(
LINKAT
,
AT_FDCWD
,
path1
,
AT_FDCWD
,
path2
,
0
)
})
as
c_int
}
}
pub
fn
listen
(
socket
:
c_int
,
backlog
:
c_int
)
->
c_int
{
e
(
unsafe
{
syscall!
(
LISTEN
,
socket
,
backlog
)
})
as
c_int
}
pub
fn
lseek
(
fildes
:
c_int
,
offset
:
off_t
,
whence
:
c_int
)
->
off_t
{
pub
fn
lseek
(
fildes
:
c_int
,
offset
:
off_t
,
whence
:
c_int
)
->
off_t
{
e
(
unsafe
{
syscall!
(
LSEEK
,
fildes
,
offset
,
whence
)
})
as
off_t
e
(
unsafe
{
syscall!
(
LSEEK
,
fildes
,
offset
,
whence
)
})
as
off_t
}
}
...
@@ -243,6 +257,20 @@ pub fn setreuid(ruid: uid_t, euid: uid_t) -> c_int {
...
@@ -243,6 +257,20 @@ pub fn setreuid(ruid: uid_t, euid: uid_t) -> c_int {
e
(
unsafe
{
syscall!
(
SETREUID
,
ruid
,
euid
)
})
as
c_int
e
(
unsafe
{
syscall!
(
SETREUID
,
ruid
,
euid
)
})
as
c_int
}
}
pub
fn
setsockopt
(
socket
:
c_int
,
level
:
c_int
,
option_name
:
c_int
,
option_value
:
*
const
c_void
,
option_len
:
socklen_t
,
)
->
c_int
{
e
(
unsafe
{
syscall!
(
SETSOCKOPT
,
socket
,
level
,
option_name
,
option_value
,
option_len
)
})
as
c_int
}
pub
fn
shutdown
(
socket
:
c_int
,
how
:
c_int
)
->
c_int
{
e
(
unsafe
{
syscall!
(
SHUTDOWN
,
socket
,
how
)
})
as
c_int
}
pub
fn
stat
(
file
:
*
const
c_char
,
buf
:
*
mut
stat
)
->
c_int
{
pub
fn
stat
(
file
:
*
const
c_char
,
buf
:
*
mut
stat
)
->
c_int
{
e
(
unsafe
{
syscall!
(
NEWFSTATAT
,
AT_FDCWD
,
file
,
buf
,
0
)
})
as
c_int
e
(
unsafe
{
syscall!
(
NEWFSTATAT
,
AT_FDCWD
,
file
,
buf
,
0
)
})
as
c_int
}
}
...
@@ -251,6 +279,15 @@ pub fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int {
...
@@ -251,6 +279,15 @@ pub fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int {
e
(
unsafe
{
syscall!
(
SOCKET
,
domain
,
kind
,
protocol
)
})
as
c_int
e
(
unsafe
{
syscall!
(
SOCKET
,
domain
,
kind
,
protocol
)
})
as
c_int
}
}
pub
fn
socketpair
(
domain
:
c_int
,
kind
:
c_int
,
protocol
:
c_int
,
socket_vector
:
*
mut
c_int
,
)
->
c_int
{
e
(
unsafe
{
syscall!
(
SOCKETPAIR
,
domain
,
kind
,
protocol
,
socket_vector
)
})
as
c_int
}
pub
fn
uname
(
utsname
:
usize
)
->
c_int
{
pub
fn
uname
(
utsname
:
usize
)
->
c_int
{
e
(
unsafe
{
syscall!
(
UNAME
,
utsname
,
0
)
})
as
c_int
e
(
unsafe
{
syscall!
(
UNAME
,
utsname
,
0
)
})
as
c_int
}
}
...
...
This diff is collapsed.
Click to expand it.
src/platform/src/redox/mod.rs
+
46
−
0
View file @
55e618d8
//! sys/socket implementation, following http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/socket.h.html
//! sys/socket implementation, following http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/socket.h.html
use
core
::
fmt
::
Write
;
use
core
::
mem
;
use
core
::
mem
;
use
core
::
ptr
;
use
core
::
ptr
;
use
core
::
slice
;
use
core
::
slice
;
...
@@ -331,6 +332,18 @@ pub unsafe fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *m
...
@@ -331,6 +332,18 @@ pub unsafe fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *m
e
(
inner_get_name
(
true
,
socket
,
address
,
address_len
))
as
c_int
e
(
inner_get_name
(
true
,
socket
,
address
,
address_len
))
as
c_int
}
}
pub
fn
getsockopt
(
socket
:
c_int
,
level
:
c_int
,
option_name
:
c_int
,
option_value
:
*
mut
c_void
,
option_len
:
*
mut
socklen_t
,
)
->
c_int
{
let
_
=
write!
(::
FileWriter
(
2
),
"unimplemented: getsockopt({}, {}, {}, {:p}, {:p})"
,
socket
,
level
,
option_name
,
option_value
,
option_len
);
-
1
}
pub
fn
getuid
()
->
uid_t
{
pub
fn
getuid
()
->
uid_t
{
e
(
syscall
::
getuid
())
as
pid_t
e
(
syscall
::
getuid
())
as
pid_t
}
}
...
@@ -349,6 +362,11 @@ pub fn link(path1: *const c_char, path2: *const c_char) -> c_int {
...
@@ -349,6 +362,11 @@ pub fn link(path1: *const c_char, path2: *const c_char) -> c_int {
e
(
unsafe
{
syscall
::
link
(
path1
.as_ptr
(),
path2
.as_ptr
())
})
as
c_int
e
(
unsafe
{
syscall
::
link
(
path1
.as_ptr
(),
path2
.as_ptr
())
})
as
c_int
}
}
pub
fn
listen
(
socket
:
c_int
,
backlog
:
c_int
)
->
c_int
{
// TODO
0
}
pub
fn
lseek
(
fd
:
c_int
,
offset
:
off_t
,
whence
:
c_int
)
->
off_t
{
pub
fn
lseek
(
fd
:
c_int
,
offset
:
off_t
,
whence
:
c_int
)
->
off_t
{
e
(
syscall
::
lseek
(
e
(
syscall
::
lseek
(
fd
as
usize
,
fd
as
usize
,
...
@@ -499,6 +517,23 @@ pub fn setreuid(ruid: uid_t, euid: uid_t) -> c_int {
...
@@ -499,6 +517,23 @@ pub fn setreuid(ruid: uid_t, euid: uid_t) -> c_int {
e
(
syscall
::
setreuid
(
ruid
as
usize
,
euid
as
usize
))
as
c_int
e
(
syscall
::
setreuid
(
ruid
as
usize
,
euid
as
usize
))
as
c_int
}
}
pub
fn
setsockopt
(
socket
:
c_int
,
level
:
c_int
,
option_name
:
c_int
,
option_value
:
*
const
c_void
,
option_len
:
socklen_t
,
)
->
c_int
{
let
_
=
write!
(::
FileWriter
(
2
),
"unimplemented: setsockopt({}, {}, {}, {:p}, {})"
,
socket
,
level
,
option_name
,
option_value
,
option_len
);
-
1
}
pub
fn
shutdown
(
socket
:
c_int
,
how
:
c_int
)
->
c_int
{
let
_
=
write!
(::
FileWriter
(
2
),
"unimplemented: shutdown({}, {})"
,
socket
,
how
);
-
1
}
pub
fn
stat
(
path
:
*
const
c_char
,
buf
:
*
mut
stat
)
->
c_int
{
pub
fn
stat
(
path
:
*
const
c_char
,
buf
:
*
mut
stat
)
->
c_int
{
let
path
=
unsafe
{
c_str
(
path
)
};
let
path
=
unsafe
{
c_str
(
path
)
};
match
syscall
::
open
(
path
,
O_RDONLY
)
{
match
syscall
::
open
(
path
,
O_RDONLY
)
{
...
@@ -543,6 +578,17 @@ pub unsafe fn socket(domain: c_int, mut kind: c_int, protocol: c_int) -> c_int {
...
@@ -543,6 +578,17 @@ pub unsafe fn socket(domain: c_int, mut kind: c_int, protocol: c_int) -> c_int {
}
}
}
}
pub
fn
socketpair
(
domain
:
c_int
,
kind
:
c_int
,
protocol
:
c_int
,
socket_vector
:
*
mut
c_int
,
)
->
c_int
{
let
_
=
write!
(::
FileWriter
(
2
),
"unimplemented: socketpair({}, {}, {}, {:p})"
,
domain
,
kind
,
protocol
,
socket_vector
);
-
1
}
pub
fn
unlink
(
path
:
*
const
c_char
)
->
c_int
{
pub
fn
unlink
(
path
:
*
const
c_char
)
->
c_int
{
let
path
=
unsafe
{
c_str
(
path
)
};
let
path
=
unsafe
{
c_str
(
path
)
};
e
(
syscall
::
unlink
(
path
))
as
c_int
e
(
syscall
::
unlink
(
path
))
as
c_int
...
...
This diff is collapsed.
Click to expand it.
src/sys_socket/src/lib.rs
+
7
−
7
View file @
55e618d8
...
@@ -75,12 +75,12 @@ pub unsafe extern "C" fn getsockopt(
...
@@ -75,12 +75,12 @@ pub unsafe extern "C" fn getsockopt(
option_value
:
*
mut
c_void
,
option_value
:
*
mut
c_void
,
option_len
:
*
mut
socklen_t
,
option_len
:
*
mut
socklen_t
,
)
->
c_int
{
)
->
c_int
{
unimplemented!
();
platform
::
getsockopt
(
socket
,
level
,
option_name
,
option_value
,
option_len
)
}
}
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
listen
(
socket
:
c_int
,
backlog
:
c_int
)
->
c_int
{
pub
unsafe
extern
"C"
fn
listen
(
socket
:
c_int
,
backlog
:
c_int
)
->
c_int
{
unimplemented!
();
platform
::
listen
(
socket
,
backlog
)
}
}
#[no_mangle]
#[no_mangle]
...
@@ -156,12 +156,12 @@ pub unsafe extern "C" fn setsockopt(
...
@@ -156,12 +156,12 @@ pub unsafe extern "C" fn setsockopt(
option_value
:
*
const
c_void
,
option_value
:
*
const
c_void
,
option_len
:
socklen_t
,
option_len
:
socklen_t
,
)
->
c_int
{
)
->
c_int
{
unimplemented!
();
platform
::
setsockopt
(
socket
,
level
,
option_name
,
option_value
,
option_len
)
}
}
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
shutdown
(
socket
:
c_int
,
how
:
c_int
)
->
c_int
{
pub
unsafe
extern
"C"
fn
shutdown
(
socket
:
c_int
,
how
:
c_int
)
->
c_int
{
unimplemented!
();
platform
::
shutdown
(
socket
,
how
)
}
}
#[no_mangle]
#[no_mangle]
...
@@ -172,9 +172,9 @@ pub unsafe extern "C" fn socket(domain: c_int, kind: c_int, protocol: c_int) ->
...
@@ -172,9 +172,9 @@ pub unsafe extern "C" fn socket(domain: c_int, kind: c_int, protocol: c_int) ->
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
socketpair
(
pub
unsafe
extern
"C"
fn
socketpair
(
domain
:
c_int
,
domain
:
c_int
,
_type
:
c_int
,
kind
:
c_int
,
protocol
:
c_int
,
protocol
:
c_int
,
socket_vector
:
[
c_int
;
2
]
,
socket_vector
:
*
mut
c_int
,
)
->
c_int
{
)
->
c_int
{
unimplemented!
();
platform
::
socketpair
(
domain
,
kind
,
protocol
,
socket_vector
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment