config.mk: improve feature test macros and compatibility

- add missing header netinet/in.h for socket declarations (POSIX).
- rename sendfile to responsefile, sendfile(2) is a syscall on FreeBSD.
- remove _XOPEN_SOURCE: this will give a warning about strptime on Linux
  glibc, but unbreaks the build on NetBSD and FreeBSD.

thanks also to josuah and quinq for testing!
This commit is contained in:
Hiltjo Posthuma 2017-08-30 14:27:04 +02:00 committed by Laslo Hunhold
parent 7e199ee04d
commit 5defa985db
2 changed files with 4 additions and 3 deletions

View file

@ -8,7 +8,7 @@ PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man MANPREFIX = $(PREFIX)/share/man
# flags # flags
CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_BSD_SOURCE
CFLAGS = -std=c99 -pedantic -Wall -Os CFLAGS = -std=c99 -pedantic -Wall -Os
LDFLAGS = -s LDFLAGS = -s

View file

@ -1,4 +1,5 @@
/* See LICENSE file for license details. */ /* See LICENSE file for license details. */
#include <netinet/in.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -418,7 +419,7 @@ cleanup:
} }
static enum status static enum status
sendfile(int fd, char *name, struct request *r, struct stat *st, char *mime, responsefile(int fd, char *name, struct request *r, struct stat *st, char *mime,
off_t lower, off_t upper) off_t lower, off_t upper)
{ {
FILE *fp; FILE *fp;
@ -754,7 +755,7 @@ sendresponse(int fd, struct request *r)
} }
} }
return sendfile(fd, RELPATH(realtarget), r, &st, mime, lower, upper); return responsefile(fd, RELPATH(realtarget), r, &st, mime, lower, upper);
} }
static void static void