mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1232067 - Ensure the libc free() is used if the a.out free() is not available. r=yoric
--HG-- extra : rebase_source : 9545ddec5807d63fc2a002480db02c81f2324a72
This commit is contained in:
parent
e93ec93a47
commit
5f700307ff
@ -1050,6 +1050,42 @@ Library.prototype = Object.freeze({
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Define a js-ctypes function lazily using ctypes method declare,
|
||||
* with a fallback library to use if this library can't be opened
|
||||
* or the function cannot be declared.
|
||||
*
|
||||
* @param {fallbacklibrary} The fallback Library object.
|
||||
* @param {object} The object containing the function as a field.
|
||||
* @param {string} The name of the field containing the function.
|
||||
* @param {string} symbol The name of the function, as defined in the
|
||||
* library.
|
||||
* @param {ctypes.abi} abi The abi to use, or |null| for default.
|
||||
* @param {ctypes.CType} returnType The type of values returned by the function.
|
||||
* @param {...ctypes.CType} argTypes The type of arguments to the function.
|
||||
*/
|
||||
declareLazyWithFallback: function(fallbacklibrary, object, field, ...args) {
|
||||
let lib = this;
|
||||
Object.defineProperty(object, field, {
|
||||
get: function() {
|
||||
delete this[field];
|
||||
try {
|
||||
let ffi = lib.library.declare(...args);
|
||||
if (ffi) {
|
||||
return this[field] = ffi;
|
||||
}
|
||||
} catch (ex) {
|
||||
// Use the fallback library and get the symbol from there.
|
||||
fallbacklibrary.declareLazy(object, field, ...args);
|
||||
return object[field];
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
});
|
||||
},
|
||||
|
||||
toString: function() {
|
||||
return "[Library " + this.name + "]";
|
||||
}
|
||||
|
@ -264,26 +264,18 @@
|
||||
// We override the definition of free() on several platforms.
|
||||
let default_lib = new SharedAll.Library("default_lib",
|
||||
"a.out");
|
||||
try {
|
||||
// On platforms for which we override free(), nspr defines
|
||||
// a special library name "a.out" that will resolve to the
|
||||
// correct implementation free().
|
||||
|
||||
default_lib.declareLazy(SysFile, "free",
|
||||
"free", ctypes.default_abi,
|
||||
/*return*/ ctypes.void_t,
|
||||
/*ptr*/ ctypes.voidptr_t);
|
||||
// On platforms for which we override free(), nspr defines
|
||||
// a special library name "a.out" that will resolve to the
|
||||
// correct implementation free().
|
||||
// If it turns out we don't have an a.out library or a.out
|
||||
// doesn't contain free, use the ordinary libc free.
|
||||
|
||||
} catch (ex) {
|
||||
// We don't have an a.out library or a.out doesn't contain free.
|
||||
// Either way, use the ordinary libc free.
|
||||
|
||||
libc.declareLazy(SysFile, "free",
|
||||
"free", ctypes.default_abi,
|
||||
/*return*/ ctypes.void_t,
|
||||
/*ptr*/ ctypes.voidptr_t);
|
||||
}
|
||||
}
|
||||
default_lib.declareLazyWithFallback(libc, SysFile, "free",
|
||||
"free", ctypes.default_abi,
|
||||
/*return*/ ctypes.void_t,
|
||||
/*ptr*/ ctypes.voidptr_t);
|
||||
}
|
||||
|
||||
|
||||
// Other functions
|
||||
@ -625,7 +617,7 @@
|
||||
/*fd*/ Type.fd,
|
||||
/*buf*/ Type.stat.out_ptr);
|
||||
|
||||
|
||||
|
||||
SysFile.stat = function stat(path, buf) {
|
||||
return Stat.xstat(ver, path, buf);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user