mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 19:36:47 +00:00
minilibc
This commit is contained in:
parent
77d4854db7
commit
edb21695ae
2
.vscode/c_cpp_properties.json
vendored
2
.vscode/c_cpp_properties.json
vendored
@ -6,7 +6,7 @@
|
|||||||
"${workspaceFolder}/**"
|
"${workspaceFolder}/**"
|
||||||
],
|
],
|
||||||
"defines": [
|
"defines": [
|
||||||
"x86_64",
|
"__x86_64__",
|
||||||
"DEBUG"
|
"DEBUG"
|
||||||
],
|
],
|
||||||
"compilerPath": "/usr/bin/gcc",
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -94,7 +94,8 @@
|
|||||||
"fcntl.h": "c",
|
"fcntl.h": "c",
|
||||||
"types.h": "c",
|
"types.h": "c",
|
||||||
"string.h": "c",
|
"string.h": "c",
|
||||||
"math.h": "c"
|
"math.h": "c",
|
||||||
|
"ipi.h": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.errorSquiggles": "Enabled",
|
"C_Cpp.errorSquiggles": "Enabled",
|
||||||
"esbonio.sphinx.confDir": ""
|
"esbonio.sphinx.confDir": ""
|
||||||
|
2
Makefile
2
Makefile
@ -3,7 +3,7 @@ SUBDIRS = kernel user
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
export ARCH=x86_64
|
export ARCH=__x86_64__
|
||||||
export ROOT_PATH=$(shell pwd)
|
export ROOT_PATH=$(shell pwd)
|
||||||
|
|
||||||
export DEBUG=DEBUG
|
export DEBUG=DEBUG
|
||||||
|
@ -89,7 +89,7 @@ VFS.o: filesystem/VFS/VFS.c
|
|||||||
gcc $(CFLAGS) -c filesystem/VFS/VFS.c -o filesystem/VFS/VFS.o
|
gcc $(CFLAGS) -c filesystem/VFS/VFS.c -o filesystem/VFS/VFS.o
|
||||||
|
|
||||||
# IPI的代码
|
# IPI的代码
|
||||||
ifeq ($(ARCH), x86_64)
|
ifeq ($(ARCH), __x86_64__)
|
||||||
OBJ_LIST += ipi.o
|
OBJ_LIST += ipi.o
|
||||||
LD_LIST += arch/x86_64/x86_64_ipi.o
|
LD_LIST += arch/x86_64/x86_64_ipi.o
|
||||||
ipi.o: arch/x86_64/x86_64_ipi.c
|
ipi.o: arch/x86_64/x86_64_ipi.c
|
||||||
|
12
kernel/arch/arch.h
Normal file
12
kernel/arch/arch.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define ARCH(arch) (defined(AK_ARCH_##arch) && AK_ARCH_##arch)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __i386__
|
||||||
|
# define AK_ARCH_I386 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
|
# define AK_ARCH_X86_64 1
|
||||||
|
#endif
|
@ -8,8 +8,10 @@
|
|||||||
//引入对bool类型的支持
|
//引入对bool类型的支持
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <common/miniLibc/stddef.h>
|
||||||
|
#include <arch/arch.h>
|
||||||
|
|
||||||
|
|
||||||
#define NULL 0
|
|
||||||
|
|
||||||
#define sti() __asm__ __volatile__("sti\n\t" :: \
|
#define sti() __asm__ __volatile__("sti\n\t" :: \
|
||||||
: "memory") //开启外部中断
|
: "memory") //开启外部中断
|
||||||
|
7
kernel/common/miniLibc/stddef.h
Normal file
7
kernel/common/miniLibc/stddef.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "./sys/types.h"
|
||||||
|
|
||||||
|
#define NULL 0
|
||||||
|
|
||||||
|
typedef __PTRDIFF_TYPE__ ptrdiff_t; // Signed integer type of the result of subtracting two pointers.
|
84
kernel/common/miniLibc/sys/types.h
Normal file
84
kernel/common/miniLibc/sys/types.h
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef unsigned char u_char;
|
||||||
|
typedef unsigned short u_short;
|
||||||
|
typedef unsigned int u_int;
|
||||||
|
typedef unsigned long u_long;
|
||||||
|
|
||||||
|
typedef uint32_t uid_t;
|
||||||
|
typedef uint32_t gid_t;
|
||||||
|
typedef long long ssize_t;
|
||||||
|
|
||||||
|
typedef int __pid_t;
|
||||||
|
#define pid_t __pid_t
|
||||||
|
typedef __SIZE_TYPE__ size_t;
|
||||||
|
|
||||||
|
typedef char *caddr_t;
|
||||||
|
|
||||||
|
typedef int id_t;
|
||||||
|
|
||||||
|
typedef uint64_t ino_t;
|
||||||
|
typedef int64_t off_t;
|
||||||
|
|
||||||
|
typedef uint32_t blkcnt_t;
|
||||||
|
typedef uint32_t blksize_t;
|
||||||
|
typedef uint32_t dev_t;
|
||||||
|
typedef uint16_t mode_t;
|
||||||
|
typedef uint32_t nlink_t;
|
||||||
|
|
||||||
|
typedef int64_t time_t;
|
||||||
|
typedef uint32_t useconds_t;
|
||||||
|
typedef int32_t suseconds_t;
|
||||||
|
typedef uint32_t clock_t;
|
||||||
|
|
||||||
|
typedef uint64_t fsblkcnt_t;
|
||||||
|
typedef uint64_t fsfilcnt_t;
|
||||||
|
|
||||||
|
#define __socklen_t_defined
|
||||||
|
#define __socklen_t uint32_t
|
||||||
|
typedef __socklen_t socklen_t;
|
||||||
|
|
||||||
|
struct utimbuf
|
||||||
|
{
|
||||||
|
time_t actime;
|
||||||
|
time_t modtime;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef int pthread_t;
|
||||||
|
typedef int pthread_key_t;
|
||||||
|
typedef uint32_t pthread_once_t;
|
||||||
|
|
||||||
|
typedef struct __pthread_mutex_t
|
||||||
|
{
|
||||||
|
uint32_t lock;
|
||||||
|
pthread_t owner;
|
||||||
|
int level;
|
||||||
|
int type;
|
||||||
|
} pthread_mutex_t;
|
||||||
|
|
||||||
|
typedef void *pthread_attr_t;
|
||||||
|
typedef struct __pthread_mutexattr_t
|
||||||
|
{
|
||||||
|
int type;
|
||||||
|
} pthread_mutexattr_t;
|
||||||
|
|
||||||
|
typedef struct __pthread_cond_t
|
||||||
|
{
|
||||||
|
pthread_mutex_t *mutex;
|
||||||
|
uint32_t value;
|
||||||
|
int clockid; // clockid_t
|
||||||
|
} pthread_cond_t;
|
||||||
|
|
||||||
|
typedef uint64_t pthread_rwlock_t;
|
||||||
|
typedef void *pthread_rwlockattr_t;
|
||||||
|
typedef struct __pthread_spinlock_t
|
||||||
|
{
|
||||||
|
int m_lock;
|
||||||
|
} pthread_spinlock_t;
|
||||||
|
typedef struct __pthread_condattr_t
|
||||||
|
{
|
||||||
|
int clockid; // clockid_t
|
||||||
|
} pthread_condattr_t;
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef x86_64
|
#include <arch/arch.h>
|
||||||
|
#if ARCH(I386) || ARCH(X86_64)
|
||||||
#include <arch/x86_64/x86_64_ipi.h>
|
#include <arch/x86_64/x86_64_ipi.h>
|
||||||
#else
|
#else
|
||||||
#error "error type of arch!"
|
#error "error type of arch!"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user