ObjFW  Check-in [530decab01]

Overview
Comment:Revive the PSP port.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 530decab01e2feca4d3f2786a03ad826ae4747331ba6a88f6971dd24a9f640ef
User & Date: js on 2013-06-26 17:18:16
Other Links: manifest | tags
Context
2013-06-27
09:38
Improve OFFile API. check-in: 20a5c3d547 user: js tags: trunk
2013-06-26
17:18
Revive the PSP port. check-in: 530decab01 user: js tags: trunk
16:33
OF(Big)DataArray: Fix capacity handling. check-in: 93755dd482 user: js tags: trunk
Changes

Modified configure.ac from [88fb3a6ad9] to [b939ec3d54].

1
2
3
4




5



6
7
8





9
10
11
12
13
14
15
AC_INIT(ObjFW, 0.8-dev, js@webkeks.org)
AC_CONFIG_SRCDIR(src)

AS_IF([test x"$host" = x"psp"], [




	OBJCFLAGS="-G0 $OBJCFLAGS"



	LIBS="$LIBS -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc"
	LIBS="$LIBS -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver"
	LIBS="$LIBS -lpsputility -lpspuser -lpspkernel"





])

AC_CANONICAL_HOST

AC_LANG([Objective C])
AC_PROG_OBJC([clang gcc])
AC_PROG_OBJCPP




>
>
>
>
|
>
>
>
|
|
|
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
AC_INIT(ObjFW, 0.8-dev, js@webkeks.org)
AC_CONFIG_SRCDIR(src)

AS_IF([test x"$host" = x"psp"], [
	AS_IF([test x"$DEVKITPSP" = x""], [
		AC_MSG_ERROR([DEVKITPSP is not set! Please set DEVKITPSP.])
	])

	OBJCFLAGS="$OBJCFLAGS -G0"
	CPPFLAGS="$CPPFLAGS -I$DEVKITPSP/psp/sdk/include"
	LDFLAGS="$LDFLAGS -G0"
	LIBS="$LIBS -L$DEVKITPSP/psp/sdk/lib -lpspdebug -lpspdisplay -lpspge"
	LIBS="$LIBS -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet"
	LIBS="$LIBS -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser"
	LIBS="$LIBS -lpspkernel"
	enable_shared="no"
	enable_threads="no"	# TODO
	enable_sockets="no"	# TODO

	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
])

AC_CANONICAL_HOST

AC_LANG([Objective C])
AC_PROG_OBJC([clang gcc])
AC_PROG_OBJCPP
32
33
34
35
36
37
38


39
40
41
42
43
44
45
	OBJCFLAGS="$OBJCFLAGS -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float"
	CPPFLAGS="$CPPFLAGS -I$DEVKITPRO/libogc/include"
	LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float"
	LIBS="$LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc"
	TESTS_LIBS="$TESTS_LIBS -lwiiuse -lbte"
	enable_shared="no"
	enable_threads="no"	# TODO


])

AX_CHECK_COMPILER_FLAGS(-std=gnu99, [OBJCFLAGS="$OBJCFLAGS -std=gnu99"])
case $OBJC in
	*clang*)
		;;
	*)







>
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	OBJCFLAGS="$OBJCFLAGS -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float"
	CPPFLAGS="$CPPFLAGS -I$DEVKITPRO/libogc/include"
	LDFLAGS="$LDFLAGS -mrvl -mcpu=750 -meabi -mhard-float"
	LIBS="$LIBS -L$DEVKITPRO/libogc/lib/wii -lfat -logc"
	TESTS_LIBS="$TESTS_LIBS -lwiiuse -lbte"
	enable_shared="no"
	enable_threads="no"	# TODO

	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$@.map'])
])

AX_CHECK_COMPILER_FLAGS(-std=gnu99, [OBJCFLAGS="$OBJCFLAGS -std=gnu99"])
case $OBJC in
	*clang*)
		;;
	*)
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
		AC_MSG_RESULT(no)
	], [
		AC_MSG_RESULT(yes)
		OBJCFLAGS="$old_OBJCFLAGS"
	])
])

AS_IF([test x"$with_wii" = x"yes"], [
	AC_SUBST(MAP_LDFLAGS, ['-Wl,-Map,$$(basename $@).map'])
])

