Merge branch 'master' of git://github.com/thepowersgang/acess2
authorJohn Hodge <[email protected]>
Mon, 12 Jan 2015 11:24:19 +0000 (19:24 +0800)
committerJohn Hodge <[email protected]>
Mon, 12 Jan 2015 11:24:19 +0000 (19:24 +0800)
21 files changed:
Externals/glib/Makefile [new file with mode: 0644]
Externals/glib/patches/config.sub.patch [new file with mode: 0644]
Externals/pkgconfig/patches/config.sub.patch [new file with mode: 0644]
Externals/pkgconfig/patches/glib/config.sub.patch [new file with mode: 0644]
Usermode/Libraries/Makefile.tpl
Usermode/Libraries/libc.so_src/Makefile
Usermode/Libraries/libc.so_src/TEST_string.c [new file with mode: 0644]
Usermode/Libraries/libc.so_src/errno.c
Usermode/Libraries/libc.so_src/include_exp/errno.enum.h
Usermode/Libraries/libc.so_src/include_exp/stdlib.h
Usermode/Libraries/libc.so_src/stdio.c
Usermode/Libraries/libc.so_src/string.c
Usermode/Libraries/libposix.so_src/include_exp/glob.h [new file with mode: 0644]
Usermode/Libraries/libposix.so_src/include_exp/regex.h
Usermode/Libraries/libpthread.so_src/Makefile
Usermode/Libraries/libpthread.so_src/include_exp/pthread.h
Usermode/Libraries/libpthread.so_src/thread.c [new file with mode: 0644]
Usermode/Libraries/libresolv.so_src/Makefile [new file with mode: 0644]
Usermode/Libraries/libresolv.so_src/include_exp/arpa/nameser.h [new file with mode: 0644]
Usermode/Libraries/libresolv.so_src/include_exp/resolv.h [new file with mode: 0644]
Usermode/Libraries/libresolv.so_src/resolv.c [new file with mode: 0644]

diff --git a/Externals/glib/Makefile b/Externals/glib/Makefile
new file mode 100644 (file)
index 0000000..953ef03
--- /dev/null
@@ -0,0 +1,17 @@
+#
+# Acess2 Externals - glib
+# - Patches and Makefile by John Hodge (thePowersGang)
+#
+
+DEPS := libffi
+_NAME := glib
+TARBALL_PATTERN := $(_NAME)-*.tar.xz
+TARBALL_TO_DIR_L := $(_NAME)-%.tar.xz
+TARBALL_TO_DIR_R := $(_NAME)-%
+PATCHES := config.sub
+CONFIGURE_ARGS := glib_cv_stack_grows=no ac_cv_func_posix_getpwuid_r=no ac_cv_func_posix_getgrgid_r=no
+CONFIGURE_ARGS += LDFLAGS=-lpsocket
+
+include ../common_automake.mk
+
+
diff --git a/Externals/glib/patches/config.sub.patch b/Externals/glib/patches/config.sub.patch
new file mode 100644 (file)
index 0000000..f600ad4
--- /dev/null
@@ -0,0 +1,8 @@
+--- glib/config.sub
++++ glib/config.sub
+@@ -1335,2 +1335,5 @@
+               ;;
++      -acess2)
++              os=-acess2
++              ;;
+       -solaris)
diff --git a/Externals/pkgconfig/patches/config.sub.patch b/Externals/pkgconfig/patches/config.sub.patch
new file mode 100644 (file)
index 0000000..b2d7389
--- /dev/null
@@ -0,0 +1,7 @@
+--- bochs-2.6.2_orig/config.sub        2013-06-17 11:39:39.670720710 +0800
++++ bochs-2.6.2/config.sub     2013-06-17 11:48:09.149384231 +0800
+@@ -1344,2 +1344,3 @@
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
++            | -acess2 \
+             | -aos* | -aros* \
+
diff --git a/Externals/pkgconfig/patches/glib/config.sub.patch b/Externals/pkgconfig/patches/glib/config.sub.patch
new file mode 100644 (file)
index 0000000..f600ad4
--- /dev/null
@@ -0,0 +1,8 @@
+--- glib/config.sub
++++ glib/config.sub
+@@ -1335,2 +1335,5 @@
+               ;;
++      -acess2)
++              os=-acess2
++              ;;
+       -solaris)
index 5e241f2..8f548bf 100644 (file)
@@ -43,7 +43,7 @@ else
 V := @
 endif
 
