1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibC: Run clang-format on everything.

This commit is contained in:
Andreas Kling 2019-06-07 11:49:03 +02:00
parent 892acfb10d
commit 46527b72d7
40 changed files with 181 additions and 234 deletions

View file

@ -1,7 +1,7 @@
#include <LibC/SharedBuffer.h>
#include <unistd.h>
#include <stdio.h>
#include <AK/kmalloc.h>
#include <LibC/SharedBuffer.h>
#include <stdio.h>
#include <unistd.h>
RetainPtr<SharedBuffer> SharedBuffer::create(pid_t peer, int size)
{

View file

@ -1,7 +1,7 @@
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <errno.h>
extern "C" {
@ -56,6 +56,4 @@ in_addr_t inet_addr(const char* str)
return INADDR_NONE;
return tmp;
}
}

View file

@ -1,6 +1,6 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
extern "C" {
@ -11,8 +11,8 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
dbgprintf("USERSPACE(%d) ASSERTION FAILED: %s\n%s:%u in %s\n", getpid(), msg, file, line, func);
fprintf(stderr, "ASSERTION FAILED: %s\n%s:%u in %s\n", msg, file, line, func);
abort();
for (;;);
for (;;)
;
}
#endif
}

View file

@ -51,5 +51,4 @@ int _start(int argc, char** argv, char** env)
void __cxa_atexit()
{
}
}

View file

@ -5,18 +5,18 @@ extern "C" {
const char _ctype_[256] = {
_C, _C, _C, _C, _C, _C, _C, _C,
_C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C,
_C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C,
_C, _C, _C, _C, _C, _C, _C, _C,
_C, _C, _C, _C, _C, _C, _C, _C,
(char)(_S|_B), _P, _P, _P, _P, _P, _P, _P,
(char)(_S | _B), _P, _P, _P, _P, _P, _P, _P,
_P, _P, _P, _P, _P, _P, _P, _P,
_N, _N, _N, _N, _N, _N, _N, _N,
_N, _N, _P, _P, _P, _P, _P, _P,
_P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U,
_P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U,
_U, _U, _U, _U, _U, _U, _U, _U,
_U, _U, _U, _U, _U, _U, _U, _U,
_U, _U, _U, _P, _P, _P, _P, _P,
_P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
_P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L,
_L, _L, _L, _L, _L, _L, _L, _L,
_L, _L, _L, _L, _L, _L, _L, _L,
_L, _L, _L, _P, _P, _P, _P, _C
@ -35,5 +35,4 @@ int toupper(int c)
return c & ~0x20;
return c;
}
}

View file

@ -9,7 +9,6 @@
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>
extern "C" {
@ -39,7 +38,8 @@ int closedir(DIR* dirp)
return rc;
}
struct [[gnu::packed]] sys_dirent {
struct [[gnu::packed]] sys_dirent
{
ino_t ino;
byte file_type;
size_t namelen;
@ -91,6 +91,4 @@ int dirfd(DIR* dirp)
ASSERT(dirp);
return dirp->fd;
}
}

View file

@ -8,19 +8,18 @@ int dlclose(void*)
ASSERT_NOT_REACHED();
}
char *dlerror()
char* dlerror()
{
ASSERT_NOT_REACHED();
}
void *dlopen(const char*, int)
void* dlopen(const char*, int)
{
ASSERT_NOT_REACHED();
}
void *dlsym(void*, const char*)
void* dlsym(void*, const char*)
{
ASSERT_NOT_REACHED();
}
}

View file