AS_IF([test x"$cross_compiling" = x"yes"], [
	AC_SUBST(BIN_PREFIX, "$host-")

	case "$host" in
		*-*-mingw*)
			AC_CHECK_PROG(WINE, wine, wine)








<
<
<
<







862
863
864
865
866
867
868




869
870
871
872
873
874
875
		AC_MSG_RESULT(no)
	], [
		AC_MSG_RESULT(yes)
		OBJCFLAGS="$old_OBJCFLAGS"
	])
])





AS_IF([test x"$cross_compiling" = x"yes"], [
	AC_SUBST(BIN_PREFIX, "$host-")

	case "$host" in
		*-*-mingw*)
			AC_CHECK_PROG(WINE, wine, wine)

Modified src/OFDataArray.m from [b741186d9f] to [b66ecb349c].

197
198
199
200
201
202
203
204
205
206
207
208
209
210

211
212
213
214
215
216
217
	Class c;

	c = [self class];
	[self release];

	pool = objc_autoreleasePoolPush();

#ifdef OF_HAVE_SOCKETS
	if ([[URL scheme] isEqual: @"file"]) {
		self = [[c alloc] initWithContentsOfFile: [URL path]];
		objc_autoreleasePoolPop(pool);
		return self;
	}


	client = [OFHTTPClient client];
	request = [OFHTTPRequest requestWithURL: URL];
	reply = [client performRequest: request];

	if ([reply statusCode] != 200)
		@throw [OFHTTPRequestFailedException
		    exceptionWithRequest: request







<






>







197
198
199
200
201
202
203

204
205
206
207
208
209
210
211
212
213
214
215
216
217
	Class c;

	c = [self class];
	[self release];

	pool = objc_autoreleasePoolPush();


	if ([[URL scheme] isEqual: @"file"]) {
		self = [[c alloc] initWithContentsOfFile: [URL path]];
		objc_autoreleasePoolPop(pool);
		return self;
	}

#ifdef OF_HAVE_SOCKETS
	client = [OFHTTPClient client];
	request = [OFHTTPRequest requestWithURL: URL];
	reply = [client performRequest: request];

	if ([reply statusCode] != 200)
		@throw [OFHTTPRequestFailedException
		    exceptionWithRequest: request

Modified src/OFTCPSocket.m from [3305aefb9e] to [68c36aac7d].

79
80
81
82
83
84
85












86
87
88
89
90
91
92

static OFMutex *mutex = nil;
#endif

#ifdef _WIN32
# define close(sock) closesocket(sock)
#endif













#ifdef __wii__
# define accept(sock, addr, addrlen) net_accept(sock, addr, addrlen)
# define bind(sock, addr, addrlen) net_bind(sock, addr, addrlen)
# define close(sock) net_close(sock)
# define connect(sock, addr, addrlen) net_connect(sock, addr, addrlen)
# define gethostbyname(name) net_gethostbyname(name)







>
>
>
>
>
>
>
>
>
>
>
>







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

static OFMutex *mutex = nil;
#endif

#ifdef _WIN32
# define close(sock) closesocket(sock)
#endif

#ifdef _PSP
/* PSP defines AF_INET6, even though sockaddr_in6 is missing */
# undef AF_INET6
struct sockaddr_storage {
	uint8_t	       ss_len;
	sa_family_t    ss_family;
	in_port_t      ss_data1;
	struct in_addr ss_data2;
	int8_t	       ss_data3[8];
};
#endif

#ifdef __wii__
# define accept(sock, addr, addrlen) net_accept(sock, addr, addrlen)
# define bind(sock, addr, addrlen) net_bind(sock, addr, addrlen)
# define close(sock) net_close(sock)
# define connect(sock, addr, addrlen) net_connect(sock, addr, addrlen)
# define gethostbyname(name) net_gethostbyname(name)

Modified src/macros.h from [533552d659] to [b1f9e2924b].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <stdlib.h>

#if defined(OF_APPLE_RUNTIME)
# import <objc/runtime.h>
#endif

#ifdef _PSP
# define INTMAX_MAX LONG_LONG_MAX
#endif

#ifdef __GNUC__
# define OF_INLINE inline __attribute__((always_inline))
# define OF_LIKELY(cond) (__builtin_expect(!!(cond), 1))
# define OF_UNLIKELY(cond) (__builtin_expect(!!(cond), 0))
# define OF_CONST_FUNC __attribute__((const))
#else
# define OF_INLINE inline







<
<
<
<







21
22
23
24
25
26
27




28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>

#if defined(OF_APPLE_RUNTIME)
# import <objc/runtime.h>
#endif





#ifdef __GNUC__
# define OF_INLINE inline __attribute__((always_inline))
# define OF_LIKELY(cond) (__builtin_expect(!!(cond), 1))
# define OF_UNLIKELY(cond) (__builtin_expect(!!(cond), 0))
# define OF_CONST_FUNC __attribute__((const))
#else
# define OF_INLINE inline

Modified src/of_asprintf.m from [2e133e3806] to [aad6d97af9].

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
		}

		break;
	case 'j':
#if defined(_WIN32)
		if (!append_subformat(ctx, "I64", 3))
			return false;
#elif defined(__wii__)
		if (!append_subformat(ctx, "ll", 2))
			return false;
#else
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
			return false;
#endif

		ctx->length_modifier = LENGTH_MODIFIER_J;

		break;
	case 'z':
#if defined(_WIN32)
		if (!append_subformat(ctx, "I", 1))
			return false;
#elif defined(__wii__)
		if (!append_subformat(ctx, "l", 1))
			return false;
#else
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
			return false;
#endif

		ctx->length_modifier = LENGTH_MODIFIER_Z;

		break;
	case 't':
#if defined(_WIN32)
		if (!append_subformat(ctx, "I", 1))
			return false;
#elif defined(__wii__)
		if (!append_subformat(ctx, "l", 1))
			return false;
#else
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
			return false;
#endif








|














|














|







196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
		}

		break;
	case 'j':
#if defined(_WIN32)
		if (!append_subformat(ctx, "I64", 3))
			return false;
#elif defined(__wii__) || defined(_PSP)
		if (!append_subformat(ctx, "ll", 2))
			return false;
#else
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
			return false;
#endif

		ctx->length_modifier = LENGTH_MODIFIER_J;

		break;
	case 'z':
#if defined(_WIN32)
		if (!append_subformat(ctx, "I", 1))
			return false;
#elif defined(__wii__) || defined(_PSP)
		if (!append_subformat(ctx, "l", 1))
			return false;
#else
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
			return false;
#endif

		ctx->length_modifier = LENGTH_MODIFIER_Z;

		break;
	case 't':
#if defined(_WIN32)
		if (!append_subformat(ctx, "I", 1))
			return false;
#elif defined(__wii__) || defined(_PSP)
		if (!append_subformat(ctx, "l", 1))
			return false;
#else
		if (!append_subformat(ctx, ctx->format + ctx->i, 1))
			return false;
#endif

Modified tests/TestsAppDelegate.m from [f5e90b7f86] to [fcc3870011].

76
77
78
79
80
81
82

83





84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

102

103
104
105
106
107
108

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143

	VIDEO_WaitVSync();
	if (rmode->viTVMode & VI_NON_INTERLACE)
		VIDEO_WaitVSync();

	CON_InitEx(rmode, 10, 20, rmode->fbWidth - 10, rmode->xfbHeight - 20);
	VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK);







	@try {
		return of_application_main(&argc, &argv,
		    [TestsAppDelegate class]);
	} @catch (id e) {
		TestsAppDelegate *delegate =
		    [[OFApplication sharedApplication] delegate];
		OFString *string = [OFString stringWithFormat:
		    @"\nRuntime error: Unhandled exception:\n%@\n", e];
		OFString *backtrace = [OFString stringWithFormat:
		    @"\nBacktrace:\n  %@\n\n",
		    [[e backtrace] componentsJoinedByString: @"\n  "]];

		[delegate outputString: string
			       inColor: RED];
		[delegate outputString: backtrace
			       inColor: RED];
		[delegate outputString: @"Press home button to exit!\n"
			       inColor: NO_COLOR];

		for (;;) {

			WPAD_ScanPads();

			if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
				[OFApplication terminateWithStatus: 1];

			VIDEO_WaitVSync();

		}
	}