-.PHONY: all clean install postbuild
+.PHONY: all clean install postbuild utest-build utest-run generate_exp
 
 all: _libs $(_BIN) $(_XBIN)
 
@@ -60,16 +60,13 @@ _libs: $(HEADERS)
 
 .PHONY: utest utest-build utest-run $(UTESTS:%=runtest-%)
 
-utest: utest-build utest-run
+utest: utest-build generate_exp utest-run
 
 generate_exp: $(UTESTS:%=EXP_%.txt)
-       @echo > /dev/null
 
 utest-build: $(UTESTS:%=TEST_%)
-       @echo > /dev/null
 
 utest-run: $(UTESTS:%=runtest-%)
-       @echo > /dev/null
 
 $(UTESTS:%=runtest-%): runtest-%: TEST_% EXP_%.txt
        @echo --- [TEST] $*
index 40977e9..64749b3 100644 (file)
@@ -29,8 +29,8 @@ endif
 include ../Makefile.tpl\r
 \r
 EXP_%.txt: TEST_%.native\r
-       ./$< > $@\r
-       rm $<\r
+       @./$< > $@\r
+       @rm $<\r
 EXP_strtoi.txt:\r
        echo -n "" > $@\r
 \r
diff --git a/Usermode/Libraries/libc.so_src/TEST_string.c b/Usermode/Libraries/libc.so_src/TEST_string.c
new file mode 100644 (file)
index 0000000..46fcee5
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ */
+#include <stdio.h>
+#include <string.h>
+
+#define ASSERT(cnd)    printf("ASSERT: "#cnd" == %s\n", ((cnd) ? "pass" : "FAIL"))
+
+int main()
+{
+       ASSERT(strcmp("hello", "world") < 0);
+       ASSERT(strcmp("hello", "hello") == 0);
+       ASSERT(strcmp("wello", "hello") > 0);
+       ASSERT(strcmp("\xff", "\1") > 0);
+       ASSERT(strcmp("\1", "\xff") < 0);
+       ASSERT(strcmp("Hello", "hello") < 0);
+       
+       ASSERT(strncmp("hello world", "hello", 5) == 0);
+       
+       ASSERT(strcasecmp("hello", "world") < 0);
+       ASSERT(strcasecmp("hello", "hello") == 0);
+       ASSERT(strcasecmp("wello", "hello") > 0);
+       ASSERT(strcasecmp("\xff", "\1") > 0);
+       ASSERT(strcasecmp("\1", "\xff") < 0);
+       ASSERT(strcasecmp("Hello", "hello") == 0);
+       ASSERT(strcasecmp("Hello", "Hello") == 0);
+       ASSERT(strcasecmp("hellO", "Hello") == 0);
+       
+       
+       char buf[13];
+       memset(buf, 0, 13);
+       ASSERT(buf[0] == 0);    ASSERT(buf[12] == 0);
+       
+       ASSERT(memchr("\xffhello", 'x', 6) == NULL);
+}
+
index f5a142a..295183c 100644 (file)
@@ -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";
        }
index be8c882..d7b1053 100755 (executable)
@@ -37,8 +37,9 @@ enum libc_eErrorNumbers {
 
        // psockets
        EAFNOSUPPORT,   
-       EADDRINUSE,     // Specified addres is already in use
+       EADDRINUSE,     // (POSIX.1) Specified addres is already in use
        ETIMEDOUT,
+       EOPNOTSUPP,     // (POSIX.1) Operation not supported on socket
        
        EINTERNAL       // Internal Error
 };
index 07fc81f..fa923ee 100644 (file)
@@ -112,6 +112,8 @@ extern int  rand_p(unsigned int *seedp);
 # define SEEK_END      (-1)\r
 #endif\r
 \r
+#define MB_CUR_MAX     5       // (C99) Max number of bytes in a single multibyte character (UTF8=5)\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
index cf2e733..55fd521 100644 (file)
@@ -795,13 +795,12 @@ EXPORT char *fgets(char *s, int size, FILE *fp)
  */\r
 EXPORT int fputc(int c, FILE *fp)\r
 {\r
-       char    ch = c;\r
+       unsigned char   ch = c;\r
        return fwrite(&ch, 1, 1, fp);\r
 }\r
 \r
 EXPORT int putchar(int c)\r
 {\r
-       c &= 0xFF;\r
        return fputc(c, stdout);\r
 }\r
 \r
