Kernel - Imported userland strtoi file (and other minor changes)
authorJohn Hodge (sonata) <[email protected]>
Sat, 1 Dec 2012 08:45:31 +0000 (16:45 +0800)
committerJohn Hodge (sonata) <[email protected]>
Sat, 1 Dec 2012 08:45:31 +0000 (16:45 +0800)
KernelLand/Kernel/arch/x86/include/arch.h
KernelLand/Kernel/include/acess.h
KernelLand/Kernel/include/errno.h
KernelLand/Kernel/include/syscalls.h
KernelLand/Kernel/libc.c
KernelLand/Modules/Storage/ATA/main.c
Usermode/Applications/ip_src/routes.c
Usermode/Libraries/libc.so_src/include_exp/errno.enum.h [new file with mode: 0644]
Usermode/Libraries/libc.so_src/include_exp/errno.h
Usermode/Libraries/libc.so_src/strtoi.c

index 040e18b..6586845 100644 (file)
@@ -78,7 +78,6 @@ typedef signed char           Sint8;
 typedef signed short   Sint16;
 typedef signed long            Sint32;
 typedef signed long long       Sint64;
-typedef Uint   size_t;
 typedef char   BOOL;
 
 typedef Uint32 tPAddr;
index 27dbb2a..24148e1 100644 (file)
@@ -9,10 +9,9 @@
  * \brief Acess2 Kernel API Core
  */
 
+#include <stddef.h>
 #include <arch.h>
 
-//! NULL Pointer
-#define NULL   ((void*)0)
 //! Pack a structure
 #define PACKED __attribute__((packed))
 //! Mark a function as not returning
@@ -23,8 +22,6 @@
 #define DEPRECATED     __attribute__((deprecated))
 //! Mark a parameter as unused
 #define UNUSED(x)      UNUSED_##x __attribute__((unused))
