comparison src/sysdep.c @ 272:c5d627a313b1 r21-0b34

Import from CVS: tag r21-0b34
author cvs
date Mon, 13 Aug 2007 10:28:48 +0200
parents 727739f917cb
children ca9a9ec9c1c1
comparison
equal deleted inserted replaced
271:c7b7086b0a39 272:c5d627a313b1
42 #endif /* WINDOWSNT */ 42 #endif /* WINDOWSNT */
43 43
44 #include "lisp.h" 44 #include "lisp.h"
45 45
46 #include <stddef.h> 46 #include <stddef.h>
47 #include <stdlib.h>
47 48
48 /* ------------------------------- */ 49 /* ------------------------------- */
49 /* basic includes */ 50 /* basic includes */
50 /* ------------------------------- */ 51 /* ------------------------------- */
51 52
944 DEVICE_TTY_DATA (d)->ospeed = sg.sg_ospeed; 945 DEVICE_TTY_DATA (d)->ospeed = sg.sg_ospeed;
945 #endif 946 #endif
946 } 947 }
947 948
948 DEVICE_BAUD_RATE (d) = 949 DEVICE_BAUD_RATE (d) =
949 (DEVICE_TTY_DATA (d)->ospeed < sizeof baud_convert / sizeof baud_convert[0] 950 (DEVICE_TTY_DATA (d)->ospeed < countof (baud_convert)
950 ? baud_convert[DEVICE_TTY_DATA (d)->ospeed] 951 ? baud_convert[DEVICE_TTY_DATA (d)->ospeed]
951 : 9600); 952 : 9600);
952 953
953 if (DEVICE_BAUD_RATE (d) == 0) 954 if (DEVICE_BAUD_RATE (d) == 0)
954 DEVICE_BAUD_RATE (d) = 1200; 955 DEVICE_BAUD_RATE (d) = 1200;
2164 * at the normal shared text boundry and the startofdata variable 2165 * at the normal shared text boundry and the startofdata variable
2165 * will be patched by unexec to the correct value. 2166 * will be patched by unexec to the correct value.
2166 * 2167 *
2167 */ 2168 */
2168 2169
2170 #ifdef ORDINARY_LINK
2171 extern char **environ;
2172 #endif
2173
2169 void * 2174 void *
2170 start_of_data (void) 2175 start_of_data (void)
2171 { 2176 {
2172 #ifdef DATA_START 2177 #ifdef DATA_START
2173 return ((char *) DATA_START); 2178 return ((char *) DATA_START);
2177 * This is a hack. Since we're not linking crt0.c or pre_crt0.c, 2182 * This is a hack. Since we're not linking crt0.c or pre_crt0.c,
2178 * data_start isn't defined. We take the address of environ, which 2183 * data_start isn't defined. We take the address of environ, which
2179 * is known to live at or near the start of the system crt0.c, and 2184 * is known to live at or near the start of the system crt0.c, and
2180 * we don't sweat the handful of bytes that might lose. 2185 * we don't sweat the handful of bytes that might lose.
2181 */ 2186 */
2182 extern char **environ;
2183 #ifdef HEAP_IN_DATA 2187 #ifdef HEAP_IN_DATA
2184 extern char* static_heap_base; 2188 extern char* static_heap_base;
2185 if (!initialized) 2189 if (!initialized)
2186 return static_heap_base; 2190 return static_heap_base;
2187 #endif 2191 #endif
2279 libraries on some machines and make the dumped emacs core dump. */ 2283 libraries on some machines and make the dumped emacs core dump. */
2280 # ifndef CANNOT_DUMP 2284 # ifndef CANNOT_DUMP
2281 if (initialized) 2285 if (initialized)
2282 # endif /* not CANNOT_DUMP */ 2286 # endif /* not CANNOT_DUMP */
2283 { 2287 {
2284 struct hostent *hp; 2288 struct hostent *hp = NULL;
2285 int count; 2289 int count;
2286 # ifdef TRY_AGAIN 2290 # ifdef TRY_AGAIN
2287 for (count = 0; count < 10; count++) 2291 for (count = 0; count < 10; count++)
2288 { 2292 {
2289 h_errno = 0; 2293 h_errno = 0;
2567 /************************************************************************/ 2571 /************************************************************************/
2568 /* Encapsulations of system calls */ 2572 /* Encapsulations of system calls */
2569 /************************************************************************/ 2573 /************************************************************************/
2570 2574
2571 #define PATHNAME_CONVERT_OUT(path) \ 2575 #define PATHNAME_CONVERT_OUT(path) \
2572 GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA (path, path) 2576 GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA ((CONST Bufbyte *) path, path)
2573 2577
2574 /***** MSDOS versions are in msdos.c *****/ 2578 /***** MSDOS versions are in msdos.c *****/
2575 2579
2576 /***************** low-level calls ****************/ 2580 /***************** low-level calls ****************/
2577 2581
2635 2639
2636 /* Must copy PATH, because it might be the data of a Lisp_String, 2640 /* Must copy PATH, because it might be the data of a Lisp_String,
2637 which could be relocated by GC when checking for QUIT. */ 2641 which could be relocated by GC when checking for QUIT. */
2638 memcpy (nonreloc, path, len + 1); 2642 memcpy (nonreloc, path, len + 1);
2639 2643
2640 /* The same as PATHNAME_CONVERT_OUT in sysdep.c. */ 2644 PATHNAME_CONVERT_OUT (nonreloc);
2641 GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA (nonreloc, nonreloc);
2642 2645
2643 for (;;) 2646 for (;;)
2644 { 2647 {
2645 int rtnval = open (nonreloc, oflag, mode); 2648 int rtnval = open (nonreloc, oflag, mode);
2646 if (!(rtnval == -1 && errno == EINTR)) 2649 if (!(rtnval == -1 && errno == EINTR))
2674 #endif 2677 #endif
2675 } 2678 }
2676 #endif /* ENCAPSULATE_CLOSE */ 2679 #endif /* ENCAPSULATE_CLOSE */
2677 2680
2678 int 2681 int
2679 sys_read_1 (int fildes, void *buf, unsigned int nbyte, int allow_quit) 2682 sys_read_1 (int fildes, void *buf, size_t nbyte, int allow_quit)
2680 { 2683 {
2681 int rtnval; 2684 int rtnval;
2682 2685
2683 /* No harm in looping regardless of the INTERRUPTIBLE_IO setting. */ 2686 /* No harm in looping regardless of the INTERRUPTIBLE_IO setting. */
2684 while ((rtnval = read (fildes, buf, nbyte)) == -1 2687 while ((rtnval = read (fildes, buf, nbyte)) == -1
2690 return rtnval; 2693 return rtnval;
2691 } 2694 }
2692 2695
2693 #ifdef ENCAPSULATE_READ 2696 #ifdef ENCAPSULATE_READ
2694 int 2697 int
2695 sys_read (int fildes, void *buf, unsigned int nbyte) 2698 sys_read (int fildes, void *buf, size_t nbyte)
2696 { 2699 {
2697 return sys_read_1 (fildes, buf, nbyte, 0); 2700 return sys_read_1 (fildes, buf, nbyte, 0);
2698 } 2701 }
2699 #endif /* ENCAPSULATE_READ */ 2702 #endif /* ENCAPSULATE_READ */
2700 2703
2701 int 2704 int
2702 sys_write_1 (int fildes, CONST void *buf, unsigned int nbyte, int allow_quit) 2705 sys_write_1 (int fildes, CONST void *buf, size_t nbyte, int allow_quit)
2703 { 2706 {
2704 int rtnval; 2707 int rtnval;
2705 int bytes_written = 0; 2708 int bytes_written = 0;
2706 CONST char *b = (CONST char *) buf; 2709 CONST char *b = (CONST char *) buf;
2707 2710
2727 return (bytes_written); 2730 return (bytes_written);
2728 } 2731 }
2729 2732
2730 #ifdef ENCAPSULATE_WRITE 2733 #ifdef ENCAPSULATE_WRITE
2731 int 2734 int
2732 sys_write (int fildes, CONST void *buf, unsigned int nbyte) 2735 sys_write (int fildes, CONST void *buf, size_t nbyte)
2733 { 2736 {
2734 return sys_write_1 (fildes, buf, nbyte, 0); 2737 return sys_write_1 (fildes, buf, nbyte, 0);
2735 } 2738 }
2736 #endif /* ENCAPSULATE_WRITE */ 2739 #endif /* ENCAPSULATE_WRITE */
2737 2740
2859 #endif /* ENCAPSULATE_CHDIR */ 2862 #endif /* ENCAPSULATE_CHDIR */
2860 2863
2861 2864
2862 #ifdef ENCAPSULATE_MKDIR 2865 #ifdef ENCAPSULATE_MKDIR
2863 int 2866 int
2864 sys_mkdir (CONST char *path, int mode) 2867 sys_mkdir (CONST char *path, mode_t mode)
2865 { 2868 {
2866 PATHNAME_CONVERT_OUT (path); 2869 PATHNAME_CONVERT_OUT (path);
2867 return mkdir (path, mode); 2870 return mkdir (path, mode);
2868 } 2871 }
2869 #endif /* ENCAPSULATE_MKDIR */ 2872 #endif /* ENCAPSULATE_MKDIR */
2998 #endif /* ENCAPSULATE_LSTAT */ 3001 #endif /* ENCAPSULATE_LSTAT */
2999 3002
3000 3003
3001 #ifdef ENCAPSULATE_READLINK 3004 #ifdef ENCAPSULATE_READLINK
3002 int 3005 int
3003 sys_readlink (CONST char *path, char *buf, int bufsiz) 3006 sys_readlink (CONST char *path, char *buf, size_t bufsiz)
3004 { 3007 {
3005 PATHNAME_CONVERT_OUT (path); 3008 PATHNAME_CONVERT_OUT (path);
3006 /* #### currently we don't do conversions on the incoming data */ 3009 /* #### currently we don't do conversions on the incoming data */
3007 return readlink (path, buf, bufsiz); 3010 return readlink (path, buf, bufsiz);
3008 } 3011 }
3021 3024
3022 /****************** file-manipulation calls *****************/ 3025 /****************** file-manipulation calls *****************/
3023 3026
3024 #ifdef ENCAPSULATE_CHMOD 3027 #ifdef ENCAPSULATE_CHMOD
3025 int 3028 int
3026 sys_chmod (CONST char *path, int mode) 3029 sys_chmod (CONST char *path, mode_t mode)
3027 { 3030 {
3028 PATHNAME_CONVERT_OUT (path); 3031 PATHNAME_CONVERT_OUT (path);
3029 return chmod (path, mode); 3032 return chmod (path, mode);
3030 } 3033 }
3031 #endif /* ENCAPSULATE_CHMOD */ 3034 #endif /* ENCAPSULATE_CHMOD */
3032 3035
3033 3036
3034 #ifdef ENCAPSULATE_CREAT 3037 #ifdef ENCAPSULATE_CREAT
3035 int 3038 int
3036 sys_creat (CONST char *path, int mode) 3039 sys_creat (CONST char *path, mode_t mode)
3037 { 3040 {
3038 PATHNAME_CONVERT_OUT (path); 3041 PATHNAME_CONVERT_OUT (path);
3039 return creat (path, mode); 3042 return creat (path, mode);
3040 } 3043 }
3041 #endif /* ENCAPSULATE_CREAT */ 3044 #endif /* ENCAPSULATE_CREAT */
3087 #ifdef ENCAPSULATE_EXECVP 3090 #ifdef ENCAPSULATE_EXECVP
3088 int 3091 int
3089 sys_execvp (CONST char *path, char * CONST * argv) 3092 sys_execvp (CONST char *path, char * CONST * argv)
3090 { 3093 {
3091 int i, argc; 3094 int i, argc;
3092 CONST char ** new_argv; 3095 char ** new_argv;
3093 3096
3094 PATHNAME_CONVERT_OUT (path); 3097 PATHNAME_CONVERT_OUT (path);
3095 for (argc = 0; argv[argc]; argc++) 3098 for (argc = 0; argv[argc]; argc++)
3096 ; 3099 ;
3097 new_argv = alloca_array (CONST char *, argc + 1); 3100 new_argv = alloca_array (char *, argc + 1);
3098 for (i = 0; i < argc; i++) 3101 for (i = 0; i < argc; i++)
3099 GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA (argv[i], new_argv[i]); 3102 {
3103 new_argv[i] = argv[i];
3104 PATHNAME_CONVERT_OUT (new_argv[i]);
3105 }
3100 new_argv[argc] = NULL; 3106 new_argv[argc] = NULL;
3101 return execvp (path, (char **) new_argv); 3107 return execvp (path, new_argv);
3102 } 3108 }
3103 #endif /* ENCAPSULATE_EXECVP */ 3109 #endif /* ENCAPSULATE_EXECVP */
3104 3110
3105 3111
3106 /************************************************************************/ 3112 /************************************************************************/
3401 #endif /* need at least 4 */ 3407 #endif /* need at least 4 */
3402 #endif /* need at least 3 */ 3408 #endif /* need at least 3 */
3403 #endif /* need at least 2 */ 3409 #endif /* need at least 2 */
3404 return val & ((1L << VALBITS) - 1); 3410 return val & ((1L << VALBITS) - 1);
3405 } 3411 }
3406
3407 #ifdef WRONG_NAME_INSQUE
3408
3409 void
3410 insque (caddr_t q, caddr_t p)
3411 {
3412 _insque (q,p);
3413 }
3414
3415 #endif
3416 3412
3417 3413
3418 /************************************************************************/ 3414 /************************************************************************/
3419 /* Strings corresponding to defined signals */ 3415 /* Strings corresponding to defined signals */
3420 /************************************************************************/ 3416 /************************************************************************/