Files
mtkports/dev-vcs/git/compat/sys/socket.h
T
2026-08-09 10:47:07 +02:00

82 lines
2.3 KiB
C

/*
* <sys/socket.h> for the MontaukOS git port.
*
* MontaukOS does have TCP -- the kernel exposes it as IPC handles through
* montauk::socket(), not as BSD descriptors -- but nothing bridges the two
* into the fd space that read()/write() use, and git's transports assume a
* descriptor it can hand to a sub-process. Until that bridge exists, every
* call here fails with ENOSYS, which surfaces as "unable to connect" from
* `git clone git://...` rather than as a crash.
*
* That leaves the local transports -- init, add, commit, log, diff, and
* clone/fetch/push against a path on disk -- which are what this port is for.
*
* Implementations in montauk-compat.c.
*/
#ifndef _MONTAUK_GIT_SYS_SOCKET_H_
#define _MONTAUK_GIT_SYS_SOCKET_H_
#include <sys/types.h>
typedef unsigned int socklen_t;
typedef unsigned short sa_family_t;
#define AF_UNSPEC 0
#define AF_UNIX 1
#define AF_LOCAL 1
#define AF_INET 2
#define AF_INET6 10
#define PF_UNSPEC AF_UNSPEC
#define PF_UNIX AF_UNIX
#define PF_INET AF_INET
#define PF_INET6 AF_INET6
#define SOCK_STREAM 1
#define SOCK_DGRAM 2
#define SOL_SOCKET 1
#define SO_REUSEADDR 2
#define SO_ERROR 4
#define SO_KEEPALIVE 9
#define SO_LINGER 13
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
#define MSG_PEEK 2
struct sockaddr {
sa_family_t sa_family;
char sa_data[14];
};
/* Large enough for sockaddr_in6, aligned like the real thing. */
struct sockaddr_storage {
sa_family_t ss_family;
unsigned long __ss_align;
char __ss_padding[112];
};
struct linger {
int l_onoff;
int l_linger;
};
int socket(int domain, int type, int protocol);
int connect(int fd, const struct sockaddr *addr, socklen_t len);
int bind(int fd, const struct sockaddr *addr, socklen_t len);
int listen(int fd, int backlog);
int accept(int fd, struct sockaddr *addr, socklen_t *len);
int shutdown(int fd, int how);
int setsockopt(int fd, int level, int name, const void *val, socklen_t len);
int getsockopt(int fd, int level, int name, void *val, socklen_t *len);
int getsockname(int fd, struct sockaddr *addr, socklen_t *len);
int getpeername(int fd, struct sockaddr *addr, socklen_t *len);
ssize_t send(int fd, const void *buf, size_t len, int flags);
ssize_t recv(int fd, void *buf, size_t len, int flags);
#endif /* _MONTAUK_GIT_SYS_SOCKET_H_ */