Skip to content

Commit

Permalink
options/posix: Implement swab
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennisbonke committed Jul 26, 2024
1 parent 195b55d commit 2acb421
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions options/posix/generic/unistd-stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,15 @@ int setuid(uid_t uid) {
return 0;
}

void swab(const void *__restrict, void *__restrict, ssize_t) {
__ensure(!"Not implemented");
__builtin_unreachable();
void swab(const void *_src, void *_dest, ssize_t n) {
const char *src = reinterpret_cast<const char *>(_src);
char *dest = reinterpret_cast<char *>(_dest);
for(; n > 1; n -= 2) {
dest[0] = src[1];
dest[1] = src[0];
dest += 2;
src += 2;
}
}

int symlink(const char *target_path, const char *link_path) {
Expand Down
2 changes: 1 addition & 1 deletion options/posix/include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ pid_t setsid(void);
int setuid(uid_t);
void setusershell(void);
unsigned int sleep(unsigned int);
void swab(const void *__restrict, void *__restrict, ssize_t);
void swab(const void *_src, void *_dest, ssize_t n);
int symlink(const char *, const char *);
int symlinkat(const char *, int, const char *);
void sync(void);
Expand Down

0 comments on commit 2acb421

Please sign in to comment.