@ -1,8 +1,8 @@
#include <Kernel/Syscall.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <Kernel/Syscall.h>
extern "C" {
@ -14,5 +14,4 @@ int fcntl(int fd, int cmd, ...)
int rc = syscall(SC_fcntl, fd, cmd, extra_arg);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -40,20 +40,20 @@
#include <string.h>
#include <unistd.h>
int opterr = 1; /* if error message should be printed */
int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */
int optopt; /* character checked for validity */
int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
char* optarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
int getopt(int nargc, char* const nargv[], const char* ostr)
{
static const char* place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
char* oli; /* option letter list index */
ASSERT(nargv != NULL);
ASSERT(ostr != NULL);
@ -70,7 +70,7 @@ int getopt(int nargc, char* const nargv[], const char* ostr)
place = EMSG;
return -1;
}
} /* option letter okay? */
} /* option letter okay? */
if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, optopt))) {
/*
* if the user didn't specify '-' as an option,
@ -88,8 +88,7 @@ int getopt(int nargc, char* const nargv[], const char* ostr)
optarg = NULL;
if (!*place)
++optind;
}
else { /* need an argument */
} else { /* need an argument */
if (*place) /* no white space */
optarg = const_cast<char*>(place);
else if (nargc <= ++optind) { /* no arg */
@ -99,8 +98,7 @@ int getopt(int nargc, char* const nargv[], const char* ostr)
if (opterr)
fprintf(stderr, "option requires an argument -- %c\n", optopt);
return BADCH;
}
else /* white space */
} else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;

View file

@ -1,9 +1,9 @@
#include <AK/AKString.h>
#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <AK/AKString.h>
#include <unistd.h>
extern "C" {
@ -138,5 +138,4 @@ int initgroups(const char* user, gid_t extra_gid)
gids[count++] = extra_gid;
return setgroups(count, gids);
}
}

View file

@ -1,8 +1,8 @@
#include <Kernel/Syscall.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <Kernel/Syscall.h>
extern "C" {
@ -14,6 +14,4 @@ int ioctl(int fd, unsigned request, ...)
int rc = syscall(SC_ioctl, fd, request, arg);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,5 +1,5 @@
#include <locale.h>
#include <assert.h>
#include <locale.h>
#include <stdio.h>
extern "C" {
@ -20,5 +20,4 @@ struct lconv* localeconv()
{
return &default_locale;
}
}

View file

@ -1,11 +1,11 @@
#include <AK/Bitmap.h>
#include <AK/InlineLinkedList.h>
#include <AK/Vector.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <serenity.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
// FIXME: Thread safety.
@ -16,7 +16,7 @@
#define FREE_SCRUB_BYTE 0x82
#define MAGIC_PAGE_HEADER 0x42657274
#define MAGIC_BIGALLOC_HEADER 0x42697267
#define PAGE_ROUND_UP(x) ((((size_t)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)))
#define PAGE_ROUND_UP(x) ((((size_t)(x)) + PAGE_SIZE - 1) & (~(PAGE_SIZE - 1)))
static const size_t number_of_chunked_blocks_to_keep_around_per_size_class = 32;
static const size_t number_of_big_blocks_to_keep_around_per_size_class = 8;
@ -45,7 +45,8 @@ struct FreelistEntry {
FreelistEntry* next;
};
struct ChunkedBlock : public CommonHeader, public InlineLinkedListNode<ChunkedBlock> {
struct ChunkedBlock : public CommonHeader
, public InlineLinkedListNode<ChunkedBlock> {
ChunkedBlock(size_t bytes_per_chunk)
{
m_magic = MAGIC_PAGE_HEADER;
@ -59,7 +60,6 @@ struct ChunkedBlock : public CommonHeader, public InlineLinkedListNode<ChunkedBl
else
entry->next = nullptr;
}
}
ChunkedBlock* m_prev { nullptr };
@ -309,6 +309,4 @@ void __malloc_init()
if (getenv("LIBC_LOG_MALLOC"))
s_log_malloc = true;
}
}

View file

