Mercurial > emacs
comparison src/sysdep.c @ 26088:b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
* Makefile.in (emacs): Set the LC_ALL environment variable to "C"
when dumping, so that the dumped Emacs doesn't have stray locale info.
(dired.o): Depend on systime.h.
(editfns.o): Depend on coding.h.
* alloc.c, buffer.c, callproc.c, ccl.c, charset.c, coding.c, data.c,
dispnew.c, editfns.c, emacs.c, filelock.c, floatfns.c, hftctl.c,
keyboard.c, process.c, sysdep.c, unexelf.c, unexhp9k800.c,
unexsunos4.c, vmsfns.c, vmsgmalloc.c, w32faces.c, w32menu.c, w32term.c,
w32xfns.c, xfaces.c, xfns.c, xmenu.c, xterm.c:
Include <config.h> before any system include files.
* alloc.c, buffer.c, ccl.c, data.c, editfns.c, emacs.c, eval.c,
fileio.c, filelock.c, frame.c, insdel.c, keymap.c, lread.c,
m/alpha.h, print.c, search.c, sysdep.c, xdisp.c, xfaces.c, xfns.c,
xmenu.c, xterm.c:
Do not include <stdlib.h>, as <config.h> does this now.
* callproc.c (Fcall_process):
Synchronize messages locale before invoking strerror.
Decode resulting string with locale-coding-system.
* coding.c (Vlocale_coding_system): New var.
(syms_of_coding): Adjust to above change.
(emacs_strerror): New function.
* coding.h (emacs_strerror, Vlocale_coding_system): New decls.
* config.in (HAVE_STDIO_EXT_H, HAVE_TM_GMTOFF, HAVE___FPENDING,
HAVE_FTELLO, HAVE_GETLOADAVG, HAVE_MBLEN, HAVE_MBRLEN,
HAVE_STRSIGNAL): New macros.
(BITS_PER_LONG): Default to 64 if _LP64 is defined.
<stdlib.h>: Include if HAVE_STDLIB_H is defined and NOT_C_CODE isn't.
* dired.c: Include "systime.h".
(Ffile_attributes): Do not cast s.st_size to int; this loses
information if int is 32 bits but st_size and EMACS_INT are larger.
Treat large device numbers like large inode numbers.
* dispnew.c (PENDING_OUTPUT_COUNT): Use __fpending if available.
* editfns.c: Include coding.h.
(emacs_strftime): Remove decl.
(emacs_strftimeu): New decl.
(emacs_memftimeu): Renamed from emacs_memftime; new arg UT.
Use emacs_strftimeu instead of emacs_strftime.
(Fformat_time_string): Convert format string using
Vlocale_coding_system, and convert result back. Synchronize time
locale before invoking lower level function. Invoke
emacs_memftimeu, passing ut, instead of emacs_memftime.
* emacs.c: Include <locale.h> if HAVE_SETLOCALE is defined.
(Vmessages_locale, Vprevious_messages_locale, Vtime_locale,
Vprevious_time_locale): New variables.
(main): Invoke setlocale early, so that initial error messages are
localized properly. But skip locale-setting if LC_ALL is "C".
Fix up locale when it's safe to do so.
(fixup_locale): Moved here from xterm.c.
(synchronize_locale, synchronize_time_locale,
synchronize_messages_locale): New functions.
(syms_of_emacs): Accommodate above changes.
* fileio.c (report_file_error): Convert strerror output according
to Vlocale_coding_system.
(Finsert_file_contents): Check for arithmetic overflow in
computations that depend on file size. Report IO errors
with emacs_strerror, not strerror.
* fns.c (Fgethash): Declare dflt parameter.
* gmalloc.c: Do not define const to nothing if HAVE_CONFIG_H
is defined; that's config.h's job.
* lisp.h (EMACS_INT, BITS_PER_EMACS_INT, EMACS_UINT): If _LP64,
default these values to long, BITS_PER_LONG, and unsigned long.
(VALBITS, MARKBIT, XINT): Do not assume 32-bit EMACS_INT.
(PNTR_COMPARISON_TYPE): Default to EMACS_UINT, not to unsigned int.
(code_convert_string_norecord, fixup_locale,
synchronize_messages_locale, synchronize_time_locale,
emacs_open, emacs_close, emacs_read, emacs_write): New decls.
All Emacs callers of open, close, read, write changed to use
emacs_open, emacs_close, emacs_read, emacs_write.
* lread.c (file_offset, file_tell): New macros. All uses of ftell
changed to file_tell.
(saved_doc_string_position, prev_saved_doc_string_position): Now
of type file_offset.
(init_lread): Do not fix locale here; fixup_locale now does this.
* m/amdahl.h, s/usg5-4.h:
(NSIG): Remove.
(NSIG_MINIMUM): New macro.
* m/cydra5.h, m/dpx2.h, m/mips.h, m/pfa50.h, m/sps7.h, m/stride.h,
m/ustation.h, s/gnu-linux.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h,
s/umips.h, s/usg5-4.h:
(SIGIO): Do not undef.
(BROKEN_SIGIO): New macro.
* m/ustation.h:
(SIGTSTP): Do not undef.
(BROKEN_SIGTSTP): New macro.
* s/gnu-linux.h:
(SIGPOLL, SIGURG): Do not undef.
(BROKEN_SIGPOLL, BROKEN_SIGURG): New macros.
* s/ptx4.h:
(SIGINFO): Do not undef.
(BROKEN_SIGINFO): New macros.
* m/delta.h, s/ptx.h, s/template.h: Doc fix.
* mktime.c, strftime.c: Update to glibc 2.1.2 version, with
some Emacs-related changes merged.
* print.c (float_to_string): Prepend "-" to representation of a
NaN if the NaN is negative.
* process.c (sys_siglist): Omit if HAVE_STRSIGNAL.
(wait_reading_process_input): Use emacs_strerror, not strerror.
* process.c (status_message, sigchld_handler): Synchronize locale,
then use strsignal istead of sys_siglist.
* w32proc.c (sys_wait): Likewise.
* s/aix3-1.h, s/bsd4-1.h, s/dgux.h, s/gnu-linux.h, s/hiuxmpp.h,
s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/irix3-3.h, s/osf1.h, s/rtu.h,
s/sunos4-1.h, s/unipl5-0.h, s/unipl5-2.h, s/usg5-0.h, s/usg5-2-2.h,
s/usg5-2.h, s/usg5-3.h, s/xenix.h:
(open, close, read, write, INTERRUPTIBLE_OPEN,
INTERRUPTIBLE_CLOSE, INTERRUPTIBLE_IO): Remove.
* s/sol2-5.h (_LARGEFILE_SOURCE, _FILE_OFFSET_BITS): New macros.
* sysdep.c (sys_read, sys_write, read, write, sys_close, close,
sys_open, open): Remove.
(emacs_open, emacs_close, emacs_read, emacs_write): Always define;
the old INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, and INTERRUPTIBLE_IO
macros are no longer used.
(emacs_open): Renamed from sys_open. Merge BSD4_1 version.
(emacs_close): Renamed from sys_close.
(emacs_read): Renamed from sys_read.
(emacs_write): Renamed from sys_write.
(sys_siglist): Do not declare if HAVE_STRSIGNAL.
(dup2): Do not print error on failure; the real dup2 doesn't.
(strsignal): New function, defined if !HAVE_STRSIGNAL.
* syssignal.h (SIGINFO): Undef if defined and if BROKEN_SIGINFO
is defined.
(SIGIO, SIGPOLL, SIGTSTP, SIGURG): Likewise.
(NSIG): If less than NSIG_MINIMUM, define to NSIG_MINIMUM.
(strsignal): Declare if !HAVE_STRSIGNAL.
* unexelf.c (ElfBitsW, ELFSIZE, ElfExpandBitsW): New macros.
(ElfW): Define in terms of ElfExpandBitsW.
* w32proc.c (sys_siglist): Remove decl.
* xdisp.c (decode_mode_spec): 3rd arg is int, not char, to comply
with ANSI C.
(display_string): Declare face_string_pos arg.
* xfns.c (Fx_show_tip): Declare timeout param.
* xterm.c: No need to include locale.h.
(x_alloc_lighter_color, x_setup_relief_color):
Pass arg as double, not float, for compatibility with ANSI C.
(fixup_locale): Move to emacs.c.
(x_term_init): Do not setlocale or fixup locale; the main program
does this now.
author | Paul Eggert <eggert@twinsun.com> |
---|---|
date | Tue, 19 Oct 1999 07:25:11 +0000 |
parents | b0d0bcf1b32e |
children | b7438760079b |
comparison
equal
deleted
inserted
replaced
26087:e0d966fb548f | 26088:b7aa6ac26872 |
---|---|
1 /* Interfaces to system-dependent kernel and library entries. | 1 /* Interfaces to system-dependent kernel and library entries. |
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95 Free Software Foundation, Inc. | 2 Copyright (C) 1985, 86,87,88,93,94,95, 1999 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GNU Emacs. | 4 This file is part of GNU Emacs. |
5 | 5 |
6 GNU Emacs is free software; you can redistribute it and/or modify | 6 GNU Emacs is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
17 along with GNU Emacs; see the file COPYING. If not, write to | 17 along with GNU Emacs; see the file COPYING. If not, write to |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 Boston, MA 02111-1307, USA. */ | 19 Boston, MA 02111-1307, USA. */ |
20 | 20 |
21 | 21 |
22 #include <config.h> | |
22 #include <signal.h> | 23 #include <signal.h> |
23 #include <setjmp.h> | 24 #include <setjmp.h> |
24 | 25 |
25 #include <config.h> | |
26 #ifdef STDC_HEADERS | |
27 #include <stdlib.h> | |
28 #endif | |
29 #include "lisp.h" | 26 #include "lisp.h" |
30 #include "blockinput.h" | 27 #include "blockinput.h" |
31 #undef NULL | 28 #undef NULL |
32 | 29 |
33 #ifdef macintosh | 30 #ifdef macintosh |
48 #endif | 45 #endif |
49 #endif /* macintosh */ | 46 #endif /* macintosh */ |
50 | 47 |
51 #define min(x,y) ((x) > (y) ? (y) : (x)) | 48 #define min(x,y) ((x) > (y) ? (y) : (x)) |
52 | 49 |
53 /* In this file, open, read and write refer to the system calls, | |
54 not our sugared interfaces sys_open, sys_read and sys_write. | |
55 Contrariwise, for systems where we use the system calls directly, | |
56 define sys_read, etc. here as aliases for them. */ | |
57 #ifndef read | |
58 #define sys_read read | |
59 #define sys_write write | |
60 #endif /* `read' is not a macro */ | |
61 | |
62 #undef read | |
63 #undef write | |
64 | |
65 #ifdef WINDOWSNT | 50 #ifdef WINDOWSNT |
66 #define read _read | 51 #define read _read |
67 #define write _write | 52 #define write _write |
68 #include <windows.h> | 53 #include <windows.h> |
69 extern int errno; | 54 extern int errno; |
70 #endif /* not WINDOWSNT */ | 55 #endif /* not WINDOWSNT */ |
71 | |
72 #ifndef close | |
73 #define sys_close close | |
74 #else | |
75 #undef close | |
76 #endif | |
77 | |
78 #ifndef open | |
79 #define sys_open open | |
80 #else /* `open' is a macro */ | |
81 #undef open | |
82 #endif /* `open' is a macro */ | |
83 | 56 |
84 /* Does anyone other than VMS need this? */ | 57 /* Does anyone other than VMS need this? */ |
85 #ifndef fwrite | 58 #ifndef fwrite |
86 #define sys_fwrite fwrite | 59 #define sys_fwrite fwrite |
87 #else | 60 #else |
2708 #endif /* not HAVE_SELECT */ | 2681 #endif /* not HAVE_SELECT */ |
2709 #endif /* not VMS */ | 2682 #endif /* not VMS */ |
2710 #endif /* not MSDOS */ | 2683 #endif /* not MSDOS */ |
2711 | 2684 |
2712 #ifdef BSD4_1 | 2685 #ifdef BSD4_1 |
2713 /* | |
2714 * Partially emulate 4.2 open call. | |
2715 * open is defined as this in 4.1. | |
2716 * | |
2717 * - added by Michael Bloom @ Citicorp/TTI | |
2718 * | |
2719 */ | |
2720 | |
2721 int | |
2722 sys_open (path, oflag, mode) | |
2723 char *path; | |
2724 int oflag, mode; | |
2725 { | |
2726 if (oflag & O_CREAT) | |
2727 return creat (path, mode); | |
2728 else | |
2729 return open (path, oflag); | |
2730 } | |
2731 | |
2732 void | 2686 void |
2733 init_sigio (fd) | 2687 init_sigio (fd) |
2734 int fd; | 2688 int fd; |
2735 { | 2689 { |
2736 if (noninteractive) | 2690 if (noninteractive) |
3091 return (char *) "Unknown error"; | 3045 return (char *) "Unknown error"; |
3092 } | 3046 } |
3093 #endif /* not WINDOWSNT */ | 3047 #endif /* not WINDOWSNT */ |
3094 #endif /* ! HAVE_STRERROR */ | 3048 #endif /* ! HAVE_STRERROR */ |
3095 | 3049 |
3096 #ifdef INTERRUPTIBLE_OPEN | 3050 int |
3097 | 3051 emacs_open (path, oflag, mode) |
3098 int | |
3099 /* VARARGS 2 */ | |
3100 sys_open (path, oflag, mode) | |
3101 char *path; | 3052 char *path; |
3102 int oflag, mode; | 3053 int oflag, mode; |
3103 { | 3054 { |
3104 register int rtnval; | 3055 register int rtnval; |
3056 | |
3057 #ifdef BSD4_1 | |
3058 if (oflag & O_CREAT) | |
3059 return creat (path, mode); | |
3060 #endif | |
3105 | 3061 |
3106 while ((rtnval = open (path, oflag, mode)) == -1 | 3062 while ((rtnval = open (path, oflag, mode)) == -1 |
3107 && (errno == EINTR)); | 3063 && (errno == EINTR)); |
3108 return (rtnval); | 3064 return (rtnval); |
3109 } | 3065 } |
3110 | 3066 |
3111 #endif /* INTERRUPTIBLE_OPEN */ | 3067 int |
3112 | 3068 emacs_close (fd) |
3113 #ifdef INTERRUPTIBLE_CLOSE | |
3114 | |
3115 int | |
3116 sys_close (fd) | |
3117 int fd; | 3069 int fd; |
3118 { | 3070 { |
3119 int did_retry = 0; | 3071 int did_retry = 0; |
3120 register int rtnval; | 3072 register int rtnval; |
3121 | 3073 |
3130 return 0; | 3082 return 0; |
3131 | 3083 |
3132 return rtnval; | 3084 return rtnval; |
3133 } | 3085 } |
3134 | 3086 |
3135 #endif /* INTERRUPTIBLE_CLOSE */ | 3087 int |
3136 | 3088 emacs_read (fildes, buf, nbyte) |
3137 #ifdef INTERRUPTIBLE_IO | |
3138 | |
3139 int | |
3140 sys_read (fildes, buf, nbyte) | |
3141 int fildes; | 3089 int fildes; |
3142 char *buf; | 3090 char *buf; |
3143 unsigned int nbyte; | 3091 unsigned int nbyte; |
3144 { | 3092 { |
3145 register int rtnval; | 3093 register int rtnval; |
3148 && (errno == EINTR)); | 3096 && (errno == EINTR)); |
3149 return (rtnval); | 3097 return (rtnval); |
3150 } | 3098 } |
3151 | 3099 |
3152 int | 3100 int |
3153 sys_write (fildes, buf, nbyte) | 3101 emacs_write (fildes, buf, nbyte) |
3154 int fildes; | 3102 int fildes; |
3155 char *buf; | 3103 char *buf; |
3156 unsigned int nbyte; | 3104 unsigned int nbyte; |
3157 { | 3105 { |
3158 register int rtnval, bytes_written; | 3106 register int rtnval, bytes_written; |
3175 nbyte -= rtnval; | 3123 nbyte -= rtnval; |
3176 bytes_written += rtnval; | 3124 bytes_written += rtnval; |
3177 } | 3125 } |
3178 return (bytes_written); | 3126 return (bytes_written); |
3179 } | 3127 } |
3180 | |
3181 #endif /* INTERRUPTIBLE_IO */ | |
3182 | 3128 |
3183 #ifndef HAVE_VFORK | 3129 #ifndef HAVE_VFORK |
3184 #ifndef WINDOWSNT | 3130 #ifndef WINDOWSNT |
3185 /* | 3131 /* |
3186 * Substitute fork for vfork on USG flavors. | 3132 * Substitute fork for vfork on USG flavors. |
3208 * system calls to a single occurrence in the source. Sure, this | 3154 * system calls to a single occurrence in the source. Sure, this |
3209 * adds an extra level of function call overhead but it is almost | 3155 * adds an extra level of function call overhead but it is almost |
3210 * always negligible. Fred Fish, Unisoft Systems Inc. | 3156 * always negligible. Fred Fish, Unisoft Systems Inc. |
3211 */ | 3157 */ |
3212 | 3158 |
3159 #ifndef HAVE_STRSIGNAL | |
3213 #ifndef HAVE_SYS_SIGLIST | 3160 #ifndef HAVE_SYS_SIGLIST |
3214 char *sys_siglist[NSIG + 1] = | 3161 char *sys_siglist[NSIG + 1] = |
3215 { | 3162 { |
3216 #ifdef AIX | 3163 #ifdef AIX |
3217 /* AIX has changed the signals a bit */ | 3164 /* AIX has changed the signals a bit */ |
3294 #endif /* sun */ | 3241 #endif /* sun */ |
3295 #endif /* not AIX */ | 3242 #endif /* not AIX */ |
3296 0 | 3243 0 |
3297 }; | 3244 }; |
3298 #endif /* HAVE_SYS_SIGLIST */ | 3245 #endif /* HAVE_SYS_SIGLIST */ |
3246 #endif /* HAVE_STRSIGNAL */ | |
3299 | 3247 |
3300 /* | 3248 /* |
3301 * Warning, this function may not duplicate 4.2 action properly | 3249 * Warning, this function may not duplicate 4.2 action properly |
3302 * under error conditions. | 3250 * under error conditions. |
3303 */ | 3251 */ |
3382 int oldd; | 3330 int oldd; |
3383 int newd; | 3331 int newd; |
3384 { | 3332 { |
3385 register int fd, ret; | 3333 register int fd, ret; |
3386 | 3334 |
3387 sys_close (newd); | 3335 emacs_close (newd); |
3388 | 3336 |
3389 #ifdef F_DUPFD | 3337 #ifdef F_DUPFD |
3390 fd = fcntl (oldd, F_DUPFD, newd); | 3338 return fcntl (oldd, F_DUPFD, newd); |
3391 if (fd != newd) | |
3392 error ("can't dup2 (%i,%i) : %s", oldd, newd, strerror (errno)); | |
3393 #else | 3339 #else |
3394 fd = dup (old); | 3340 fd = dup (old); |
3395 if (fd == -1) | 3341 if (fd == -1) |
3396 return -1; | 3342 return -1; |
3397 if (fd == new) | 3343 if (fd == new) |
3398 return new; | 3344 return new; |
3399 ret = dup2 (old,new); | 3345 ret = dup2 (old,new); |
3400 sys_close (fd); | 3346 emacs_close (fd); |
3401 return ret; | 3347 return ret; |
3402 #endif | 3348 #endif |
3403 } | 3349 } |
3404 | 3350 |
3405 #endif /* not HAVE_DUP2 */ | 3351 #endif /* not HAVE_DUP2 */ |
3450 | 3396 |
3451 #endif /* USG */ | 3397 #endif /* USG */ |
3452 | 3398 |
3453 #ifdef DGUX | 3399 #ifdef DGUX |
3454 | 3400 |
3401 #ifndef HAVE_STRSIGNAL | |
3455 char *sys_siglist[NSIG + 1] = | 3402 char *sys_siglist[NSIG + 1] = |
3456 { | 3403 { |
3457 "null signal", /* 0 SIGNULL */ | 3404 "null signal", /* 0 SIGNULL */ |
3458 "hangup", /* 1 SIGHUP */ | 3405 "hangup", /* 1 SIGHUP */ |
3459 "interrupt", /* 2 SIGINT */ | 3406 "interrupt", /* 2 SIGINT */ |
3519 "undefined", /* 62 */ | 3466 "undefined", /* 62 */ |
3520 "undefined", /* 63 */ | 3467 "undefined", /* 63 */ |
3521 "notification message in mess. queue", /* 64 SIGDGNOTIFY */ | 3468 "notification message in mess. queue", /* 64 SIGDGNOTIFY */ |
3522 0 | 3469 0 |
3523 }; | 3470 }; |
3471 #endif /* HAVE_STRSIGNAL */ | |
3524 | 3472 |
3525 #endif /* DGUX */ | 3473 #endif /* DGUX */ |
3526 | 3474 |
3527 /* Directory routines for systems that don't have them. */ | 3475 /* Directory routines for systems that don't have them. */ |
3528 | 3476 |
3536 closedir (dirp) | 3484 closedir (dirp) |
3537 register DIR *dirp; /* stream from opendir */ | 3485 register DIR *dirp; /* stream from opendir */ |
3538 { | 3486 { |
3539 int rtnval; | 3487 int rtnval; |
3540 | 3488 |
3541 rtnval = sys_close (dirp->dd_fd); | 3489 rtnval = emacs_close (dirp->dd_fd); |
3542 | 3490 |
3543 /* Some systems (like Solaris) allocate the buffer and the DIR all | 3491 /* Some systems (like Solaris) allocate the buffer and the DIR all |
3544 in one block. Why in the world are we freeing this ourselves | 3492 in one block. Why in the world are we freeing this ourselves |
3545 anyway? */ | 3493 anyway? */ |
3546 #if ! (defined (sun) && defined (USG5_4)) | 3494 #if ! (defined (sun) && defined (USG5_4)) |
3561 { | 3509 { |
3562 register DIR *dirp; /* -> malloc'ed storage */ | 3510 register DIR *dirp; /* -> malloc'ed storage */ |
3563 register int fd; /* file descriptor for read */ | 3511 register int fd; /* file descriptor for read */ |
3564 struct stat sbuf; /* result of fstat */ | 3512 struct stat sbuf; /* result of fstat */ |
3565 | 3513 |
3566 fd = sys_open (filename, 0); | 3514 fd = emacs_open (filename, O_RDONLY, 0); |
3567 if (fd < 0) | 3515 if (fd < 0) |
3568 return 0; | 3516 return 0; |
3569 | 3517 |
3570 BLOCK_INPUT; | 3518 BLOCK_INPUT; |
3571 if (fstat (fd, &sbuf) < 0 | 3519 if (fstat (fd, &sbuf) < 0 |
3572 || (sbuf.st_mode & S_IFMT) != S_IFDIR | 3520 || (sbuf.st_mode & S_IFMT) != S_IFDIR |
3573 || (dirp = (DIR *) malloc (sizeof (DIR))) == 0) | 3521 || (dirp = (DIR *) malloc (sizeof (DIR))) == 0) |
3574 { | 3522 { |
3575 sys_close (fd); | 3523 emacs_close (fd); |
3576 UNBLOCK_INPUT; | 3524 UNBLOCK_INPUT; |
3577 return 0; /* bad luck today */ | 3525 return 0; /* bad luck today */ |
3578 } | 3526 } |
3579 UNBLOCK_INPUT; | 3527 UNBLOCK_INPUT; |
3580 | 3528 |
3586 | 3534 |
3587 void | 3535 void |
3588 closedir (dirp) | 3536 closedir (dirp) |
3589 register DIR *dirp; /* stream from opendir */ | 3537 register DIR *dirp; /* stream from opendir */ |
3590 { | 3538 { |
3591 sys_close (dirp->dd_fd); | 3539 emacs_close (dirp->dd_fd); |
3592 xfree ((char *) dirp); | 3540 xfree ((char *) dirp); |
3593 } | 3541 } |
3594 | 3542 |
3595 | 3543 |
3596 #ifndef VMS | 3544 #ifndef VMS |
3620 { | 3568 { |
3621 if (dirp->dd_loc >= dirp->dd_size) | 3569 if (dirp->dd_loc >= dirp->dd_size) |
3622 dirp->dd_loc = dirp->dd_size = 0; | 3570 dirp->dd_loc = dirp->dd_size = 0; |
3623 | 3571 |
3624 if (dirp->dd_size == 0 /* refill buffer */ | 3572 if (dirp->dd_size == 0 /* refill buffer */ |
3625 && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) | 3573 && (dirp->dd_size = emacs_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) |
3626 return 0; | 3574 return 0; |
3627 | 3575 |
3628 #ifndef VMS | 3576 #ifndef VMS |
3629 dp = (struct olddir *) &dirp->dd_buf[dirp->dd_loc]; | 3577 dp = (struct olddir *) &dirp->dd_buf[dirp->dd_loc]; |
3630 dirp->dd_loc += sizeof (struct olddir); | 3578 dirp->dd_loc += sizeof (struct olddir); |
3773 * FIXME, this won't suffice to set SUID, SGID, etc. on this | 3721 * FIXME, this won't suffice to set SUID, SGID, etc. on this |
3774 * directory. Does anybody care? | 3722 * directory. Does anybody care? |
3775 */ | 3723 */ |
3776 status = umask (0); /* Get current umask */ | 3724 status = umask (0); /* Get current umask */ |
3777 status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ | 3725 status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ |
3778 fd = sys_open ("/dev/null", 2); | 3726 fd = emacs_open ("/dev/null", O_RDWR, 0); |
3779 if (fd >= 0) | 3727 if (fd >= 0) |
3780 { | 3728 { |
3781 dup2 (fd, 0); | 3729 dup2 (fd, 0); |
3782 dup2 (fd, 1); | 3730 dup2 (fd, 1); |
3783 dup2 (fd, 2); | 3731 dup2 (fd, 2); |
3819 | 3767 |
3820 case -1: /* Error in fork */ | 3768 case -1: /* Error in fork */ |
3821 return (-1); /* Errno is set already */ | 3769 return (-1); /* Errno is set already */ |
3822 | 3770 |
3823 case 0: /* Child process */ | 3771 case 0: /* Child process */ |
3824 fd = sys_open ("/dev/null", 2); | 3772 fd = emacs_open ("/dev/null", O_RDWR, 0); |
3825 if (fd >= 0) | 3773 if (fd >= 0) |
3826 { | 3774 { |
3827 dup2 (fd, 0); | 3775 dup2 (fd, 0); |
3828 dup2 (fd, 1); | 3776 dup2 (fd, 1); |
3829 dup2 (fd, 2); | 3777 dup2 (fd, 2); |
4238 sys_getuid () | 4186 sys_getuid () |
4239 { | 4187 { |
4240 return (getgid () << 16) | getuid (); | 4188 return (getgid () << 16) | getuid (); |
4241 } | 4189 } |
4242 | 4190 |
4191 #undef read | |
4243 int | 4192 int |
4244 sys_read (fildes, buf, nbyte) | 4193 sys_read (fildes, buf, nbyte) |
4245 int fildes; | 4194 int fildes; |
4246 char *buf; | 4195 char *buf; |
4247 unsigned int nbyte; | 4196 unsigned int nbyte; |
4277 * don't it adds one (nice of it isn't it!) | 4226 * don't it adds one (nice of it isn't it!) |
4278 * | 4227 * |
4279 * Thus we do this stupidity below. | 4228 * Thus we do this stupidity below. |
4280 */ | 4229 */ |
4281 | 4230 |
4231 #undef write | |
4282 int | 4232 int |
4283 sys_write (fildes, buf, nbytes) | 4233 sys_write (fildes, buf, nbytes) |
4284 int fildes; | 4234 int fildes; |
4285 char *buf; | 4235 char *buf; |
4286 unsigned int nbytes; | 4236 unsigned int nbytes; |
5320 return 0; | 5270 return 0; |
5321 #endif /* not VMS */ | 5271 #endif /* not VMS */ |
5322 } | 5272 } |
5323 #endif /* no bcmp */ | 5273 #endif /* no bcmp */ |
5324 #endif /* not BSTRING */ | 5274 #endif /* not BSTRING */ |
5325 | 5275 |
5276 #ifndef HAVE_STRSIGNAL | |
5277 char * | |
5278 strsignal (code) | |
5279 int code; | |
5280 { | |
5281 char *signame = 0; | |
5282 | |
5283 if (0 <= code && code < NSIG) | |
5284 { | |
5285 #ifdef VMS | |
5286 signame = sys_errlist[code]; | |
5287 #else | |
5288 /* Cast to suppress warning if the table has const char *. */ | |
5289 signame = (char *) sys_siglist[code]; | |
5290 #endif | |
5291 } | |
5292 | |
5293 return signame; | |
5294 } | |
5295 #endif /* HAVE_STRSIGNAL */ | |
5296 | |
5326 /* All the Macintosh stuffs go here */ | 5297 /* All the Macintosh stuffs go here */ |
5327 | 5298 |
5328 #ifdef macintosh | 5299 #ifdef macintosh |
5329 | 5300 |
5330 #include <Files.h> | 5301 #include <Files.h> |
5500 year! */ | 5471 year! */ |
5501 #define CW_UNIX_EPOCH_DIFF ((365L * 70 + 17) * 24 * 60 * 60) | 5472 #define CW_UNIX_EPOCH_DIFF ((365L * 70 + 17) * 24 * 60 * 60) |
5502 | 5473 |
5503 /* Define our own stat function for both MrC and CW. The reason for | 5474 /* Define our own stat function for both MrC and CW. The reason for |
5504 doing this: "stat" is both the name of a struct and function name: | 5475 doing this: "stat" is both the name of a struct and function name: |
5505 can't use the same trick like that for sys_open, sys_close, etc. to | 5476 we can't #define stat to something else to |
5506 redirect Emacs's calls to our own version that converts Unix style | 5477 redirect Emacs's calls to our own version that converts Unix style |
5507 filenames to Mac style filename because all sorts of compilation | 5478 filenames to Mac style filename because all sorts of compilation |
5508 errors will be generated if stat is #define'd to be sys_stat. */ | 5479 errors will be generated if stat is #define'd to be something else. */ |
5509 | 5480 |
5510 int | 5481 int |
5511 stat (const char *path, struct stat *buf) | 5482 stat (const char *path, struct stat *buf) |
5512 { | 5483 { |
5513 char MacPathname[MAXPATHLEN+1]; | 5484 char MacPathname[MAXPATHLEN+1]; |