ObjFW  Check-in [7b0cd744dc]

Overview
Comment:Make ObjFW compile on macOS/PowerPC 64
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7b0cd744dc02d432e2a1a0bf8448b970ca6f05f833406dd9a5506b468eb6e101
User & Date: js on 2024-08-21 20:14:09
Other Links: manifest | tags
Context
2024-08-21
20:18
OFSystemInfoTests: Show AltiVec support on PPC64 check-in: 62f3c342ab user: js tags: trunk
20:14
Make ObjFW compile on macOS/PowerPC 64 check-in: 7b0cd744dc user: js tags: trunk
2024-08-20
22:25
Disable buggy warning on PowerPC 64 big endian check-in: 16bfb32a24 user: js tags: trunk
Changes

Modified configure.ac from [4a09a376d7] to [5b53492ab9].

659
660
661
662
663
664
665


666
667
668


669
670
671
672
673
674
675
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679







+
+



+
+







	OBJCFLAGS="$OBJCFLAGS -lobjc"

	AC_CHECK_FUNC(objc_autoreleasePoolPush, [], [
		AC_SUBST(RUNTIME_AUTORELEASE_M, "runtime/autorelease.m")
	])
	AC_CHECK_FUNC(objc_constructInstance, [], [
		AC_SUBST(RUNTIME_INSTANCE_M, "runtime/instance.m")
		AC_DEFINE(OF_DECLARE_CONSTRUCT_INSTANCE, 1,
			[Whether to declare objc_constructInstance])
	])
	AC_CHECK_FUNCS(objc_setAssociatedObject, [], [
		AC_SUBST(RUNTIME_ASSOCIATION_M, "runtime/association.m")
		AC_DEFINE(OF_DECLARE_SET_ASSOCIATED_OBJECT, 1,
			[Whether to declare objc_setAssociatedObject])
	])

	OBJCFLAGS="$old_OBJCFLAGS"
	;;
esac

case "$host_os" in

Modified src/OFDDPSocket.m from [ff7f44acd0] to [542fe8e394].

161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
161
162
163
164
165
166
167

168
169
170
171
172
173
174
175







-
+







			    protocolType: protocolType
				  socket: self
				   errNo: EAFNOSUPPORT];
	}

