ObjFLoader.st
changeset 98 ccc7f9389a8e
parent 97 3b0d380771e9
child 100 6df9644528bd
equal deleted inserted replaced
97:3b0d380771e9 98:ccc7f9389a8e
    19 
    19 
    20 ObjectFileLoader comment:'
    20 ObjectFileLoader comment:'
    21 COPYRIGHT (c) 1993 by Claus Gittinger
    21 COPYRIGHT (c) 1993 by Claus Gittinger
    22 	     All Rights Reserved
    22 	     All Rights Reserved
    23 
    23 
    24 $Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.27 1995-07-03 02:38:34 claus Exp $
    24 $Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.28 1995-07-23 02:23:48 claus Exp $
    25 '!
    25 '!
    26 
    26 
    27 !ObjectFileLoader class methodsFor:'documentation'!
    27 !ObjectFileLoader class methodsFor:'documentation'!
    28 
    28 
    29 copyright
    29 copyright
    40 "
    40 "
    41 !
    41 !
    42 
    42 
    43 version
    43 version
    44 "
    44 "
    45 $Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.27 1995-07-03 02:38:34 claus Exp $
    45 $Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.28 1995-07-23 02:23:48 claus Exp $
    46 "
    46 "
    47 !
    47 !
    48 
    48 
    49 documentation
    49 documentation
    50 "
    50 "
   102 
   102 
   103 #ifdef DL1_6    /* dl1.6 COFF loader */
   103 #ifdef DL1_6    /* dl1.6 COFF loader */
   104 # define HAS_DL
   104 # define HAS_DL
   105 #endif
   105 #endif
   106 
   106 
   107 #ifdef aix
   107 #ifdef _AIX
   108 # define AIX_DL
   108 # define AIX_DL
   109 # define HAS_DL
   109 # define HAS_DL
   110 #endif
   110 #endif
   111 
   111 
   112 /*
   112 /*
  1080 	firstCall = 0;
  1080 	firstCall = 0;
  1081 	(void) dld_init (__myName__);
  1081 	(void) dld_init (__myName__);
  1082     }
  1082     }
  1083 
  1083 
  1084     if (__isString(pathName)) {
  1084     if (__isString(pathName)) {
  1085 	if (dld_link(_stringVal(pathName))) {
  1085 	if (dld_link(__stringVal(pathName))) {
  1086 	    if (ObjectFileLoader_Verbose == true) {
  1086 	    if (ObjectFileLoader_Verbose == true) {
  1087 		printf ("link file %s failed\n", _stringVal(pathName));
  1087 		printf ("link file %s failed\n", __stringVal(pathName));
  1088 		dld_perror("cant link");
  1088 		dld_perror("cant link");
  1089 	    }
  1089 	    }
  1090 	    ObjectFileLoader_LastError = @symbol(linkError);
  1090 	    ObjectFileLoader_LastError = @symbol(linkError);
  1091 	    RETURN ( nil );
  1091 	    RETURN ( nil );
  1092 	}
  1092 	}
  1098 #ifdef DL1_6
  1098 #ifdef DL1_6
  1099     extern char *__myName__;
  1099     extern char *__myName__;
  1100     char *ldname;
  1100     char *ldname;
  1101 
  1101 
  1102     if (__isString(pathName)) {
  1102     if (__isString(pathName)) {
  1103 	if ( dl_loadmod_only(__myName__, _stringVal(pathName), &ldname) == 0 ) {
  1103 	if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) {
  1104 	    if (ObjectFileLoader_Verbose == true) {
  1104 	    if (ObjectFileLoader_Verbose == true) {
  1105 		printf ("link file %s failed\n", _stringVal(pathName));
  1105 		printf ("link file %s failed\n", __stringVal(pathName));
  1106 	    }
  1106 	    }
  1107 	    RETURN ( nil );
  1107 	    RETURN ( nil );
  1108 	}
  1108 	}
  1109 	/*
  1109 	/*
  1110 	 * returns the name of the temporary ld-file
  1110 	 * returns the name of the temporary ld-file
  1121     int *handle;
  1121     int *handle;
  1122 
  1122 
  1123     if (__isString(pathName)) {
  1123     if (__isString(pathName)) {
  1124 	if (__isArray(aBuffer)
  1124 	if (__isArray(aBuffer)
  1125 	 && (_arraySize(aBuffer) == 2)) {;
  1125 	 && (_arraySize(aBuffer) == 2)) {;
  1126 	    if ( (handle = load(_stringVal(pathName), 0, 0)) == 0 ) {
  1126 	    if ( (handle = load(__stringVal(pathName), 0, 0)) == 0 ) {
  1127 		if (ObjectFileLoader_Verbose == true) {
  1127 		if (ObjectFileLoader_Verbose == true) {
  1128 		    printf ("link file %s failed\n", _stringVal(pathName));
  1128 		    printf ("load file %s failed\n", __stringVal(pathName));
  1129 		}
  1129 		}
  1130 		RETURN ( nil );
  1130 		RETURN ( nil );
  1131 	    }
  1131 	    }
  1132 	    if (ObjectFileLoader_Verbose == true)
  1132 	    if (ObjectFileLoader_Verbose == true)
  1133 		printf("load %s handle = %x\n", _stringVal(pathName), handle);
  1133 		printf("load %s handle = %x\n", __stringVal(pathName), handle);
  1134 
  1134 
  1135 	    _ArrayInstPtr(aBuffer)->a_element[0] = 
  1135 	    _ArrayInstPtr(aBuffer)->a_element[0] = 
  1136 				       _MKSMALLINT( (int)handle & 0xFFFF );
  1136 				       _MKSMALLINT( (int)handle & 0xFFFF );
  1137 	    _ArrayInstPtr(aBuffer)->a_element[1] = 
  1137 	    _ArrayInstPtr(aBuffer)->a_element[1] = 
  1138 				       _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
  1138 				       _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
  1142     RETURN ( nil );
  1142     RETURN ( nil );
  1143 #endif
  1143 #endif
  1144 
  1144 
  1145 #ifdef SYSV4_DL
  1145 #ifdef SYSV4_DL
  1146     void *handle;
  1146     void *handle;
       
  1147     char *nm;
  1147 
  1148 
  1148     if ((pathName == nil) || __isString(pathName)) {
  1149     if ((pathName == nil) || __isString(pathName)) {
  1149 	if (__isArray(aBuffer)
  1150 	if (__isArray(aBuffer)
  1150 	 && (_arraySize(aBuffer) == 2)) {;
  1151 	 && (_arraySize(aBuffer) == 2)) {;
  1151 	    if (pathName == nil)
  1152 	    handle = dlopen(pathName == nil ? 
  1152 		handle = dlopen((char *)0, RTLD_NOW);
  1153 				(char *)0 : 
  1153 	    else
  1154 				__stringVal(pathName), 
  1154 		handle = dlopen(_stringVal(pathName), RTLD_NOW);
  1155 			    RTLD_NOW);
  1155 
  1156 
  1156 	    if (! handle) {
  1157 	    if (! handle) {
  1157 		fprintf(stderr, "dlopen %s error: <%s>\n", 
  1158 		fprintf(stderr, "dlopen %s error: <%s>\n", 
  1158 				_stringVal(pathName), dlerror());
  1159 				__stringVal(pathName), dlerror());
  1159 		ObjectFileLoader_LastError = @symbol(linkError);
  1160 		ObjectFileLoader_LastError = @symbol(linkError);
  1160 		RETURN (nil);
  1161 		RETURN (nil);
  1161 	    }
  1162 	    }
  1162 
  1163 
  1163 	    if (ObjectFileLoader_Verbose == true)
  1164 	    if (ObjectFileLoader_Verbose == true)
  1164 		printf("open %s handle = %x\n", _stringVal(pathName), handle);
  1165 		printf("open %s handle = %x\n", __stringVal(pathName), handle);
  1165 
  1166 
  1166 	    _ArrayInstPtr(aBuffer)->a_element[0] = 
  1167 	    _ArrayInstPtr(aBuffer)->a_element[0] = 
  1167 				       _MKSMALLINT( (int)handle & 0xFFFF );
  1168 				       _MKSMALLINT( (int)handle & 0xFFFF );
  1168 	    _ArrayInstPtr(aBuffer)->a_element[1] = 
  1169 	    _ArrayInstPtr(aBuffer)->a_element[1] = 
  1169 				       _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
  1170 				       _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
  1179 	if (__isArray(aBuffer)
  1180 	if (__isArray(aBuffer)
  1180 	 && (_arraySize(aBuffer) == 2)) {;
  1181 	 && (_arraySize(aBuffer) == 2)) {;
  1181 	    if (pathName == nil)
  1182 	    if (pathName == nil)
  1182 		handle = dlopen((char *)0, 1);
  1183 		handle = dlopen((char *)0, 1);
  1183 	    else
  1184 	    else
  1184 		handle = dlopen(_stringVal(pathName), 1);
  1185 		handle = dlopen(__stringVal(pathName), 1);
  1185 
  1186 
  1186 	    if (! handle) {
  1187 	    if (! handle) {
  1187 		fprintf(stderr, "dlopen %s error: <%s>\n", 
  1188 		fprintf(stderr, "dlopen %s error: <%s>\n", 
  1188 				_stringVal(pathName), dlerror());
  1189 				__stringVal(pathName), dlerror());
  1189 		ObjectFileLoader_LastError = @symbol(linkError);
  1190 		ObjectFileLoader_LastError = @symbol(linkError);
  1190 		RETURN (nil);
  1191 		RETURN (nil);
  1191 	    }
  1192 	    }
  1192 
  1193 
  1193 	    if (ObjectFileLoader_Verbose == true)
  1194 	    if (ObjectFileLoader_Verbose == true)
  1194 		printf("open %s handle = %x\n", _stringVal(pathName), handle);
  1195 		printf("open %s handle = %x\n", __stringVal(pathName), handle);
  1195 
  1196 
  1196 	    _ArrayInstPtr(aBuffer)->a_element[0] = 
  1197 	    _ArrayInstPtr(aBuffer)->a_element[0] = 
  1197 				       _MKSMALLINT( (int)handle & 0xFFFF );
  1198 				       _MKSMALLINT( (int)handle & 0xFFFF );
  1198 	    _ArrayInstPtr(aBuffer)->a_element[1] = 
  1199 	    _ArrayInstPtr(aBuffer)->a_element[1] = 
  1199 				       _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
  1200 				       _MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
  1206     long result;
  1207     long result;
  1207     char *files[2];
  1208     char *files[2];
  1208     NXStream *errOut;
  1209     NXStream *errOut;
  1209 
  1210 
  1210     if (__isString(pathName)) {
  1211     if (__isString(pathName)) {
  1211 	files[0] = (char *) _stringVal(pathName);
  1212 	files[0] = (char *) __stringVal(pathName);
  1212 	files[1] = (char *) 0;
  1213 	files[1] = (char *) 0;
  1213 	errOut = NXOpenFile(2, 2);
  1214 	errOut = NXOpenFile(2, 2);
  1214 	result = rld_load(errOut,
  1215 	result = rld_load(errOut,
  1215 			  (struct mach_header **)0,
  1216 			  (struct mach_header **)0,
  1216 			  files,
  1217 			  files,
  1217 			  (char *)0);
  1218 			  (char *)0);
  1218 	NXClose(errOut);
  1219 	NXClose(errOut);
  1219 	if (! result) {
  1220 	if (! result) {
  1220 	    ObjectFileLoader_LastError = @symbol(linkError);
  1221 	    ObjectFileLoader_LastError = @symbol(linkError);
  1221 	    fprintf(stderr, "rld_load %s failed\n", _stringVal(pathName));
  1222 	    fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName));
  1222 	    RETURN (nil);
  1223 	    RETURN (nil);
  1223 	}
  1224 	}
  1224 
  1225 
  1225 	if (ObjectFileLoader_Verbose == true)
  1226 	if (ObjectFileLoader_Verbose == true)
  1226 	    printf("rld_load %s ok\n", _stringVal(pathName));
  1227 	    printf("rld_load %s ok\n", __stringVal(pathName));
  1227 
  1228 
  1228 	RETURN (pathName);
  1229 	RETURN (pathName);
  1229     }
  1230     }
  1230 #endif
  1231 #endif
  1231 %}.
  1232 %}.
  1261     |low hi|
  1262     |low hi|
  1262 
  1263 
  1263 %{
  1264 %{
  1264 #ifdef GNU_DL
  1265 #ifdef GNU_DL
  1265     if (__isString(handle)) {
  1266     if (__isString(handle)) {
  1266 	if (dld_unlink_by_file(_stringVal(handle), 1)) {
  1267 	if (dld_unlink_by_file(__stringVal(handle), 1)) {
  1267 	    if (ObjectFileLoader_Verbose == true) {
  1268 	    if (ObjectFileLoader_Verbose == true) {
  1268 		printf ("unlink file %s failed\n", _stringVal(handle));
  1269 		printf ("unlink file %s failed\n", __stringVal(handle));
  1269 		dld_perror("cant unlink");
  1270 		dld_perror("cant unlink");
  1270 	    }
  1271 	    }
  1271 	    RETURN (false);
  1272 	    RETURN (false);
  1272 	}
  1273 	}
  1273 	RETURN (true);
  1274 	RETURN (true);
  1421     void (*func)();
  1422     void (*func)();
  1422     unsigned long addr;
  1423     unsigned long addr;
  1423     char *name;
  1424     char *name;
  1424 
  1425 
  1425     if (__isString(aString)) {
  1426     if (__isString(aString)) {
  1426 	name = (char *) _stringVal(aString);
  1427 	name = (char *) __stringVal(aString);
  1427 	if (isFunction == false) {
  1428 	if (isFunction == false) {
  1428 	    addr = dld_get_symbol(name);
  1429 	    addr = dld_get_symbol(name);
  1429 	} else {
  1430 	} else {
  1430 	    func = (void (*) ()) dld_get_func(name);
  1431 	    func = (void (*) ()) dld_get_func(name);
  1431 	    if (func) {
  1432 	    if (func) {
  1468 
  1469 
  1469     if (__isString(aString)) {
  1470     if (__isString(aString)) {
  1470 	if (__isString(handle)) {
  1471 	if (__isString(handle)) {
  1471 	    if (ObjectFileLoader_Verbose == true)
  1472 	    if (ObjectFileLoader_Verbose == true)
  1472 		printf("get sym <%s> handle = %x\n",
  1473 		printf("get sym <%s> handle = %x\n",
  1473 			_stringVal(aString), _stringVal(handle));
  1474 			__stringVal(aString), __stringVal(handle));
  1474 	    addr = dl_getsymbol(_stringVal(handle), _stringVal(aString));
  1475 	    addr = dl_getsymbol(__stringVal(handle), __stringVal(aString));
  1475 	    if (addr) {
  1476 	    if (addr) {
  1476 		if (ObjectFileLoader_Verbose == true)
  1477 		if (ObjectFileLoader_Verbose == true)
  1477 		    printf("addr = %x\n", addr);
  1478 		    printf("addr = %x\n", addr);
  1478 		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
  1479 		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
  1479 		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
  1480 		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
  1480 	    } else {
  1481 	    } else {
  1481 		if (ObjectFileLoader_Verbose == true)
  1482 		if (ObjectFileLoader_Verbose == true)
  1482 		    printf("dl_getsymbol %s failed\n", _stringVal(aString));
  1483 		    printf("dl_getsymbol %s failed\n", __stringVal(aString));
  1483 	    }
  1484 	    }
  1484 	}
  1485 	}
  1485     }
  1486     }
  1486 #endif
  1487 #endif
  1487 
  1488 
  1501     if (__bothSmallInteger(low, hi)) {
  1502     if (__bothSmallInteger(low, hi)) {
  1502 	val = (_intVal(hi) << 16) + _intVal(low);
  1503 	val = (_intVal(hi) << 16) + _intVal(low);
  1503 	h = (void *)(val);
  1504 	h = (void *)(val);
  1504 	if (__isString(aString)) {
  1505 	if (__isString(aString)) {
  1505 	    if (ObjectFileLoader_Verbose == true)
  1506 	    if (ObjectFileLoader_Verbose == true)
  1506 		printf("get sym <%s> handle = %x\n", _stringVal(aString), h);
  1507 		printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
  1507 	    addr = dlsym(h, (char *) _stringVal(aString));
  1508 	    addr = dlsym(h, (char *) __stringVal(aString));
  1508 	    if (addr) {
  1509 	    if (addr) {
  1509 		if (ObjectFileLoader_Verbose == true)
  1510 		if (ObjectFileLoader_Verbose == true)
  1510 		    printf("addr = %x\n", addr);
  1511 		    printf("addr = %x\n", addr);
  1511 		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
  1512 		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
  1512 		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
  1513 		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
  1513 	    } else {
  1514 	    } else {
  1514 		if (ObjectFileLoader_Verbose == true)
  1515 		if (ObjectFileLoader_Verbose == true)
  1515 		    printf("dlsym %s error: %s\n", _stringVal(aString), dlerror());
  1516 		    printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
  1516 	    }
  1517 	    }
  1517 	}
  1518 	}
  1518     }
  1519     }
  1519 #endif
  1520 #endif
  1520 
  1521 
  1538 	val = (_intVal(hi) << 16) + _intVal(low);
  1539 	val = (_intVal(hi) << 16) + _intVal(low);
  1539 	h = (void *)(val);
  1540 	h = (void *)(val);
  1540 	if (__isString(aString)) {
  1541 	if (__isString(aString)) {
  1541 	    if (ObjectFileLoader_Verbose == true)
  1542 	    if (ObjectFileLoader_Verbose == true)
  1542 		printf("get sym <%s> handle = %x file = %s\n", 
  1543 		printf("get sym <%s> handle = %x file = %s\n", 
  1543 			_stringVal(aString), h, _stringVal(fileName));
  1544 			__stringVal(aString), h, __stringVal(fileName));
  1544 
  1545 
  1545 	    nl[0].n_name = _stringVal(aString);
  1546 	    nl[0].n_name = __stringVal(aString);
  1546 	    nl[1].n_name = "";
  1547 	    nl[1].n_name = "";
  1547 
  1548 
  1548 	    if (nlist(_stringVal(fileName), &nl) == -1) {
  1549 	    if (nlist(__stringVal(fileName), &nl) == -1) {
  1549 		if (ObjectFileLoader_Verbose == true)
  1550 		if (ObjectFileLoader_Verbose == true)
  1550 		    printf("nlist error\n");
  1551 		    printf("nlist error\n");
  1551 	    } else {
  1552 	    } else {
  1552 		printf("value=%x section=%d type=%x sclass=%d\n", 
  1553 		printf("value=%x section=%d type=%x sclass=%d\n", 
  1553 			nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass);
  1554 			nl[0].n_value, nl[0].n_scnum, nl[0].n_type, nl[0].n_sclass);
  1573     if (__bothSmallInteger(low, hi)) {
  1574     if (__bothSmallInteger(low, hi)) {
  1574 	val = (_intVal(hi) << 16) + _intVal(low);
  1575 	val = (_intVal(hi) << 16) + _intVal(low);
  1575 	h = (void *)(val);
  1576 	h = (void *)(val);
  1576 	if (__isString(aString)) {
  1577 	if (__isString(aString)) {
  1577 	    if (ObjectFileLoader_Verbose == true)
  1578 	    if (ObjectFileLoader_Verbose == true)
  1578 		printf("get sym <%s> handle = %x\n", _stringVal(aString), h);
  1579 		printf("get sym <%s> handle = %x\n", __stringVal(aString), h);
  1579 	    addr = dlsym(h, _stringVal(aString));
  1580 	    addr = dlsym(h, __stringVal(aString));
  1580 	    if (addr) {
  1581 	    if (addr) {
  1581 		if (ObjectFileLoader_Verbose == true)
  1582 		if (ObjectFileLoader_Verbose == true)
  1582 		    printf("addr = %x\n", addr);
  1583 		    printf("addr = %x\n", addr);
  1583 		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
  1584 		lowAddr = _MKSMALLINT( (int)addr & 0xFFFF );
  1584 		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
  1585 		hiAddr = _MKSMALLINT( ((int)addr >> 16) & 0xFFFF );
  1585 	    } else {
  1586 	    } else {
  1586 		if (ObjectFileLoader_Verbose == true)
  1587 		if (ObjectFileLoader_Verbose == true)
  1587 		    printf("dlsym %s error: %s\n", _stringVal(aString), dlerror());
  1588 		    printf("dlsym %s error: %s\n", __stringVal(aString), dlerror());
  1588 	    }
  1589 	    }
  1589 	}
  1590 	}
  1590     }
  1591     }
  1591 #endif
  1592 #endif
  1592 
  1593 
  1595     long result;
  1596     long result;
  1596     NXStream *errOut;
  1597     NXStream *errOut;
  1597 
  1598 
  1598     if (__isString(aString)) {
  1599     if (__isString(aString)) {
  1599 	if (ObjectFileLoader_Verbose == true)
  1600 	if (ObjectFileLoader_Verbose == true)
  1600 	    printf("get sym <%s>\n", _stringVal(aString));
  1601 	    printf("get sym <%s>\n", __stringVal(aString));
  1601 	errOut = NXOpenFile(2, 2);
  1602 	errOut = NXOpenFile(2, 2);
  1602 	result = rld_lookup(errOut,
  1603 	result = rld_lookup(errOut,
  1603 			    (char *) _stringVal(aString),
  1604 			    (char *) __stringVal(aString),
  1604 			    &addr);
  1605 			    &addr);
  1605 	NXClose(errOut);
  1606 	NXClose(errOut);
  1606 	if (result) {
  1607 	if (result) {
  1607 	    if (ObjectFileLoader_Verbose == true)
  1608 	    if (ObjectFileLoader_Verbose == true)
  1608 		printf("addr = %x\n", addr);
  1609 		printf("addr = %x\n", addr);
  1821 %{
  1822 %{
  1822     void (*addr)();
  1823     void (*addr)();
  1823     unsigned val;
  1824     unsigned val;
  1824     typedef void (*VOIDFUNC)();
  1825     typedef void (*VOIDFUNC)();
  1825     int savInt;
  1826     int savInt;
  1826     extern int __immediateInterrupt__;
       
  1827     int prevSpace, force;
  1827     int prevSpace, force;
  1828     int arg = 0;
  1828     int arg = 0;
  1829     int wasBlocked = 1;
  1829     int wasBlocked = 1;
  1830     extern OBJ __BLOCKINTERRUPTS();
  1830     extern OBJ __BLOCKINTERRUPTS();
  1831 
  1831 
  1837 	    addr = (VOIDFUNC) val;
  1837 	    addr = (VOIDFUNC) val;
  1838 
  1838 
  1839 	    /*
  1839 	    /*
  1840 	     * allow function to be interrupted
  1840 	     * allow function to be interrupted
  1841 	     */
  1841 	     */
  1842 #ifdef OLD
       
  1843 	    savInt = __immediateInterrupt__;
       
  1844 	    __immediateInterrupt__ = 1;
       
  1845 #endif
       
  1846 	    if (interruptable != true) {
  1842 	    if (interruptable != true) {
  1847 		wasBlocked = (__BLOCKINTERRUPTS() == true);
  1843 		wasBlocked = (__BLOCKINTERRUPTS() == true);
  1848 	    }
  1844 	    }
  1849 
  1845 
  1850 	    force = (forceOld == true);
  1846 	    force = (forceOld == true);
  1862 	    }
  1858 	    }
  1863 
  1859 
  1864 	    if (! wasBlocked) {
  1860 	    if (! wasBlocked) {
  1865 		__UNBLOCKINTERRUPTS();
  1861 		__UNBLOCKINTERRUPTS();
  1866 	    }
  1862 	    }
  1867 #ifdef OLD
       
  1868 	    __immediateInterrupt__ = savInt;
       
  1869 #endif
       
  1870 	    RETURN (self);
  1863 	    RETURN (self);
  1871 	}
  1864 	}
  1872     }
  1865     }
  1873 %}.
  1866 %}.
  1874     self primitiveFailed
  1867     self primitiveFailed
  1878     "initialization phases after registration.
  1871     "initialization phases after registration.
  1879      DANGER: Pure magic; internal only -> dont use in your programs."
  1872      DANGER: Pure magic; internal only -> dont use in your programs."
  1880 
  1873 
  1881 %{
  1874 %{
  1882     int savInt;
  1875     int savInt;
  1883     extern int __immediateInterrupt__;
       
  1884     int prevSpace, force;
  1876     int prevSpace, force;
  1885     int arg = 0;
  1877     int arg = 0;
  1886     int wasBlocked = 1;
  1878     int wasBlocked = 1;
  1887     extern OBJ __BLOCKINTERRUPTS();
  1879     extern OBJ __BLOCKINTERRUPTS();
  1888 
  1880 
  1889     if (_isSmallInteger(phase)) {
  1881     if (_isSmallInteger(phase)) {
  1890 	/*
       
  1891 	 * allow function to be interrupted
       
  1892 	 */
       
  1893 #ifdef OLD
       
  1894 	savInt = __immediateInterrupt__;
       
  1895 	__immediateInterrupt__ = 1;
       
  1896 #endif
       
  1897 	if (interruptable != true) {
  1882 	if (interruptable != true) {
  1898 	    wasBlocked = (__BLOCKINTERRUPTS() == true);
  1883 	    wasBlocked = (__BLOCKINTERRUPTS() == true);
  1899 	}
  1884 	}
  1900 
  1885 
  1901 	force = (forceOld == true);
  1886 	force = (forceOld == true);
  1910 	}
  1895 	}
  1911 
  1896 
  1912 	if (! wasBlocked) {
  1897 	if (! wasBlocked) {
  1913 	    __UNBLOCKINTERRUPTS();
  1898 	    __UNBLOCKINTERRUPTS();
  1914 	}
  1899 	}
  1915 #ifdef OLD
       
  1916 	__immediateInterrupt__ = savInt;
       
  1917 #endif
       
  1918 	RETURN (self);
  1900 	RETURN (self);
  1919     }
  1901     }
  1920 %}.
  1902 %}.
  1921     self primitiveFailed
  1903     self primitiveFailed
  1922 ! !
  1904 ! !
  1939 
  1921 
  1940     if (! __isString(aFileName)) {
  1922     if (! __isString(aFileName)) {
  1941 	RETURN (nil);
  1923 	RETURN (nil);
  1942     }
  1924     }
  1943 
  1925 
  1944     fname = (char *) _stringVal(aFileName);
  1926     fname = (char *) __stringVal(aFileName);
  1945 
  1927 
  1946 # if defined(A_DOT_OUT) && !defined(ELF)
  1928 # if defined(A_DOT_OUT) && !defined(ELF)
  1947 #  if !defined(sco) && !defined(isc)
  1929 #  if !defined(sco) && !defined(isc)
  1948     {
  1930     {
  1949 	struct exec header;
  1931 	struct exec header;
  1993 
  1975 
  1994     if (! __isString(aFileName)) {
  1976     if (! __isString(aFileName)) {
  1995 	RETURN ( nil );
  1977 	RETURN ( nil );
  1996     }
  1978     }
  1997 
  1979 
  1998     fname = (char *) _stringVal(aFileName);
  1980     fname = (char *) __stringVal(aFileName);
  1999 
  1981 
  2000 # if defined(A_DOT_OUT) && !defined(ELF)
  1982 # if defined(A_DOT_OUT) && !defined(ELF)
  2001 #  if !defined(sco) && !defined(isc)
  1983 #  if !defined(sco) && !defined(isc)
  2002     {
  1984     {
  2003 	struct exec header;
  1985 	struct exec header;
  2056     }
  2038     }
  2057 
  2039 
  2058 # if defined(A_DOT_OUT) && !defined(ELF)
  2040 # if defined(A_DOT_OUT) && !defined(ELF)
  2059 #  if !defined(sco) && !defined(isc)
  2041 #  if !defined(sco) && !defined(isc)
  2060     {
  2042     {
  2061 	char *fname = (char *) _stringVal(aFileName);
  2043 	char *fname = (char *) __stringVal(aFileName);
  2062 	unsigned taddr, daddr;
  2044 	unsigned taddr, daddr;
  2063 	unsigned tsize, dsize;
  2045 	unsigned tsize, dsize;
  2064 	unsigned toffset = 0;
  2046 	unsigned toffset = 0;
  2065 	unsigned doffset = 0;
  2047 	unsigned doffset = 0;
  2066 	int fd;
  2048 	int fd;