OSDN Git Service

1999-06-23 Bruce Korb <ddsinc09@ix.netcom.com>
[pf3gnuchains/gcc-fork.git] / gcc / fixinc / fixinc.x86-linux-gnu
1 #! /bin/sh
2 #
3 # The script is created for Cygnus by vmakarov@cygnus.com and based on
4 # fixinc.wrap
5 #
6 # This script is designed for x86 with gnulibc of version 2.0 and less
7 # for solution of problems with invalid asm-statements by creating
8 # small wrappers around the include files containg the asm-statements.
9 #
10 # See README-fixinc for more information.
11
12
13 # Directory in which to store the results.
14 LIB=${1?"fixincludes: output directory not specified"}
15
16 # Make sure it exists.
17 if [ ! -d $LIB ]; then
18   mkdir $LIB || exit 1
19 fi
20
21 # Make LIB absolute if it is relative.
22 # Don't do this if not necessary, since may screw up automounters.
23 case $LIB in
24 /*)
25         ;;
26 *)
27         cd $LIB; LIB=`${PWDCMD-pwd}`
28         ;;
29 esac
30
31 echo Building fixed headers in ${LIB}
32   
33 file=selectbits.h
34 echo Fixed $file for glibc-2.0.x
35 rm -f $LIB/$file
36 cat <<'__EOF__' >$LIB/$file
37 /* This file fixes __FD_ZERO bug for glibc-2.0.x. */
38 #ifndef _SELECTBITS_H_WRAPPER
39 #include <features.h>
40 #include_next <selectbits.h>
41
42 #if defined(__FD_ZERO) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 0
43 #undef __FD_ZERO
44 #define __FD_ZERO(fdsetp) \
45   do { \
46     int __d0, __d1; \
47   __asm__ __volatile__ ("cld; rep; stosl" \
48                         : "=&c" (__d0), "=&D" (__d1) \
49                         : "a" (0), "0" (sizeof (__fd_set) \
50                                         / sizeof (__fd_mask)), \
51                           "1" ((__fd_mask *) (fdsetp)) \
52                         : "memory"); \
53   } while (0)
54 #endif
55
56 #define _SELECTBITS_H_WRAPPER
57 #endif /* _SELECTBITS_H_WRAPPER */
58 __EOF__
59 # Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
60 # the start, so that if #include_next gets another instance of
61 # the wrapper, this will follow the #include_next chain until
62 # we arrive at the real <selectbits.h>.
63 chmod a+r $LIB/$file
64
65 # asm/posix_types.h for libc version 1.x
66 file=asm/posix_types.h
67 echo Fixed $file for glibc-1.x
68 rm -f $LIB/$file
69 dir=`dirname $LIB/$file`
70 if [ ! -d $dir ]; then
71   mkdir -p $dir || exit 1
72 fi
73 cat <<'__EOF__' >$LIB/$file
74 /* This file fixes __FD_ZERO bug for glibc-1.x. */
75 #ifndef _POSIX_TYPES_H_WRAPPER
76 #include <features.h>
77 #include_next <asm/posix_types.h>
78
79 #if defined(__FD_ZERO) && !defined(__GLIBC__)
80 #undef __FD_ZERO
81 #define __FD_ZERO(fdsetp) \
82   do { \
83     int __d0, __d1; \
84                 __asm__ __volatile__("cld ; rep ; stosl" \
85                         : "=&c" (__d0), "=&D" (__d1) \
86                         : "a" (0), "0" (__FDSET_LONGS), \
87                           "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
88   } while (0)
89 #endif
90
91 #define _POSIX_TYPES_H_WRAPPER
92 #endif /* _POSIX_TYPES_H_WRAPPER */
93 __EOF__
94 # Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
95 # the start, so that if #include_next gets another instance of
96 # the wrapper, this will follow the #include_next chain until
97 # we arrive at the real <asm/posix_types.h>.
98 chmod a+r $LIB/$file
99
100 # gnu/types.h for libc version 1.x
101 file=gnu/types.h
102 echo Fixed $file for glibc-1.x
103 rm -f $LIB/$file
104 dir=`dirname $LIB/$file`
105 if [ ! -d $dir ]; then
106   mkdir -p $dir || exit 1
107 fi
108 cat <<'__EOF__' >$LIB/$file
109 /* This file fixes __FD_ZERO bug for glibc-1.x. */
110 #ifndef _TYPES_H_WRAPPER
111 #include <features.h>
112 #include_next <gnu/types.h>
113
114 #if defined(__FD_ZERO) && !defined(__GLIBC__)
115 #undef __FD_ZERO
116 # define __FD_ZERO(fdsetp) \
117   do { \
118     int __d0, __d1; \
119         __asm__ __volatile__("cld ; rep ; stosl" \
120                 : "=&c" (__d0), "=&D" (__d1) \
121                 : "a" (0), "0" (__FDSET_LONGS), \
122                   "1" ((__fd_set *) (fdsetp)) :"memory"); \
123   } while (0)
124 #endif
125
126 #define _TYPES_H_WRAPPER
127 #endif /* _TYPES_H_WRAPPER */
128 __EOF__
129 # Define _TYPES_H_WRAPPER at the end of the wrapper, not the start,
130 # so that if #include_next gets another instance of the wrapper,
131 # this will follow the #include_next chain until we arrive at
132 # the real <gnu/types.h>.
133 chmod a+r $LIB/$file
134
135 if [ x${INSTALL_ASSERT_H} != x ]
136 then
137   cd ${ORIG_DIR}
138   rm -f include/assert.h
139   cp ${srcdir}/assert.h include/assert.h || exit 1
140   chmod a+r include/assert.h
141 fi
142
143 exit 0