ObjFW  Check-in [2379608969]

Overview
Comment:invoke-x86_64.m: Fix compilation with GCC
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2379608969e26ebb4562d59893c6c74c57ef420020a85c7739f90283095cd171
User & Date: js on 2017-09-16 20:05:42
Other Links: manifest | tags
Context
2017-09-16
20:20
invoke-x86_64.m: Correctly align __int128 for GCC check-in: c14dfdc8e5 user: js tags: trunk
20:05
invoke-x86_64.m: Fix compilation with GCC check-in: 2379608969 user: js tags: trunk
19:11
OFInvocation: Support for invoking on x86_64/ELF check-in: 6d2f81aea9 user: js tags: trunk
Changes

Modified src/invocation/invoke-x86_64.m from [75aba7c79f] to [03bcbc3b9d].

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

static void
pushDouble(struct call_context **context, size_t *currentSSE, double value)
{
	struct call_context *newContext;

	if (*currentSSE < NUM_SSE_IN) {
		(*context)->sse[(*currentSSE)++] = _mm_set_sd(value);
		(*context)->num_sse_used++;
		return;
	}

	if ((newContext = realloc(*context,
	    sizeof(**context) + ((*context)->stack_size + 1) * 8)) == NULL) {
		free(*context);







|







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

static void
pushDouble(struct call_context **context, size_t *currentSSE, double value)
{
	struct call_context *newContext;

	if (*currentSSE < NUM_SSE_IN) {
		(*context)->sse[(*currentSSE)++] = (__m128)_mm_set_sd(value);
		(*context)->num_sse_used++;
		return;
	}

	if ((newContext = realloc(*context,
	    sizeof(**context) + ((*context)->stack_size + 1) * 8)) == NULL) {
		free(*context);
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
		case 'f':;
			float floatTmp;
			_mm_store_ss(&floatTmp, context->sse[0]);
			[invocation setReturnValue: &floatTmp];
			break;
		case 'd':;
			double doubleTmp;
			_mm_store_sd(&doubleTmp, context->sse[0]);
			[invocation setReturnValue: &doubleTmp];
			break;
		case 'D':
			[invocation setReturnValue: &context->x87[0]];
			break;
		CASE_GPR('B', _Bool)
		CASE_GPR('*', uintptr_t)







|







271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
		case 'f':;
			float floatTmp;
			_mm_store_ss(&floatTmp, context->sse[0]);
			[invocation setReturnValue: &floatTmp];
			break;
		case 'd':;
			double doubleTmp;
			_mm_store_sd(&doubleTmp, (__m128d)context->sse[0]);
			[invocation setReturnValue: &doubleTmp];
			break;
		case 'D':
			[invocation setReturnValue: &context->x87[0]];
			break;
		CASE_GPR('B', _Bool)
		CASE_GPR('*', uintptr_t)

Modified tests/OFInvocationTests.m from [943b8e059c] to [23dbe050f2].

100
101
102
103
104
105
106

107
108
109
110
111
112
113
				    : (long double)d16
{
	return (d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10 + d11 +
	    d12 + d13 + d14 + d15 + d16) / 16;
}

#ifdef __SIZEOF_INT128__

- (__int128)invocationTestMethod5: (__int128)i1
				 : (__int128)i2
				 : (int)i3	 /* to check alignment */
				 : (__int128)i4
				 : (__int128)i5
				 : (__int128)i6
				 : (__int128)i7







>







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
				    : (long double)d16
{
	return (d1 + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d9 + d10 + d11 +
	    d12 + d13 + d14 + d15 + d16) / 16;
}

#ifdef __SIZEOF_INT128__
__extension__
- (__int128)invocationTestMethod5: (__int128)i1
				 : (__int128)i2
				 : (int)i3	 /* to check alignment */
				 : (__int128)i4
				 : (__int128)i5
				 : (__int128)i6
				 : (__int128)i7
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294

295
296
297
298
299
300

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int i = 1; i <= 16; i++) {
		__int128 i128 = 0xFFFFFFFFFFFFFFFF;
		i128 <<= 64;
		i128 |= i;

		if (i == 3)
			[invocation setArgument: &i
					atIndex: i + 1];
		else
			[invocation setArgument: &i128
					atIndex: i + 1];
	}

	__int128 int128Result;
	TEST(@"-[invoke] #4", R([invocation invoke]) &&
	    R([invocation getReturnValue: &int128Result]) &&
	    int128Result == ((__int128)0xFFFFFFFFFFFFFFFF << 64) + 8)

# endif
#endif

	[pool drain];
}
@end







|











|


|
>






273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302

	[invocation setArgument: &self
			atIndex: 0];
	[invocation setArgument: &selector
			atIndex: 1];

	for (int i = 1; i <= 16; i++) {
		__extension__ __int128 i128 = 0xFFFFFFFFFFFFFFFF;
		i128 <<= 64;
		i128 |= i;

		if (i == 3)
			[invocation setArgument: &i
					atIndex: i + 1];
		else
			[invocation setArgument: &i128
					atIndex: i + 1];
	}

	__extension__ __int128 int128Result;
	TEST(@"-[invoke] #4", R([invocation invoke]) &&
	    R([invocation getReturnValue: &int128Result]) &&
	    int128Result == __extension__ ((__int128)0xFFFFFFFFFFFFFFFF << 64) +
	    8)
# endif
#endif

	[pool drain];
}
@end