@ -1,7 +1,7 @@
#include <mman.h>
#include <errno.h>
#include <stdio.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <mman.h>
#include <stdio.h>
extern "C" {
@ -50,5 +50,4 @@ int shm_unlink(const char* name)
int rc = syscall(SC_unlink, name);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,5 +1,5 @@
#include <mntent.h>
#include <assert.h>
#include <mntent.h>
extern "C" {
@ -8,6 +8,4 @@ struct mntent* getmntent(FILE*)
ASSERT_NOT_REACHED();
return nullptr;
}
}

View file

@ -1,6 +1,6 @@
#include <poll.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <poll.h>
extern "C" {
@ -9,6 +9,4 @@ int poll(struct pollfd* fds, int nfds, int timeout)
int rc = syscall(SC_poll, fds, nfds, timeout);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,9 +1,9 @@
#include <AK/AKString.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <AK/AKString.h>
#include <unistd.h>
extern "C" {
@ -125,5 +125,4 @@ next_entry:
strncpy(__pwdb_entry->shell_buffer, e_shell.characters(), PWDB_STR_MAX_LEN);
return __pwdb_entry;
}
}

View file

@ -35,16 +35,16 @@
static char sccsid[] = "@(#)qsort.c 5.9 (Berkeley) 2/23/91";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <stdlib.h>
#include <sys/types.h>
static void insertion_sort(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
static void insertion_sort_r(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, const void*, void*), void* arg);
void qsort(void* bot, size_t nmemb, size_t size, int (*compar)(const void *, const void *))
void qsort(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, const void*))
{
if (nmemb <= 1)
return;
if (nmemb <= 1)
return;
insertion_sort(bot, nmemb, size, compar);
}
@ -64,27 +64,29 @@ void insertion_sort(void* bot, size_t nmemb, size_t size, int (*compar)(const vo
char *s1, *s2, *t1, *t2, *top;
top = (char*)bot + nmemb * size;
for (t1 = (char*)bot + size; t1 < top;) {
for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2) < 0;);
if (t1 != (t2 += size)) {
for (cnt = size; cnt--; ++t1) {
ch = *t1;
for (s1 = s2 = t1; (s2 -= size) >= t2; s1 = s2)
*s1 = *s2;
*s1 = ch;
}
} else
t1 += size;
}
}
void insertion_sort_r(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, const void*, void*), void* arg)
{
int cnt;
unsigned char ch;
char *s1, *s2, *t1, *t2, *top;
top = (char*)bot + nmemb * size;
for (t1 = (char*)bot + size; t1 < top;) {
for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2, arg) < 0;);
for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2) < 0;)
;
if (t1 != (t2 += size)) {
for (cnt = size; cnt--; ++t1) {
ch = *t1;
for (s1 = s2 = t1; (s2 -= size) >= t2; s1 = s2)
*s1 = *s2;
*s1 = ch;
}
} else
t1 += size;
}
}
void insertion_sort_r(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, const void*, void*), void* arg)
{
int cnt;
unsigned char ch;
char *s1, *s2, *t1, *t2, *top;
top = (char*)bot + nmemb * size;
for (t1 = (char*)bot + size; t1 < top;) {
for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2, arg) < 0;)
;
if (t1 != (t2 += size)) {
for (cnt = size; cnt--; ++t1) {
ch = *t1;

View file

@ -28,10 +28,10 @@
* SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
static const char* determine_base(const char* p, int& base)
{
@ -119,31 +119,32 @@ int atob(unsigned int* vp, const char* p, int base)
#define ISSPACE " \t\n\r\f\v"
int vsscanf(const char *buf, const char *s, va_list ap)
int vsscanf(const char* buf, const char* s, va_list ap)
{
int base = 10;
char *t;
char* t;
char tmp[BUFSIZ];
bool noassign = false;
int count = 0;
int width = 0;
while (*s && *buf) {
while (isspace (*s))
while (isspace(*s))
s++;
if (*s == '%') {
s++;
for (; *s; s++) {
if (strchr ("dibouxcsefg%", *s))
if (strchr("dibouxcsefg%", *s))
break;
if (*s == '*')
noassign = true;
else if (*s >= '1' && *s <= '9') {
const char* tc;
for (tc = s; isdigit(*s); s++);
strncpy (tmp, tc, s - tc);
for (tc = s; isdigit(*s); s++)
;
strncpy(tmp, tc, s - tc);
tmp[s - tc] = '\0';
atob ((uint32_t*)&width, tmp, 10);
atob((uint32_t*)&width, tmp, 10);
s--;
}
}
@ -180,7 +181,7 @@ int vsscanf(const char *buf, const char *s, va_list ap)
if (isspace(*(s + 1)) || *(s + 1) == 0) {
width = strcspn(buf, ISSPACE);
} else {
auto* p = strchr(buf, *(s+1));
auto* p = strchr(buf, *(s + 1));
if (p)
width = p - buf;
else {
@ -204,7 +205,7 @@ int vsscanf(const char *buf, const char *s, va_list ap)
++s;
} else {
while (isspace(*buf))
buf++;
buf++;
if (*s != *buf)
break;
else {

View file

@ -1,6 +1,6 @@
#include <sched.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <sched.h>
extern "C" {
@ -22,17 +22,15 @@ int sched_get_priority_max(int policy)
return 3; // High
}
int sched_setparam(pid_t pid, const struct sched_param *param)
int sched_setparam(pid_t pid, const struct sched_param* param)
{
int rc = syscall(SC_sched_setparam, pid, param);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int sched_getparam(pid_t pid, struct sched_param *param)
int sched_getparam(pid_t pid, struct sched_param* param)
{
int rc = syscall(SC_sched_getparam, pid, param);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,7 +1,7 @@
#pragma once
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS
@ -18,7 +18,7 @@ struct sched_param {
int sched_get_priority_min(int policy);
int sched_get_priority_max(int policy);
int sched_setparam(pid_t pid, const struct sched_param *param);
int sched_getparam(pid_t pid, struct sched_param *param);
int sched_setparam(pid_t pid, const struct sched_param* param);
int sched_getparam(pid_t pid, struct sched_param* param);
__END_DECLS

View file

@ -1,10 +1,10 @@
#include <unistd.h>
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <setjmp.h>
#include <assert.h>
#include <Kernel/Syscall.h>
#include <unistd.h>
extern "C" {
@ -160,5 +160,4 @@ int sigsuspend(const sigset_t*)
dbgprintf("FIXME: Implement sigsuspend()\n");
ASSERT_NOT_REACHED();
}
}

View file

@ -1,8 +1,8 @@
#include <sys/stat.h>
#include <errno.h>
#include <assert.h>
#include <stdio.h>
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
extern "C" {
@ -28,6 +28,4 @@ int fchmod(int fd, mode_t mode)
int rc = syscall(SC_fchmod, fd, mode);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -11,7 +11,6 @@
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <unistd.h>
extern "C" {
@ -573,6 +572,4 @@ FILE* tmpfile()
dbgprintf("FIXME: Implement tmpfile()\n");
ASSERT_NOT_REACHED();
}
}

View file

@ -18,7 +18,7 @@
extern "C" {
typedef void(*__atexit_handler)();
typedef void (*__atexit_handler)();
static int __atexit_handler_count = 0;
static __atexit_handler __atexit_handlers[32];
@ -41,7 +41,6 @@ int atexit(void (*handler)())
return 0;
}
void abort()
{
raise(SIGABRT);
@ -98,8 +97,8 @@ int unsetenv(const char* name)
return 0; // not found: no failure.
// Shuffle the existing array down by one.
memmove(&environ[skip], &environ[skip+1], ((environ_size-1)-skip) * sizeof(environ[0]));
environ[environ_size-1] = nullptr;
memmove(&environ[skip], &environ[skip + 1], ((environ_size - 1) - skip) * sizeof(environ[0]));
environ[environ_size - 1] = nullptr;
free_environment_variable_if_needed(name);
return 0;
@ -143,7 +142,7 @@ int putenv(char* new_var)
// At this point, we need to append the new var.
// 2 here: one for the new var, one for the sentinel value.
char **new_environ = (char**)malloc((environ_size + 2) * sizeof(char*));
char** new_environ = (char**)malloc((environ_size + 2) * sizeof(char*));
if (new_environ == nullptr) {
errno = ENOMEM;
return -1;
@ -237,7 +236,7 @@ static unsigned long s_next_rand = 1;
int rand()
{
s_next_rand = s_next_rand * 1103515245 + 12345;
return((unsigned)(s_next_rand/((RAND_MAX + 1) * 2)) % (RAND_MAX + 1));
return ((unsigned)(s_next_rand / ((RAND_MAX + 1) * 2)) % (RAND_MAX + 1));
}
void srand(unsigned seed)
@ -302,7 +301,7 @@ char* mktemp(char* pattern)
return pattern;
}
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void *, const void *))
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*))
{
dbgprintf("FIXME(LibC): bsearch(%p, %p, %u, %u, %p)\n", key, base, nmemb, size, compar);
ASSERT_NOT_REACHED();
@ -347,8 +346,7 @@ long strtol(const char* str, char** endptr, int base)
c = *s++;
} else if (c == '+')
c = *s++;
if ((base == 0 || base == 16) &&
c == '0' && (*s == 'x' || *s == 'X')) {
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) {
c = s[1];
s += 2;
base = 16;
@ -392,5 +390,4 @@ unsigned long strtoul(const char* str, char** endptr, int base)
ASSERT(value >= 0);
return value;
}
}

View file

@ -1,12 +1,12 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <assert.h>
#include <stdlib.h>
#include <AK/Types.h>
#include <AK/StdLibExtras.h>
#include "ctype.h"
#include <AK/StdLibExtras.h>
#include <AK/Types.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern "C" {
@ -42,7 +42,7 @@ size_t strcspn(const char* s, const char* reject)
do {
if ((rc = *rp++) == c)
return p - 1 - s;
} while(rc);
} while (rc);
}
}
@ -146,17 +146,14 @@ void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
"rep movsl\n"
: "=S"(src), "=D"(dest)
: "S"(src), "D"(dest), "c"(dwords)
: "memory"
);
: "memory");
n -= dwords * sizeof(dword);
if (n == 0)
return dest_ptr;
}
asm volatile(
"rep movsb\n"
:: "S"(src), "D"(dest), "c"(n)
: "memory"
);
"rep movsb\n" ::"S"(src), "D"(dest), "c"(n)
: "memory");
return dest_ptr;
}
@ -173,38 +170,36 @@ void* memset(void* dest_ptr, int c, size_t n)
"rep stosl\n"
: "=D"(dest)
: "D"(dest), "c"(dwords), "a"(expanded_c)
: "memory"
);
: "memory");
n -= dwords * sizeof(dword);
if (n == 0)
return dest_ptr;
}
asm volatile(
"rep stosb\n"
: "=D" (dest), "=c" (n)
: "0" (dest), "1" (n), "a" (c)
: "memory"
);
: "=D"(dest), "=c"(n)
: "0"(dest), "1"(n), "a"(c)
: "memory");
return dest_ptr;
}
void* memmove(void* dest, const void* src, size_t n)
{
if (dest < src)
return memcpy(dest, src, n);
byte *pd = (byte*)dest;
const byte *ps = (const byte*)src;
byte* pd = (byte*)dest;
const byte* ps = (const byte*)src;
for (pd += n, ps += n; n--;)
*--pd = *--ps;
return dest;
}
char* strcpy(char* dest, const char *src)
char* strcpy(char* dest, const char* src)
{
char* originalDest = dest;
while ((*dest++ = *src++) != '\0');
while ((*dest++ = *src++) != '\0')
;
return originalDest;
}
@ -213,7 +208,7 @@ char* strncpy(char* dest, const char* src, size_t n)
size_t i;
for (i = 0; i < n && src[i] != '\0'; ++i)
dest[i] = src[i];
for ( ; i < n; ++i)
for (; i < n; ++i)
dest[i] = '\0';
return dest;
}
@ -242,7 +237,7 @@ void* memchr(const void* ptr, int c, size_t size)
char* strrchr(const char* str, int ch)
{
char *last = nullptr;
char* last = nullptr;
char c;
for (; (c = *str); ++str) {
if (c == ch)
@ -251,21 +246,21 @@ char* strrchr(const char* str, int ch)
return last;
}
char* strcat(char *dest, const char *src)
char* strcat(char* dest, const char* src)
{
size_t dest_length = strlen(dest);
size_t i;
for (i = 0 ; src[i] != '\0' ; i++)
for (i = 0; src[i] != '\0'; i++)
dest[dest_length + i] = src[i];
dest[dest_length + i] = '\0';
return dest;
}
char* strncat(char *dest, const char *src, size_t n)
char* strncat(char* dest, const char* src, size_t n)
{
size_t dest_length = strlen(dest);
size_t i;
for (i = 0 ; i < n && src[i] != '\0' ; i++)
for (i = 0; i < n && src[i] != '\0'; i++)
dest[dest_length + i] = src[i];
dest[dest_length + i] = '\0';
return dest;
@ -387,12 +382,12 @@ char* strstr(const char* haystack, const char* needle)
char* strpbrk(const char* s, const char* accept)
{
while (*s)
if(strchr(accept, *s++))
if (strchr(accept, *s++))
return const_cast<char*>(--s);
return nullptr;
}
char *strtok(char* str, const char* delim)
char* strtok(char* str, const char* delim)
{
(void)str;
(void)delim;
@ -409,10 +404,8 @@ size_t strxfrm(char* dest, const char* src, size_t n)
size_t i;
for (i = 0; i < n && src[i] != '\0'; ++i)
dest[i] = src[i];
for ( ; i < n; ++i)
for (; i < n; ++i)
dest[i] = '\0';
return i;
}
}

View file

@ -1,6 +1,6 @@
#include <strings.h>
#include <assert.h>
#include <ctype.h>
#include <strings.h>
extern "C" {
@ -32,5 +32,4 @@ int strncasecmp(const char* s1, const char* s2, size_t n)
} while (--n);
return 0;
}
}

