ObjFW  Check-in [a30a0ab261]

Overview
Comment:Add initial socket code for Nintendo Switch

This doesn't work yet (it crashes on recvfrom), so it's not enabled in
configure for now.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nintendo-switch
Files: files | file ages | folders
SHA3-256: a30a0ab261acffd689560207c5e0780989520a42734812a9b5343f5b95caaff1
User & Date: js on 2022-07-31 13:55:49
Other Links: branch diff | manifest | tags
Context
2022-07-31
13:56
PLATFORMS.md: Add Nintendo Switch Closed-Leaf check-in: b366e52dee user: js tags: nintendo-switch
13:55
Add initial socket code for Nintendo Switch check-in: a30a0ab261 user: js tags: nintendo-switch
2022-07-17
22:49
Add support for files on Nintendo Switch check-in: 3228d624fe user: js tags: nintendo-switch
Changes

Modified src/OFFile.m from [732a34cd87] to [6bda5c55f7].

169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
169
170
171
172
173
174
175










176
177
178
179
180
181
182







-
-
-
-
-
-
-
-
-
-







		return MODE_READWRITE;
	}

	return -1;
}
#endif

#ifdef OF_NINTENDO_SWITCH
static bool initialized = false;

OF_DESTRUCTOR()
{
	if (initialized)
		romfsExit();
}
#endif

@implementation OFFile
+ (void)initialize
{
	if (self != [OFFile class])
		return;

#ifdef OF_WII
203
204
205
206
207
208
209
210

211
212
213
214
215
216
217
193
194
195
196
197
198
199

200
201
202
203
204
205
206
207







-
+








#ifdef OF_NINTENDO_SWITCH
	if (R_SUCCEEDED(romfsInit()))
		/*
		 * Errors are intentionally ignored, as it's possible we just
		 * have no romfs.
		 */
		initialized = true;
		atexit((void (*)(void))romfsExit);
#endif
}

+ (instancetype)fileWithPath: (OFString *)path mode: (OFString *)mode
{
	return [[[self alloc] initWithPath: path mode: mode] autorelease];
}

Modified src/OFSocket.m from [8f11763ca5] to [16116f3ca3].

52
53
54
55
56
57
58






59
60
61
62
63
64
65
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71







+
+
+
+
+
+







# include <proto/exec.h>
#endif

#ifdef OF_NINTENDO_3DS
# include <3ds/types.h>
# include <3ds/services/soc.h>
#endif

#ifdef OF_NINTENDO_SWITCH
# define id nx_id
# include <switch.h>
# undef id
#endif

#if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS))
static OFMutex *mutex;

static void
releaseMutex(void)
{
126
127
128
129
130
131
132





133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148





149
150
151
152
153
154
155







+
+
+
+
+





-
-
-
-
-







	if ((ctx = memalign(0x1000, 0x100000)) == NULL)
		return;

	if (socInit(ctx, 0x100000) != 0)
		return;

	atexit((void (*)(void))socExit);
# elif defined(OF_NINTENDO_SWITCH)
	if (R_FAILED(socketInitializeDefault()))
		return;

	atexit(socketExit);
# endif

# if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS))
	mutex = [[OFMutex alloc] init];
	atexit(releaseMutex);

#  ifdef OF_WII
	if (OFSpinlockNew(&spinlock) != 0)
		return;
#  endif
# endif

	initSuccessful = true;
}

OF_DESTRUCTOR()
{