#else
	return of_application_main(&argc, &argv, [TestsAppDelegate class]);
#endif
}

@implementation TestsAppDelegate
- (void)outputString: (OFString*)str
	     inColor: (int)color
{
#if defined(_PSP)
	char i, space = ' ';
	int y = pspDebugScreenGetY();

	pspDebugScreenSetXY(0, y);
	for (i = 0; i < 68; i++)
		pspDebugScreenPrintData(&space, 1);

	switch (color) {



	case 0:
		pspDebugScreenSetTextColor(0x00FFFF);
		break;
	case 1:
		pspDebugScreenSetTextColor(0x00FF00);
		break;
	case 2:
		pspDebugScreenSetTextColor(0x0000FF);
		break;
	}

	pspDebugScreenSetXY(0, y);
	pspDebugScreenPrintData([str UTF8String], [str UTF8StringLength]);
#elif defined(STDOUT)
	switch (color) {







>

>
>
>
>
>


















>

>






>




















>
>
>
|
|

|


|
|







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155

	VIDEO_WaitVSync();
	if (rmode->viTVMode & VI_NON_INTERLACE)
		VIDEO_WaitVSync();

	CON_InitEx(rmode, 10, 20, rmode->fbWidth - 10, rmode->xfbHeight - 20);
	VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK);
#endif

#ifdef _PSP
	pspDebugScreenInit();
#endif

#if defined(__wii__) || defined(_PSP)
	@try {
		return of_application_main(&argc, &argv,
		    [TestsAppDelegate class]);
	} @catch (id e) {
		TestsAppDelegate *delegate =
		    [[OFApplication sharedApplication] delegate];
		OFString *string = [OFString stringWithFormat:
		    @"\nRuntime error: Unhandled exception:\n%@\n", e];
		OFString *backtrace = [OFString stringWithFormat:
		    @"\nBacktrace:\n  %@\n\n",
		    [[e backtrace] componentsJoinedByString: @"\n  "]];

		[delegate outputString: string
			       inColor: RED];
		[delegate outputString: backtrace
			       inColor: RED];
		[delegate outputString: @"Press home button to exit!\n"
			       inColor: NO_COLOR];

		for (;;) {
# ifdef __wii__
			WPAD_ScanPads();

			if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
				[OFApplication terminateWithStatus: 1];

			VIDEO_WaitVSync();
# endif
		}
	}
#else
	return of_application_main(&argc, &argv, [TestsAppDelegate class]);
#endif
}

