From 85362e8a4c919b58cd261345d29f26bae4ad75e2 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 11 Dec 2014 17:33:53 +0800 Subject: [PATCH] Usermode - More hackery to get glib compiling --- Usermode/Libraries/libc.so_src/errno.c | 1 + .../libc.so_src/include_exp/stdlib.h | 2 + Usermode/Libraries/libpthread.so_src/Makefile | 2 +- .../libpthread.so_src/include_exp/pthread.h | 2 +- Usermode/Libraries/libpthread.so_src/thread.c | 44 +++++++++++++++++++ Usermode/Libraries/libresolv.so_src/Makefile | 16 +++++++ .../include_exp/arpa/nameser.h | 16 +++++++ .../libresolv.so_src/include_exp/resolv.h | 20 +++++++++ Usermode/Libraries/libresolv.so_src/resolv.c | 33 ++++++++++++++ 9 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 Usermode/Libraries/libpthread.so_src/thread.c create mode 100644 Usermode/Libraries/libresolv.so_src/Makefile create mode 100644 Usermode/Libraries/libresolv.so_src/include_exp/arpa/nameser.h create mode 100644 Usermode/Libraries/libresolv.so_src/include_exp/resolv.h create mode 100644 Usermode/Libraries/libresolv.so_src/resolv.c diff --git a/Usermode/Libraries/libc.so_src/errno.c b/Usermode/Libraries/libc.so_src/errno.c index f5a142a8..295183c4 100644 --- a/Usermode/Libraries/libc.so_src/errno.c +++ b/Usermode/Libraries/libc.so_src/errno.c @@ -56,6 +56,7 @@ EXPORT char *strerror(int errnum) case EAFNOSUPPORT: return "Address family not supported"; case EADDRINUSE: return "Address already in use"; case ETIMEDOUT: return "Operation timed out"; + case EOPNOTSUPP: return "Operation not supported on socket"; case EINTERNAL: return "Internal error"; } diff --git a/Usermode/Libraries/libc.so_src/include_exp/stdlib.h b/Usermode/Libraries/libc.so_src/include_exp/stdlib.h index 07fc81f4..fa923eef 100644 --- a/Usermode/Libraries/libc.so_src/include_exp/stdlib.h +++ b/Usermode/Libraries/libc.so_src/include_exp/stdlib.h @@ -112,6 +112,8 @@ extern int rand_p(unsigned int *seedp); # define SEEK_END (-1) #endif +#define MB_CUR_MAX 5 // (C99) Max number of bytes in a single multibyte character (UTF8=5) + #ifdef __cplusplus } #endif diff --git a/Usermode/Libraries/libpthread.so_src/Makefile b/Usermode/Libraries/libpthread.so_src/Makefile index fe3fc8c2..0870c0cf 100644 --- a/Usermode/Libraries/libpthread.so_src/Makefile +++ b/Usermode/Libraries/libpthread.so_src/Makefile @@ -6,7 +6,7 @@ CPPFLAGS += CFLAGS += -Wall LDFLAGS += -lc -soname libpthread.so -OBJ = main.o +OBJ = main.o thread.o BIN = libpthread.so include ../Makefile.tpl diff --git a/Usermode/Libraries/libpthread.so_src/include_exp/pthread.h b/Usermode/Libraries/libpthread.so_src/include_exp/pthread.h index 8f4f779e..376fb0e2 100644 --- a/Usermode/Libraries/libpthread.so_src/include_exp/pthread.h +++ b/Usermode/Libraries/libpthread.so_src/include_exp/pthread.h @@ -60,7 +60,7 @@ struct pthread_mutex_s { void* futex; }; -#define PTHREAD_MUTEX_INITIALIZER ((struct pthread_mutex_s){NULL}) +#define PTHREAD_MUTEX_INITIALIZER ((struct pthread_mutex_s){0}) typedef struct pthread_mutex_s pthread_mutex_t; extern int pthread_mutex_init(pthread_mutex_t * mutex, const pthread_mutexattr_t *attrs); extern int pthread_mutex_lock(pthread_mutex_t *lock); diff --git a/Usermode/Libraries/libpthread.so_src/thread.c b/Usermode/Libraries/libpthread.so_src/thread.c new file mode 100644 index 00000000..4b5f51fe --- /dev/null +++ b/Usermode/Libraries/libpthread.so_src/thread.c @@ -0,0 +1,44 @@ +/* + * Acess2 libpthread + * - By John Hodge (thePowersGang) + * + * thread.c + * - Thread management for pthreads + */ +#include +#include + +int pthread_create(pthread_t *threadptr, const pthread_attr_t * attrs, void* (*fcn)(void*), void* arg) +{ + assert(!"TODO: pthread_create"); + return 0; +} +int pthread_detach(pthread_t thread) +{ + assert(!"TODO: pthread_detach"); + return 0; +} +int pthread_join(pthread_t thread, void **retvalptr) +{ + assert(!"TODO: pthread_join"); + return 0; +} +int pthread_cancel(pthread_t thread) +{ + assert(!"TODO: pthread_cancel"); + return 0; +} +int pthread_equal(pthread_t t1, pthread_t t2) +{ + assert(!"TODO: pthread_equal"); + return 0; +} +pthread_t pthread_self(void) +{ + assert(!"TODO: pthread_self"); + return (pthread_t){0}; +} +void pthread_exit(void* retval) +{ + assert(!"TODO: pthread_create"); +} diff --git a/Usermode/Libraries/libresolv.so_src/Makefile b/Usermode/Libraries/libresolv.so_src/Makefile new file mode 100644 index 00000000..21eb942d --- /dev/null +++ b/Usermode/Libraries/libresolv.so_src/Makefile @@ -0,0 +1,16 @@ +# Acess2 BSD "resolv" library +# Makefile + +-include ../Makefile.cfg + +CPPFLAGS += +CFLAGS += -Wextra +ASFLAGS += +LDFLAGS += +LIBS += -lnet -lpsocket + +OBJ = resolv.o +BIN = libresolv.so + +include ../Makefile.tpl + diff --git a/Usermode/Libraries/libresolv.so_src/include_exp/arpa/nameser.h b/Usermode/Libraries/libresolv.so_src/include_exp/arpa/nameser.h new file mode 100644 index 00000000..5f2532b5 --- /dev/null +++ b/Usermode/Libraries/libresolv.so_src/include_exp/arpa/nameser.h @@ -0,0 +1,16 @@ +/* + * Acess2 POSIX Sockets Emulation + * - By John Hodge (thePowersGang) + * + * arpa/nameser.h + * - BSD name resolution (TODO: move to libresolv) + * + * NOTE: I have no fucking idea who/what defines this header, it's wanted by glib + */ +#ifndef _LIBPSOCKET__ARPA_NAMESER_H_ +#define _LIBPSOCKET__ARPA_NAMESER_H_ + +#define C_IN 0x1 + +#endif + diff --git a/Usermode/Libraries/libresolv.so_src/include_exp/resolv.h b/Usermode/Libraries/libresolv.so_src/include_exp/resolv.h new file mode 100644 index 00000000..66d96573 --- /dev/null +++ b/Usermode/Libraries/libresolv.so_src/include_exp/resolv.h @@ -0,0 +1,20 @@ +/* + */ +#ifndef _LIBRESOLV__RESOLV_H_ +#define _LIBRESOLV__RESOLV_H_ + +extern int res_init(void); + +extern int res_query(const char *dname, int class, int type, unsigned char *answer, int anslen); + +extern int res_search(const char *dname, int class, int type, unsigned char *answer, int anslen); + +extern int res_querydomain(const char *name, const char *domain, int class, int type, unsigned char *answer, int anslen); + +extern int res_mkquery(int op, const char *dname, int class, int type, char *data, int datalen, struct rrec *newrr, char *buf, int buflen); + +extern int res_send(const char *msg, int msglen, char *answer, int anslen); + + +#endif + diff --git a/Usermode/Libraries/libresolv.so_src/resolv.c b/Usermode/Libraries/libresolv.so_src/resolv.c new file mode 100644 index 00000000..e8d121be --- /dev/null +++ b/Usermode/Libraries/libresolv.so_src/resolv.c @@ -0,0 +1,33 @@ +/* + */ + +int res_init(void) +{ + return 1; +} + +int res_query(const char *dname, int class, int type, unsigned char *answer, int anslen) +{ + return 1; +} + +int res_search(const char *dname, int class, int type, unsigned char *answer, int anslen) +{ + return 1; +} + +int res_querydomain(const char *name, const char *domain, int class, int type, unsigned char *answer, int anslen) +{ + return 1; +} + +int res_mkquery(int op, const char *dname, int class, int type, char *data, int datalen, struct rrec *newrr, char *buf, int buflen) +{ + return 1; +} + +int res_send(const char *msg, int msglen, char *answer, int anslen) +{ + return 1; +} + -- 2.20.1