Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
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
Service Desk
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
cm-projects
RIOT
Commits
96e0ce8e
Commit
96e0ce8e
authored
8 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
atmega_common: provide implementation for POSIX syscalls
parent
8b5eda90
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cpu/atmega_common/posix_unistd.c
+144
-0
144 additions, 0 deletions
cpu/atmega_common/posix_unistd.c
with
144 additions
and
0 deletions
cpu/atmega_common/posix_unistd.c
0 → 100644
+
144
−
0
View file @
96e0ce8e
/*
* Copyright (C) 2017 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @{
*
* @file
* @brief Implements various POSIX syscalls
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#include
<errno.h>
#include
<sys/stat.h>
#include
<unistd.h>
#ifdef MODULE_VFS
#include
"vfs.h"
#elif defined(MODULE_UART_STDIO)
#include
"uart_stdio.h"
#endif
int
close
(
int
fd
)
{
#ifdef MODULE_VFS
int
res
=
vfs_close
(
fd
);
if
(
res
<
0
)
{
errno
=
-
res
;
return
-
1
;
}
return
res
;
#else
(
void
)
fd
;
errno
=
ENODEV
;
return
-
1
;
#endif
}
off_t
lseek
(
int
fd
,
off_t
off
,
int
whence
)
{
#ifdef MODULE_VFS
off_t
res
=
vfs_lseek
(
fd
,
off
,
whence
);
if
(
res
<
0
)
{
errno
=
-
res
;
return
-
1
;
}
return
res
;
#else
(
void
)
fd
;
(
void
)
off
;
(
void
)
whence
;
errno
=
ENODEV
;
return
-
1
;
#endif
}
int
fcntl
(
int
fd
,
int
cmd
,
int
arg
)
{
#ifdef MODULE_VFS
int
res
=
vfs_fcntl
(
fd
,
cmd
,
arg
);
if
(
res
<
0
)
{
errno
=
-
res
;
return
-
1
;
}
return
res
;
#else
(
void
)
fd
;
(
void
)
cmd
;
(
void
)
arg
;
errno
=
ENODEV
;
return
-
1
;
#endif
}
int
fstat
(
int
fd
,
struct
stat
*
buf
)
{
#ifdef MODULE_VFS
int
res
=
vfs_fstat
(
fd
,
buf
);
if
(
res
<
0
)
{
errno
=
-
res
;
return
-
1
;
}
return
res
;
#else
(
void
)
fd
;
(
void
)
buf
;
errno
=
ENODEV
;
return
-
1
;
#endif
}
ssize_t
read
(
int
fd
,
void
*
dest
,
size_t
count
)
{
#ifdef MODULE_VFS
ssize_t
res
=
vfs_read
(
fd
,
dest
,
count
);
if
(
res
<
0
)
{
errno
=
-
res
;
return
-
1
;
}
return
res
;
#elif defined(MODULE_UART_STDIO)
if
(
fd
==
0
)
{
return
uart_stdio_read
(
dest
,
count
);
}
errno
=
EBADF
;
return
-
1
;
#else
(
void
)
fd
;
(
void
)
dest
;
(
void
)
count
;
errno
=
ENODEV
;
return
-
1
;
#endif
}
ssize_t
write
(
int
fd
,
const
void
*
src
,
size_t
count
)
{
#ifdef MODULE_VFS
ssize_t
res
=
vfs_write
(
fd
,
src
,
count
);
if
(
res
<
0
)
{
errno
=
-
res
;
return
-
1
;
}
return
res
;
#elif defined(MODULE_UART_STDIO)
if
(
fd
==
0
)
{
return
uart_stdio_write
(
src
,
count
);
}
errno
=
EBADF
;
return
-
1
;
#else
(
void
)
fd
;
(
void
)
src
;
(
void
)
count
;
errno
=
ENODEV
;
return
-
1
;
#endif
}
/** @} */
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