ObjFW  Diff

Differences From Artifact [ebf56cad93]:

To Artifact [34bd39e695]:


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# include "threading.h"

static of_once_t onceControl = OF_ONCE_INIT;
static of_mutex_t mutex;
#endif
static bool initialized = false;

#ifdef __wii__
# ifdef OF_HAVE_THREADS
static of_spinlock_t spinlock;
# endif
static uint8_t portRegistry[2][65536 / 8];
#endif

static void
init(void)
{
#if defined(_WIN32)
	WSADATA wsa;

	if (WSAStartup(MAKEWORD(2, 0), &wsa))
		return;
#elif defined(__wii__)
	if (net_init() < 0)
		return;
#endif

#ifdef OF_HAVE_THREADS
	if (!of_mutex_new(&mutex))
		return;

# ifdef __wii__
	if (!of_spinlock_new(&spinlock))
		return;
# endif
#endif

	initialized = true;
}







|









|




|








|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# include "threading.h"

static of_once_t onceControl = OF_ONCE_INIT;
static of_mutex_t mutex;
#endif
static bool initialized = false;

#ifdef OF_WII
# ifdef OF_HAVE_THREADS
static of_spinlock_t spinlock;
# endif
static uint8_t portRegistry[2][65536 / 8];
#endif

static void
init(void)
{
#if defined(OF_WINDOWS)
	WSADATA wsa;

	if (WSAStartup(MAKEWORD(2, 0), &wsa))
		return;
#elif defined(OF_WII)
	if (net_init() < 0)
		return;
#endif

#ifdef OF_HAVE_THREADS
	if (!of_mutex_new(&mutex))
		return;

# ifdef OF_WII
	if (!of_spinlock_new(&spinlock))
		return;
# endif
#endif

	initialized = true;
}
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

	return initialized;
}

int
of_socket_errno()
{
#ifndef _WIN32
	return errno;
#else
	switch (WSAGetLastError()) {
	case WSAEACCES:
		return EACCES;
	case WSAEADDRINUSE:
		return EADDRINUSE;







|







77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

	return initialized;
}

int
of_socket_errno()
{
#ifndef OF_WINDOWS
	return errno;
#else
	switch (WSAGetLastError()) {
	case WSAEACCES:
		return EACCES;
	case WSAEADDRINUSE:
		return EADDRINUSE;
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
		return EWOULDBLOCK;
	}

	return 0;
#endif
}

#ifndef __wii__
int
of_getsockname(of_socket_t socket, struct sockaddr *restrict address,
    socklen_t *restrict address_len)
{
	int ret;

# ifdef OF_HAVE_THREADS







|







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
		return EWOULDBLOCK;
	}

	return 0;
#endif
}

#ifndef OF_WII
int
of_getsockname(of_socket_t socket, struct sockaddr *restrict address,
    socklen_t *restrict address_len)
{
	int ret;

# ifdef OF_HAVE_THREADS