ObjFW  Check-in [d230ac577d]

Overview
Comment:Initial PSP port.

Does compile with --disable-threads --disable-shared, but does not link
yet.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d230ac577d54fa5e1d6913b74691699ac7733ff68b0f4cfdb65b0ebdfd895eb7
User & Date: js on 2011-02-09 18:55:29
Other Links: manifest | tags
Context
2011-02-09
19:34
More changes to port ObjFW to PSP. check-in: 33f646ce2d user: js tags: trunk
18:55
Initial PSP port. check-in: d230ac577d user: js tags: trunk
18:27
Add two missing includes. check-in: 90893f3cbe user: js tags: trunk
Changes

Modified config.sub from [4960851b86] to [7000ece130].

730
731
732
733
734
735
736




737
738
739
740
741
742
743
	miniframe)
		basic_machine=m68000-convergent
		;;
	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
		basic_machine=m68k-atari
		os=-mint
		;;




	mips3*-*)
		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
		;;
	mips3*)
		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
		;;
	monitor)







>
>
>
>







730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
	miniframe)
		basic_machine=m68000-convergent
		;;
	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
		basic_machine=m68k-atari
		os=-mint
		;;
	psp)
		basic_machine=mipsallegrexel-psp
		os=-elf
		;;
	mips3*-*)
		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
		;;
	mips3*)
		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
		;;
	monitor)

Modified configure.ac from [d6ec578bbd] to [ecf4c3dfb1].

1
2





3
4
5
6
7
8
9
AC_INIT(ObjFW, 0.4-dev, js@webkeks.org)
AC_CONFIG_SRCDIR(src)






AC_CANONICAL_HOST

AC_LANG([Objective C])
AC_PROG_OBJC
AC_PROG_OBJCPP
AC_PROG_LN_S


>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
AC_INIT(ObjFW, 0.4-dev, js@webkeks.org)
AC_CONFIG_SRCDIR(src)

AS_IF([test x"$host" = x"psp"], [
	LIBS="$LIBS -lc -lpspkernel -lpspuser"
	LIBS="$LIBS -lpspnet -lpspnet_inet -lpspnet_resolver"
])

AC_CANONICAL_HOST

AC_LANG([Objective C])
AC_PROG_OBJC
AC_PROG_OBJCPP
AC_PROG_LN_S
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
AC_MSG_CHECKING(which Objective C runtime we use)
case $objc_runtime in
	ObjFW-RT)
		AC_DEFINE(OF_OBJFW_RUNTIME, 1,
			[Whether we use the ObjFW runtime])
		AC_SUBST(GNU_RUNTIME, "-fgnu-runtime")
		OBJCFLAGS="$OBJCFLAGS -fgnu-runtime"
		LIBS="$LIBS -lobjfw-rt"
		;;
	Apple)
		AC_DEFINE(OF_APPLE_RUNTIME, 1,
			[Whether we use the Apple ObjC runtime])
		LIBS="$LIBS -lobjc"
		;;
	GNU)
		AC_DEFINE(OF_GNU_RUNTIME, 1,
			[Whether we use the GNU ObjC runtime])
		LIBS="$LIBS -lobjc"
		;;
	"old GNU")
		AC_DEFINE(OF_OLD_GNU_RUNTIME, 1,
			[Whether we use the old GNU ObjC runtime])
		LIBS="$LIBS -lobjc"
		;;
	*)
		AC_MSG_RESULT(none)
		AC_MSG_ERROR(No ObjC runtime found! Please install ObjFW-RT!)
		;;
esac
AC_MSG_RESULT($objc_runtime)







|




|




|




|







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
AC_MSG_CHECKING(which Objective C runtime we use)
case $objc_runtime in
	ObjFW-RT)
		AC_DEFINE(OF_OBJFW_RUNTIME, 1,
			[Whether we use the ObjFW runtime])
		AC_SUBST(GNU_RUNTIME, "-fgnu-runtime")
		OBJCFLAGS="$OBJCFLAGS -fgnu-runtime"
		LIBS="-lobjfw-rt $LIBS"
		;;
	Apple)
		AC_DEFINE(OF_APPLE_RUNTIME, 1,
			[Whether we use the Apple ObjC runtime])
		LIBS="-lobjc $LIBS"
		;;
	GNU)
		AC_DEFINE(OF_GNU_RUNTIME, 1,
			[Whether we use the GNU ObjC runtime])
		LIBS="-lobjc $LIBS"
		;;
	"old GNU")
		AC_DEFINE(OF_OLD_GNU_RUNTIME, 1,
			[Whether we use the old GNU ObjC runtime])
		LIBS="-lobjc $LIBS"
		;;
	*)
		AC_MSG_RESULT(none)
		AC_MSG_ERROR(No ObjC runtime found! Please install ObjFW-RT!)
		;;