View file

@ -3,7 +3,7 @@
#define _POSIX_VERSION 200809L
#ifndef ALWAYS_INLINE
#define ALWAYS_INLINE inline __attribute__((always_inline))
# define ALWAYS_INLINE inline __attribute__((always_inline))
#endif
#ifdef __cplusplus

View file

@ -1,7 +1,7 @@
#include <sys/select.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <stdio.h>
#include <sys/select.h>
extern "C" {
@ -11,5 +11,4 @@ int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struc
int rc = syscall(SC_select, &params);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,8 +1,8 @@
#include <sys/socket.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <AK/Assertions.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <stdio.h>
#include <sys/socket.h>
extern "C" {
@ -85,5 +85,4 @@ int getpeername(int sockfd, struct sockaddr* addr, socklen_t* addrlen)
int rc = syscall(SC_getpeername, sockfd, addr, addrlen);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,6 +1,6 @@
#include <sys/uio.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <sys/uio.h>
extern "C" {
@ -9,5 +9,4 @@ ssize_t writev(int fd, const struct iovec* iov, int iov_count)
int rc = syscall(SC_writev, fd, iov, iov_count);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,6 +1,6 @@
#include <assert.h>
#include <sys/wait.h>
#include <unistd.h>
#include <assert.h>
extern "C" {
@ -8,5 +8,4 @@ pid_t wait(int* wstatus)
{
return waitpid(-1, wstatus, 0);
}
}

View file

@ -1,9 +1,9 @@
#include <termcap.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <AK/HashMap.h>
#include <AK/AKString.h>
#include <AK/HashMap.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <termcap.h>
//#define TERMCAP_DEBUG
@ -126,6 +126,4 @@ int tputs(const char* str, int affcnt, int (*putc)(int))
putc(str[i]);
return 0;
}
}

View file

@ -1,8 +1,8 @@
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <Kernel/Syscall.h>
#include <termios.h>
extern "C" {
@ -27,8 +27,8 @@ int tcsetattr(int fd, int optional_actions, const struct termios* t)
int tcflow(int fd, int action)
{
(void) fd;
(void) action;
(void)fd;
(void)action;
ASSERT_NOT_REACHED();
}
@ -48,6 +48,4 @@ speed_t cfgetospeed(const struct termios* tp)
{
return tp->c_ospeed;
}
}

View file

@ -1,9 +1,9 @@
#include <time.h>
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/times.h>
#include <errno.h>
#include <assert.h>
#include <Kernel/Syscall.h>
#include <time.h>
extern "C" {
@ -91,7 +91,7 @@ struct tm* gmtime(const time_t* t)
return localtime(t);
}
char *asctime(const struct tm*)
char* asctime(const struct tm*)
{
ASSERT_NOT_REACHED();
}
@ -117,5 +117,4 @@ clock_t clock()
times(&tms);
return tms.tms_utime + tms.tms_stime;
}
}

