From 41f5ae91719f3d989a02b95c3afcda6b857eef57 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 26 Jan 2012 11:58:35 +0800 Subject: [PATCH] Usermode - Cleaning up while attempting to port dropbear/openssl --- Usermode/include/acess/intdefs.h | 35 ++++++++++++++++++++++++++++++++ Usermode/include/errno.h | 15 +++++++++++++- Usermode/include/signal.h | 6 ++++++ Usermode/include/stdint.h | 33 +++++++++++------------------- Usermode/include/stdio.h | 1 + Usermode/include/sys/stat.h | 15 +++++++------- Usermode/include/sys/types.h | 6 ++++++ Usermode/include/time.h | 9 ++++++++ 8 files changed, 91 insertions(+), 29 deletions(-) create mode 100644 Usermode/include/acess/intdefs.h diff --git a/Usermode/include/acess/intdefs.h b/Usermode/include/acess/intdefs.h new file mode 100644 index 00000000..c33e7d54 --- /dev/null +++ b/Usermode/include/acess/intdefs.h @@ -0,0 +1,35 @@ +/* + */ +#ifndef _ACESS_INTDEFS_H_ +#define _ACESS_INTDEFS_H_ + +#define INT_MIN -0x80000000 +#define INT_MAX 0x7FFFFFFF + +typedef unsigned char __uint8_t; +typedef unsigned short __uint16_t; +typedef unsigned int __uint32_t; +typedef unsigned long long __uint64_t; + +typedef signed char __int8_t; +typedef signed short __int16_t; +typedef signed int __int32_t; +typedef signed long long __int64_t; + +#if ARCHDIR_is_x86 +typedef __int32_t __intptr_t; +typedef __uint32_t __uintptr_t; +#elif ARCHDIR_is_x86_64 +typedef __int64_t __intptr_t; +typedef __uint64_t __uintptr_t; +#elif ARCHDIR_is_armv7 +typedef __int32_t __intptr_t; +typedef __uint32_t __uintptr_t; +#else +# error "Unknown pointer size" +#endif + +//typedef uint64_t off_t; + +#endif + diff --git a/Usermode/include/errno.h b/Usermode/include/errno.h index 738541d1..ea352f3b 100644 --- a/Usermode/include/errno.h +++ b/Usermode/include/errno.h @@ -3,13 +3,26 @@ // TODO: Fully implement errno.h, make sure it matches the kernel one +extern int _errno; #define errno _errno #define strerror(_x) "Unimplemented" enum { - EINVAL + EOK, + EINVAL, + ERANGE, + ENODEV, + EBADF, + EINTR, + EAGAIN, + ENOMEM, + + EADDRNOTAVAIL, + EINPROGRESS, + + E_LAST }; #endif diff --git a/Usermode/include/signal.h b/Usermode/include/signal.h index f71b2e73..cc72b00b 100644 --- a/Usermode/include/signal.h +++ b/Usermode/include/signal.h @@ -8,7 +8,13 @@ #ifndef _SIGNAL_H_ #define _SIGNAL_H_ +#define SIG_DFL ((void*)0) +#define SIG_ERR ((void*)-1) +#define SIGABRT 6 + +#define SIGPIPE 1001 +#define SIGCHLD 1002 #endif diff --git a/Usermode/include/stdint.h b/Usermode/include/stdint.h index d0f949ef..5df57eae 100644 --- a/Usermode/include/stdint.h +++ b/Usermode/include/stdint.h @@ -3,31 +3,22 @@ #ifndef _STDINT_H_ #define _STDINT_H_ +#include "acess/intdefs.h" + #define INT_MIN -0x80000000 #define INT_MAX 0x7FFFFFFF -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; - -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; -typedef signed long long int64_t; +typedef __uint8_t uint8_t; +typedef __uint16_t uint16_t; +typedef __uint32_t uint32_t; +typedef __uint64_t uint64_t; +typedef __int8_t int8_t; +typedef __int16_t int16_t; +typedef __int32_t int32_t; +typedef __int64_t int64_t; -#if ARCHDIR_is_x86 -typedef int32_t intptr_t; -typedef uint32_t uintptr_t; -#elif ARCHDIR_is_x86_64 -typedef int64_t intptr_t; -typedef uint64_t uintptr_t; -#elif ARCHDIR_is_armv7 -typedef int32_t intptr_t; -typedef uint32_t uintptr_t; -#else -# error "Unknown pointer size" -#endif +typedef __intptr_t intptr_t; +typedef __uintptr_t uintptr_t; //typedef uint64_t off_t; diff --git a/Usermode/include/stdio.h b/Usermode/include/stdio.h index 8d950656..be4f20aa 100644 --- a/Usermode/include/stdio.h +++ b/Usermode/include/stdio.h @@ -13,6 +13,7 @@ typedef struct sFILE FILE; /* === CONSTANTS === */ #define EOF (-1) +#define BUFSIZ 1024 /* --- Standard IO --- */ extern int printf(const char *format, ...); diff --git a/Usermode/include/sys/stat.h b/Usermode/include/sys/stat.h index 10384bae..ecd0fa32 100644 --- a/Usermode/include/sys/stat.h +++ b/Usermode/include/sys/stat.h @@ -5,18 +5,19 @@ #ifndef _SYS_STAT_H_ #define _SYS_STAT_H_ -#include /* Evil */ -#include +#include /* Evil */ +#include "../stddef.h" +; typedef void *dev_t; /* TODO: How to identify a device with Acess */ -typedef uint64_t ino_t; +typedef __uint64_t ino_t; typedef unsigned int blksize_t; -typedef uint64_t blkcnt_t; +typedef __uint64_t blkcnt_t; typedef unsigned int nlink_t; -typedef uint32_t mode_t; +typedef __uint32_t mode_t; -typedef uint32_t uid_t; -typedef uint32_t gid_t; +typedef __uint32_t uid_t; +typedef __uint32_t gid_t; #define S_IFMT 0170000 /* type of file */ #define S_IFDIR 0040000 /* directory */ diff --git a/Usermode/include/sys/types.h b/Usermode/include/sys/types.h index 0cc50d16..206211dd 100644 --- a/Usermode/include/sys/types.h +++ b/Usermode/include/sys/types.h @@ -3,6 +3,8 @@ #ifndef _SYS_TYPES_H #define _SYS_TYPES_H +#include + typedef struct stat t_fstat; #define FD_SETSIZE 128 @@ -52,6 +54,10 @@ extern void FD_CLR(int fd, fd_set *fdsetp); extern void FD_SET(int fd, fd_set *fdsetp); extern int FD_ISSET(int fd, fd_set *fdsetp); +typedef __uint8_t u_int8_t; +typedef __uint16_t u_int16_t; +typedef __uint32_t u_int32_t; + #include "../sys/stat.h" #endif diff --git a/Usermode/include/time.h b/Usermode/include/time.h index 7861255f..bd7afce9 100644 --- a/Usermode/include/time.h +++ b/Usermode/include/time.h @@ -8,6 +8,9 @@ #ifndef _TIME_H_ #define _TIME_H_ +#include +#include // time_t + struct tm { int tm_sec; @@ -21,5 +24,11 @@ struct tm int tm_isdst; }; +#define CLOCKS_PER_SEC 1000 + +typedef signed long long clock_t; + +extern clock_t clock(); + #endif -- 2.20.1