extern int _SysWaitEvent(int EventMask);
extern int waittid(int id, int *status);
extern int clone(int flags, void *stack);
-extern int execve(char *path, char **argv, char **envp);
+extern int execve(const char *path, char **argv, char **envp);
extern int _SysSpawn(const char *Path, const char **argv, const char **envp, int nFDs, int *FDs, struct s_sys_spawninfo *info);
extern int gettid(void);
extern int getpid(void);
#include "../acess/intdefs.h"
+typedef signed int ssize_t;
+//#ifdef __USE_BSD
+typedef unsigned int u_int;
+//#endif
+
typedef struct stat t_fstat;
#define FD_SETSIZE 128
#define O_WRONLY OPENFLAG_WRITE
#define O_TRUNC OPENFLAG_TRUNCATE
#define O_APPEND OPENFLAG_APPEND
-
-//typedef intptr_t ssize_t;
+#define O_NONBLOCK 0 // TODO:
#include "acess/sys.h"
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+static inline int fork(void) { return clone(CLONE_VM, 0); }
+static inline int execv(const char *b,char *v[]) { return execve(b,v,NULL); }
#endif
\r
/* --- StdLib --- */\r
extern void _exit(int code) __attribute__((noreturn)); /* NOTE: Also defined in acess/sys.h */\r
+\r
extern long long strtoll(const char *ptr, char **end, int base);\r
extern long strtol(const char *ptr, char **end, int base);\r
+extern unsigned long long strtoull(const char *ptr, char **end, int base);\r
+extern unsigned long strtoul(const char *ptr, char **end, int base);\r
extern int atoi(const char *ptr);\r
extern void exit(int status) __attribute__((noreturn));\r
extern void abort(void);\r
}\r
}\r
\r
-EXPORT long long strtoll(const char *str, char **end, int base)\r
+EXPORT unsigned long long strtoull(const char *str, char **end, int base)\r
{\r
- int neg = 0;\r
long long ret = 0;\r
\r
if( !str || base < 0 || base > 36 || base == 1 ) {\r
while( isspace(*str) )\r
str++;\r
\r
- // Check for negative (or positive) sign\r
- if(*str == '-' || *str == '+') {\r
- neg = (*str == '-');\r
- str++;\r
- }\r
- \r
if( base == 0 || base == 16 ) {\r
if( *str == '0' && str[1] == 'x' ) {\r
str += 2;\r
str ++;\r
}\r
\r
- if( neg )\r
- ret = -ret; \r
-\r
if(end)\r
*end = (char*)str;\r
return ret;\r
}\r
\r
+EXPORT unsigned long strtoul(const char *ptr, char **end, int base)\r
+{\r
+ unsigned long long tmp = strtoull(ptr, end, base);\r
+ \r
+ if( tmp > ULONG_MAX ) {\r
+ errno = ERANGE;\r
+ return ULONG_MAX;\r
+ }\r
+ \r
+ return tmp;\r
+}\r
+\r
+EXPORT long long strtoll(const char *str, char **end, int base)\r
+{\r
+ int neg = 0;\r
+ unsigned long long ret;\r
+\r
+ if( !str ) {\r
+ errno = EINVAL;\r
+ return 0;\r
+ }\r
+ \r
+ while( isspace(*str) )\r
+ str++;\r
+ \r
+ // Check for negative (or positive) sign\r
+ if(*str == '-' || *str == '+') {\r
+ neg = (*str == '-');\r
+ str++;\r
+ }\r
+\r
+ ret = strtoull(str, end, base); \r
+\r
+ if( neg )\r
+ return -ret;\r
+ else\r
+ return ret;\r
+}\r
+\r
EXPORT long strtol(const char *str, char **end, int base)\r
{\r
long long tmp = strtoll(str, end, base);\r
// Acess doesn't implement lseek
#define lseek(_1,_2,_3) (seek(_1,_2,_3),tell(_1))
+enum e_fcntl_cmds
+{
+ F_SETFL
+};
+
+int fcntl(int fd, int cmd, ...) { return -1; }
+
#endif
rlim_t rlim_max;
};
+enum
+{
+ RLIMIT_AS, // Address space size
+ RLIMIT_CORE, // Max core file size
+ RLIMIT_CPU, // CPU time limit in s (SIGXCPU when reached)
+ RLIMIT_DATA,
+ // TODO: More?
+};
+
struct rusage
{
struct timeval ru_time;
// getsockopt/setsockopt(level)
enum {
- IPPROTO_IP,
+ IPPROTO_IP = 1,
IPPROTO_ICMP,
IPPROTO_TCP,
IPPROTO_UDP
--- /dev/null
+/*
+ * Acess2 POSIX Sockets Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * netinet/tcp.h
+ * - TCP Options
+ */
+#ifndef _NETINET__TCP_H_
+#define _NETINET__TCP_H_
+
+
+/**
+ * \brief Values for \a option_name in setsockopt/getsockopt
+ */
+enum eSockOpts_TCP
+{
+ TCP_NODELAY
+};
+
+#endif
+
{
AF_UNSPEC = 0,
AF_PACKET = 1,
+ AF_LOCAL = 2,
AF_INET = 4,
AF_INET6 = 6,
} sa_family_t;
+#define AF_UNIX AF_LOCAL
struct sockaddr
{
*/
enum eSocketDomains
{
+ PF_UNSPEC,
PF_LOCAL, //!< Machine-local comms
PF_INET, //!< IPv4
PF_INET6, //!< IPv6
};
#define PF_UNIX PF_LOCAL
+// getsockopt/setsockopt level
+enum
+{
+ SOL_SOCKET
+};
+
+
+// SOL_SOCKET getsockopt/setsockopt names
+enum
+{
+ SO_REUSEADDR,
+ SO_LINGER
+};
+
/**
* \brief Create a new socket descriptor
* \param domain Address family
extern int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
extern int getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len);
+extern int getsockname(int socket, struct sockaddr *addr, socklen_t *addrlen);
+extern int getpeername(int socket, struct sockaddr *addr, socklen_t *addrlen);
+
#endif