Skip to content

Commit c167dee

Browse files
committed
consolidate with bsd headers
1 parent 28e7be8 commit c167dee

13 files changed

Lines changed: 39 additions & 242 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ target_include_directories(libogc_inc INTERFACE
2929
gc/sdcard
3030
gc/wiiuse
3131
gc/di
32+
external/bsd/include
3233
)
3334

3435
target_compile_options(libogc_inc INTERFACE
@@ -87,3 +88,10 @@ install(
8788
PATTERN "*.hpp"
8889
PATTERN "*.inc"
8990
)
91+
92+
install(
93+
DIRECTORY ${PROJECT_SOURCE_DIR}/external/bsd/include/
94+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
95+
FILES_MATCHING
96+
PATTERN "*.h"
97+
)

external/bsd/include/poll.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ struct pollfd {
6565
* POLLIN includes all of normal, band and urgent data. Most poll handlers
6666
* on FreeBSD only treat it as "normal" data.
6767
*/
68-
#define POLLIN 0x0001 /* any readable data available */
69-
#define POLLPRI 0x0002 /* OOB/Urgent readable data */
70-
#define POLLOUT 0x0004 /* file descriptor is writeable */
71-
#define POLLRDNORM 0x0040 /* non-OOB/URG data available */
72-
#define POLLWRNORM POLLOUT /* no write type differentiation */
73-
#define POLLRDBAND 0x0080 /* OOB/Urgent readable data */
74-
#define POLLWRBAND 0x0100 /* OOB/Urgent data can be written */
68+
#define POLLRDNORM 0x0001 /* non-OOB/URG data available */
69+
#define POLLRDBAND 0x0002 /* OOB/Urgent readable data */
70+
#define POLLPRI 0x0004 /* OOB/Urgent readable data */
71+
#define POLLWRNORM 0x0008 /* no write type differentiation */
72+
#define POLLWRBAND 0x0010 /* OOB/Urgent data can be written */
73+
#define POLLIN (POLLRDNORM|POLLRDBAND) /* any readable data available */
74+
#define POLLOUT POLLWRNORM /* file descriptor is writeable */
75+
7576

7677
#if __BSD_VISIBLE
7778
/* General FreeBSD extension (currently only supported for sockets): */
@@ -82,9 +83,9 @@ struct pollfd {
8283
* These events are set if they occur regardless of whether they were
8384
* requested.
8485
*/
85-
#define POLLERR 0x0008 /* some poll error occurred */
86-
#define POLLHUP 0x0010 /* file descriptor was "hung up" */
87-
#define POLLNVAL 0x0020 /* requested events "invalid" */
86+
#define POLLERR 0x0020 /* some poll error occurred */
87+
#define POLLHUP 0x0040 /* file descriptor was "hung up" */
88+
#define POLLNVAL 0x0080 /* requested events "invalid" */
8889

8990
#if __BSD_VISIBLE
9091

external/bsd/include/sys/socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ struct msghdr {
406406
#define MSG_CTRUNC 0x00000020 /* control data lost before delivery */
407407
#define MSG_WAITALL 0x00000040 /* wait for full request or error */
408408
#if __BSD_VISIBLE
409-
#define MSG_DONTWAIT 0x00000080 /* this message should be nonblocking */
409+
#define MSG_DONTWAIT 0x00000040 /* this message should be nonblocking */
410410
#define MSG_EOF 0x00000100 /* data completes connection */
411411
/* 0x00000200 unused */
412412
/* 0x00000400 unused */

gc/ipv4/lwip/inet.h

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#ifndef __LWIP_INET_H__
3333
#define __LWIP_INET_H__
3434

35+
#include <arpa/inet.h>
36+
3537
#include "lwip/arch.h"
3638

3739
#include "lwip/opt.h"
@@ -47,41 +49,6 @@ u16_t inet_chksum_pseudo(struct pbuf *p,
4749
struct ip_addr *src, struct ip_addr *dest,
4850
u8_t proto, u16_t proto_len);
4951

50-
u32_t inet_addr(const char *cp);
51-
s8_t inet_aton(const char *cp, struct in_addr *addr);
52-
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
53-
54-
#ifdef htons
55-
#undef htons
56-
#endif /* htons */
57-
#ifdef htonl
58-
#undef htonl
59-
#endif /* htonl */
60-
#ifdef ntohs
61-
#undef ntohs
62-
#endif /* ntohs */
63-
#ifdef ntohl
64-
#undef ntohl
65-
#endif /* ntohl */
66-
67-
#if BYTE_ORDER == BIG_ENDIAN
68-
#define htons(x) (x)
69-
#define ntohs(x) (x)
70-
#define htonl(x) (x)
71-
#define ntohl(x) (x)
72-
#else
73-
#ifdef LWIP_PREFIX_BYTEORDER_FUNCS
74-
/* workaround for naming collisions on some platforms */
75-
#define htons lwip_htons
76-
#define ntohs lwip_ntohs
77-
#define htonl lwip_htonl
78-
#define ntohl lwip_ntohl
79-
#endif
80-
u16_t htons(u16_t x);
81-
u16_t ntohs(u16_t x);
82-
u32_t htonl(u32_t x);
83-
u32_t ntohl(u32_t x);
84-
#endif
8552

8653
#endif /* __LWIP_INET_H__ */
8754

gc/ipv4/lwip/ip.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
5757
#define IP_PROTO_UDPLITE 170
5858
#define IP_PROTO_TCP 6
5959

60-
/* This is passed as the destination address to ip_output_if (not
61-
to ip_output), meaning that an IP header already is constructed
62-
in the pbuf. This is used when TCP retransmits. */
63-
#ifdef IP_HDRINCL
64-
#undef IP_HDRINCL
65-
#endif /* IP_HDRINCL */
66-
#define IP_HDRINCL NULL
67-
68-
6960
/* This is the common part of all PCB types. It needs to be at the
7061
beginning of a PCB type definition. It is located here so that
7162
changes to this common part are made in one location instead of

gc/ipv4/lwip/ip_addr.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ PACK_STRUCT_END
5858
# include "arch/epstruct.h"
5959
#endif
6060

61-
/* For compatibility with BSD code */
62-
#ifndef HAVE_IN_ADDR
63-
#define HAVE_IN_ADDR
64-
struct in_addr {
65-
u32_t s_addr;
66-
};
67-
#endif
68-
6961
struct netif;
7062

7163
extern const struct ip_addr ip_addr_any;
@@ -77,40 +69,6 @@ extern const struct ip_addr ip_addr_broadcast;
7769
#define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any)
7870
#define IP_ADDR_BROADCAST ((struct ip_addr *)&ip_addr_broadcast)
7971

80-
#define INADDR_NONE ((u32_t) 0xffffffff) /* 255.255.255.255 */
81-
#define INADDR_LOOPBACK ((u32_t) 0x7f000001) /* 127.0.0.1 */
82-
83-
/* Definitions of the bits in an Internet address integer.
84-
85-
On subnets, host and network parts are found according to
86-
the subnet mask, not these masks. */
87-
88-
#define IN_CLASSA(a) ((((u32_t)(a)) & 0x80000000) == 0)
89-
#define IN_CLASSA_NET 0xff000000
90-
#define IN_CLASSA_NSHIFT 24
91-
#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
92-
#define IN_CLASSA_MAX 128
93-
94-
#define IN_CLASSB(a) ((((u32_t)(a)) & 0xc0000000) == 0x80000000)
95-
#define IN_CLASSB_NET 0xffff0000
96-
#define IN_CLASSB_NSHIFT 16
97-
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
98-
#define IN_CLASSB_MAX 65536
99-
100-
#define IN_CLASSC(a) ((((u32_t)(a)) & 0xe0000000) == 0xc0000000)
101-
#define IN_CLASSC_NET 0xffffff00
102-
#define IN_CLASSC_NSHIFT 8
103-
#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
104-
105-
#define IN_CLASSD(a) (((u32_t)(a) & 0xf0000000) == 0xe0000000)
106-
#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
107-
#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
108-
#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
109-
#define IN_MULTICAST(a) IN_CLASSD(a)
110-
111-
#define IN_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000) == 0xf0000000)
112-
#define IN_BADCLASS(a) (((u32_t)(a) & 0xf0000000) == 0xf0000000)
113-
11472
#define IN_LOOPBACKNET 127 /* official! */
11573

11674

gc/network.h

Lines changed: 8 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
#include <sys/time.h>
66
#include <sys/types.h>
77

8+
#include <sys/socket.h>
9+
#include <sys/ioctl.h>
10+
#include <netinet/in.h>
11+
#include <arpa/inet.h>
12+
#include <netdb.h>
13+
814
#define INVALID_SOCKET (~0)
915
#define SOCKET_ERROR (-1)
1016

@@ -41,15 +47,6 @@
4147
#define SO_TYPE 0x1008 /* get socket type */
4248

4349

44-
45-
/*
46-
* Structure used for manipulating linger option.
47-
*/
48-
struct linger {
49-
int l_onoff; /* option on/off */
50-
int l_linger; /* linger time */
51-
};
52-
5350
/*
5451
* Level number for (get/set)sockopt() to apply to socket itself.
5552
*/
@@ -64,17 +61,11 @@ struct linger {
6461
#define IPPROTO_TCP 6
6562
#define IPPROTO_UDP 17
6663

67-
#define INADDR_ANY 0
68-
#define INADDR_BROADCAST 0xffffffff
69-
70-
/* Flags we can use with send and recv. */
71-
#define MSG_DONTWAIT 0x40 /* Nonblocking i/o for this operation only */
72-
7364
/*
7465
* Options for level IPPROTO_IP
7566
*/
76-
#define IP_TOS 1
77-
#define IP_TTL 2
67+
//#define IP_TOS 1
68+
//#define IP_TTL 2
7869

7970

8071
#define IPTOS_TOS_MASK 0x1E
@@ -99,48 +90,6 @@ struct linger {
9990
#define IPTOS_PREC_PRIORITY 0x20
10091
#define IPTOS_PREC_ROUTINE 0x00
10192

102-
103-
/*
104-
* Commands for ioctlsocket(), taken from the BSD file fcntl.h.
105-
*
106-
*
107-
* Ioctl's have the command encoded in the lower word,
108-
* and the size of any in or out parameters in the upper
109-
* word. The high 2 bits of the upper word are used
110-
* to encode the in/out status of the parameter; for now
111-
* we restrict parameters to at most 128 bytes.
112-
*/
113-
#if !defined(FIONREAD) || !defined(FIONBIO)
114-
#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
115-
#define IOC_VOID 0x20000000 /* no parameters */
116-
#define IOC_OUT 0x40000000 /* copy out parameters */
117-
#define IOC_IN 0x80000000 /* copy in parameters */
118-
#define IOC_INOUT (IOC_IN|IOC_OUT)
119-
/* 0x20000000 distinguishes new &
120-
old ioctl's */
121-
#define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
122-
123-
#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
124-
125-
#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
126-
#endif
127-
128-
#ifndef FIONREAD
129-
#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */
130-
#endif
131-
#ifndef FIONBIO
132-
#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
133-
#endif
134-
135-
/* Socket I/O Controls */
136-
#ifndef SIOCSHIWAT
137-
#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */
138-
#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */
139-
#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */
140-
#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */
141-
#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */
142-
#endif
143-
14493
#ifndef O_NONBLOCK
14594
#define O_NONBLOCK 04000U
14695
#endif
@@ -195,59 +144,17 @@ struct linger {
195144
#define ip4_addr4(ipaddr) ((u32)(ntohl((ipaddr)->s_addr)) & 0xff)
196145
#endif
197146

198-
#define POLLRDNORM 0x0001
199-
#define POLLRDBAND 0x0002
200-
#define POLLPRI 0x0004
201-
#define POLLWRNORM 0x0008
202-
#define POLLWRBAND 0x0010
203-
#define POLLERR 0x0020
204-
#define POLLHUP 0x0040
205-
#define POLLNVAL 0x0080
206-
#define POLLIN (POLLRDNORM|POLLRDBAND)
207-
#define POLLOUT POLLWRNORM
208-
209147
#ifdef __cplusplus
210148
extern "C" {
211149
#endif
212150

213-
#ifndef HAVE_IN_ADDR
214-
#define HAVE_IN_ADDR
215-
struct in_addr {
216-
u32 s_addr;
217-
};
218-
#endif
219-
220-
struct sockaddr_in {
221-
u8 sin_len;
222-
u8 sin_family;
223-
u16 sin_port;
224-
struct in_addr sin_addr;
225-
s8 sin_zero[8];
226-
};
227-
228-
struct sockaddr {
229-
u8 sa_len;
230-
u8 sa_family;
231-
s8 sa_data[14];
232-
};
233-
234-
struct hostent {
235-
char *h_name; /* official name of host */
236-
char **h_aliases; /* alias list */
237-
u16 h_addrtype; /* host address type */
238-
u16 h_length; /* length of address */
239-
char **h_addr_list; /* list of addresses from name server */
240-
};
241-
242151
struct pollsd {
243152
s32 socket;
244153
u32 events;
245154
u32 revents;
246155
};
247156

248157
u32 inet_addr(const char *cp);
249-
s8 inet_aton(const char *cp, struct in_addr *addr);
250-
char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
251158

252159
s32 if_config( char *local_ip, char *netmask, char *gateway,bool use_dhcp, int max_retries);
253160
s32 if_configex(struct in_addr *local_ip, struct in_addr *netmask, struct in_addr *gateway, bool use_dhcp, int max_retries);

libdb/tcpip.h

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,8 @@
44
#include "uIP/uip.h"
55
#include <sys/time.h>
66
#include <sys/types.h>
7-
8-
#define AF_UNSPEC 0
9-
#define AF_INET 2
10-
#define PF_INET AF_INET
11-
#define PF_UNSPEC AF_UNSPEC
12-
13-
#define INADDR_ANY 0
14-
#define INADDR_BROADCAST 0xffffffff
15-
16-
#ifndef socklen_t
17-
#define socklen_t u32_t
18-
#endif
19-
20-
#ifndef HAVE_IN_ADDR
21-
#define HAVE_IN_ADDR
22-
struct in_addr {
23-
u32 s_addr;
24-
};
25-
#endif
26-
27-
struct sockaddr_in {
28-
u8 sin_len;
29-
u8 sin_family;
30-
u16 sin_port;
31-
struct in_addr sin_addr;
32-
s8 sin_zero[8];
33-
};
34-
35-
struct sockaddr {
36-
u8 sa_len;
37-
u8 sa_family;
38-
s8 sa_data[14];
39-
};
7+
#include <sys/socket.h>
8+
#include "netinet/in.h"
409

4110
struct dbginterface* tcpip_init(struct uip_ip_addr *localip,struct uip_ip_addr *netmask,struct uip_ip_addr *gateway,u16 port);
4211

0 commit comments

Comments
 (0)