From: KuhnChris <kuhnchris+github@kuhnchris.eu>
To: passt-dev@passt.top
Cc: KuhnChris <kuhnchris+github@kuhnchris.eu>
Subject: [PATCH 1/3] musl adaptations
Date: Fri, 3 Mar 2023 22:49:29 +0000 [thread overview]
Message-ID: <20230303224931.11791-1-kuhnchris+github@kuhnchris.eu> (raw)
---
conf.c | 6 +++---
passt.c | 2 +-
passt.h | 4 ++--
util.h | 14 ++++++++++++++
4 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/conf.c b/conf.c
index 0e512f4..c1dd9ba 100644
--- a/conf.c
+++ b/conf.c
@@ -1305,13 +1305,13 @@ void conf(struct ctx *c, int argc, char **argv)
if (logfile)
die("Can't log to both file and stderr");
- if (c->stderr)
+ if (c->force_stderr)
die("Multiple --stderr options given");
- c->stderr = 1;
+ c->force_stderr = 1;
break;
case 'l':
- if (c->stderr)
+ if (c->force_stderr)
die("Can't log to both stderr and file");
if (logfile)
diff --git a/passt.c b/passt.c
index 5b8146e..f67213a 100644
--- a/passt.c
+++ b/passt.c
@@ -241,7 +241,7 @@ int main(int argc, char **argv)
conf(&c, argc, argv);
trace_init(c.trace);
- if (c.stderr || isatty(fileno(stdout)))
+ if (c.force_stderr || isatty(fileno(stdout)))
__openlog(log_name, LOG_PERROR, LOG_DAEMON);
quit_fd = pasta_netns_quit_init(&c);
diff --git a/passt.h b/passt.h
index e0383eb..71d3602 100644
--- a/passt.h
+++ b/passt.h
@@ -32,7 +32,7 @@ struct tap_l4_msg {
union epoll_ref;
#include <stdbool.h>
-
+#include <bits/limits.h>
#include "packet.h"
#include "icmp.h"
#include "port_fwd.h"
@@ -197,7 +197,7 @@ struct ctx {
int trace;
int quiet;
int foreground;
- int stderr;
+ int force_stderr;
int nofile;
char sock_path[UNIX_PATH_MAX];
char pcap[PATH_MAX];
diff --git a/util.h b/util.h
index 570094c..7315ce2 100644
--- a/util.h
+++ b/util.h
@@ -7,7 +7,10 @@
#define UTIL_H
#include <stdlib.h>
+#include <stdio.h>
#include <stdarg.h>
+#include <signal.h>
+#include <byteswap.h>
#include "log.h"
@@ -88,6 +91,8 @@
#define MAC_ZERO ((uint8_t [ETH_ALEN]){ 0 })
#define MAC_IS_ZERO(addr) (!memcmp((addr), MAC_ZERO, ETH_ALEN))
+#if defined(__GLIBC__) || defined(__UCLIBC__)
+
#if __BYTE_ORDER == __BIG_ENDIAN
#define htons_constant(x) (x)
#define htonl_constant(x) (x)
@@ -96,6 +101,15 @@
#define htonl_constant(x) (__bswap_constant_32(x))
#endif
+#else
+
+/* mainly musl fallback */
+
+#define htons_constant(x) (x)
+#define htonl_constant(x) (x)
+
+#endif
+
#define IN4_IS_ADDR_UNSPECIFIED(a) \
((a)->s_addr == htonl(INADDR_ANY))
#define IN4_IS_ADDR_BROADCAST(a) \
--
@@ -7,7 +7,10 @@
#define UTIL_H
#include <stdlib.h>
+#include <stdio.h>
#include <stdarg.h>
+#include <signal.h>
+#include <byteswap.h>
#include "log.h"
@@ -88,6 +91,8 @@
#define MAC_ZERO ((uint8_t [ETH_ALEN]){ 0 })
#define MAC_IS_ZERO(addr) (!memcmp((addr), MAC_ZERO, ETH_ALEN))
+#if defined(__GLIBC__) || defined(__UCLIBC__)
+
#if __BYTE_ORDER == __BIG_ENDIAN
#define htons_constant(x) (x)
#define htonl_constant(x) (x)
@@ -96,6 +101,15 @@
#define htonl_constant(x) (__bswap_constant_32(x))
#endif
+#else
+
+/* mainly musl fallback */
+
+#define htons_constant(x) (x)
+#define htonl_constant(x) (x)
+
+#endif
+
#define IN4_IS_ADDR_UNSPECIFIED(a) \
((a)->s_addr == htonl(INADDR_ANY))
#define IN4_IS_ADDR_BROADCAST(a) \
--
2.38.4
next reply other threads:[~2023-03-03 22:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 22:49 KuhnChris [this message]
2023-03-03 22:49 ` [PATCH 2/3] sbrivio/manual buffer size due to musl being 1024 KuhnChris
2023-03-04 9:54 ` Stefano Brivio
2023-03-03 22:49 ` [PATCH 3/3] define _bswap_constant_16/32 for musl This uses the implementation from libiio (https://github.com/analogdevicesinc/libiio/commit/9c6c6a432a0cbe2832bc97a7eeddfb61f6b8b856) Also restored the old behavior from the old util.h KuhnChris
2023-03-04 9:55 ` Stefano Brivio
2023-03-04 9:54 ` [PATCH 1/3] musl adaptations Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230303224931.11791-1-kuhnchris+github@kuhnchris.eu \
--to=kuhnchris+github@kuhnchris.eu \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).