@implementation TestsAppDelegate
- (void)outputString: (OFString*)str
	     inColor: (int)color
{
#if defined(_PSP)
	char i, space = ' ';
	int y = pspDebugScreenGetY();

	pspDebugScreenSetXY(0, y);
	for (i = 0; i < 68; i++)
		pspDebugScreenPrintData(&space, 1);

	switch (color) {
	case NO_COLOR:
		pspDebugScreenSetTextColor(0xFFFFFF);
		break;
	case RED:
		pspDebugScreenSetTextColor(0x0000FF);
		break;
	case GREEN:
		pspDebugScreenSetTextColor(0x00FF00);
		break;
	case YELLOW:
		pspDebugScreenSetTextColor(0x00FFFF);
		break;
	}

	pspDebugScreenSetXY(0, y);
	pspDebugScreenPrintData([str UTF8String], [str UTF8StringLength]);
#elif defined(STDOUT)
	switch (color) {
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
		VIDEO_WaitVSync();
	}
#endif
}

- (void)applicationDidFinishLaunching
{
#ifdef _PSP
	pspDebugScreenInit();
#endif
#ifdef __wii__
	[OFFile changeToDirectoryAtPath: @"/apps/objfw-tests"];
#endif

	[self objectTests];
#ifdef OF_HAVE_BLOCKS
	[self blockTests];







<
<
<







218
219
220
221
222
223
224



225
226
227
228
229
230
231
		VIDEO_WaitVSync();
	}
#endif
}

- (void)applicationDidFinishLaunching
{



#ifdef __wii__
	[OFFile changeToDirectoryAtPath: @"/apps/objfw-tests"];
#endif

	[self objectTests];
#ifdef OF_HAVE_BLOCKS
	[self blockTests];