Check-in [aa53dedc32]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixed pointer imports
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: aa53dedc32d95ee118861660f08cbe887a841431fc44d335ba2393a9c034eaf3
User & Date: grable 2018-11-03 01:25:36.933
Context
2018-11-04
16:04
fixed comparing typeinfo callbacks to handle NULLs check-in: f5850b2ee6 user: grable tags: trunk
2018-11-03
01:25
fixed pointer imports check-in: aa53dedc32 user: grable tags: trunk
01:15
added some support functions for struct jimff_typeinfo, and some more error conditions to jimff_import_symbol() check-in: 68b67b4789 user: grable tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to jimff.c.
238
239
240
241
242
243
244

245
246
247
248
249
250
251
	free((void*)typeinfo->pointersizes);
	for( int i = 0; i < typeinfo->numcallbacks; i++) free((void*)typeinfo->callbacks[i]);
	free((void*)typeinfo->callbacks);
}

//NOTE: returns boolean 0 or 1
static int jimff_compare_typeinfo( const struct jimff_typeinfo* a, const struct jimff_typeinfo* b) {

	if( a->argc != b->argc || strcmp( a->typetag, b->typetag)) return 0;
	for( int i = 0; i < a->numpointers; i++) {
		if( a->pointersizes[i] != b->pointersizes[i]) return 0;
	}
	for( int i = 0; i < a->numcallbacks; i++) {
		if( strcmp( a->callbacks[i], b->callbacks[i])) return 0;
	}







>







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
	free((void*)typeinfo->pointersizes);
	for( int i = 0; i < typeinfo->numcallbacks; i++) free((void*)typeinfo->callbacks[i]);
	free((void*)typeinfo->callbacks);
}

//NOTE: returns boolean 0 or 1
static int jimff_compare_typeinfo( const struct jimff_typeinfo* a, const struct jimff_typeinfo* b) {
	if(a == b) return 1;
	if( a->argc != b->argc || strcmp( a->typetag, b->typetag)) return 0;
	for( int i = 0; i < a->numpointers; i++) {
		if( a->pointersizes[i] != b->pointersizes[i]) return 0;
	}
	for( int i = 0; i < a->numcallbacks; i++) {
		if( strcmp( a->callbacks[i], b->callbacks[i])) return 0;
	}
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
	int size = 0;
	struct jimff_typeinfo typeinfo = {0};
	
	// check if symbol is already imported
	if(sym = jimff_find_symbol( lib, name)) {
		if(!alias || !strcmp( name, alias)) {
			// only return symbols if they match exactly
			if(tag == JIMFF_SYM_POINTER) {
				if(sym->tag != tag || sym->size != (size_t)argument.size) return JIMFF_REDEFINED_SIZE;
			} else {
				//TODO: find a better way to compare symbol typetags
				if(!jimff_validate_typetag( argument.typetag, &typeinfo)) return JIMFF_INVALID_TYPETAG;
				int fail = (sym->tag != tag || !jimff_compare_typeinfo( &sym->typeinfo, &typeinfo));
				jimff_free_typeinfo(&typeinfo);
				if(fail) return JIMFF_REDEFINED_TYPETAG;







|







422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
	int size = 0;
	struct jimff_typeinfo typeinfo = {0};
	
	// check if symbol is already imported
	if(sym = jimff_find_symbol( lib, name)) {
		if(!alias || !strcmp( name, alias)) {
			// only return symbols if they match exactly
			if(tag == JIMFF_SYM_POINTER || sym->tag == JIMFF_SYM_POINTER) {
				if(sym->tag != tag || sym->size != (size_t)argument.size) return JIMFF_REDEFINED_SIZE;
			} else {
				//TODO: find a better way to compare symbol typetags
				if(!jimff_validate_typetag( argument.typetag, &typeinfo)) return JIMFF_INVALID_TYPETAG;
				int fail = (sym->tag != tag || !jimff_compare_typeinfo( &sym->typeinfo, &typeinfo));
				jimff_free_typeinfo(&typeinfo);
				if(fail) return JIMFF_REDEFINED_TYPETAG;