Simplify by avoiding confusing use of strncpy etc.
[bpt/emacs.git] / src / s / gnu-linux.h
CommitLineData
3a707ba5 1/* This file is the configuration file for Linux-based GNU systems
2f86b22b 2
acaf905b 3Copyright (C) 1985-1986, 1992, 1994, 1996, 1999, 2001-2012
e9bffc61 4 Free Software Foundation, Inc.
566e3587 5
e05aebe9
GM
6This file was put together by Michael K. Johnson and Rik Faith.
7
566e3587
JB
8This file is part of GNU Emacs.
9
4b158629 10GNU Emacs is free software: you can redistribute it and/or modify
566e3587 11it under the terms of the GNU General Public License as published by
4b158629
GM
12the Free Software Foundation, either version 3 of the License, or
13(at your option) any later version.
566e3587
JB
14
15GNU Emacs is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
4b158629 21along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
566e3587 22
e05aebe9
GM
23/* Define symbols to identify the version of Unix this is.
24 Define all the symbols that apply correctly. */
566e3587 25#define USG
8db5530a 26#define GNU_LINUX
566e3587 27
65953053 28#ifdef emacs
b764619d 29#ifdef HAVE_LINUX_VERSION_H
65953053 30#include <linux/version.h>
566e3587 31
85a71b37 32#if LINUX_VERSION_CODE >= 0x20400
c5e7567d
DN
33/* 21 Jun 06: Eric Hanchrow <offby1@blarg.net> says this works. */
34#define SIGNALS_VIA_CHARACTERS
85a71b37 35#endif /* LINUX_VERSION_CODE >= 0x20400 */
b764619d 36#endif /* HAVE_LINUX_VERSION_H */
aa7fcbb0 37#endif /* emacs */
566e3587 38
71125fb8
GM
39#if defined HAVE_GRANTPT
40#define UNIX98_PTYS
566e3587 41
e05aebe9 42/* Run only once. We need a `for'-loop because the code uses `continue'. */
be02381c 43#define PTY_ITERATION int i; for (i = 0; i < 1; i++)
fdc5e0fc 44
71125fb8
GM
45#ifdef HAVE_GETPT
46#define PTY_NAME_SPRINTF
47#define PTY_OPEN fd = getpt ()
48#else /* not HAVE_GETPT */
49#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
50#endif /* not HAVE_GETPT */
51
52/* Note that grantpt and unlockpt may fork. We must block SIGCHLD to
53 prevent sigchld_handler from intercepting the child's death. */
71125fb8
GM
54#define PTY_TTY_NAME_SPRINTF \
55 { \
56 char *ptyname; \
57 \
58 sigblock (sigmask (SIGCHLD)); \
59 if (grantpt (fd) == -1 || unlockpt (fd) == -1 \
60 || !(ptyname = ptsname(fd))) \
61 { \
62 sigunblock (sigmask (SIGCHLD)); \
63 close (fd); \
64 return -1; \
65 } \
e99a530f 66 snprintf (pty_name, sizeof pty_name, "%s", ptyname); \
71125fb8
GM
67 sigunblock (sigmask (SIGCHLD)); \
68 }
fdc5e0fc 69
dacbb818 70#else /* not HAVE_GRANTPT */
fdc5e0fc 71
71125fb8
GM
72/* Letter to use in finding device name of first pty,
73 if system supports pty's. 'p' means it is /dev/ptyp0 */
71125fb8 74#define FIRST_PTY_LETTER 'p'
fdc5e0fc 75
132d0475 76#endif /* not HAVE_GRANTPT */
fdc5e0fc 77
e05aebe9 78/* Define HAVE_PTYS if the system supports pty devices. */
566e3587
JB
79#define HAVE_PTYS
80
dad29761 81#define HAVE_SOCKETS
566e3587 82
566e3587
JB
83/* Define CLASH_DETECTION if you want lock files to be written
84 so that Emacs can tell instantly when you try to modify
85 a file that someone else has modified in his Emacs. */
b2e209ba 86#define CLASH_DETECTION
566e3587
JB
87
88/* Here, on a separate page, add any special hacks needed
89 to make Emacs work on this system. For example,
90 you might define certain system call names that don't
91 exist on your system, or that do different things on
92 your system and must be used only through an encapsulation
93 (Which you should place, by convention, in sysdep.c). */
94\f
e05aebe9 95/* This is needed for dispnew.c:update_frame. */
5e5623c2 96#ifdef emacs
a9c82aaf 97#include <stdio.h> /* Get the definition of _IO_STDIO_H. */
5e617bc2 98#if defined (_IO_STDIO_H) || defined (_STDIO_USES_IOSTREAM)
e05aebe9 99/* New C libio names. */
c2c3f859 100#define GNU_LIBRARY_PENDING_OUTPUT_COUNT(FILE) \
5e5623c2 101 ((FILE)->_IO_write_ptr - (FILE)->_IO_write_base)
65f451d0 102#elif defined (__UCLIBC__)
e05aebe9 103/* Using the uClibc library. */
65f451d0
DN
104#define GNU_LIBRARY_PENDING_OUTPUT_COUNT(FILE) \
105 ((FILE)->__bufpos - (FILE)->__bufstart)
106#else /* !_IO_STDIO_H && ! __UCLIBC__ */
e05aebe9 107/* Old C++ iostream names. */
c2c3f859 108#define GNU_LIBRARY_PENDING_OUTPUT_COUNT(FILE) \
5e5623c2 109 ((FILE)->_pptr - (FILE)->_pbase)
65f451d0 110#endif /* !_IO_STDIO_H && ! __UCLIBC__ */
566e3587 111
65953053 112#define INTERRUPT_INPUT
9539dc5d 113#endif /* emacs */
566e3587 114
1abbab7a 115#define POSIX /* affects getpagesize.h and systty.h */
566e3587 116
639f52d8
RS
117/* This is to work around mysterious gcc failures in some system versions.
118 It is unlikely that Emacs changes will work around this problem;
119 therefore, this should remain permanently. */
e3b89505
RS
120#ifndef HAVE_XRMSETDATABASE
121#define HAVE_XRMSETDATABASE
122#endif
e2000885 123
2327e4a0
GM
124#define NARROWPROTO 1
125
bb15bd9a 126/* Tell that garbage collector that setjmp is known to save all
e05aebe9 127 registers relevant for conservative garbage collection in the jmp_buf. */
e7b6b572
DL
128/* Not all the architectures are tested, but there are Debian packages
129 for SCM and/or Guile on them, so the technique must work. See also
130 comments in alloc.c concerning setjmp and gcc. Fixme: it's
131 probably safe to make this conditional just on GCC, except for ia64
132 register window-flushing. */
a8f77aaa
GM
133/* Don't use #cpu here since in newest development versions of GCC,
134 we must call cpp with -traditional, and that disables #cpu. */
e7b6b572
DL
135#if defined __i386__ || defined __sparc__ || defined __mc68000__ \
136 || defined __alpha__ || defined __mips__ || defined __s390__ \
e3177e43 137 || defined __arm__ || defined __powerpc__ || defined __amd64__ \
00f37552 138 || defined __ia64__ || defined __sh__
bb15bd9a 139#define GC_SETJMP_WORKS 1
e3177e43
AS
140#ifdef __ia64__
141#define GC_MARK_SECONDARY_STACK() \
142 do { \
143 extern void *__libc_ia64_register_backing_store_base; \
144 __builtin_ia64_flushrs (); \
145 mark_memory (__libc_ia64_register_backing_store_base, \
2adb6e85 146 __builtin_ia64_bsp ()); \
e3177e43
AS
147 } while (0)
148#endif
b948ce8b
PE
149#else
150#define GC_MARK_STACK GC_USE_GCPROS_AS_BEFORE
bb15bd9a 151#endif
34374650
PE
152
153#ifdef __i386__
154/* libc-linux/sysdeps/linux/i386/ulimit.c says that due to shared library, */
155/* we cannot get the maximum address for brk */
156# define ULIMIT_BREAK_VALUE (32*1024*1024)
157#endif