Add functions to manipulate FDs with DMC's runtime. #361

Merged
merged 1 commit into from Dec 12, 2012

3 participants

@alexrp
D Programming Language member

Another bunch of changes by @schveiguy (originally for Phobos) needed for the new std.process.

@CyberShadow
D Programming Language member

Perhaps, version(DigitalMars) ? To make things easier to Windows GDC maintainers...

@alexrp
D Programming Language member

Done.

(Test failures not related to this pull request, by the way.)

@andralex andralex commented on an outdated diff Dec 12, 2012
src/core/stdc/stdio.d
@@ -640,3 +640,120 @@ else
}
void perror(in char* s);
+
+version (DigitalMars) version (Win32)
+{
+ private import core.sys.windows.windows;
@andralex
D Programming Language member

import is private by default, mumble mumble

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@andralex andralex commented on an outdated diff Dec 12, 2012
src/core/stdc/stdio.d
+
+ // this is copied from semlock.h in DMC's runtime.
+ private void LockSemaphore(uint num)
+ {
+ asm
+ {
+ mov EDX, num;
+ lock;
+ inc _iSemLockCtrs[EDX * 2];
+ jz lsDone;
+ push EDX;
+ call _WaitSemaphore;
+ add ESP, 4;
+ }
+
+lsDone: {}
@andralex
D Programming Language member

label aligns at scope level (i.e. is outdented only once here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@andralex andralex commented on an outdated diff Dec 12, 2012
src/core/stdc/stdio.d
+
+ // this is copied from semlock.h in DMC's runtime.
+ private void UnlockSemaphore(uint num)
+ {
+ asm
+ {
+ mov EDX, num;
+ lock;
+ dec _iSemLockCtrs[EDX * 2];
+ js usDone;
+ push EDX;
+ call _ReleaseSemaphore;
+ add ESP, 4;
+ }
+
+usDone: {}
@andralex
D Programming Language member

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@andralex andralex commented on an outdated diff Dec 12, 2012
src/core/stdc/stdio.d
+ js usDone;
+ push EDX;
+ call _ReleaseSemaphore;
+ add ESP, 4;
+ }
+
+usDone: {}
+ }
+
+ // This converts a HANDLE to a file descriptor in DMC's runtime
+ int _handleToFD(HANDLE h, int flags)
+ {
+ LockSemaphore(_semIO);
+ scope(exit) UnlockSemaphore(_semIO);
+
+ for (int fd = 0; fd < _NFILE; fd++)
@andralex
D Programming Language member

foreach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@andralex andralex merged commit 905b1b1 into dlang:master Dec 12, 2012

1 check was pending

Details default Pass: 8, In Progress: 1, Pending: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment