Changeset bc0d32 in git
- Timestamp:
- Apr 9, 2013, 3:33:02 PM (11 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- bdda8c2a271e7650c11462d22c70cd15d21d34f1
- Parents:
- f8565ac2b56eae4e46fb63670efa1bc402ae3628
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-04-09 15:33:02+02:00
- git-committer:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2013-04-09 15:33:47+02:00
- Location:
- Singular
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/links/ndbm.cc
rf8565a rbc0d32 15 15 16 16 #include "config.h" 17 #include <Singular/si_signals.h> 17 18 #include <kernel/mod2.h> 18 19 #ifdef HAVE_DBM … … 86 87 strcpy(db->dbm_pagbuf, file); 87 88 strcat(db->dbm_pagbuf, ".pag"); 88 db->dbm_pagf = open(db->dbm_pagbuf, flags, mode);89 db->dbm_pagf = si_open(db->dbm_pagbuf, flags, mode); 89 90 if (db->dbm_pagf < 0) 90 91 goto bad; 91 92 strcpy(db->dbm_pagbuf, file); 92 93 strcat(db->dbm_pagbuf, ".dir"); 93 db->dbm_dirf = open(db->dbm_pagbuf, flags, mode);94 db->dbm_dirf = si_open(db->dbm_pagbuf, flags, mode); 94 95 if (db->dbm_dirf < 0) 95 96 goto bad1; … … 99 100 return (db); 100 101 bad1: 101 (void) close(db->dbm_pagf);102 (void) si_close(db->dbm_pagf); 102 103 bad: 103 104 free((char *)db); … … 107 108 void dbm_close(DBM *db) 108 109 { 109 (void) close(db->dbm_dirf);110 (void) close(db->dbm_pagf);110 (void) si_close(db->dbm_dirf); 111 (void) si_close(db->dbm_pagf); 111 112 free((char *)db); 112 113 } … … 166 167 db->dbm_pagbno = db->dbm_blkno; 167 168 (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET); 168 if ( write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ)169 if (si_write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) 169 170 { 170 171 err: … … 206 207 db->dbm_pagbno = db->dbm_blkno; 207 208 (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET); 208 if ( (ret= write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ)) != PBLKSIZ)209 if ( (ret=si_write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ)) != PBLKSIZ) 209 210 { 210 211 db->dbm_flags |= _DBM_IOERR; … … 245 246 db->dbm_pagbno = db->dbm_blkno; 246 247 (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET); 247 if ( write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ)248 if (si_write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) 248 249 { 249 250 db->dbm_flags |= _DBM_IOERR; … … 251 252 } 252 253 (void) lseek(db->dbm_pagf, (db->dbm_blkno+db->dbm_hmask+1)*PBLKSIZ, L_SET); 253 if ( write(db->dbm_pagf, ovfbuf, PBLKSIZ) != PBLKSIZ)254 if (si_write(db->dbm_pagf, ovfbuf, PBLKSIZ) != PBLKSIZ) 254 255 { 255 256 db->dbm_flags |= _DBM_IOERR; … … 284 285 db->dbm_pagbno = db->dbm_blkptr; 285 286 (void) lseek(db->dbm_pagf, db->dbm_blkptr*PBLKSIZ, L_SET); 286 if ( read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ)287 if (si_read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) 287 288 memset(db->dbm_pagbuf, 0, PBLKSIZ); 288 289 #ifdef DEBUG … … 323 324 db->dbm_pagbno = db->dbm_blkno; 324 325 (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET); 325 if ( read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ)326 if (si_read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) 326 327 memset(db->dbm_pagbuf, 0, PBLKSIZ); 327 328 #ifdef DEBUG … … 348 349 db->dbm_dirbno = b; 349 350 (void) lseek(db->dbm_dirf, (long)b*DBLKSIZ, L_SET); 350 if ( read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ)351 if (si_read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ) 351 352 memset(db->dbm_dirbuf, 0, DBLKSIZ); 352 353 } … … 369 370 db->dbm_dirbno = b; 370 371 (void) lseek(db->dbm_dirf, (long)b*DBLKSIZ, L_SET); 371 if ( read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ)372 if (si_read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ) 372 373 memset(db->dbm_dirbuf, 0, DBLKSIZ); 373 374 } … … 375 376 db->dbm_dirbno = b; 376 377 (void) lseek(db->dbm_dirf, (long)b*DBLKSIZ, L_SET); 377 if ( write(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ)378 if (si_write(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ) 378 379 db->dbm_flags |= _DBM_IOERR; 379 380 } -
Singular/links/pipeLink.cc
rf8565a rbc0d32 27 27 #include "lists.h" 28 28 #include "pipeLink.h" 29 #include <Singular/si_signals.h> 29 30 30 31 typedef struct … … 53 54 { 54 55 /* close unnecessary pipe descriptors for a clean environment */ 55 close(pc[1]);close(cp[0]);56 si_close(pc[1]); si_close(cp[0]); 56 57 /* dup pipe read/write to stdin/stdout */ 57 dup2( pc[0], STDIN_FILENO );58 dup2( cp[1], STDOUT_FILENO );58 si_dup2( pc[0], STDIN_FILENO ); 59 si_dup2( cp[1], STDOUT_FILENO ); 59 60 int r=system(l->name); 60 close(pc[0]);61 close(cp[1]);61 si_close(pc[0]); 62 si_close(cp[1]); 62 63 exit(r); 63 64 /* never reached*/ … … 66 67 { 67 68 d->pid=pid; 68 close(pc[0]);close(cp[1]);69 si_close(pc[0]); si_close(cp[1]); 69 70 d->f_read=fdopen(cp[0],"r"); 70 71 d->fd_read=cp[0]; … … 176 177 //Print("test fd %d\n",d->fd_read); 177 178 /* check with select: chars waiting: no -> not ready */ 178 s=s elect(d->fd_read+1, &mask, NULL, NULL, &wt);179 s=si_select(d->fd_read+1, &mask, NULL, NULL, &wt); 179 180 } 180 181 switch (s) -
Singular/links/s_buff.cc
rf8565a rbc0d32 11 11 #include <omalloc/omalloc.h> 12 12 #include <Singular/links/s_buff.h> 13 #include <Singular/si_signals.h> 13 14 //struct s_buff_s 14 15 //{ … … 43 44 { 44 45 SSI_BLOCK_CHLD; 45 int fd= open(n,O_RDONLY);46 int fd=si_open(n,O_RDONLY); 46 47 SSI_UNBLOCK_CHLD; 47 48 return s_open(fd); … … 54 55 SSI_BLOCK_CHLD; 55 56 omFreeSize(F->buff,S_BUFF_LEN); 56 int r= close(F->fd);57 int r=si_close(F->fd); 57 58 omFreeSize(F,sizeof(*F)); 58 59 F=NULL; … … 74 75 memset(F->buff,0,S_BUFF_LEN); /*debug*/ 75 76 SSI_BLOCK_CHLD; 76 int r= read(F->fd,F->buff,S_BUFF_LEN);77 int r=si_read(F->fd,F->buff,S_BUFF_LEN); 77 78 SSI_UNBLOCK_CHLD; 78 79 if (r<=0) -
Singular/links/ssiLink.cc
rf8565a rbc0d32 25 25 #include "config.h" 26 26 #include <kernel/mod2.h> 27 #include <Singular/si_signals.h> 27 28 28 29 #include <omalloc/omalloc.h> … … 832 833 ssiToBeClosed->next=NULL; 833 834 SSI_BLOCK_CHLD; 834 close(pc[1]);close(cp[0]);835 si_close(pc[1]); si_close(cp[0]); 835 836 d->f_write=fdopen(cp[1],"w"); 836 837 SSI_UNBLOCK_CHLD; … … 869 870 d->pid=pid; 870 871 SSI_BLOCK_CHLD; 871 close(pc[0]);close(cp[1]);872 si_close(pc[0]); si_close(cp[1]); 872 873 d->f_write=fdopen(pc[1],"w"); 873 874 SSI_UNBLOCK_CHLD; … … 919 920 Print("waiting on port %d\n", portno);mflush(); 920 921 listen(sockfd,1); 921 newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);922 newsockfd = si_accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen); 922 923 if(newsockfd < 0) 923 924 { … … 933 934 d->f_write = fdopen(newsockfd, "w"); 934 935 SI_LINK_SET_RW_OPEN_P(l); 935 close(sockfd);936 si_close(sockfd); 936 937 } 937 938 // no ssi-Link on stdin or stdout … … 1008 1009 omFree(ser_host); 1009 1010 clilen = sizeof(cli_addr); 1010 newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);1011 newsockfd = si_accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen); 1011 1012 if(newsockfd < 0) 1012 1013 { … … 1022 1023 SSI_BLOCK_CHLD; 1023 1024 d->f_write = fdopen(newsockfd, "w"); 1024 close(sockfd);1025 si_close(sockfd); 1025 1026 SSI_UNBLOCK_CHLD; 1026 1027 SI_LINK_SET_RW_OPEN_P(l); … … 1052 1053 server->h_length); 1053 1054 serv_addr.sin_port = htons(portno); 1054 if ( connect(sockfd,(sockaddr*)&serv_addr,sizeof(serv_addr)) < 0)1055 if (si_connect(sockfd,(sockaddr*)&serv_addr,sizeof(serv_addr)) < 0) 1055 1056 { Werror("ERROR connecting(errno=%d)",errno); return TRUE; } 1056 1057 //PrintS("connected\n");mflush(); … … 1162 1163 if (d->r!=NULL) rKill(d->r); 1163 1164 if ((d->pid!=0) 1164 && ( waitpid(d->pid,NULL,WNOHANG)==0))1165 && (si_waitpid(d->pid,NULL,WNOHANG)==0)) 1165 1166 { 1166 1167 struct timespec t; … … 1168 1169 t.tv_nsec=50000000; // <=50 ms 1169 1170 int r=nanosleep(&t,NULL); 1170 if((r==0) && ( waitpid(d->pid,NULL,WNOHANG)==0))1171 if((r==0) && (si_waitpid(d->pid,NULL,WNOHANG)==0)) 1171 1172 { 1172 1173 kill(d->pid,15); … … 1174 1175 t.tv_nsec=10000000; // <=10 ms 1175 1176 r=nanosleep(&t,NULL); 1176 if((r==0)&&( waitpid(d->pid,NULL,WNOHANG)==0))1177 if((r==0)&&(si_waitpid(d->pid,NULL,WNOHANG)==0)) 1177 1178 { 1178 1179 kill(d->pid,9); // just to be sure 1179 waitpid(d->pid,NULL,0);1180 si_waitpid(d->pid,NULL,0); 1180 1181 } 1181 1182 } … … 1498 1499 //Print("test fd %d\n",d->fd_read); 1499 1500 /* check with select: chars waiting: no -> not ready */ 1500 switch (s elect(d->fd_read+1, &mask, NULL, NULL, &wt))1501 switch (si_select(d->fd_read+1, &mask, NULL, NULL, &wt)) 1501 1502 { 1502 1503 case 0: /* not ready */ return "not ready"; … … 1669 1670 #endif 1670 1671 #ifdef HAVE_PSELECT 1671 s = pselect(max_fd, &mask, NULL, NULL, wt_ptr, &sigmask);1672 s = si_pselect(max_fd, &mask, NULL, NULL, wt_ptr, &sigmask); 1672 1673 #else 1673 1674 SSI_BLOCK_CHLD; 1674 s = s elect(max_fd, &mask, NULL, NULL, wt_ptr);1675 s = si_select(max_fd, &mask, NULL, NULL, wt_ptr); 1675 1676 SSI_UNBLOCK_CHLD; 1676 1677 #endif … … 1848 1849 struct sockaddr_in cli_addr; 1849 1850 int clilen = sizeof(cli_addr); 1850 int newsockfd = accept(ssiReserved_sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen);1851 int newsockfd = si_accept(ssiReserved_sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen); 1851 1852 if(newsockfd < 0) 1852 1853 { … … 1894 1895 { 1895 1896 ssiReserved_P=0; 1896 close(ssiReserved_sockfd);1897 si_close(ssiReserved_sockfd); 1897 1898 } 1898 1899 return l; … … 1919 1920 loop 1920 1921 { 1921 kidpid = waitpid(-1, &status, WNOHANG);1922 kidpid = si_waitpid(-1, &status, WNOHANG); 1922 1923 if (kidpid==-1) 1923 1924 { -
Singular/sdb.cc
rf8565a rbc0d32 138 138 PrintS("cannot get the procedure body\n"); 139 139 fclose(fp); 140 unlink(filename);140 si_unlink(filename); 141 141 omFree(filename); 142 142 return; … … 190 190 } 191 191 } 192 unlink(filename);192 si_unlink(filename); 193 193 omFree(filename); 194 194 } -
Singular/si_signals.h
rf8565a rbc0d32 4 4 /* 5 5 * ABSTRACT: wrappijng signal-interuptable system calls 6 * AUTHOR: Alexander Dreyer, The PolyBoRi Team 6 * AUTHOR: Alexander Dreyer, The PolyBoRi Team, 2013 7 7 */ 8 8 … … 18 18 #include <sys/socket.h> 19 19 #include <time.h> 20 #include <stdio.h> 21 #include <semaphore.h> 22 #include <stdarg.h> 20 23 21 24 #ifndef SINGULAR_SI_SIGNALS_H 22 25 #define SINGULAR_SI_SIGNALS_H 23 26 24 #define SI_EINTR_SAVE_FUNC (return_type, func, decl, args)\25 inline return_type si_##func decl\27 #define SI_EINTR_SAVE_FUNC_TEMPLATE(return_type, newfunc, func, decl, args, err_domain) \ 28 static inline return_type newfunc decl \ 26 29 { \ 27 30 int res = -1; \ … … 29 32 { \ 30 33 res = func args; \ 31 } while((res < 0) && (errno == EINTR));\34 } while((res err_domain) && (errno == EINTR));\ 32 35 return res; \ 33 36 } 34 37 38 #define SI_EINTR_SAVE_FUNC(return_type, func, decl, args) \ 39 SI_EINTR_SAVE_FUNC_TEMPLATE(return_type, si_##func, func, decl, args, < 0) 40 41 #define SI_EINTR_SAVE_SCANF(return_type, func, decl, args) \ 42 SI_EINTR_SAVE_FUNC_TEMPLATE(return_type, si_##func, func, decl, args, == EOF) 35 43 36 44 SI_EINTR_SAVE_FUNC(int, select, … … 40 48 ) 41 49 50 #ifdef HAVE_PSELECT 42 51 SI_EINTR_SAVE_FUNC(int, pselect, 43 52 (int nfds, fd_set *readfds, fd_set *writefds, … … 46 55 (nfds, readfds, writefds, exceptfds, timeout,sigmask) 47 56 ) 57 #endif 48 58 49 59 SI_EINTR_SAVE_FUNC(pid_t, wait, (int *status), (status)) … … 51 61 (pid, status, options)) 52 62 53 SI_EINTR_SAVE_FUNC(int, waitid,54 (idtype_t idtype, id_t id, siginfo_t *infop, int options),55 (idtype, id, infop, options))63 //SI_EINTR_SAVE_FUNC(int, waitid, 64 // (idtype_t idtype, id_t id, siginfo_t *infop, int options), 65 // (idtype, id, infop, options)) 56 66 57 67 SI_EINTR_SAVE_FUNC(ssize_t, read, (int fd, void *buf, size_t count), … … 68 78 SI_EINTR_SAVE_FUNC(ssize_t, writev, (int fd, const struct iovec *iov, int iovcnt), 69 79 (fd, iov, iovcnt) ) 70 71 SI_EINTR_SAVE_FUNC(int, open, (const char *pathname, int flags), 72 (pathname, flags)) 73 74 SI_EINTR_SAVE_FUNC(int, open, (const char *pathname, int flags, mode_t mode), 75 (pathname, flags, mode)) 80 81 SI_EINTR_SAVE_FUNC_TEMPLATE(int, si_open1, open, (const char *pathname, int flags), 82 (pathname, flags), < 0) 83 SI_EINTR_SAVE_FUNC_TEMPLATE(int, si_open2, open, 84 (const char *pathname, int flags, mode_t mode), 85 (pathname, flags, mode), < 0) 86 87 /* Enulate overloading usung preprocessor (we need to be C-compatible) */ 88 #define SI_GET_FIFTH(_4,_3, _2, _1, N, ...) N 89 #define si_open(...) SI_GET_FIFTH(X,##__VA_ARGS__, si_open2, si_open1)(__VA_ARGS__) 90 91 SI_EINTR_SAVE_FUNC(int, creat, (const char *pathname, mode_t mode), 92 (pathname, mode)) 93 76 94 77 95 SI_EINTR_SAVE_FUNC(int, close, (int fd), (fd)) … … 80 98 (int sockfd, struct sockaddr *addr, socklen_t *addrlen), 81 99 (sockfd, addr, addrlen)) 82 100 83 101 SI_EINTR_SAVE_FUNC(int, connect, 84 102 (int sockfd, const struct sockaddr *addr, socklen_t addrlen), 85 103 (sockfd, addr, addrlen)) 86 104 87 SI_EINTR_SAVE_FUNC(int, nanosleep, 88 (const struct timespec *req, struct timespec *rem), 89 (req, rem)) 90 91 inline unsigned int si_sleep(unsigned int seconds) 105 /* @note: We respect that the user may explictely deactivate the 106 * restart feature by setting the second argumetn to NULL. 107 */ 108 static inline int 109 si_nanosleep(const struct timespec *req, struct timespec *rem) { 110 111 int res = -1; 112 do 113 { 114 res = nanosleep(req, rem); 115 } while((rem != NULL) && (res < 0) && (errno == EINTR)); 116 return res; 117 } 118 119 static inline unsigned int 120 si_sleep(unsigned int seconds) 92 121 { 93 122 do … … 98 127 } 99 128 100 // still todo: read,write,open in ./omalloc/Misc/dlmalloc 101 /// TODO: wrap and replace the following system calls: from man 7 signal 102 /// ???fread, fwrite, fopen, fdopen, popen, fclose 103 104 105 /// 106 /// regardless of the use of SA_RESTART: 107 /// 108 /// nanosleep(2), and usleep(3). 109 /// sleep(3) 110 111 112 129 SI_EINTR_SAVE_FUNC(int, dup, (int oldfd), (oldfd)) 130 SI_EINTR_SAVE_FUNC(int, dup2, (int oldfd, int newfd), (oldfd, newfd)) 131 //SI_EINTR_SAVE_FUNC(int, dup3, (int oldfd, int newfd, int flags), 132 // (oldfd, newfd, flags)) 133 134 SI_EINTR_SAVE_FUNC(int, unlink, (const char *pathname), (pathname)) 135 136 SI_EINTR_SAVE_SCANF(int, vscanf, 137 (const char *format, va_list ap), 138 (format, ap)) 139 140 static inline 141 int si_scanf(const char *format, ...) 142 { 143 va_list argptr; 144 va_start(argptr, format); 145 int res = si_vscanf(format, argptr); 146 va_end(argptr); 147 return res; 148 } 149 150 SI_EINTR_SAVE_SCANF(int, vfscanf, 151 (FILE *stream, const char *format, va_list ap), 152 (stream, format, ap)) 153 154 static inline int 155 si_fscanf(FILE *stream, const char *format, ...) 156 { 157 va_list argptr; 158 va_start(argptr, format); 159 int res = si_vfscanf(stream, format, argptr); 160 va_end(argptr); 161 return res; 162 } 163 164 SI_EINTR_SAVE_SCANF(int, vsscanf, 165 (const char *str, const char *format, va_list ap), 166 (str, format, ap)) 167 168 static inline int 169 si_sscanf(const char *str, const char *format, ...) 170 { 171 va_list argptr; 172 va_start(argptr, format); 173 int res = si_vsscanf(str, format, argptr); 174 va_end(argptr); 175 return res; 176 } 177 178 SI_EINTR_SAVE_FUNC(int, stat, (const char *path, struct stat *buf), 179 (path, buf)) 180 SI_EINTR_SAVE_FUNC(int, fstat, (int fd, struct stat *buf), 181 (fd, buf)) 182 SI_EINTR_SAVE_FUNC(int, lstat, (const char *path, struct stat *buf), 183 (path, buf)) 184 185 186 SI_EINTR_SAVE_FUNC(int, sigaction, 187 (int signum, const struct sigaction *act, 188 struct sigaction *oldact), 189 (signum, act, oldact)) 190 191 192 #ifdef HAVE_SIGINTERRUPT 193 SI_EINTR_SAVE_FUNC(int, siginterrupt, (int sig, int flag), 194 (sig, flag)) 195 #else 196 #define si_siginterrupt(arg1, arg2) 197 #endif 198 199 200 SI_EINTR_SAVE_FUNC(int, sem_wait, (sem_t *sem), (sem)) 201 SI_EINTR_SAVE_FUNC(int, sem_trywait, (sem_t *sem), (sem)) 202 //SI_EINTR_SAVE_FUNC(int, sem_timedwait, 203 // (sem_t *sem, const struct timespec *abs_timeout), 204 // (sem, abs_timeout)) 113 205 114 206
Note: See TracChangeset
for help on using the changeset viewer.