-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dprintf() polyfill for Illumos #1911
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,10 @@ | |
#define alloca(size) __builtin_alloca(size) | ||
#endif | ||
|
||
#ifdef __sun | ||
#define NEED_DPRINTF | ||
#endif | ||
|
||
#include "nnn.h" | ||
#include "dbg.h" | ||
|
||
|
@@ -856,6 +860,27 @@ static void notify_fifo(bool force); | |
|
||
/* Functions */ | ||
|
||
#ifdef NEED_DPRINTF | ||
static int dprintf(int fd, const char *format, ...) | ||
{ | ||
va_list ap; | ||
char *s; | ||
int len, nwritten; | ||
|
||
va_start(ap, format); | ||
len = vasprintf(&s, format, ap); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although posix doesn't require it, the general expectation is for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it would be better but I couldn't find a better alternative with the available primitives. One could use a static buffer but then you're length limited. |
||
va_end(ap); | ||
|
||
if (len == -1) | ||
return -1; | ||
|
||
nwritten = write(fd, s, len); | ||
free(s); | ||
|
||
return nwritten; | ||
} | ||
#endif | ||
|
||
static void sigint_handler(int sig) | ||
{ | ||
(void) sig; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Illumos is maintained, why don't they add
dprintf
? It's more economical for them to add it instead of N projects to carry their own implementation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better if they did indeed. But that does leave legacy systems, and even there nnn can be very useful.