Fiddling with IPStack
[tpg/acess2.git] / Kernel / include / acess.h
index f6f87f7..779cf88 100644 (file)
@@ -1,16 +1,15 @@
 /*
  * AcessOS Microkernel Version
- * common.h
+ * acess.h
  */
-#ifndef _COMMON_H
-#define _COMMON_H
+#ifndef _ACESS_H
+#define _ACESS_H
 
 #define NULL   ((void*)0)
 #define PACKED __attribute__((packed))
 #define UNUSED(x)      UNUSED_##x __attribute__((unused))
 #define offsetof(st, m) ((Uint)((char *)&((st *)(0))->m - (char *)0 ))
 
-//#include <stdint.h>
 #include <arch.h>
 #include <stdarg.h>
 #include "errno.h"
@@ -21,6 +20,15 @@ typedef  int tTID;
 typedef Uint   tUID;
 typedef Uint   tGID;
 typedef Sint64 tTimestamp;
+typedef struct sShortSpinlock  tShortSpinlock;
+typedef struct sMutex  tMutex;
+
+struct sMutex {
+       tShortSpinlock  Protector;      //!< Protector for the lock strucure
+       struct sThread  *volatile Owner;        //!< Owner of the lock (set upon getting the lock)
+       struct sThread  *Waiting;       //!< Waiting threads
+       struct sThread  *LastWaiting;   //!< Waiting threads
+};
 
 // --- Helper Macros ---
 /**
@@ -254,6 +262,7 @@ extern tPAddr       MM_AllocPhys(void);
 /**
  * \brief Allocate a contiguous range of physical pages
  * \param Pages        Number of pages to allocate
+ * \param MaxBits      Maximum number of address bits allowed
  * \return First physical address allocated
  */
 extern tPAddr  MM_AllocPhysRange(int Pages, int MaxBits);
@@ -320,8 +329,11 @@ extern char        *strncpy(char *__dest, const char *__src, size_t max);
 extern int     strcmp(const char *__str1, const char *__str2);
 extern int     strncmp(const char *Str1, const char *Str2, size_t num);
 extern int     strucmp(const char *Str1, const char *Str2);
-extern char    *strdup(const char *Str);
+//extern char  *strdup(const char *Str);
+#define strdup(Str)    _strdup(_MODULE_NAME_"/"__FILE__, __LINE__, (Str))
+extern char    *_strdup(const char *File, int Line, const char *Str);
 extern char    **str_split(const char *__str, char __ch);
+extern char    *strchr(const char *__s, int __c);
 extern int     strpos(const char *Str, char Ch);
 extern int     strpos8(const char *str, Uint32 search);
 extern void    itoa(char *buf, Uint num, int base, int minLength, char pad);
@@ -330,7 +342,9 @@ extern int  ReadUTF8(Uint8 *str, Uint32 *Val);
 extern int     WriteUTF8(Uint8 *str, Uint32 Val);
 extern int     ModUtil_SetIdent(char *Dest, char *Value);
 extern int     ModUtil_LookupString(char **Array, char *Needle);
+
 extern Uint8   ByteSum(void *Ptr, int Size);
+extern int     UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString);
 /**
  * \}
  */
@@ -403,6 +417,9 @@ extern tGID Threads_GetGID(void);
 extern int     SpawnTask(tThreadFunction Function, void *Arg);
 extern Uint    *Threads_GetCfgPtr(int Id);
 extern int     Threads_SetName(char *NewName);
+extern void    Mutex_Acquire(tMutex *Mutex);
+extern void    Mutex_Release(tMutex *Mutex);
+extern int     Mutex_IsLocked(tMutex *Mutex);
 /**
  * \}
  */

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