3 # The script is created for Cygnus by vmakarov@cygnus.com and based on
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.
10 # See README-fixinc for more information.
13 # Directory in which to store the results.
14 LIB=${1?"fixincludes: output directory not specified"}
16 # Make sure it exists.
17 if [ ! -d $LIB ]; then
21 # Make LIB absolute if it is relative.
22 # Don't do this if not necessary, since may screw up automounters.
27 cd $LIB; LIB=`${PWDCMD-pwd}`
31 echo Building fixed headers in ${LIB}
34 echo Fixed $file for glibc-2.0.x
36 cat <<'__EOF__' >$LIB/$file
37 /* This file fixes __FD_ZERO bug for glibc-2.0.x. */
38 #ifndef _SELECTBITS_H_WRAPPER
40 #include_next <selectbits.h>
42 #if defined(__FD_ZERO) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 0
44 #define __FD_ZERO(fdsetp) \
47 __asm__ __volatile__ ("cld; rep; stosl" \
48 : "=m" (((__fd_mask *) \
49 (fdsetp))[__FDELT (__FD_SETSIZE)]), \
50 "=&c" (__d0), "=&D" (__d1) \
51 : "a" (0), "1" (sizeof (__fd_set) \
52 / sizeof (__fd_mask)), \
53 "2" ((__fd_mask *) (fdsetp)) \
58 #define _SELECTBITS_H_WRAPPER
59 #endif /* _SELECTBITS_H_WRAPPER */
61 # Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
62 # the start, so that if #include_next gets another instance of
63 # the wrapper, this will follow the #include_next chain until
64 # we arrive at the real <selectbits.h>.
67 # asm/posix_types.h for libc version 1.x
68 file=asm/posix_types.h
69 echo Fixed $file for glibc-1.x
71 dir=`dirname $LIB/$file`
72 if [ ! -d $dir ]; then
73 mkdir -p $dir || exit 1
75 cat <<'__EOF__' >$LIB/$file
76 /* This file fixes __FD_ZERO bug for glibc-1.x. */
77 #ifndef _POSIX_TYPES_H_WRAPPER
79 #include_next <asm/posix_types.h>
81 #if defined(__FD_ZERO) && !defined(__GLIBC__)
83 #define __FD_ZERO(fdsetp) \
86 __asm__ __volatile__("cld ; rep ; stosl" \
87 : "=m" (*(__kernel_fd_set *) (fdsetp)), \
88 "=&c" (__d0), "=&D" (__d1) \
89 : "a" (0), "1" (__FDSET_LONGS), \
90 "2" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
94 #define _POSIX_TYPES_H_WRAPPER
95 #endif /* _POSIX_TYPES_H_WRAPPER */
97 # Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
98 # the start, so that if #include_next gets another instance of
99 # the wrapper, this will follow the #include_next chain until
100 # we arrive at the real <asm/posix_types.h>.
103 # gnu/types.h for libc version 1.x
105 echo Fixed $file for glibc-1.x
107 dir=`dirname $LIB/$file`
108 if [ ! -d $dir ]; then
109 mkdir -p $dir || exit 1
111 cat <<'__EOF__' >$LIB/$file
112 /* This file fixes __FD_ZERO bug for glibc-1.x. */
113 #ifndef _TYPES_H_WRAPPER
114 #include <features.h>
115 #include_next <gnu/types.h>
117 #if defined(__FD_ZERO) && !defined(__GLIBC__)
119 # define __FD_ZERO(fdsetp) \
122 __asm__ __volatile__("cld ; rep ; stosl" \
123 : "=m" (*(__fd_set *) (fdsetp)), \
124 "=&c" (__d0), "=&D" (__d1) \
125 : "a" (0), "1" (__FDSET_LONGS), \
126 "2" ((__fd_set *) (fdsetp)) :"memory"); \
130 #define _TYPES_H_WRAPPER
131 #endif /* _TYPES_H_WRAPPER */
133 # Define _TYPES_H_WRAPPER at the end of the wrapper, not the start,
134 # so that if #include_next gets another instance of the wrapper,
135 # this will follow the #include_next chain until we arrive at
136 # the real <gnu/types.h>.