View file

@ -1,6 +1,6 @@
#include <sys/times.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <sys/times.h>
clock_t times(struct tms* buf)
{

View file

@ -1,13 +1,12 @@
#include <ulimit.h>
#include <assert.h>
#include <ulimit.h>
extern "C" {
long ulimit(int cmd, long newlimit)
{
(void) cmd;
(void) newlimit;
(void)cmd;
(void)newlimit;
ASSERT_NOT_REACHED();
}
}

View file

@ -1,18 +1,18 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <AK/AKString.h>
#include <AK/Vector.h>
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <Kernel/Syscall.h>
#include <AK/Vector.h>
#include <AK/AKString.h>
#include <unistd.h>
extern "C" {
@ -225,7 +225,7 @@ int stat(const char* path, struct stat* statbuf)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int fstat(int fd, struct stat *statbuf)
int fstat(int fd, struct stat* statbuf)
{
int rc = syscall(SC_fstat, fd, statbuf);
__RETURN_WITH_ERRNO(rc, rc, -1);
@ -378,15 +378,15 @@ int mknod(const char* pathname, mode_t mode, dev_t dev)
long fpathconf(int fd, int name)
{
(void) fd;
(void) name;
(void)fd;
(void)name;
ASSERT_NOT_REACHED();
}
long pathconf(const char* path, int name)
{
(void) path;
(void) name;
(void)path;
(void)name;
ASSERT_NOT_REACHED();
}
@ -451,7 +451,7 @@ char* getlogin()
return nullptr;
}
int create_thread(int(*entry)(void*), void* argument)
int create_thread(int (*entry)(void*), void* argument)
{
int rc = syscall(SC_create_thread, entry, argument);
__RETURN_WITH_ERRNO(rc, rc, -1);
@ -492,5 +492,4 @@ int fsync(int fd)
dbgprintf("FIXME: Implement fsync()\n");
return 0;
}
}

View file

@ -1,6 +1,6 @@
#include <utime.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <utime.h>
extern "C" {
@ -9,6 +9,4 @@ int utime(const char* pathname, const struct utimbuf* buf)
int rc = syscall(SC_utime, (dword)pathname, (dword)buf);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,6 +1,6 @@
#include <sys/utsname.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <sys/utsname.h>
extern "C" {
@ -9,6 +9,4 @@ int uname(struct utsname* buf)
int rc = syscall(SC_uname, buf);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}