diff options
Diffstat (limited to 'src/sysdep.c')
| -rw-r--r-- | src/sysdep.c | 204 |
1 files changed, 91 insertions, 113 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index 11a6f4a76ce..6439697501e 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -306,7 +306,7 @@ get_child_status (pid_t child, int *status, int options, bool interruptible) | |||
| 306 | /* If successful and status is requested, tell wait_reading_process_output | 306 | /* If successful and status is requested, tell wait_reading_process_output |
| 307 | that it needs to wake up and look around. */ | 307 | that it needs to wake up and look around. */ |
| 308 | if (pid && status && input_available_clear_time) | 308 | if (pid && status && input_available_clear_time) |
| 309 | *input_available_clear_time = make_emacs_time (0, 0); | 309 | *input_available_clear_time = make_timespec (0, 0); |
| 310 | 310 | ||
| 311 | return pid; | 311 | return pid; |
| 312 | } | 312 | } |
| @@ -337,16 +337,6 @@ child_status_changed (pid_t child, int *status, int options) | |||
| 337 | return get_child_status (child, status, WNOHANG | options, 0); | 337 | return get_child_status (child, status, WNOHANG | options, 0); |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | /* | ||
| 341 | * flush any pending output | ||
| 342 | * (may flush input as well; it does not matter the way we use it) | ||
| 343 | */ | ||
| 344 | |||
| 345 | void | ||
| 346 | flush_pending_output (int channel) | ||
| 347 | { | ||
| 348 | /* FIXME: maybe this function should be removed */ | ||
| 349 | } | ||
| 350 | 340 | ||
| 351 | /* Set up the terminal at the other end of a pseudo-terminal that | 341 | /* Set up the terminal at the other end of a pseudo-terminal that |
| 352 | we will be controlling an inferior through. | 342 | we will be controlling an inferior through. |
| @@ -481,10 +471,20 @@ sys_subshell (void) | |||
| 481 | pid_t pid; | 471 | pid_t pid; |
| 482 | int status; | 472 | int status; |
| 483 | struct save_signal saved_handlers[5]; | 473 | struct save_signal saved_handlers[5]; |
| 484 | Lisp_Object dir; | 474 | char *str = SSDATA (encode_current_directory ()); |
| 485 | unsigned char *volatile str_volatile = 0; | 475 | |
| 486 | unsigned char *str; | 476 | #ifdef DOS_NT |
| 487 | int len; | 477 | pid = 0; |
| 478 | #else | ||
| 479 | { | ||
| 480 | char *volatile str_volatile = str; | ||
| 481 | pid = vfork (); | ||
| 482 | str = str_volatile; | ||
| 483 | } | ||
| 484 | #endif | ||
| 485 | |||
| 486 | if (pid < 0) | ||
| 487 | error ("Can't spawn subshell"); | ||
| 488 | 488 | ||
| 489 | saved_handlers[0].code = SIGINT; | 489 | saved_handlers[0].code = SIGINT; |
| 490 | saved_handlers[1].code = SIGQUIT; | 490 | saved_handlers[1].code = SIGQUIT; |
| @@ -496,31 +496,8 @@ sys_subshell (void) | |||
| 496 | saved_handlers[3].code = 0; | 496 | saved_handlers[3].code = 0; |
| 497 | #endif | 497 | #endif |
| 498 | 498 | ||
| 499 | /* Mentioning current_buffer->buffer would mean including buffer.h, | ||
| 500 | which somehow wedges the hp compiler. So instead... */ | ||
| 501 | |||
| 502 | dir = intern ("default-directory"); | ||
| 503 | if (NILP (Fboundp (dir))) | ||
| 504 | goto xyzzy; | ||
| 505 | dir = Fsymbol_value (dir); | ||
| 506 | if (!STRINGP (dir)) | ||
| 507 | goto xyzzy; | ||
| 508 | |||
| 509 | dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); | ||
| 510 | str_volatile = str = alloca (SCHARS (dir) + 2); | ||
| 511 | len = SCHARS (dir); | ||
| 512 | memcpy (str, SDATA (dir), len); | ||
| 513 | if (str[len - 1] != '/') str[len++] = '/'; | ||
| 514 | str[len] = 0; | ||
| 515 | xyzzy: | ||
| 516 | |||
| 517 | #ifdef DOS_NT | 499 | #ifdef DOS_NT |
| 518 | pid = 0; | ||
| 519 | save_signal_handlers (saved_handlers); | 500 | save_signal_handlers (saved_handlers); |
| 520 | #else | ||
| 521 | pid = vfork (); | ||
| 522 | if (pid == -1) | ||
| 523 | error ("Can't spawn subshell"); | ||
| 524 | #endif | 501 | #endif |
| 525 | 502 | ||
| 526 | if (pid == 0) | 503 | if (pid == 0) |
| @@ -538,11 +515,10 @@ sys_subshell (void) | |||
| 538 | sh = "sh"; | 515 | sh = "sh"; |
| 539 | 516 | ||
| 540 | /* Use our buffer's default directory for the subshell. */ | 517 | /* Use our buffer's default directory for the subshell. */ |
| 541 | str = str_volatile; | 518 | if (chdir (str) != 0) |
| 542 | if (str && chdir ((char *) str) != 0) | ||
| 543 | { | 519 | { |
| 544 | #ifndef DOS_NT | 520 | #ifndef DOS_NT |
| 545 | emacs_perror ((char *) str); | 521 | emacs_perror (str); |
| 546 | _exit (EXIT_CANCELED); | 522 | _exit (EXIT_CANCELED); |
| 547 | #endif | 523 | #endif |
| 548 | } | 524 | } |
| @@ -556,8 +532,6 @@ sys_subshell (void) | |||
| 556 | if (epwd) | 532 | if (epwd) |
| 557 | { | 533 | { |
| 558 | strcpy (old_pwd, epwd); | 534 | strcpy (old_pwd, epwd); |
| 559 | if (str[len - 1] == '/') | ||
| 560 | str[len - 1] = '\0'; | ||
| 561 | setenv ("PWD", str, 1); | 535 | setenv ("PWD", str, 1); |
| 562 | } | 536 | } |
| 563 | st = system (sh); | 537 | st = system (sh); |
| @@ -614,7 +588,7 @@ restore_signal_handlers (struct save_signal *saved_handlers) | |||
| 614 | } | 588 | } |
| 615 | 589 | ||
| 616 | #ifdef USABLE_SIGIO | 590 | #ifdef USABLE_SIGIO |
| 617 | static int old_fcntl_flags[MAXDESC]; | 591 | static int old_fcntl_flags[FD_SETSIZE]; |
| 618 | #endif | 592 | #endif |
| 619 | 593 | ||
| 620 | void | 594 | void |
| @@ -843,7 +817,7 @@ emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp) | |||
| 843 | 817 | ||
| 844 | 818 | ||
| 845 | #ifdef F_SETOWN | 819 | #ifdef F_SETOWN |
| 846 | static int old_fcntl_owner[MAXDESC]; | 820 | static int old_fcntl_owner[FD_SETSIZE]; |
| 847 | #endif /* F_SETOWN */ | 821 | #endif /* F_SETOWN */ |
| 848 | 822 | ||
| 849 | /* This may also be defined in stdio, | 823 | /* This may also be defined in stdio, |
| @@ -1196,7 +1170,8 @@ get_tty_size (int fd, int *widthp, int *heightp) | |||
| 1196 | } | 1170 | } |
| 1197 | 1171 | ||
| 1198 | /* Set the logical window size associated with descriptor FD | 1172 | /* Set the logical window size associated with descriptor FD |
| 1199 | to HEIGHT and WIDTH. This is used mainly with ptys. */ | 1173 | to HEIGHT and WIDTH. This is used mainly with ptys. |
| 1174 | Return a negative value on failure. */ | ||
| 1200 | 1175 | ||
| 1201 | int | 1176 | int |
| 1202 | set_window_size (int fd, int height, int width) | 1177 | set_window_size (int fd, int height, int width) |
| @@ -1208,10 +1183,7 @@ set_window_size (int fd, int height, int width) | |||
| 1208 | size.ws_row = height; | 1183 | size.ws_row = height; |
| 1209 | size.ws_col = width; | 1184 | size.ws_col = width; |
| 1210 | 1185 | ||
| 1211 | if (ioctl (fd, TIOCSWINSZ, &size) == -1) | 1186 | return ioctl (fd, TIOCSWINSZ, &size); |
| 1212 | return 0; /* error */ | ||
| 1213 | else | ||
| 1214 | return 1; | ||
| 1215 | 1187 | ||
| 1216 | #else | 1188 | #else |
| 1217 | #ifdef TIOCSSIZE | 1189 | #ifdef TIOCSSIZE |
| @@ -1221,10 +1193,7 @@ set_window_size (int fd, int height, int width) | |||
| 1221 | size.ts_lines = height; | 1193 | size.ts_lines = height; |
| 1222 | size.ts_cols = width; | 1194 | size.ts_cols = width; |
| 1223 | 1195 | ||
| 1224 | if (ioctl (fd, TIOCGSIZE, &size) == -1) | 1196 | return ioctl (fd, TIOCGSIZE, &size); |
| 1225 | return 0; | ||
| 1226 | else | ||
| 1227 | return 1; | ||
| 1228 | #else | 1197 | #else |
| 1229 | return -1; | 1198 | return -1; |
| 1230 | #endif /* not SunOS-style */ | 1199 | #endif /* not SunOS-style */ |
| @@ -2052,8 +2021,8 @@ seed_random (void *seed, ptrdiff_t seed_size) | |||
| 2052 | void | 2021 | void |
| 2053 | init_random (void) | 2022 | init_random (void) |
| 2054 | { | 2023 | { |
| 2055 | EMACS_TIME t = current_emacs_time (); | 2024 | struct timespec t = current_timespec (); |
| 2056 | uintmax_t v = getpid () ^ EMACS_SECS (t) ^ EMACS_NSECS (t); | 2025 | uintmax_t v = getpid () ^ t.tv_sec ^ t.tv_nsec; |
| 2057 | seed_random (&v, sizeof v); | 2026 | seed_random (&v, sizeof v); |
| 2058 | } | 2027 | } |
| 2059 | 2028 | ||
| @@ -2388,7 +2357,7 @@ emacs_perror (char const *message) | |||
| 2388 | Use the least timeval not less than T. | 2357 | Use the least timeval not less than T. |
| 2389 | Return an extremal value if the result would overflow. */ | 2358 | Return an extremal value if the result would overflow. */ |
| 2390 | struct timeval | 2359 | struct timeval |
| 2391 | make_timeval (EMACS_TIME t) | 2360 | make_timeval (struct timespec t) |
| 2392 | { | 2361 | { |
| 2393 | struct timeval tv; | 2362 | struct timeval tv; |
| 2394 | tv.tv_sec = t.tv_sec; | 2363 | tv.tv_sec = t.tv_sec; |
| @@ -2415,7 +2384,7 @@ make_timeval (EMACS_TIME t) | |||
| 2415 | If FD is nonnegative, then FILE can be NULL. */ | 2384 | If FD is nonnegative, then FILE can be NULL. */ |
| 2416 | int | 2385 | int |
| 2417 | set_file_times (int fd, const char *filename, | 2386 | set_file_times (int fd, const char *filename, |
| 2418 | EMACS_TIME atime, EMACS_TIME mtime) | 2387 | struct timespec atime, struct timespec mtime) |
| 2419 | { | 2388 | { |
| 2420 | struct timespec timespec[2]; | 2389 | struct timespec timespec[2]; |
| 2421 | timespec[0] = atime; | 2390 | timespec[0] = atime; |
| @@ -2485,7 +2454,7 @@ serial_configure (struct Lisp_Process *p, | |||
| 2485 | Lisp_Object childp2 = Qnil; | 2454 | Lisp_Object childp2 = Qnil; |
| 2486 | Lisp_Object tem = Qnil; | 2455 | Lisp_Object tem = Qnil; |
| 2487 | struct termios attr; | 2456 | struct termios attr; |
| 2488 | int err = -1; | 2457 | int err; |
| 2489 | char summary[4] = "???"; /* This usually becomes "8N1". */ | 2458 | char summary[4] = "???"; /* This usually becomes "8N1". */ |
| 2490 | 2459 | ||
| 2491 | childp2 = Fcopy_sequence (p->childp); | 2460 | childp2 = Fcopy_sequence (p->childp); |
| @@ -2732,7 +2701,7 @@ list_system_processes (void) | |||
| 2732 | #endif /* !defined (WINDOWSNT) */ | 2701 | #endif /* !defined (WINDOWSNT) */ |
| 2733 | 2702 | ||
| 2734 | #if defined GNU_LINUX && defined HAVE_LONG_LONG_INT | 2703 | #if defined GNU_LINUX && defined HAVE_LONG_LONG_INT |
| 2735 | static EMACS_TIME | 2704 | static struct timespec |
| 2736 | time_from_jiffies (unsigned long long tval, long hz) | 2705 | time_from_jiffies (unsigned long long tval, long hz) |
| 2737 | { | 2706 | { |
| 2738 | unsigned long long s = tval / hz; | 2707 | unsigned long long s = tval / hz; |
| @@ -2741,34 +2710,34 @@ time_from_jiffies (unsigned long long tval, long hz) | |||
| 2741 | 2710 | ||
| 2742 | if (TYPE_MAXIMUM (time_t) < s) | 2711 | if (TYPE_MAXIMUM (time_t) < s) |
| 2743 | time_overflow (); | 2712 | time_overflow (); |
| 2744 | if (LONG_MAX - 1 <= ULLONG_MAX / EMACS_TIME_RESOLUTION | 2713 | if (LONG_MAX - 1 <= ULLONG_MAX / TIMESPEC_RESOLUTION |
| 2745 | || frac <= ULLONG_MAX / EMACS_TIME_RESOLUTION) | 2714 | || frac <= ULLONG_MAX / TIMESPEC_RESOLUTION) |
| 2746 | ns = frac * EMACS_TIME_RESOLUTION / hz; | 2715 | ns = frac * TIMESPEC_RESOLUTION / hz; |
| 2747 | else | 2716 | else |
| 2748 | { | 2717 | { |
| 2749 | /* This is reachable only in the unlikely case that HZ * HZ | 2718 | /* This is reachable only in the unlikely case that HZ * HZ |
| 2750 | exceeds ULLONG_MAX. It calculates an approximation that is | 2719 | exceeds ULLONG_MAX. It calculates an approximation that is |
| 2751 | guaranteed to be in range. */ | 2720 | guaranteed to be in range. */ |
| 2752 | long hz_per_ns = (hz / EMACS_TIME_RESOLUTION | 2721 | long hz_per_ns = (hz / TIMESPEC_RESOLUTION |
| 2753 | + (hz % EMACS_TIME_RESOLUTION != 0)); | 2722 | + (hz % TIMESPEC_RESOLUTION != 0)); |
| 2754 | ns = frac / hz_per_ns; | 2723 | ns = frac / hz_per_ns; |
| 2755 | } | 2724 | } |
| 2756 | 2725 | ||
| 2757 | return make_emacs_time (s, ns); | 2726 | return make_timespec (s, ns); |
| 2758 | } | 2727 | } |
| 2759 | 2728 | ||
| 2760 | static Lisp_Object | 2729 | static Lisp_Object |
| 2761 | ltime_from_jiffies (unsigned long long tval, long hz) | 2730 | ltime_from_jiffies (unsigned long long tval, long hz) |
| 2762 | { | 2731 | { |
| 2763 | EMACS_TIME t = time_from_jiffies (tval, hz); | 2732 | struct timespec t = time_from_jiffies (tval, hz); |
| 2764 | return make_lisp_time (t); | 2733 | return make_lisp_time (t); |
| 2765 | } | 2734 | } |
| 2766 | 2735 | ||
| 2767 | static EMACS_TIME | 2736 | static struct timespec |
| 2768 | get_up_time (void) | 2737 | get_up_time (void) |
| 2769 | { | 2738 | { |
| 2770 | FILE *fup; | 2739 | FILE *fup; |
| 2771 | EMACS_TIME up = make_emacs_time (0, 0); | 2740 | struct timespec up = make_timespec (0, 0); |
| 2772 | 2741 | ||
| 2773 | block_input (); | 2742 | block_input (); |
| 2774 | fup = emacs_fopen ("/proc/uptime", "r"); | 2743 | fup = emacs_fopen ("/proc/uptime", "r"); |
| @@ -2786,18 +2755,18 @@ get_up_time (void) | |||
| 2786 | if (TYPE_MAXIMUM (time_t) < upsec) | 2755 | if (TYPE_MAXIMUM (time_t) < upsec) |
| 2787 | { | 2756 | { |
| 2788 | upsec = TYPE_MAXIMUM (time_t); | 2757 | upsec = TYPE_MAXIMUM (time_t); |
| 2789 | upfrac = EMACS_TIME_RESOLUTION - 1; | 2758 | upfrac = TIMESPEC_RESOLUTION - 1; |
| 2790 | } | 2759 | } |
| 2791 | else | 2760 | else |
| 2792 | { | 2761 | { |
| 2793 | int upfraclen = upfrac_end - upfrac_start; | 2762 | int upfraclen = upfrac_end - upfrac_start; |
| 2794 | for (; upfraclen < LOG10_EMACS_TIME_RESOLUTION; upfraclen++) | 2763 | for (; upfraclen < LOG10_TIMESPEC_RESOLUTION; upfraclen++) |
| 2795 | upfrac *= 10; | 2764 | upfrac *= 10; |
| 2796 | for (; LOG10_EMACS_TIME_RESOLUTION < upfraclen; upfraclen--) | 2765 | for (; LOG10_TIMESPEC_RESOLUTION < upfraclen; upfraclen--) |
| 2797 | upfrac /= 10; | 2766 | upfrac /= 10; |
| 2798 | upfrac = min (upfrac, EMACS_TIME_RESOLUTION - 1); | 2767 | upfrac = min (upfrac, TIMESPEC_RESOLUTION - 1); |
| 2799 | } | 2768 | } |
| 2800 | up = make_emacs_time (upsec, upfrac); | 2769 | up = make_timespec (upsec, upfrac); |
| 2801 | } | 2770 | } |
| 2802 | fclose (fup); | 2771 | fclose (fup); |
| 2803 | } | 2772 | } |
| @@ -2852,29 +2821,41 @@ procfs_ttyname (int rdev) | |||
| 2852 | return build_string (name); | 2821 | return build_string (name); |
| 2853 | } | 2822 | } |
| 2854 | 2823 | ||
| 2855 | static unsigned long | 2824 | static uintmax_t |
| 2856 | procfs_get_total_memory (void) | 2825 | procfs_get_total_memory (void) |
| 2857 | { | 2826 | { |
| 2858 | FILE *fmem; | 2827 | FILE *fmem; |
| 2859 | unsigned long retval = 2 * 1024 * 1024; /* default: 2GB */ | 2828 | uintmax_t retval = 2 * 1024 * 1024; /* default: 2 GiB */ |
| 2829 | int c; | ||
| 2860 | 2830 | ||
| 2861 | block_input (); | 2831 | block_input (); |
| 2862 | fmem = emacs_fopen ("/proc/meminfo", "r"); | 2832 | fmem = emacs_fopen ("/proc/meminfo", "r"); |
| 2863 | 2833 | ||
| 2864 | if (fmem) | 2834 | if (fmem) |
| 2865 | { | 2835 | { |
| 2866 | unsigned long entry_value; | 2836 | uintmax_t entry_value; |
| 2867 | char entry_name[20]; /* the longest I saw is 13+1 */ | 2837 | bool done; |
| 2838 | |||
| 2839 | do | ||
| 2840 | switch (fscanf (fmem, "MemTotal: %"SCNuMAX, &entry_value)) | ||
| 2841 | { | ||
| 2842 | case 1: | ||
| 2843 | retval = entry_value; | ||
| 2844 | done = 1; | ||
| 2845 | break; | ||
| 2846 | |||
| 2847 | case 0: | ||
| 2848 | while ((c = getc (fmem)) != EOF && c != '\n') | ||
| 2849 | continue; | ||
| 2850 | done = c == EOF; | ||
| 2851 | break; | ||
| 2852 | |||
| 2853 | default: | ||
| 2854 | done = 1; | ||
| 2855 | break; | ||
| 2856 | } | ||
| 2857 | while (!done); | ||
| 2868 | 2858 | ||
| 2869 | while (!feof (fmem) && !ferror (fmem)) | ||
| 2870 | { | ||
| 2871 | if (fscanf (fmem, "%s %lu kB\n", entry_name, &entry_value) >= 2 | ||
| 2872 | && strcmp (entry_name, "MemTotal:") == 0) | ||
| 2873 | { | ||
| 2874 | retval = entry_value; | ||
| 2875 | break; | ||
| 2876 | } | ||
| 2877 | } | ||
| 2878 | fclose (fmem); | 2859 | fclose (fmem); |
| 2879 | } | 2860 | } |
| 2880 | unblock_input (); | 2861 | unblock_input (); |
| @@ -2906,7 +2887,7 @@ system_process_attributes (Lisp_Object pid) | |||
| 2906 | unsigned long long u_time, s_time, cutime, cstime, start; | 2887 | unsigned long long u_time, s_time, cutime, cstime, start; |
| 2907 | long priority, niceness, rss; | 2888 | long priority, niceness, rss; |
| 2908 | unsigned long minflt, majflt, cminflt, cmajflt, vsize; | 2889 | unsigned long minflt, majflt, cminflt, cmajflt, vsize; |
| 2909 | EMACS_TIME tnow, tstart, tboot, telapsed, us_time; | 2890 | struct timespec tnow, tstart, tboot, telapsed, us_time; |
| 2910 | double pcpu, pmem; | 2891 | double pcpu, pmem; |
| 2911 | Lisp_Object attrs = Qnil; | 2892 | Lisp_Object attrs = Qnil; |
| 2912 | Lisp_Object cmd_str, decoded_cmd; | 2893 | Lisp_Object cmd_str, decoded_cmd; |
| @@ -3027,20 +3008,19 @@ system_process_attributes (Lisp_Object pid) | |||
| 3027 | attrs = Fcons (Fcons (Qnice, make_number (niceness)), attrs); | 3008 | attrs = Fcons (Fcons (Qnice, make_number (niceness)), attrs); |
| 3028 | attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (thcount)), | 3009 | attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (thcount)), |
| 3029 | attrs); | 3010 | attrs); |
| 3030 | tnow = current_emacs_time (); | 3011 | tnow = current_timespec (); |
| 3031 | telapsed = get_up_time (); | 3012 | telapsed = get_up_time (); |
| 3032 | tboot = sub_emacs_time (tnow, telapsed); | 3013 | tboot = timespec_sub (tnow, telapsed); |
| 3033 | tstart = time_from_jiffies (start, clocks_per_sec); | 3014 | tstart = time_from_jiffies (start, clocks_per_sec); |
| 3034 | tstart = add_emacs_time (tboot, tstart); | 3015 | tstart = timespec_add (tboot, tstart); |
| 3035 | attrs = Fcons (Fcons (Qstart, make_lisp_time (tstart)), attrs); | 3016 | attrs = Fcons (Fcons (Qstart, make_lisp_time (tstart)), attrs); |
| 3036 | attrs = Fcons (Fcons (Qvsize, make_fixnum_or_float (vsize / 1024)), | 3017 | attrs = Fcons (Fcons (Qvsize, make_fixnum_or_float (vsize / 1024)), |
| 3037 | attrs); | 3018 | attrs); |
| 3038 | attrs = Fcons (Fcons (Qrss, make_fixnum_or_float (4 * rss)), attrs); | 3019 | attrs = Fcons (Fcons (Qrss, make_fixnum_or_float (4 * rss)), attrs); |
| 3039 | telapsed = sub_emacs_time (tnow, tstart); | 3020 | telapsed = timespec_sub (tnow, tstart); |
| 3040 | attrs = Fcons (Fcons (Qetime, make_lisp_time (telapsed)), attrs); | 3021 | attrs = Fcons (Fcons (Qetime, make_lisp_time (telapsed)), attrs); |
| 3041 | us_time = time_from_jiffies (u_time + s_time, clocks_per_sec); | 3022 | us_time = time_from_jiffies (u_time + s_time, clocks_per_sec); |
| 3042 | pcpu = (EMACS_TIME_TO_DOUBLE (us_time) | 3023 | pcpu = timespectod (us_time) / timespectod (telapsed); |
| 3043 | / EMACS_TIME_TO_DOUBLE (telapsed)); | ||
| 3044 | if (pcpu > 1.0) | 3024 | if (pcpu > 1.0) |
| 3045 | pcpu = 1.0; | 3025 | pcpu = 1.0; |
| 3046 | attrs = Fcons (Fcons (Qpcpu, make_float (100 * pcpu)), attrs); | 3026 | attrs = Fcons (Fcons (Qpcpu, make_float (100 * pcpu)), attrs); |
| @@ -3243,13 +3223,11 @@ system_process_attributes (Lisp_Object pid) | |||
| 3243 | attrs); | 3223 | attrs); |
| 3244 | 3224 | ||
| 3245 | decoded_cmd = (code_convert_string_norecord | 3225 | decoded_cmd = (code_convert_string_norecord |
| 3246 | (make_unibyte_string (pinfo.pr_fname, | 3226 | (build_unibyte_string (pinfo.pr_fname), |
| 3247 | strlen (pinfo.pr_fname)), | ||
| 3248 | Vlocale_coding_system, 0)); | 3227 | Vlocale_coding_system, 0)); |
| 3249 | attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs); | 3228 | attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs); |
| 3250 | decoded_cmd = (code_convert_string_norecord | 3229 | decoded_cmd = (code_convert_string_norecord |
| 3251 | (make_unibyte_string (pinfo.pr_psargs, | 3230 | (build_unibyte_string (pinfo.pr_psargs), |
| 3252 | strlen (pinfo.pr_psargs)), | ||
| 3253 | Vlocale_coding_system, 0)); | 3231 | Vlocale_coding_system, 0)); |
| 3254 | attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs); | 3232 | attrs = Fcons (Fcons (Qargs, decoded_cmd), attrs); |
| 3255 | } | 3233 | } |
| @@ -3260,16 +3238,16 @@ system_process_attributes (Lisp_Object pid) | |||
| 3260 | 3238 | ||
| 3261 | #elif defined __FreeBSD__ | 3239 | #elif defined __FreeBSD__ |
| 3262 | 3240 | ||
| 3263 | static EMACS_TIME | 3241 | static struct timespec |
| 3264 | timeval_to_EMACS_TIME (struct timeval t) | 3242 | timeval_to_timespec (struct timeval t) |
| 3265 | { | 3243 | { |
| 3266 | return make_emacs_time (t.tv_sec, t.tv_usec * 1000); | 3244 | return make_timespec (t.tv_sec, t.tv_usec * 1000); |
| 3267 | } | 3245 | } |
| 3268 | 3246 | ||
| 3269 | static Lisp_Object | 3247 | static Lisp_Object |
| 3270 | make_lisp_timeval (struct timeval t) | 3248 | make_lisp_timeval (struct timeval t) |
| 3271 | { | 3249 | { |
| 3272 | return make_lisp_time (timeval_to_EMACS_TIME (t)); | 3250 | return make_lisp_time (timeval_to_timespec (t)); |
| 3273 | } | 3251 | } |
| 3274 | 3252 | ||
| 3275 | Lisp_Object | 3253 | Lisp_Object |
| @@ -3277,14 +3255,14 @@ system_process_attributes (Lisp_Object pid) | |||
| 3277 | { | 3255 | { |
| 3278 | int proc_id; | 3256 | int proc_id; |
| 3279 | int pagesize = getpagesize (); | 3257 | int pagesize = getpagesize (); |
| 3280 | int npages; | 3258 | unsigned long npages; |
| 3281 | int fscale; | 3259 | int fscale; |
| 3282 | struct passwd *pw; | 3260 | struct passwd *pw; |
| 3283 | struct group *gr; | 3261 | struct group *gr; |
| 3284 | char *ttyname; | 3262 | char *ttyname; |
| 3285 | size_t len; | 3263 | size_t len; |
| 3286 | char args[MAXPATHLEN]; | 3264 | char args[MAXPATHLEN]; |
| 3287 | EMACS_TIME t, now; | 3265 | struct timespec t, now; |
| 3288 | 3266 | ||
| 3289 | int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID}; | 3267 | int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID}; |
| 3290 | struct kinfo_proc proc; | 3268 | struct kinfo_proc proc; |
| @@ -3319,9 +3297,9 @@ system_process_attributes (Lisp_Object pid) | |||
| 3319 | if (gr) | 3297 | if (gr) |
| 3320 | attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); | 3298 | attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs); |
| 3321 | 3299 | ||
| 3322 | decoded_comm = code_convert_string_norecord | 3300 | decoded_comm = (code_convert_string_norecord |
| 3323 | (make_unibyte_string (proc.ki_comm, strlen (proc.ki_comm)), | 3301 | (build_unibyte_string (proc.ki_comm), |
| 3324 | Vlocale_coding_system, 0); | 3302 | Vlocale_coding_system, 0)); |
| 3325 | 3303 | ||
| 3326 | attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs); | 3304 | attrs = Fcons (Fcons (Qcomm, decoded_comm), attrs); |
| 3327 | { | 3305 | { |
| @@ -3371,8 +3349,8 @@ system_process_attributes (Lisp_Object pid) | |||
| 3371 | attrs); | 3349 | attrs); |
| 3372 | attrs = Fcons (Fcons (Qstime, make_lisp_timeval (proc.ki_rusage.ru_stime)), | 3350 | attrs = Fcons (Fcons (Qstime, make_lisp_timeval (proc.ki_rusage.ru_stime)), |
| 3373 | attrs); | 3351 | attrs); |
| 3374 | t = add_emacs_time (timeval_to_EMACS_TIME (proc.ki_rusage.ru_utime), | 3352 | t = timespec_add (timeval_to_timespec (proc.ki_rusage.ru_utime), |
| 3375 | timeval_to_EMACS_TIME (proc.ki_rusage.ru_stime)); | 3353 | timeval_to_timespec (proc.ki_rusage.ru_stime)); |
| 3376 | attrs = Fcons (Fcons (Qtime, make_lisp_time (t)), attrs); | 3354 | attrs = Fcons (Fcons (Qtime, make_lisp_time (t)), attrs); |
| 3377 | 3355 | ||
| 3378 | attrs = Fcons (Fcons (Qcutime, | 3356 | attrs = Fcons (Fcons (Qcutime, |
| @@ -3381,8 +3359,8 @@ system_process_attributes (Lisp_Object pid) | |||
| 3381 | attrs = Fcons (Fcons (Qcstime, | 3359 | attrs = Fcons (Fcons (Qcstime, |
| 3382 | make_lisp_timeval (proc.ki_rusage_ch.ru_utime)), | 3360 | make_lisp_timeval (proc.ki_rusage_ch.ru_utime)), |
| 3383 | attrs); | 3361 | attrs); |
| 3384 | t = add_emacs_time (timeval_to_EMACS_TIME (proc.ki_rusage_ch.ru_utime), | 3362 | t = timespec_add (timeval_to_timespec (proc.ki_rusage_ch.ru_utime), |
| 3385 | timeval_to_EMACS_TIME (proc.ki_rusage_ch.ru_stime)); | 3363 | timeval_to_timespec (proc.ki_rusage_ch.ru_stime)); |
| 3386 | attrs = Fcons (Fcons (Qctime, make_lisp_time (t)), attrs); | 3364 | attrs = Fcons (Fcons (Qctime, make_lisp_time (t)), attrs); |
| 3387 | 3365 | ||
| 3388 | attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (proc.ki_numthreads)), | 3366 | attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (proc.ki_numthreads)), |
| @@ -3394,8 +3372,8 @@ system_process_attributes (Lisp_Object pid) | |||
| 3394 | attrs = Fcons (Fcons (Qrss, make_number (proc.ki_rssize * pagesize >> 10)), | 3372 | attrs = Fcons (Fcons (Qrss, make_number (proc.ki_rssize * pagesize >> 10)), |
| 3395 | attrs); | 3373 | attrs); |
| 3396 | 3374 | ||
| 3397 | now = current_emacs_time (); | 3375 | now = current_timespec (); |
| 3398 | t = sub_emacs_time (now, timeval_to_EMACS_TIME (proc.ki_start)); | 3376 | t = timespec_sub (now, timeval_to_timespec (proc.ki_start)); |
| 3399 | attrs = Fcons (Fcons (Qetime, make_lisp_time (t)), attrs); | 3377 | attrs = Fcons (Fcons (Qetime, make_lisp_time (t)), attrs); |
| 3400 | 3378 | ||
| 3401 | len = sizeof fscale; | 3379 | len = sizeof fscale; |