esac
AC_MSG_RESULT($objc_runtime)

Modified src/OFExceptions.m from [66659ddd45] to [c20d586426].

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#  define GET_AT_ERRNO	h_errno
# else
#  define GET_AT_ERRNO	errno
# endif
# define GET_SOCK_ERRNO	errno
# define ERRFMT		"Error string was: %s"
# define ERRPARAM	strerror(errNo)
# ifndef HAVE_THREADSAFE_GETADDRINFO
#  define AT_ERRPARAM	hstrerror(errNo)
# else
#  define AT_ERRPARAM	strerror(errNo)
# endif
#else
# include <windows.h>
# define GET_ERRNO	GetLastError()







|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#  define GET_AT_ERRNO	h_errno
# else
#  define GET_AT_ERRNO	errno
# endif
# define GET_SOCK_ERRNO	errno
# define ERRFMT		"Error string was: %s"
# define ERRPARAM	strerror(errNo)
# if !defined(HAVE_THREADSAFE_GETADDRINFO) && !defined(_PSP)
#  define AT_ERRPARAM	hstrerror(errNo)
# else
#  define AT_ERRPARAM	strerror(errNo)
# endif
#else
# include <windows.h>
# define GET_ERRNO	GetLastError()

Modified src/OFFile.h from [c3892e8bd0] to [ee5f8a5c17].

176
177
178
179
180
181
182

183

184
185
186
187
188
189
190
 * Not available on Windows.
 *
 * \param src The path to the file of which should be linked as a string
 * \param dest The path to where the file should be linked as a string
 */
+ (void)linkFileAtPath: (OFString*)src
		toPath: (OFString*)dest;



/**
 * Symlinks a file.
 *
 * Not available on Windows.
 *
 * \param src The path to the file of which should be symlinked as a string
 * \param dest The path to where the file should be symlinked as a string







>

>







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
 * Not available on Windows.
 *
 * \param src The path to the file of which should be linked as a string
 * \param dest The path to where the file should be linked as a string
 */
+ (void)linkFileAtPath: (OFString*)src
		toPath: (OFString*)dest;
#endif

