Skip to content

Commit 9d0ea81

Browse files
committed
Added some libc I/O stubs to get Python module importing to work:
* fdopen: no-op. * __01lseek64_: linked tp fseek. * __01open64_: calls open() with swapped args. * unlink: no-op. * __01fstat64_: linked to fstat. Added myself to AUTHORS.
1 parent b8d7596 commit 9d0ea81

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ under the licensing terms detailed in LICENSE.
33

44
* Alon Zakai <[email protected]> (copyright owned by Mozilla Foundation)
55
* Tim Dawborn <[email protected]>
6-
6+
* Max Shawabkeh <[email protected]>

src/library.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ var Library = {
368368
},
369369
__01fopen64_: 'fopen',
370370

371+
fdopen: function(descriptor, mode) {
372+
// TODO: Check whether mode is acceptable for the current stream.
373+
return descriptor;
374+
},
375+
371376
rewind__deps: ['$STDIO'],
372377
rewind: function(stream) {
373378
var info = STDIO.streams[stream];
@@ -388,6 +393,7 @@ var Library = {
388393
return 0;
389394
},
390395
__01fseeko64_: 'fseek',
396+
__01lseek64_: 'fseek',
391397

392398
ftell__deps: ['$STDIO'],
393399
ftell: function(stream) {
@@ -511,6 +517,13 @@ var Library = {
511517
}
512518
},
513519

520+
__01open64___deps: ['open'],
521+
__01open64_: function(filename, mode, flags) {
522+
// open(), but with flags and mode switched.
523+
// TODO: Verify why this happens at all.
524+
return _open(filename, flags, mode);
525+
},
526+
514527
close: function(stream) {
515528
return 0;
516529
},
@@ -1211,6 +1224,11 @@ var Library = {
12111224
return 0; // NULL
12121225
},
12131226

1227+
unlink: function(filename) {
1228+
// TODO: Actually implement.
1229+
return 0;
1230+
},
1231+
12141232
// time.h
12151233

12161234
time: function(ptr) {
@@ -1259,7 +1277,7 @@ var Library = {
12591277
// stat.h
12601278

12611279
__01stat64_: function() { return -1 },
1262-
__01fstat64_: function() { return -1 },
1280+
__01fstat64_: 'fstat',
12631281

12641282
// locale.h
12651283

0 commit comments

Comments
 (0)