Compare commits
No commits in common. "e54f033578205d50ce3152ac5d13896d4b649a64" and "a3896c254642e94616fe64e22e5e9f3c7d1c83cf" have entirely different histories.
e54f033578
...
a3896c2546
@ -1,8 +1,6 @@
|
||||
#ifndef _FCNTL_H
|
||||
#define _FCNTL_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Open for reading only. */
|
||||
#define O_RDONLY 1
|
||||
/* Open for writing only. */
|
||||
@ -44,10 +42,6 @@ extern "C"
|
||||
/* Opens the file specified by pathname. Returns a file descriptor on success, or -1 on error. */
|
||||
int open(const char* pathname, int flags, ...);
|
||||
|
||||
/* Opens the file specified by pathname, creating it if it doesn't exist or overwriting it otherwise. Calling this
|
||||
* function is equivalent to calling open(pathname, O_WRONLY|O_CREAT|O_TRUNC, mode) */
|
||||
int creat(const char* pathname, mode_t mode);
|
||||
|
||||
/* Performs an operation on the file descriptor fd determined by cmd. */
|
||||
int fcntl(int fd, int cmd, ...);
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#define ATEXIT_MAX 32
|
||||
|
||||
#define NAME_MAX 64
|
||||
#define PATH_MAX 4096
|
||||
|
||||
#define PAGESIZE 4096
|
||||
#define PAGE_SIZE 4096
|
||||
|
@ -6,20 +6,15 @@
|
||||
#include <luna/os-limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// Standard IO streams.
|
||||
#define STDIN_FILENO 0 // The standard input stream.
|
||||
#define STDOUT_FILENO 1 // The standard output stream.
|
||||
#define STDERR_FILENO 2 // The standard error stream.
|
||||
|
||||
// Possible arguments to access()
|
||||
#define F_OK 0 // Check for a file's existence.
|
||||
#define R_OK 1 // Check whether a file is readable.
|
||||
#define W_OK 2 // Check whether a file is writable.
|
||||
#define X_OK 4 // Check whether a file is executable.
|
||||
|
||||
// Name values for pathconf()
|
||||
#define _PC_PATH_MAX 0 // Maximum length of a path relative to the provided name.
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
@ -108,12 +103,6 @@ extern "C"
|
||||
int chdir(const char* path); // Not implemented.
|
||||
int pipe(int fd[2]); // Not implemented.
|
||||
|
||||
/* Returns a configuration value for the file at path. */
|
||||
long pathconf(const char* path, int name);
|
||||
|
||||
/* Returns the maximum number of file descriptors a process can have open at the same time. */
|
||||
int getdtablesize(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,24 +1,11 @@
|
||||
#ifndef _WCHAR_H
|
||||
#define _WCHAR_H
|
||||
|
||||
#include <bits/macros.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef unsigned int wint_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Return the length of a wide-character string. */
|
||||
size_t wcslen(const wchar_t* str);
|
||||
|
||||
/* Concatenates the wide-character string src into dest. */
|
||||
__lc_is_deprecated wchar_t* wcscat(wchar_t* dest, const wchar_t* src);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#ifndef __WINT_TYPE__
|
||||
#define __WINT_TYPE__ unsigned int
|
||||
#endif
|
||||
typedef __WINT_TYPE__ wint_t;
|
||||
|
||||
#endif
|
@ -15,13 +15,6 @@ extern "C"
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
int creat(const char* pathname, mode_t mode)
|
||||
{
|
||||
return (int)__lc_fast_syscall3(SYS_open, pathname, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
mode); // we don't need to pass this through to open(), we can avoid variadic
|
||||
// stuff since we're sure mode exists.
|
||||
}
|
||||
|
||||
int fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
@ -203,9 +203,9 @@ extern "C"
|
||||
size_t dest_len = strlen(dest);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; *(src + i); i++) *(dest + dest_len + i) = *(src + i);
|
||||
for (i = 0; *(src + i); i++) *(char*)(dest + dest_len + i) = *(const char*)(src + i);
|
||||
|
||||
*(dest + dest_len + i) = '\0';
|
||||
*(char*)(dest + dest_len + i) = '\0';
|
||||
|
||||
return dest;
|
||||
}
|
||||
@ -215,9 +215,9 @@ extern "C"
|
||||
size_t dest_len = strlen(dest);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < max && *(src + i); i++) *(dest + dest_len + i) = *(src + i);
|
||||
for (i = 0; i < max && *(src + i); i++) *(char*)(dest + dest_len + i) = *(const char*)(src + i);
|
||||
|
||||
*(dest + dest_len + i) = '\0';
|
||||
*(char*)(dest + dest_len + i) = '\0';
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
@ -163,18 +163,4 @@ extern "C"
|
||||
{
|
||||
NOT_IMPLEMENTED("pipe");
|
||||
}
|
||||
|
||||
long pathconf(const char* path, int name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case _PC_PATH_MAX: return PATH_MAX - (strlen(path) + 1);
|
||||
default: errno = EINVAL; return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int getdtablesize(void)
|
||||
{
|
||||
return OPEN_MAX;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#include <wchar.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
size_t wcslen(const wchar_t* str)
|
||||
{
|
||||
const wchar_t* i = str;
|
||||
for (; *i; ++i)
|
||||
;
|
||||
return (i - str);
|
||||
}
|
||||
|
||||
wchar_t* wcscat(wchar_t* dest, const wchar_t* src)
|
||||
{
|
||||
size_t dest_len = wcslen(dest);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; *(src + i); i++) *(dest + dest_len + i) = *(src + i);
|
||||
|
||||
*(dest + dest_len + i) = L'\0';
|
||||
|
||||
return dest;
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ DESTDIR := $(LUNA_ROOT)/initrd/bin
|
||||
build:
|
||||
@mkdir -p $(TESTDIR)/bin
|
||||
$(LUNA_ROOT)/tools/sync-libc.sh
|
||||
$(CC) $(TESTDIR)/string.c $(TESTDIR)/stdlib.c $(TESTDIR)/wchar.c $(TESTDIR)/Test.c -I$(LUNA_ROOT)/tests -o $(TESTDIR)/bin/test-libc -Wall -Wextra -Wno-deprecated-declarations -Wno-stringop-overread -Werror
|
||||
$(CC) $(TESTDIR)/string.c $(TESTDIR)/stdlib.c $(TESTDIR)/Test.c -I$(LUNA_ROOT)/tests -o $(TESTDIR)/bin/test-libc -Wall -Wextra -Wno-deprecated-declarations -Wno-stringop-overread -Werror
|
||||
|
||||
install:
|
||||
$(LUNA_ROOT)/tools/clean.sh
|
||||
|
@ -30,9 +30,6 @@ DEFINE_TEST(mktemp);
|
||||
DEFINE_TEST(qsort);
|
||||
DEFINE_TEST(bsearch);
|
||||
|
||||
// wchar.h
|
||||
DEFINE_TEST(wcslen);
|
||||
|
||||
int main()
|
||||
{
|
||||
START_TEST_CASE(string.h);
|
||||
@ -64,7 +61,4 @@ int main()
|
||||
RUN_TEST(mktemp);
|
||||
RUN_TEST(qsort);
|
||||
RUN_TEST(bsearch);
|
||||
|
||||
START_TEST_CASE(wchar.h);
|
||||
RUN_TEST(wcslen);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
#include "Test.h"
|
||||
#include <wchar.h>
|
||||
|
||||
DEFINE_TEST(wcslen)
|
||||
{
|
||||
START_TEST(wcslen);
|
||||
|
||||
const wchar_t* str = L"Hello, World!";
|
||||
|
||||
size_t len = wcslen(str);
|
||||
|
||||
EXPECT_EQ(len, 13);
|
||||
|
||||
wchar_t null[] = {L'\0'};
|
||||
|
||||
len = wcslen(null);
|
||||
|
||||
EXPECT_EQ(len, 0);
|
||||
|
||||
TEST_SUCCESS();
|
||||
}
|
Loading…
Reference in New Issue
Block a user