#if !defined(_WIN32) && !defined(_PSP)
/**
 * Symlinks a file.
 *
 * Not available on Windows.
 *
 * \param src The path to the file of which should be symlinked as a string
 * \param dest The path to where the file should be symlinked as a string

Modified src/OFFile.m from [719e5e7862] to [ab8f876cd6].

590
591
592
593
594
595
596

597

598
599
600
601
602
603
604
	}

	if (link([src cString], [dest cString]) != 0)
		@throw [OFLinkFailedException newWithClass: self
						sourcePath: src
					   destinationPath: dest];
}



+ (void)symlinkFileAtPath: (OFString*)src
		   toPath: (OFString*)dest
{
	if ([self directoryExistsAtPath: dest]) {
		OFString *filename = [self lastComponentOfPath: src];
		dest = [OFString stringWithPath: dest, filename, nil];
	}







>

>







590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
	}

	if (link([src cString], [dest cString]) != 0)
		@throw [OFLinkFailedException newWithClass: self
						sourcePath: src
					   destinationPath: dest];
}
#endif

#if !defined(_WIN32) && !defined(_PSP)
+ (void)symlinkFileAtPath: (OFString*)src
		   toPath: (OFString*)dest
{
	if ([self directoryExistsAtPath: dest]) {
		OFString *filename = [self lastComponentOfPath: src];
		dest = [OFString stringWithPath: dest, filename, nil];
	}

Modified src/OFTCPSocket.m from [b9305562e5] to [1565c3535f].

101
102
103
104
105
106
107

108

109
110
111
112
113
114
115
		break;
	}

	freeaddrinfo(res0);
#else
	BOOL connected = NO;
	struct hostent *he;

	struct servent *se;

	struct sockaddr_in addr;
	uint16_t port;
	char **ip;
# ifdef OF_THREADS
	OFDataArray *addrlist;

	addrlist = [[OFDataArray alloc] initWithItemSize: sizeof(char**)];







>

>







101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
		break;
	}

	freeaddrinfo(res0);
#else
	BOOL connected = NO;
	struct hostent *he;
# ifndef _PSP
	struct servent *se;
# endif
	struct sockaddr_in addr;
	uint16_t port;
	char **ip;
# ifdef OF_THREADS
	OFDataArray *addrlist;

	addrlist = [[OFDataArray alloc] initWithItemSize: sizeof(char**)];
123
124
125
126
127
128
129

130
131
132

133
134
135
136
137
138
139
# endif
		@throw [OFAddressTranslationFailedException
		    newWithClass: isa
			    node: node
			 service: service];
	}


	if ((se = getservbyname([service cString], "tcp")) != NULL)
		port = se->s_port;
	else {

		@try {
			intmax_t p = [service decimalValue];

			if (p < 1 || p > 65535)
				@throw [OFOutOfRangeException
				    newWithClass: isa];








>



>







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# endif
		@throw [OFAddressTranslationFailedException
		    newWithClass: isa
			    node: node
			 service: service];
	}

# ifndef _PSP
	if ((se = getservbyname([service cString], "tcp")) != NULL)
		port = se->s_port;
	else {
# endif
		@try {
			intmax_t p = [service decimalValue];

			if (p < 1 || p > 65535)
				@throw [OFOutOfRangeException
				    newWithClass: isa];

151
152
153
154
155
156
157

158

159
160
161
162
163
164
165
		} @catch (id e) {
# ifdef OF_THREADS
			[addrlist release];
			[mutex unlock];
# endif
			@throw e;
		}

	}


	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = port;

	if (he->h_addrtype != AF_INET ||
	    (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {







>

>







155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
		} @catch (id e) {
# ifdef OF_THREADS
			[addrlist release];
			[mutex unlock];
# endif
			@throw e;
		}
# ifndef _PSP
	}
# endif

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = port;

	if (he->h_addrtype != AF_INET ||
	    (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
248
249
250
251
252
253
254

255

256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272

273
274
275

276
277
278
279
280
281
282
						      node: node
						   service: service];
	}

	freeaddrinfo(res);
#else
	struct hostent *he;

	struct servent *se;

	struct sockaddr_in addr;
	uint16_t port;

# ifdef OF_THREADS
	[mutex lock];
# endif

	if ((he = gethostbyname([node cString])) == NULL) {
# ifdef OF_THREADS
		[mutex unlock];
# endif
		@throw [OFAddressTranslationFailedException
		    newWithClass: isa
			    node: node
			 service: service];
	}


	if ((se = getservbyname([service cString], "tcp")) != NULL)
		port = se->s_port;
	else {

		@try {
			intmax_t p = [service decimalValue];

			if (p < 1 || p > 65535)
				@throw [OFOutOfRangeException
				    newWithClass: isa];








>

>

















>



>







254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
						      node: node
						   service: service];
	}

	freeaddrinfo(res);
#else
	struct hostent *he;
# ifndef _PSP
	struct servent *se;
# endif
	struct sockaddr_in addr;
	uint16_t port;

# ifdef OF_THREADS
	[mutex lock];
# endif

	if ((he = gethostbyname([node cString])) == NULL) {
# ifdef OF_THREADS
		[mutex unlock];
# endif
		@throw [OFAddressTranslationFailedException
		    newWithClass: isa
			    node: node
			 service: service];
	}

# ifndef _PSP
	if ((se = getservbyname([service cString], "tcp")) != NULL)
		port = se->s_port;
	else {
# endif
		@try {
			intmax_t p = [service decimalValue];

			if (p < 1 || p > 65535)
				@throw [OFOutOfRangeException
				    newWithClass: isa];

292
293
294
295
296
297
298

299

300
301
302
303
304
305
306
				 service: service];
		} @catch (id e) {
# ifdef OF_THREADS
			[mutex unlock];
# endif
			@throw e;
		}

	}


	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = port;

	if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) {
# ifdef OF_THREADS







>

>







302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
				 service: service];
		} @catch (id e) {
# ifdef OF_THREADS
			[mutex unlock];
# endif
			@throw e;
		}
# ifndef _PSP
	}
# endif

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = port;

	if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) {
# ifdef OF_THREADS

Modified src/macros.h from [00f7754073] to [957228cdfe].

21
22
23
24
25
26
27




28
29
30
31
32
33
34
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif

#include <stddef.h>
#include <stdint.h>





#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







>
>
>
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#endif
#ifndef __STDC_CONSTANT_MACROS
# define __STDC_CONSTANT_MACROS
#endif

#include <stddef.h>
#include <stdint.h>

#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