diff options
author | Guido van Rossum <guido@python.org> | 1992-08-05 19:58:53 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-08-05 19:58:53 (GMT) |
commit | ff4949eeee7f86117d4a69599777ff5564315e39 (patch) | |
tree | 551b1b2d53d665fb81d10dd1d51e433be0512604 /Modules/posixmodule.c | |
parent | 25bec8c8dc0de55694cc573ef6d213ee5babd306 (diff) | |
download | cpython-ff4949eeee7f86117d4a69599777ff5564315e39.zip cpython-ff4949eeee7f86117d4a69599777ff5564315e39.tar.gz cpython-ff4949eeee7f86117d4a69599777ff5564315e39.tar.bz2 |
* Makefile: cosmetics
* socketmodule.c: get rid of makepair(); fix makesocketaddr to fix
broken recvfrom()
* socketmodule: get rid of getStrarg()
* ceval.h: move eval_code() to new file eval.h, so compile.h is no
longer needed.
* ceval.c: move thread comments to ceval.h; always make save/restore
thread functions available (for dynloaded modules)
* cdmodule.c, listobject.c: don't include compile.h
* flmodule.c: include ceval.h
* import.c: include eval.h instead of ceval.h
* cgen.py: add forground(); noport(); winopen(""); to initgl().
* bltinmodule.c, socketmodule.c, fileobject.c, posixmodule.c,
selectmodule.c:
adapt to threads (add BGN/END SAVE macros)
* stdwinmodule.c: adapt to threads and use a special stdwin lock.
* pythonmain.c: don't include getpythonpath().
* pythonrun.c: use BGN/END SAVE instead of direct calls; also more
BGN/END SAVE calls etc.
* thread.c: bigger stack size for sun; change exit() to _exit()
* threadmodule.c: use BGN/END SAVE macros where possible
* timemodule.c: adapt better to threads; use BGN/END SAVE; add
longsleep internal function if BSD_TIME; cosmetics
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 67 |
1 files changed, 56 insertions, 11 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8ae1758..367e21c 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -73,6 +73,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "allobjects.h" #include "modsupport.h" +#include "ceval.h" extern char *strerror PROTO((int)); @@ -128,9 +129,13 @@ posix_1str(args, func) int (*func) FPROTO((const char *)); { char *path1; + int res; if (!getstrarg(args, &path1)) return NULL; - if ((*func)(path1) < 0) + BGN_SAVE + res = (*func)(path1); + END_SAVE + if (res < 0) return posix_error(); INCREF(None); return None; @@ -142,9 +147,13 @@ posix_2str(args, func) int (*func) FPROTO((const char *, const char *)); { char *path1, *path2; + int res; if (!getstrstrarg(args, &path1, &path2)) return NULL; - if ((*func)(path1, path2) < 0) + BGN_SAVE + res = (*func)(path1, path2); + END_SAVE + if (res < 0) return posix_error(); INCREF(None); return None; @@ -157,9 +166,13 @@ posix_strint(args, func) { char *path; int i; + int res; if (!getstrintarg(args, &path, &i)) return NULL; - if ((*func)(path, i) < 0) + BGN_SAVE + res = (*func)(path, i); + END_SAVE + if (res < 0) return posix_error(); INCREF(None); return None; @@ -174,9 +187,13 @@ posix_do_stat(self, args, statfunc) struct stat st; char *path; object *v; + int res; if (!getstrarg(args, &path)) return NULL; - if ((*statfunc)(path, &st) != 0) + BGN_SAVE + res = (*statfunc)(path, &st); + END_SAVE + if (res != 0) return posix_error(); v = newtupleobject(10); if (v == NULL) @@ -227,10 +244,14 @@ posix_getcwd(self, args) object *args; { char buf[1026]; + char *res; extern char *getcwd PROTO((char *, int)); if (!getnoarg(args)) return NULL; - if (getcwd(buf, sizeof buf) == NULL) + BGN_SAVE + res = getcwd(buf, sizeof buf); + END_SAVE + if (res == NULL) return posix_error(); return newstringobject(buf); } @@ -284,10 +305,14 @@ posix_listdir(self, args) struct direct *ep; if (!getstrarg(args, &name)) return NULL; - if ((dirp = opendir(name)) == NULL) + BGN_SAVE + if ((dirp = opendir(name)) == NULL) { + RET_SAVE return posix_error(); + } if ((d = newlistobject(0)) == NULL) { closedir(dirp); + RET_SAVE return NULL; } while ((ep = readdir(dirp)) != NULL) { @@ -306,6 +331,7 @@ posix_listdir(self, args) DECREF(v); } closedir(dirp); + END_SAVE #endif /* !MSDOS */ return d; @@ -368,11 +394,13 @@ posix_system(self, args) object *args; { char *command; - int sts; + long sts; if (!getstrarg(args, &command)) return NULL; + BGN_SAVE sts = system(command); - return newintobject((long)sts); + END_SAVE + return newintobject(sts); } #ifndef MSDOS @@ -411,9 +439,13 @@ posix_uname(self, args) extern int uname PROTO((struct utsname *)); struct utsname u; object *v; + int res; if (!getnoarg(args)) return NULL; - if (uname(&u) < 0) + BGN_SAVE + res = uname(&u); + END_SAVE + if (res < 0) return posix_error(); v = newtupleobject(5); if (v == NULL) @@ -443,6 +475,7 @@ posix_utime(self, args) object *args; { char *path; + int res; #ifdef UTIME_STRUCT struct utimbuf buf; @@ -459,7 +492,10 @@ posix_utime(self, args) if (!getargs(args, "(s(ll))", &path, &ATIME, &MTIME)) return NULL; - if (utime(path, UTIME_ARG) < 0) + BGN_SAVE + res = utime(path, UTIME_ARG); + END_SAVE + if (res < 0) return posix_error(); INCREF(None); return None; @@ -648,7 +684,9 @@ posix_popen(self, args) FILE *fp; if (!getargs(args, "(ss)", &name, &mode)) return NULL; + BGN_SAVE fp = popen(name, mode); + END_SAVE if (fp == NULL) return posix_error(); /* From now on, ignore SIGPIPE and let the error checking @@ -664,8 +702,11 @@ posix_wait(self, args) /* Also waitpid() */ { object *v; int pid, sts; - if (args == NULL) + if (args == NULL) { + BGN_SAVE pid = wait(&sts); + END_SAVE + } else { #ifdef NO_WAITPID err_setstr(PosixError, @@ -674,7 +715,9 @@ posix_wait(self, args) /* Also waitpid() */ int options; if (!getintintarg(args, &pid, &options)) return NULL; + BGN_SAVE pid = waitpid(pid, &sts, options); + END_SAVE #endif } if (pid == -1) @@ -719,7 +762,9 @@ posix_readlink(self, args) int n; if (!getstrarg(args, &path)) return NULL; + BGN_SAVE n = readlink(path, buf, (int) sizeof buf); + END_SAVE if (n < 0) return posix_error(); return newsizedstringobject(buf, n); |