summaryrefslogtreecommitdiff
path: root/gnu/egcs/gcc/fixinc/fixinc.x86-linux-gnu
blob: d53694d9bfa1aa642b56e4e77e82167de645f4ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#! /bin/sh
#
# The script is created for Cygnus by vmakarov@cygnus.com and based on
# fixinc.wrap
#
# This script is designed for x86 with gnulibc of version 2.0 and less
# for solution of problems with invalid asm-statements by creating
# small wrappers around the include files containg the asm-statements.
#
# See README-fixinc for more information.


# Directory in which to store the results.
LIB=${1?"fixincludes: output directory not specified"}

# Make sure it exists.
if [ ! -d $LIB ]; then
  mkdir $LIB || exit 1
fi

# Make LIB absolute if it is relative.
# Don't do this if not necessary, since may screw up automounters.
case $LIB in
/*)
	;;
*)
	cd $LIB; LIB=`${PWDCMD-pwd}`
	;;
esac

echo Building fixed headers in ${LIB}
  
file=selectbits.h
echo Fixed $file for glibc-2.0.x
rm -f $LIB/$file
cat <<'__EOF__' >$LIB/$file
/* This file fixes __FD_ZERO bug for glibc-2.0.x. */
#ifndef _SELECTBITS_H_WRAPPER
#include <features.h>
#include_next <selectbits.h>

#if defined(__FD_ZERO) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 0
#undef __FD_ZERO
#define __FD_ZERO(fdsetp) \
  do { \
    int __d0, __d1; \
  __asm__ __volatile__ ("cld; rep; stosl" \
                        : "=&c" (__d0), "=&D" (__d1) \
                        : "a" (0), "0" (sizeof (__fd_set) \
                                        / sizeof (__fd_mask)), \
                          "1" ((__fd_mask *) (fdsetp)) \
                        : "memory"); \
  } while (0)
#endif

#define _SELECTBITS_H_WRAPPER
#endif /* _SELECTBITS_H_WRAPPER */
__EOF__
# Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
# the start, so that if #include_next gets another instance of
# the wrapper, this will follow the #include_next chain until
# we arrive at the real <selectbits.h>.
chmod a+r $LIB/$file

# asm/posix_types.h for libc version 1.x
file=asm/posix_types.h
echo Fixed $file for glibc-1.x
rm -f $LIB/$file
dir=`dirname $LIB/$file`
if [ ! -d $dir ]; then
  mkdir -p $dir || exit 1
fi
cat <<'__EOF__' >$LIB/$file
/* This file fixes __FD_ZERO bug for glibc-1.x. */
#ifndef _POSIX_TYPES_H_WRAPPER
#include <features.h>
#include_next <asm/posix_types.h>

#if defined(__FD_ZERO) && !defined(__GLIBC__)
#undef __FD_ZERO
#define __FD_ZERO(fdsetp) \
  do { \
    int __d0, __d1; \
		__asm__ __volatile__("cld ; rep ; stosl" \
			: "=&c" (__d0), "=&D" (__d1) \
			: "a" (0), "0" (__FDSET_LONGS), \
			  "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
  } while (0)
#endif

#define _POSIX_TYPES_H_WRAPPER
#endif /* _POSIX_TYPES_H_WRAPPER */
__EOF__
# Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
# the start, so that if #include_next gets another instance of
# the wrapper, this will follow the #include_next chain until
# we arrive at the real <asm/posix_types.h>.
chmod a+r $LIB/$file

# gnu/types.h for libc version 1.x
file=gnu/types.h
echo Fixed $file for glibc-1.x
rm -f $LIB/$file
dir=`dirname $LIB/$file`
if [ ! -d $dir ]; then
  mkdir -p $dir || exit 1
fi
cat <<'__EOF__' >$LIB/$file
/* This file fixes __FD_ZERO bug for glibc-1.x. */
#ifndef _TYPES_H_WRAPPER
#include <features.h>
#include_next <gnu/types.h>

#if defined(__FD_ZERO) && !defined(__GLIBC__)
#undef __FD_ZERO
# define __FD_ZERO(fdsetp) \
  do { \
    int __d0, __d1; \
	__asm__ __volatile__("cld ; rep ; stosl" \
        	: "=&c" (__d0), "=&D" (__d1) \
        	: "a" (0), "0" (__FDSET_LONGS), \
		  "1" ((__fd_set *) (fdsetp)) :"memory"); \
  } while (0)
#endif

#define _TYPES_H_WRAPPER
#endif /* _TYPES_H_WRAPPER */
__EOF__
# Define _TYPES_H_WRAPPER at the end of the wrapper, not the start,
# so that if #include_next gets another instance of the wrapper,
# this will follow the #include_next chain until we arrive at
# the real <gnu/types.h>.
chmod a+r $LIB/$file

if [ x${INSTALL_ASSERT_H} != x ]
then
  cd ${ORIG_DIR}
  rm -f include/assert.h
  cp ${srcdir}/assert.h include/assert.h || exit 1
  chmod a+r include/assert.h
fi

exit 0