-//! Get the offset of a member in a structure
-#define offsetof(st, m) ((Uint)((char *)&((st *)(0))->m - (char *)0 ))
 
 /**
  * \name Boolean constants
index 31f68a0..f6ec953 100644 (file)
@@ -5,29 +5,6 @@
 #ifndef _ERRNO_H
 #define _ERRNO_H
 
-enum eErrorNums
-{
-       EOK,
-       
-       ENOSYS, // Invalid Instruction
-       EINVAL, // Invalid Paramater
-       ENOMEM, // No free memory
-       EACCES, // Not permitted
-       EBUSY,  // Resource is busy
-       ENOTFOUND,      // Item not found
-       EREADONLY,      // Read only
-       ENOTIMPL,       // Not implemented
-       ENOENT, // No entry?
-       EEXIST, // Already exists
-       ENFILE, // Too many open files
-       ENOTDIR,        // Not a directory
-       EIO,    // IO Error
-       EINTR,  // Operation interrupted (signal)
-       
-       EALREADY,       // Operation was a NOP
-       EINTERNAL,      // Internal Error
-       
-       NUM_ERRS
-};
+#include "../../../Usermode/Libraries/libc.so_src/include_exp/errno.enum.h"
 
 #endif
index 601a7f4..4164e64 100644 (file)
@@ -69,7 +69,6 @@
 #define SYS_DEBUG      0x100
 
 #ifndef __ASSEMBLER__
-#ifndef NO_SYSCALL_STRS
 static const char *cSYSCALL_NAMES[] = {
        "SYS_EXIT",
        "SYS_CLONE",
@@ -163,6 +162,5 @@ static const char *cSYSCALL_NAMES[] = {
        ""
 };
 #endif
-#endif
 
 #endif
index 67ce9b2..a5f87e4 100644 (file)
@@ -67,15 +67,10 @@ EXPORT(CheckString);
 EXPORT(CheckMem);
 
 // === CODE ===
-/**
- * \brief Convert a string into an integer
- */
-int atoi(const char *string)
-{
-       int ret = 0;
-       ParseInt(string, &ret);
-       return ret;
-}
+// - Import userland stroi.c file
+#define _LIB_H_
+#include "../../Usermode/Libraries/libc.so_src/strtoi.c"
+
 int ParseInt(const char *string, int *Val)
 {
         int    ret = 0;
index a131a44..050faad 100644 (file)
@@ -122,7 +122,7 @@ int ATA_ScanDisk(int Disk)
 /**
  * \fn Uint ATA_ReadRaw(Uint64 Address, Uint Count, void *Buffer, Uint Disk)
  */
-int ATA_ReadRaw(void *Ptr, Uint64 Address, Uint Count, void *Buffer)
+int ATA_ReadRaw(void *Ptr, Uint64 Address, size_t Count, void *Buffer)
 {
         int    Disk = (tVAddr)Ptr;
         int    ret;
@@ -160,7 +160,7 @@ int ATA_ReadRaw(void *Ptr, Uint64 Address, Uint Count, void *Buffer)
 /**
  * \fn Uint ATA_WriteRaw(Uint64 Address, Uint Count, const void *Buffer, Uint Disk)
  */
-int ATA_WriteRaw(void *Ptr, Uint64 Address, Uint Count, const void *Buffer)
+int ATA_WriteRaw(void *Ptr, Uint64 Address, size_t Count, const void *Buffer)
 {
         int    Disk = (tVAddr)Ptr;
         int    ret;
index ba56813..a5f682c 100644 (file)
@@ -50,15 +50,15 @@ int Routes_main(int argc, char *argv[])
                }
                
                // Destination IP
-               addrType = ParseIPAddress(argv[3], dest, &subnetBits);
+               addrType = ParseIPAddress(argv[2], dest, &subnetBits);
                if( subnetBits == -1 ) {
                        subnetBits = Net_GetAddressSize(addrType)*8;
                }
                // Interface Name / Next Hop
-               if( (nextHopType = ParseIPAddress(argv[4], nextHop, &nextHopBits)) == 0 )
+               if( (nextHopType = ParseIPAddress(argv[3], nextHop, &nextHopBits)) == 0 )
                {
                        // Interface name
-                       ifaceName = argv[4];
+                       ifaceName = argv[3];
                }
                else
                {
@@ -78,8 +78,8 @@ int Routes_main(int argc, char *argv[])
                // Metric
                if( argc - 3 >= 3 )
                {
-                       metric = atoi(argv[5]);
-                       if( metric == 0 && argv[5][0] != '0' ) {
+                       metric = atoi(argv[4]);
+                       if( metric == 0 && argv[4][0] != '0' ) {
                                fprintf(stderr, "ERROR: Metric should be a number\n");
                                return -1;
                        }
diff --git a/Usermode/Libraries/libc.so_src/include_exp/errno.enum.h b/Usermode/Libraries/libc.so_src/include_exp/errno.enum.h
new file mode 100644 (file)
index 0000000..090b06b
--- /dev/null
@@ -0,0 +1,25 @@
+
+enum {
+       EOK,
+       ENOSYS, // Invalid Instruction
+       EINVAL, // Invalid Paramater
+       ENOMEM, // No free memory
+       EACCES, // Not permitted
+       EBUSY,  // Resource is busy
+       ERANGE, // Value out of range
+       ENOTFOUND,      // Item not found
+       EREADONLY,      // Read only
+       ENOTIMPL,       // Not implemented
+       ENOENT, // No entry?
+       EEXIST, // Already exists
+       ENFILE, // Too many open files
+       ENOTDIR,        // Not a directory
+       EIO,    // IO Error
+       EINTR,  // Operation interrupted (signal)
+       
+       EALREADY,       // Operation was a NOP
+       EINTERNAL,      // Internal Error
+       
+       NUM_ERRNO
+};
+
index ea352f3..cbe8749 100644 (file)
@@ -8,21 +8,6 @@ extern int     _errno;
 
 #define strerror(_x)   "Unimplemented"
 
-enum
-{
-       EOK,
-       EINVAL,
-       ERANGE,
-       ENODEV,
-       EBADF,
-       EINTR,
-       EAGAIN,
-       ENOMEM,
-
-       EADDRNOTAVAIL,
-       EINPROGRESS,
-
-       E_LAST
-};
+#include "errno.enum.h"
 
 #endif
index 53756dc..9326fb8 100644 (file)
@@ -5,13 +5,12 @@
  * strtoi.c
  * - strto[u][l]l/atoi implimentation
  */
-#include <stdio.h>
 #include <ctype.h>
 #include <errno.h>
 #include <limits.h>
-#include "lib.h"
+#include <stddef.h>
 
-EXPORT unsigned long long strtoull(const char *str, char **end, int base)
+unsigned long long strtoull(const char *str, char **end, int base)
 {
        long long       ret = 0;
        
@@ -71,7 +70,7 @@ EXPORT unsigned long long strtoull(const char *str, char **end, int base)
        return ret;
 }
 
-EXPORT unsigned long strtoul(const char *ptr, char **end, int base)
+unsigned long strtoul(const char *ptr, char **end, int base)
 {
        unsigned long long tmp = strtoull(ptr, end, base);
        
@@ -83,7 +82,7 @@ EXPORT unsigned long strtoul(const char *ptr, char **end, int base)
        return tmp;
 }
 
-EXPORT long long strtoll(const char *str, char **end, int base)
+long long strtoll(const char *str, char **end, int base)
 {
         int    neg = 0;
        unsigned long long      ret;
@@ -110,7 +109,7 @@ EXPORT long long strtoll(const char *str, char **end, int base)
                return ret;
 }
 
-EXPORT long strtol(const char *str, char **end, int base)
+long strtol(const char *str, char **end, int base)
 {
        long long tmp = strtoll(str, end, base);
        if( tmp > LONG_MAX || tmp < LONG_MIN ) {
@@ -121,10 +120,10 @@ EXPORT long strtol(const char *str, char **end, int base)
 }
 
 /**
- * \fn EXPORT int atoi(const char *str)
+ * \fn int atoi(const char *str)
  * \brief Convert a string to an integer
  */
-EXPORT int atoi(const char *str)
+int atoi(const char *str)
 {
        long long       tmp = strtoll(str, NULL, 0);
        if( tmp > INT_MAX || tmp < INT_MIN ) {

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