#ifdef OF_MACOS
	if (setsockopt(_socket, ATPROTO_NONE, DDP_STRIPHDR, &one,
	    sizeof(one)) != 0 || ioctl(_socket, _IOWR('a', 2,
	    (socklen_t)sizeof(one)) != 0 || ioctl(_socket, _IOWR('a', 2,
	    struct ATInterfaceConfig), &config) != 0)
		@throw [OFBindDDPSocketFailedException
		    exceptionWithNetwork: network
				    node: node
				    port: port
			    protocolType: protocolType
				  socket: self

Modified src/OFDNSResolver.m from [d30e19048e] to [632303a834].

181
182
183
184
185
186
187
188

189
190
191
192
193
194
195
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195







-
+







		OFSocketAddress address;

		if (dataLength != 4)
			@throw [OFInvalidServerResponseException exception];

		memset(&address, 0, sizeof(address));
		address.family = OFSocketAddressFamilyIPv4;
		address.length = sizeof(address.sockaddr.in);
		address.length = (socklen_t)sizeof(address.sockaddr.in);

		address.sockaddr.in.sin_family = AF_INET;
		memcpy(&address.sockaddr.in.sin_addr.s_addr, buffer + i, 4);

		return [[[OFADNSResourceRecord alloc]
		    initWithName: name
			 address: &address
368
369
370
371
372
373
374
375

376
377
378
379
380
381
382
368
369
370
371
372
373
374

375
376
377
378
379
380
381
382







-
+







		OFSocketAddress address;

		if (dataLength != 16)
			@throw [OFInvalidServerResponseException exception];

		memset(&address, 0, sizeof(address));
		address.family = OFSocketAddressFamilyIPv6;
		address.length = sizeof(address.sockaddr.in6);
		address.length = (socklen_t)sizeof(address.sockaddr.in6);

#ifdef AF_INET6
		address.sockaddr.in6.sin6_family = AF_INET6;
#else
		address.sockaddr.in6.sin6_family = AF_UNSPEC;
#endif
		memcpy(address.sockaddr.in6.sin6_addr.s6_addr, buffer + i, 16);

Modified src/OFDatagramSocket.m from [009edc504e] to [7c8f8ff231].

153
154
155
156
157
158
159
160

161
162
163
164
165
166
167
153
154
155
156
157
158
159

160
161
162
163
164
165
166
167







-
+







#endif
}

- (bool)canSendToBroadcastAddresses
{
#ifndef OF_WII
	int v;
	socklen_t len = sizeof(v);
	socklen_t len = (socklen_t)sizeof(v);

	if (getsockopt(_socket, SOL_SOCKET, SO_BROADCAST,
	    (char *)&v, &len) != 0 || len != sizeof(v))
		@throw [OFGetOptionFailedException
		    exceptionWithObject: self
				  errNo: _OFSocketErrNo()];

Modified src/OFGZIPStream.m from [7c25979fa6] to [f9be41fb0e].

245
246
247
248
249
250
251
252

253
254
255
256
257
258
259
245
246
247
248
249
250
251

252
253
254
255
256
257
258
259







-
+








			if (!_inflateStream.atEndOfStream) {
				size_t bytesRead = [_inflateStream
				    readIntoBuffer: buffer
					    length: length];

				_CRC32 = _OFCRC32(_CRC32, buffer, bytesRead);
				_uncompressedSize += bytesRead;
				_uncompressedSize += (uint32_t)bytesRead;

				return bytesRead;
			}

			[_inflateStream release];
			_inflateStream = nil;

Modified src/OFLHAArchiveEntry.m from [9d58a40bb8] to [1d66542ada].

446
447
448
449
450
451
452
453

454
455
456
457
458
459
460
446
447
448
449
450
451
452

453
454
455
456
457
458
459
460







-
+







			if (_headerLevel == 1)
				readExtensions(self, stream, encoding, false);

			objc_autoreleasePoolPop(pool);
			break;
		case 2:
		case 3:;
			uint32_t padding = 0;
			size_t padding = 0;

			_modificationDate = [[OFDate alloc]
			    initWithTimeIntervalSince1970: date];

			_CRC16 = [stream readLittleEndianInt16];
			_operatingSystemIdentifier = [stream readInt8];

Modified src/OFObject.h from [036e696929] to [19c484f42c].

1459
1460
1461
1462
1463
1464
1465
1466

1467
1468
1469


1470
1471
1472
1473
1474
1475
1476
1459
1460
1461
1462
1463
1464
1465

1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478







-
+



+
+







 *		  nothing)
 */
extern void OFFreeMemory(void *_Nullable pointer);

#ifdef OF_APPLE_RUNTIME
extern void *_Null_unspecified objc_autoreleasePoolPush(void);
extern void objc_autoreleasePoolPop(void *_Null_unspecified pool);
# ifndef __OBJC2__
# ifdef OF_DECLARE_CONSTRUCT_INSTANCE
extern id _Nullable objc_constructInstance(Class _Nullable class_,
    void *_Nullable bytes);
extern void *_Nullable objc_destructInstance(id _Nullable object);
# endif
# ifdef OF_DECLARE_SET_ASSOCIATED_OBJECT
typedef enum objc_associationPolicy {
	OBJC_ASSOCIATION_ASSIGN	= 0,
	OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1,
	OBJC_ASSOCIATION_RETAIN = OBJC_ASSOCIATION_RETAIN_NONATOMIC | 0x300,
	OBJC_ASSOCIATION_COPY_NONATOMIC = 3,
	OBJC_ASSOCIATION_COPY = OBJC_ASSOCIATION_COPY_NONATOMIC | 0x300
} objc_associationPolicy;

Modified src/OFScrypt.m from [480d9e7945] to [c50b4e74e3].

124
125
126
127
128
129
130
131
132


133
134
135
136
137
138
139
124
125
126
127
128
129
130


131
132
133
134
135
136
137
138
139







-
-
+
+








	for (size_t i = 0; i < costFactor; i++) {
		memcpy(tmp2 + i * 32 * blockSize, tmp, 128 * blockSize);
		_OFScryptBlockMix(tmp, tmp2 + i * 32 * blockSize, blockSize);
	}

	for (size_t i = 0; i < costFactor; i++) {
		uint32_t j = OFFromLittleEndian32(
		    tmp[(2 * blockSize - 1) * 16]) & (costFactor - 1);
		uint32_t j = (uint32_t)(OFFromLittleEndian32(
		    tmp[(2 * blockSize - 1) * 16]) & (costFactor - 1));

		for (size_t k = 0; k < 32 * blockSize; k++)
			tmp[k] ^= tmp2[j * 32 * blockSize + k];

		_OFScryptBlockMix(buffer, tmp, blockSize);

		if (i < costFactor - 1)

Modified src/OFSequencedPacketSocket.m from [494885f162] to [70e9e84ad7].

88
89
90
91
92
93
94
95

96
97
98
99
100
101
102
88
89
90
91
92
93
94

95
96
97
98
99
100
101
102







-
+







	[super dealloc];
}

#ifndef OF_WII
- (int)of_socketError
{
	int errNo;
	socklen_t len = sizeof(errNo);
	socklen_t len = (socklen_t)sizeof(errNo);

	if (getsockopt(_socket, SOL_SOCKET, SO_ERROR, (char *)&errNo,
	    &len) != 0)
		return _OFSocketErrNo();

	return errNo;
}

Modified src/OFSocket.m from [a3175107a5] to [7f6fdd5754].

376
377
378
379
380
381
382
383

384
385
386
387
388
389
390
376
377
378
379
380
381
382

383
384
385
386
387
388
389
390







-
+







	uint32_t addr;

	memset(&ret, '\0', sizeof(ret));
	ret.family = OFSocketAddressFamilyIPv4;
#if defined(OF_WII) || defined(OF_NINTENDO_3DS)
	ret.length = 8;
#else
	ret.length = sizeof(ret.sockaddr.in);
	ret.length = (socklen_t)sizeof(ret.sockaddr.in);
#endif

	addrIn->sin_family = AF_INET;
	addrIn->sin_port = OFToBigEndian16(port);
#ifdef OF_WII
	addrIn->sin_len = ret.length;
#endif
471
472
473
474
475
476
477
478

479
480
481
482
483
484
485
471
472
473
474
475
476
477

478
479
480
481
482
483
484
485







-
+







	void *pool = objc_autoreleasePoolPush();
	OFSocketAddress ret;
	struct sockaddr_in6 *addrIn6 = &ret.sockaddr.in6;
	size_t doubleColon, percent;

	memset(&ret, '\0', sizeof(ret));
	ret.family = OFSocketAddressFamilyIPv6;
	ret.length = sizeof(ret.sockaddr.in6);
	ret.length = (socklen_t)sizeof(ret.sockaddr.in6);

#ifdef AF_INET6
	addrIn6->sin6_family = AF_INET6;
#else
	addrIn6->sin6_family = AF_UNSPEC;
#endif
	addrIn6->sin6_port = OFToBigEndian16(port);
614
615
616
617
618
619
620
621

622
623
624
625
626
627
628
614
615
616
617
618
619
620

621
622
623
624
625
626
627
628







-
+







OFSocketAddressMakeIPX(uint32_t network, const unsigned char node[IPX_NODE_LEN],
    uint16_t port)
{
	OFSocketAddress ret;

	memset(&ret, '\0', sizeof(ret));
	ret.family = OFSocketAddressFamilyIPX;
	ret.length = sizeof(ret.sockaddr.ipx);
	ret.length = (socklen_t)sizeof(ret.sockaddr.ipx);

#ifdef AF_IPX
	ret.sockaddr.ipx.sipx_family = AF_IPX;
#else
	ret.sockaddr.ipx.sipx_family = AF_UNSPEC;
#endif
	network = OFToBigEndian32(network);
637
638
639
640
641
642
643
644

645
646
647
648
649
650
651
637
638
639
640
641
642
643

644
645
646
647
648
649
650
651







-
+







OFSocketAddress
OFSocketAddressMakeAppleTalk(uint16_t network, uint8_t node, uint8_t port)
{
	OFSocketAddress ret;

	memset(&ret, '\0', sizeof(ret));
	ret.family = OFSocketAddressFamilyAppleTalk;
	ret.length = sizeof(ret.sockaddr.at);
	ret.length = (socklen_t)sizeof(ret.sockaddr.at);

#ifdef AF_APPLETALK
	ret.sockaddr.at.sat_family = AF_APPLETALK;
#else
	ret.sockaddr.at.sat_family = AF_UNSPEC;
#endif
#ifdef OF_WINDOWS
1055
1056
1057
1058
1059
1060
1061

1062

1063
1064
1065
1066
1067
1068
1069
1055
1056
1057
1058
1059
1060
1061
1062

1063
1064
1065
1066
1067
1068
1069
1070







+
-
+







OFSocketAddressUNIXPath(const OFSocketAddress *_Nonnull address)
{
	socklen_t length;

	if (address->family != OFSocketAddressFamilyUNIX)
		@throw [OFInvalidArgumentException exception];

	length =
	length = address->length - offsetof(struct sockaddr_un, sun_path);
	    address->length - (socklen_t)offsetof(struct sockaddr_un, sun_path);

	for (socklen_t i = 0; i < length; i++)
		if (address->sockaddr.un.sun_path[i] == 0)
			length = i;

	return [OFString stringWithCString: address->sockaddr.un.sun_path
				  encoding: [OFLocale encoding]

Modified src/OFStreamSocket.m from [6bb8a2cf49] to [5f7f7d637a].

214
215
216
217
218
219
220
221

222
223
224
225
226
227
228
214
215
216
217
218
219
220

221
222
223
224
225
226
227
228







-
+







#endif
}

#ifndef OF_WII
- (int)of_socketError
{
	int errNo;
	socklen_t len = sizeof(errNo);
	socklen_t len = (socklen_t)sizeof(errNo);

	if (getsockopt(_socket, SOL_SOCKET, SO_ERROR, (char *)&errNo,
	    &len) != 0)
		return _OFSocketErrNo();

	return errNo;
}

Modified src/OFTCPSocket.m from [21bc19a6d7] to [91624c0cdb].

437
438
439
440
441
442
443
444

445
446
447
448
449
450
451
437
438
439
440
441
442
443

444
445
446
447
448
449
450
451







-
+







		    exceptionWithObject: self
				  errNo: _OFSocketErrNo()];
}

- (bool)sendsKeepAlives
{
	int v;
	socklen_t len = sizeof(v);
	socklen_t len = (socklen_t)sizeof(v);

	if (getsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE,
	    (char *)&v, &len) != 0 || len != sizeof(v))
		@throw [OFGetOptionFailedException
		    exceptionWithObject: self
				  errNo: _OFSocketErrNo()];

464
465
466
467
468
469
470
471

472
473
474
475
476
477
478
464
465
466
467
468
469
470

471
472
473
474
475
476
477
478







-
+







		    exceptionWithObject: self
				  errNo: _OFSocketErrNo()];
}

- (bool)canDelaySendingSegments
{
	int v;
	socklen_t len = sizeof(v);
	socklen_t len = (socklen_t)sizeof(v);

	if (getsockopt(_socket, IPPROTO_TCP, TCP_NODELAY,
	    (char *)&v, &len) != 0 || len != sizeof(v))
		@throw [OFGetOptionFailedException
		    exceptionWithObject: self
				  errNo: _OFSocketErrNo()];

Modified src/objfw-defs.h.in from [d61e321f94] to [0461ead01c].

1
2
3


4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
11
12



+
+







#undef OF_APPLE_RUNTIME
#undef OF_BIG_ENDIAN
#undef OF_CLASSIC_MACOS
#undef OF_DECLARE_CONSTRUCT_INSTANCE
#undef OF_DECLARE_SET_ASSOCIATED_OBJECT
#undef OF_FLOAT_BIG_ENDIAN
#undef OF_HAVE_AFUNIX_H
#undef OF_HAVE_APPLETALK
#undef OF_HAVE_ATOMIC_BUILTINS
#undef OF_HAVE_ATOMIC_OPS
#undef OF_HAVE_BUILTIN_BSWAP16
#undef OF_HAVE_BUILTIN_BSWAP32

Modified src/platform/POSIX/OFSystemInfo+NetworkInterfaces.m from [0e4f3315ec] to [11c0f091e8].

189
190
191
192
193
194
195
196

197
198
199
200
201
202
203
189
190
191
192
193
194
195

196
197
198
199
200
201
202
203







-
+







	}

	@try {
		char *buffer;

		memset(&ifc, 0, sizeof(ifc));
		ifc.ifc_buf = (void *)ifrs;
		ifc.ifc_len = 128 * sizeof(struct ifreq);
		ifc.ifc_len = 128 * (int)sizeof(struct ifreq);
		if (ioctl(sock, SIOCGIFCONF, &ifc) < 0)
			return false;

		buffer = ifc.ifc_buf;
		while (buffer < (char *)ifc.ifc_buf + ifc.ifc_len) {
			struct ifreq *current = (struct ifreq *)(void *)buffer;
			OFString *name;
652
653
654
655
656
657
658
659

660
661
662
663
664
665
666
652
653
654
655
656
657
658

659
660
661
662
663
664
665
666







-
+







	}

	@try {
		char *buffer;

		memset(&ifc, 0, sizeof(ifc));
		ifc.ifc_buf = (void *)ifrs;
		ifc.ifc_len = 128 * sizeof(struct ifreq);
		ifc.ifc_len = 128 * (int)sizeof(struct ifreq);
		if (ioctl(sock, SIOCGIFCONF, &ifc) < 0)
			return false;

		buffer = ifc.ifc_buf;
		while (buffer < (char *)ifc.ifc_buf + ifc.ifc_len) {
			struct ifreq *current = (struct ifreq *)(void *)buffer;
			struct sockaddr_dl *sdl;

Modified src/runtime/association.m from [bd088abb65] to [65070c5f4f].

182
183
184
185
186
187
188
189

190
191
192
193
194
195
196
182
183
184
185
186
187
188

189
190
191
192
193
194
195
196







-
+







#endif
}

id
objc_getAssociatedObject(id object, const void *key)
{
	size_t slot = slotForObject(object);
	id ret;
	id ret = nil;

#ifdef OF_HAVE_THREADS
	if (OFSpinlockLock(&spinlocks[slot]) != 0)
		OBJC_ERROR("Failed to lock spinlock!");

	@try {
#endif