apue patch

修改include/apue.h

include/apue.h增加

1
#include <sys/sysmacros.h>

修改stdio/buf.c

打开apue.3e/stdio/buf.c,搜索_LP64,大致在(文件的89~93行),将其删除

1
2
3
4
5
#ifdef _LP64
#define _flag __pad[4]
#define _ptr __pad[1]
#define _base __pad[2]
#endif

is_unbuffered, is_linebufferedbuffer_size替换如下

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
int
is_unbuffered(FILE *fp)
{
return(fp->_flags & _IONBF);
}

int
is_linebuffered(FILE *fp)
{
return(fp->_flags & _IOLBF);
}

int
buffer_size(FILE *fp)
{
#ifdef _LP64
return(fp->_IO_buf_end - fp->_IO_buf_base);
#else
return(BUFSIZ); /* just a guess */
#endif
}

#else

#error unknown stdio implementation!

#endif

copy头文件和库

1
2
sudo cp ./include/apue.h /usr/include/
sudo cp ./lib/libapue.a /usr/lib/