comparison src/sysdep.c @ 5494:861f2601a38b

Sync s/ files with GNU 23.1.92, delete obsolete stuff, simplify other stuff --- ChangeLog 2010-02-20 Ben Wing <ben@xemacs.org> * configure: * configure.ac (XE_EXPAND_VARIABLE): * configure.ac (TAB): irix6-0.h renamed to irix6-5.h; sco7.h deleted. bsd4-3.h renamed to bsd-common.h. Simplify setting machine= for intel386, mips. Put back linux.h. Incorporate some stuff about debug/optimization flags in irix6-5.h into configure.ac. Add a comment about LCC stuff with optimization flags that should be fixed up. --- src/ChangeLog 2010-02-20 Ben Wing <ben@xemacs.org> * sysdep.c: * sysdep.c (qxe_reliable_signal): * sysdep.c (retry_open_1): * sysdep.c (retry_close): * sysdep.c (retry_read_1): * sysdep.c (retry_write_1): * sysdep.c (retry_fopen): * sysdep.c (retry_fclose): * sysdep.c (retry_fread): * sysdep.c (retry_fwrite): Remove conditionalization on INTERRUPTIBLE_IO, INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE -- always check for EINTR as there's no harm in it. Remove old #if 0'ed out SA_RESTART code. Use manifest constant IRIX6_5 instead of IRIX. * Makefile.in.in: * dired.c: * dired.c (Ffile_attributes): Use manifest constant IRIX6_5 instead of IRIX. Eliminate constant BSD4_2, use BSD4_3 instead. * getloadavg.c: * getloadavg.c (getloadavg): * getloadavg.c (LDAV_PRIVILEGED): * getloadavg.c (LDAV_DONE): Sync with GNU 23.1.92. 2010-02-20 Ben Wing <ben@xemacs.org> * s/README: * s/aix4-2.h: * s/aix4-2.h (MAIL_USE_LOCKF): * s/bsd-common.h: * s/freebsd.h: * s/freebsd.h (Carey): * s/freebsd.h (or): * s/gnu.h: * s/gnu.h (DATA_START): * s/hpux11-shr.h: * s/hpux11.h: * s/hpux11.h (random): * s/irix6-5.h: * s/linux.h: * s/mach-bsd4-3.h: * s/netbsd.h: * s/netbsd.h (or): * s/netbsd.h (A_TEXT_OFFSET): * s/netbsd.h (NO_MATHERR): * s/openbsd.h: * s/sol2.h: * s/usg5-4-2.h: * s/usg5-4.h: * s/usg5-4.h (or): * s/usg5-4.h (ORDINARY_LINK): Sync with GNU 23.1.92. Put back linux.h. Rename: bsd4-3.h -> bsd-common.h; irix6-0.h -> irix6-5.h. Delete: template.h (useless). Delete a whole bunch of obsolete stuff in sol2.h, linux.h, freebsd.h -- assume anything over 10 years old is sufficiently obsolete to be deleted. Remove LIBS_DEBUG, C_DEBUG_SWITCH, C_OPTIMIZE_SWITCH, KERNEL_FILE, LDAV_SYMBOL, most remaining PTY stuff, remaining TERMINFO/TERMCAP stuff. Update README appropriately. Remove stuff in hpux11-shr.h duplicated in hpux11.h. Remove sco7.h, identical with usg5-4-2.h. Remove unused POSIX flag, BROKEN_TIOC*, NO_SIOCTL_H. 2010-02-20 Ben Wing <ben@xemacs.org> * m/arm.h: * m/hp800.h: * m/intel386.h: * m/mips.h: * m/powerpc.h: * m/sparc.h: * m/template.h: Temporarily ifdef out all defines involving load-average stuff -- using define ENABLE_SM_FILE_DECLS_OF_LOADAVG_STUFF, which is not defined. I'm pretty sure getloadavg.c will take care of defining stuff properly on all systems without the need to duplicate the info in m/*. --ben Delete LIBS_TERMCAP; configure auto-handles this. Delete extra stuff in hp800.h. Delete C_DEBUG_SWITCH, C_OPTIMIZE_SWITCH, LDAV_SYMBOL; incorporate some stuff into configure.ac.
author Ben Wing <ben@xemacs.org>
date Sat, 20 Feb 2010 06:03:00 -0600
parents 3c3c1d139863
children 1f0b15040456
comparison
equal deleted inserted replaced
5493:f62141fe007d 5494:861f2601a38b
2164 2164
2165 /* POSIX signals support - DJB */ 2165 /* POSIX signals support - DJB */
2166 2166
2167 #ifdef HAVE_SIGPROCMASK 2167 #ifdef HAVE_SIGPROCMASK
2168 2168
2169 /* #### Is there any reason this is static global rather than local? */
2170 static struct sigaction new_action, old_action;
2171
2172 signal_handler_t 2169 signal_handler_t
2173 qxe_reliable_signal (int signal_number, signal_handler_t action) 2170 qxe_reliable_signal (int signal_number, signal_handler_t action)
2174 { 2171 {
2175 #if 0 2172 static struct sigaction new_action, old_action;
2176 2173
2177 /* XEmacs works better if system calls are *not* restarted. 2174 /* XEmacs works better if system calls are not restarted.
2178 This allows C-g to interrupt reads and writes, on most systems. 2175 This allows C-g to interrupt reads and writes, on most systems.
2179 2176
2180 #### Another possibility is to just longjmp() out of the signal 2177 #### Another possibility is to just longjmp() out of the signal
2181 handler. According to W.R. Stevens, this should be OK on all 2178 handler. According to W.R. Stevens, this should be OK on all
2182 systems. However, I don't want to deal with the potential 2179 systems. However, I don't want to deal with the potential
2183 evil ramifications of this at this point. */ 2180 evil ramifications of this at this point. */
2184
2185 sigemptyset (&new_action.sa_mask);
2186 new_action.sa_handler = action;
2187 #if defined (SA_RESTART)
2188 /* Emacs mostly works better with restartable system services. If this
2189 * flag exists, we probably want to turn it on here.
2190 */
2191 new_action.sa_flags = SA_RESTART;
2192 #else
2193 new_action.sa_flags = 0;
2194 #endif
2195 sigaction (signal_number, &new_action, &old_action);
2196 return (old_action.sa_handler);
2197
2198 #else /* not 0 */
2199
2200 sigemptyset (&new_action.sa_mask); 2181 sigemptyset (&new_action.sa_mask);
2201 new_action.sa_handler = action; 2182 new_action.sa_handler = action;
2202 #if defined (SA_INTERRUPT) /* don't restart system calls, under SunOS */ 2183 #if defined (SA_INTERRUPT) /* don't restart system calls, under SunOS */
2203 new_action.sa_flags = SA_INTERRUPT; 2184 new_action.sa_flags = SA_INTERRUPT;
2204 #else 2185 #else
2205 new_action.sa_flags = 0; 2186 new_action.sa_flags = 0;
2206 #endif 2187 #endif
2207 sigaction (signal_number, &new_action, &old_action); 2188 sigaction (signal_number, &new_action, &old_action);
2208 return (signal_handler_t) (old_action.sa_handler); 2189 return (signal_handler_t) (old_action.sa_handler);
2209
2210 #endif /* not 0 */
2211 } 2190 }
2212 2191
2213 #elif defined (HAVE_SIGBLOCK) 2192 #elif defined (HAVE_SIGBLOCK)
2214 2193
2215 /* We use sigvec() rather than signal() if we have it, because 2194 /* We use sigvec() rather than signal() if we have it, because
2239 /* Emulation of strerror() and errno support */ 2218 /* Emulation of strerror() and errno support */
2240 /************************************************************************/ 2219 /************************************************************************/
2241 2220
2242 #ifndef HAVE_STRERROR 2221 #ifndef HAVE_STRERROR
2243 2222
2244 #if !defined(__alpha) && !defined(MACH) && !defined(LINUX) && !defined(IRIX) && !defined(__NetBSD__) 2223 #if !defined(__alpha) && !defined(MACH) && !defined(LINUX) && !defined(IRIX6_5) && !defined(__NetBSD__)
2245 /* Linux added here by Raymond L. Toy <toy@alydar.crd.ge.com> for XEmacs. */ 2224 /* Linux added here by Raymond L. Toy <toy@alydar.crd.ge.com> for XEmacs. */
2246 /* Irix added here by gparker@sni-usa.com for XEmacs. */ 2225 /* Irix added here by gparker@sni-usa.com for XEmacs. */
2247 /* NetBSD added here by James R Grinter <jrg@doc.ic.ac.uk> for XEmacs */ 2226 /* NetBSD added here by James R Grinter <jrg@doc.ic.ac.uk> for XEmacs */
2248 extern const char *sys_errlist[]; 2227 extern const char *sys_errlist[];
2249 extern int sys_nerr; 2228 extern int sys_nerr;
2326 } 2305 }
2327 2306
2328 static int 2307 static int
2329 retry_open_1 (const Extbyte *path, int oflag, int mode) 2308 retry_open_1 (const Extbyte *path, int oflag, int mode)
2330 { 2309 {
2331 #ifdef INTERRUPTIBLE_OPEN 2310 int rtnval;
2332 { 2311 while ((rtnval = underlying_open (path, oflag, mode)) == -1
2333 int rtnval; 2312 && (errno == EINTR))
2334 while ((rtnval = underlying_open (path, oflag, mode)) == -1 2313 DO_NOTHING;
2335 && (errno == EINTR)) 2314 return rtnval;
2336 DO_NOTHING;
2337 return rtnval;
2338 }
2339 #else
2340 return underlying_open (path, oflag, mode);
2341 #endif
2342 } 2315 }
2343 2316
2344 /* A version of open() that retries when interrupted. Operates on 2317 /* A version of open() that retries when interrupted. Operates on
2345 externally-encoded filenames. */ 2318 externally-encoded filenames. */
2346 2319
2430 } 2403 }
2431 2404
2432 int 2405 int
2433 retry_close (int filedes) 2406 retry_close (int filedes)
2434 { 2407 {
2435 #ifdef INTERRUPTIBLE_CLOSE
2436 int did_retry = 0; 2408 int did_retry = 0;
2437 REGISTER int rtnval; 2409 REGISTER int rtnval;
2438 2410
2439 while ((rtnval = close (filedes)) == -1 2411 while ((rtnval = close (filedes)) == -1
2440 && (errno == EINTR)) 2412 && (errno == EINTR))
2445 errno = EBADF. That means we have succeeded. */ 2417 errno = EBADF. That means we have succeeded. */
2446 if (rtnval == -1 && did_retry && errno == EBADF) 2418 if (rtnval == -1 && did_retry && errno == EBADF)
2447 return 0; 2419 return 0;
2448 2420
2449 return rtnval; 2421 return rtnval;
2450 #else
2451 return close (filedes);
2452 #endif
2453 } 2422 }
2454 2423
2455 static ssize_t 2424 static ssize_t
2456 retry_read_1 (int fildes, void *buf, size_t nbyte, int allow_quit) 2425 retry_read_1 (int fildes, void *buf, size_t nbyte, int allow_quit)
2457 { 2426 {
2458 ssize_t rtnval; 2427 ssize_t rtnval;
2459 2428
2460 /* No harm in looping regardless of the INTERRUPTIBLE_IO setting. */
2461 while ((rtnval = read (fildes, buf, nbyte)) == -1 2429 while ((rtnval = read (fildes, buf, nbyte)) == -1
2462 && (errno == EINTR)) 2430 && (errno == EINTR))
2463 { 2431 {
2464 if (allow_quit) 2432 if (allow_quit)
2465 QUIT; 2433 QUIT;
2477 retry_write_1 (int fildes, const void *buf, size_t nbyte, int allow_quit) 2445 retry_write_1 (int fildes, const void *buf, size_t nbyte, int allow_quit)
2478 { 2446 {
2479 ssize_t bytes_written = 0; 2447 ssize_t bytes_written = 0;
2480 const char *b = (const char *) buf; 2448 const char *b = (const char *) buf;
2481 2449
2482 /* No harm in looping regardless of the INTERRUPTIBLE_IO setting. */
2483 while (nbyte > 0) 2450 while (nbyte > 0)
2484 { 2451 {
2485 ssize_t rtnval = write (fildes, b, nbyte); 2452 ssize_t rtnval = write (fildes, b, nbyte);
2486 2453
2487 if (allow_quit) 2454 if (allow_quit)
2579 fd = underlying_open (path, oflag, 0644); 2546 fd = underlying_open (path, oflag, 0644);
2580 if (fd < 0) 2547 if (fd < 0)
2581 return NULL; 2548 return NULL;
2582 2549
2583 return _fdopen (fd, mode_save); 2550 return _fdopen (fd, mode_save);
2584 #elif defined (INTERRUPTIBLE_OPEN) 2551 #else
2585 { 2552 FILE *rtnval;
2586 FILE *rtnval; 2553 while (!(rtnval = fopen (path, mode)) && (errno == EINTR))
2587 while (!(rtnval = fopen (path, mode)) && (errno == EINTR)) 2554 DO_NOTHING;
2588 DO_NOTHING; 2555 return rtnval;
2589 return rtnval; 2556 #endif /* (not) WIN32_NATIVE */
2590 }
2591 #else
2592 return fopen (path, mode);
2593 #endif /* defined (INTERRUPTIBLE_OPEN) */
2594 } 2557 }
2595 2558
2596 FILE * 2559 FILE *
2597 qxe_fopen (const Ibyte *path, const Ascbyte *mode) 2560 qxe_fopen (const Ibyte *path, const Ascbyte *mode)
2598 { 2561 {
2602 } 2565 }
2603 2566
2604 int 2567 int
2605 retry_fclose (FILE *stream) 2568 retry_fclose (FILE *stream)
2606 { 2569 {
2607 #ifdef INTERRUPTIBLE_CLOSE
2608 int rtnval; 2570 int rtnval;
2609 2571
2610 while ((rtnval = fclose (stream)) == EOF 2572 while ((rtnval = fclose (stream)) == EOF
2611 && (errno == EINTR)) 2573 && (errno == EINTR))
2612 ; 2574 ;
2613 return rtnval; 2575 return rtnval;
2614 #else
2615 return fclose (stream);
2616 #endif
2617 } 2576 }
2618 2577
2619 size_t 2578 size_t
2620 retry_fread (void *ptr, size_t size, size_t nitem, FILE *stream) 2579 retry_fread (void *ptr, size_t size, size_t nitem, FILE *stream)
2621 { 2580 {
2622 #ifdef INTERRUPTIBLE_IO
2623 size_t rtnval; 2581 size_t rtnval;
2624 size_t items_read = 0; 2582 size_t items_read = 0;
2625 char *b = (char *) ptr; 2583 char *b = (char *) ptr;
2626 2584
2627 while (nitem > 0) 2585 while (nitem > 0)
2637 b += size*rtnval; 2595 b += size*rtnval;
2638 nitem -= rtnval; 2596 nitem -= rtnval;
2639 items_read += rtnval; 2597 items_read += rtnval;
2640 } 2598 }
2641 return (items_read); 2599 return (items_read);
2642 #else
2643 return fread (ptr, size, nitem, stream);
2644 #endif
2645 } 2600 }
2646 2601
2647 size_t 2602 size_t
2648 retry_fwrite (const void *ptr, size_t size, size_t nitem, FILE *stream) 2603 retry_fwrite (const void *ptr, size_t size, size_t nitem, FILE *stream)
2649 { 2604 {
2650 #ifdef INTERRUPTIBLE_IO
2651 size_t rtnval; 2605 size_t rtnval;
2652 size_t items_written = 0; 2606 size_t items_written = 0;
2653 const char *b = (const char *) ptr; 2607 const char *b = (const char *) ptr;
2654 2608
2655 while (nitem > 0) 2609 while (nitem > 0)
2665 b += size*rtnval; 2619 b += size*rtnval;
2666 nitem -= rtnval; 2620 nitem -= rtnval;
2667 items_written += rtnval; 2621 items_written += rtnval;
2668 } 2622 }
2669 return (items_written); 2623 return (items_written);
2670 #else
2671 return fwrite (ptr, size, nitem, stream);
2672 #endif
2673 } 2624 }
2674 2625
2675 /********************* directory calls *******************/ 2626 /********************* directory calls *******************/
2676 2627
2677 int 2628 int