@@ -811,7 +810,7 @@ EXPORT int putchar(int c)
  */\r
 EXPORT int fgetc(FILE *fp)\r
 {\r
-       char    ret = 0;\r
+       unsigned char   ret = 0;\r
        if( fread(&ret, 1, 1, fp) != 1 )\r
                return -1;\r
        return ret;\r
@@ -825,7 +824,6 @@ EXPORT int getchar(void)
 \r
 EXPORT int puts(const char *str)\r
 {\r
-       \r
        if(!str)        return 0;\r
         int    len = strlen(str);\r
        \r
index 0757c24..ae91b13 100644 (file)
@@ -2,7 +2,7 @@
  * AcessOS Basic C Library
  * string.c
  */
-#include <acess/sys.h>
+//#include <acess/sys.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <ctype.h>
  * \fn EXPORT int strcmp(const char *s1, const char *s2)
  * \brief Compare two strings
  */
-EXPORT int strcmp(const char *s1, const char *s2)
+EXPORT int strcmp(const char *_s1, const char *_s2)
 {
-       while(*s1 && *s1 == *s2) {
-               s1++; s2++;
-       }
-       return (int)*s1 - (int)*s2;
+       return strncmp(_s1, _s2, SIZE_MAX);
 }
 
 /**
- * \fn EXPORT int strncmp(const char *s1, const char *s2)
- * \brief Compare two strings
+ * \fn EXPORT int strncmp(const char *s1, const char *s2, size_t n)
+ * \brief Compare two strings, stopping after n characters
  */
-EXPORT int strncmp(const char *s1, const char *s2, size_t n)
+EXPORT int strncmp(const char *_s1, const char *_s2, size_t n)
 {
+       const unsigned char*    s1 = (const unsigned char*)_s1;
+       const unsigned char*    s2 = (const unsigned char*)_s2;
        while(n && *s1 && *s1 == *s2)
        {
                s1++; s2++;
@@ -38,23 +37,31 @@ EXPORT int strncmp(const char *s1, const char *s2, size_t n)
                return (int)*s1 - (int)*s2;
 }
 
-EXPORT int strcasecmp(const char *s1, const char *s2)
+EXPORT int strcasecmp(const char *_s1, const char *_s2)
 {
-        int    rv;
-       while( (rv = toupper(*s1) - toupper(*s2)) == 0 && *s1 != '\0' && *s2 != '\0' ) {
-               s1++; s2++;
-       }
-       return rv;
+       return strncasecmp(_s1, _s2, SIZE_MAX);
 }
 
-EXPORT int strncasecmp(const char *s1, const char *s2, size_t n)
+EXPORT int strncasecmp(const char *_s1, const char *_s2, size_t n)
 {
-        int    rv = 0;
-       if( n == 0 )    return 0;
-       while(n -- && (rv = toupper(*s1) - toupper(*s2)) == 0 && *s1 != '\0' && *s2 != '\0') {
-               s1++; s2++;
+       const unsigned char*    s1 = (const unsigned char*)_s1;
+       const unsigned char*    s2 = (const unsigned char*)_s2;
+       while( n-- && *s1 && *s2 )
+       {
+               if( *s1 != *s2 )
+               {
+                       int rv;
+                       rv = toupper(*s1) - toupper(*s2);
+                       if(rv != 0)
+                               return rv;
+                       rv = tolower(*s1) - tolower(*s2);
+                       if(rv != 0)
+                               return rv;
+               }
+               s1 ++;
+               s2 ++;
        }
-       return rv;
+       return 0;
 }
 
 /**
@@ -131,7 +138,8 @@ EXPORT size_t strlen(const char *str)
 EXPORT size_t strnlen(const char *str, size_t maxlen)
 {
        size_t  len;
-       for( len = 0; maxlen -- && *str; str ++, len ++ );
+       for( len = 0; maxlen -- && *str; str ++, len ++ )
+               ;
        return len;
 }
 
@@ -171,11 +179,12 @@ EXPORT char *strndup(const char *str, size_t maxlen)
  * \fn EXPORT char *strchr(char *str, int character)
  * \brief Locate a character in a string
  */
-EXPORT char *strchr(const char *str, int character)
+EXPORT char *strchr(const char *_str, int character)
 {
+       const unsigned char* str = (const unsigned char*)_str;
        for(;*str;str++)
        {
-               if(*str == character)
+               if( *str == character )
                        return (char*)str;
        }
        return NULL;
@@ -185,11 +194,10 @@ EXPORT char *strchr(const char *str, int character)
  * \fn EXPORT char *strrchr(char *str, int character)
  * \brief Locate the last occurance of a character in a string
  */
-EXPORT char *strrchr(const char *str, int character)
+EXPORT char *strrchr(const char *_str, int character)
 {
-        int    i;
-       i = strlen(str)-1;
-       while(i--)
+       const unsigned char* str = (const unsigned char*)_str;
+       for( int i = strlen(_str); i--; )
        {
                if(str[i] == character)
                        return (void*)&str[i];
@@ -277,6 +285,8 @@ EXPORT void *memcpy(void *__dest, const void *__src, size_t count)
        return __dest;
 }
 
+// TODO: memccpy (POSIX defined)
+
 /**
  * \fn EXPORT void *memmove(void *dest, const void *src, size_t count)
  * \brief Copy data in memory, avoiding overlap problems
@@ -316,7 +326,7 @@ EXPORT int memcmp(const void *mem1, const void *mem2, size_t count)
        while(count--)
        {
                if( *p1 != *p2 )
-                       return *p1 - *p2;
+                       return (int)*p1 - (int)*p2;
                p1 ++;
                p2 ++;
        }
@@ -332,11 +342,12 @@ EXPORT int memcmp(const void *mem1, const void *mem2, size_t count)
  */
 EXPORT void *memchr(const void *ptr, int value, size_t num)
 {
+       const unsigned char* buf = ptr;
        while(num--)
        {
-               if( *(const unsigned char*)ptr == (unsigned char)value )
-                       return (void*)ptr;
-               ptr ++;
+               if( *buf == (unsigned char)value )
+                       return (void*)buf;
+               buf ++;
        }
        return NULL;
 }
@@ -344,12 +355,13 @@ EXPORT void *memchr(const void *ptr, int value, size_t num)
 EXPORT size_t strcspn(const char *haystack, const char *reject)
 {
        size_t  ret = 0;
-        int    i;
        while( *haystack )
        {
-               for( i = 0; reject[i] && reject[i] == *haystack; i ++ );
-
-               if( reject[i] ) return ret;
+               for( int i = 0; reject[i]; i ++ )
+               {
+                       if( reject[i] == *haystack )
+                               return ret;
+               }
                ret ++;
        }
        return ret;
@@ -358,12 +370,13 @@ EXPORT size_t strcspn(const char *haystack, const char *reject)
 EXPORT size_t strspn(const char *haystack, const char *accept)
 {
        size_t  ret = 0;
-        int    i;
        while( *haystack )
        {
-               for( i = 0; accept[i] && accept[i] == *haystack; i ++ );
-
-               if( !accept[i] )        return ret;
+               for( int i = 0; accept[i]; i ++ )
+               {
+                       if( accept[i] != *haystack )
+                               return ret;
+               }
                ret ++;
        }
        return ret;
@@ -378,6 +391,7 @@ EXPORT char *strpbrk(const char *haystack, const char *accept)
                        if( accept[i] == *haystack )
                                return (char*)haystack;
                }
+               haystack ++;
        }
        return NULL;
 }
diff --git a/Usermode/Libraries/libposix.so_src/include_exp/glob.h b/Usermode/Libraries/libposix.so_src/include_exp/glob.h
new file mode 100644 (file)
index 0000000..ff96b8e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Acess2 POSIX Emulation Library
+ * - By John Hodge (thePowersGang)
+ *
+ * glob.h
+ * - Globbing code
+ */
+#ifndef _LIBPOSIX__GLOB_H_
+#define _LIBPOSIX__GLOB_H_
+
+
+
+#endif
index a830286..ebbe6b6 100644 (file)
@@ -30,6 +30,11 @@ enum {
        REG_BADRPT,
 };
 
+#define REG_EXTENDED   0x1
+#define REG_ICASE      0x2
+#define REG_NOSUB      0x4
+#define REG_NEWLINE    0x8
+
 
 #endif
 
index fe3fc8c..0870c0c 100644 (file)
@@ -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
index 8f4f779..376fb0e 100644 (file)
@@ -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 (file)
index 0000000..4b5f51f
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Acess2 libpthread
+ * - By John Hodge (thePowersGang)
+ *
+ * thread.c
+ * - Thread management for pthreads
+ */
+#include <pthread.h>
+#include <assert.h>
+
+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 (file)
index 0000000..21eb942
--- /dev/null
@@ -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 (file)
index 0000000..5f2532b
--- /dev/null
@@ -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 (file)
index 0000000..66d9657
--- /dev/null
@@ -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 (file)
index 0000000..e8d121b
--- /dev/null
@@ -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;
+}
+

UCC git Repository :: git.ucc.asn.au