SpiderScript - Speedups
[tpg/acess2.git] / Kernel / include / vfs_ext.h
index 720bcbe..5e6b77d 100644 (file)
@@ -29,6 +29,9 @@
 //! Marks a VFS handle as belonging to the kernel
 #define VFS_KERNEL_FLAG        0x40000000
 
+//! Architectual maximum number of file descriptors
+#define MAX_FILE_DESCS 128
+
 /**
  * \brief VFS_Seek directions
  */
@@ -104,6 +107,18 @@ typedef struct sFInfo
        tVFS_ACL        acls[]; //!< ACL buffer (size is passed in the \a MaxACLs argument to VFS_FInfo)
 }      tFInfo;
 
+/**
+ * \brief fd_set for select()
+ */
+typedef struct
+{
+       Uint16  flags[MAX_FILE_DESCS/16];
+}      fd_set;
+
+#define FD_CLR(fd, fdsetp) ((fdsetp)->flags[(fd)/16]&=~(1<<((fd)%16)))
+#define FD_SET(fd, fdsetp) ((fdsetp)->flags[(fd)/16]|=~(1<<((fd)%16)))
+#define FD_ISSET(fd, fdsetp) ((fdsetp)->flags[(fd)/16]&(1<<((fd)%16)))
+
 // === FUNCTIONS ===
 /**
  * \brief Initialise the VFS (called by system.c)
@@ -277,4 +292,16 @@ extern int VFS_ReadDir(int FD, char *Dest);
  */
 extern int     VFS_OpenChild(Uint *Errno, int FD, const char *Name, Uint Mode);
 
+/**
+ * \brief Wait for an aciton on a file descriptor
+ * \param MaxHandle    Maximum set handle in \a *Handles
+ * \param ReadHandles  Handles to wait for data on
+ * \param WriteHandles Handles to wait to write to
+ * \param ErrHandles   Handle to wait for errors on
+ * \param Timeout      Timeout for select() (if null, there is no timeout), if zero select() is non blocking
+ * \param IsKernel     Use kernel handles as opposed to user handles
+ * \return Number of handles that actioned
+ */
+extern int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, BOOL IsKernel);
+
 #endif

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