Skip to content

Commit

Permalink
Update illumos support to the modern era (#24)
Browse files Browse the repository at this point in the history
* Update Solaris / Illumos support

Old versions of Solaris did not have vasprintf, so darkhttpd defined one
gated behind an ifdef. Oracle Solaris 10 has had vasprintf since 2011.
Oracle Solaris 11 has had it since release. illumos (which also reports
as `__sun`) also has it in all current incarnations. As a result, this
ifdef'd block creates compiler errors due to a second definition of the
function. This commit removes the block.

This commit also adds `-lsendfile` to the Makefile for systems that
report as `SunOS` in `uname` (Solaris and Illumos), which is necessary
to link successfully in current day.

* Comment on manually specifying CC in readme

Some systems, including versions of illumos I use, do not have a `cc`
alias to the system C compiler. Arguably this is a flaw in the
distribution, but as a user, it's perhaps helpful to be reminded that
this is an option.
  • Loading branch information
faithanalog authored Oct 2, 2022
1 parent 1eb6daa commit 4792091
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CC?=cc
CFLAGS?=-O
LIBS=`[ \`uname\` = "SunOS" ] && echo -lsocket -lnsl`
LIBS=`[ \`uname\` = "SunOS" ] && echo -lsocket -lnsl -lsendfile`

all: darkhttpd

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ Simply run make:
make
```

If `cc` is not on your `PATH` as an alias to your C compiler, you may need to specify it. For example,

```
CC=gcc make
```

## How to run darkhttpd

Serve /var/www/htdocs on the default port (80 if running as root, else 8080):
Expand Down
10 changes: 0 additions & 10 deletions darkhttpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,6 @@ static char *xstrdup(const char *src) {
return dest;
}

#ifdef __sun /* unimpressed by Solaris */
static int vasprintf(char **strp, const char *fmt, va_list ap) {
char tmp;
int result = vsnprintf(&tmp, 1, fmt, ap);
*strp = xmalloc(result+1);
result = vsnprintf(*strp, result+1, fmt, ap);
return result;
}
#endif

/* vasprintf() that dies if it fails. */
static unsigned int xvasprintf(char **ret, const char *format, va_list ap)
__printflike(2,0);
Expand Down

0 comments on commit 4792091

Please sign in to comment.