MUSL strict POSIX C Library & MIPS atomic ops patches

Send your patches here
Post Reply
hojuruku
Posts: 10
Joined: 23 Jul 2016, 21:08

MUSL strict POSIX C Library & MIPS atomic ops patches

Post by hojuruku »

These are bundled with openwrt - very soon I'll release the package, here's the draft so far
http://pastebin.ca/3668350

MUSL support

Code: Select all

--- a/accel-pppd/include/ap_session.h
+++ b/accel-pppd/include/ap_session.h
@@ -2,6 +2,7 @@
 #define __AP_SESSION_H__
 
 #include "ap_net.h"
+#include <pthread.h>
 
 //#define AP_SESSIONID_LEN 16
 #define AP_IFNAME_LEN 16
--- a/accel-pppd/ifcfg.c
+++ b/accel-pppd/ifcfg.c
@@ -9,6 +9,7 @@
 #include <arpa/inet.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
+#include <linux/sockios.h>
 #include <linux/route.h>
 #include "linux_ppp.h"
 
--- a/accel-pppd/ppp/ppp.c	
+++ b/accel-pppd/ppp/ppp.c
@@ -10,6 +10,7 @@
 #include <signal.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
+#include <linux/sockios.h>
 #include "linux_ppp.h"
 
 #include "crypto.h"
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -11,7 +11,6 @@
 #include <net/ethernet.h>
 #include <netpacket/packet.h>
 #include <arpa/inet.h>
-#include <printf.h>
 
 #include "crypto.h"
 
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -13,6 +13,7 @@
 #include <netinet/ip.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
+#include <linux/sockios.h>
 #include <linux/if.h>
 #include <linux/route.h>
 
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -8,6 +8,7 @@
 #include <fcntl.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
+#include <linux/sockios.h>
 #include <net/ethernet.h>
 #include <netpacket/packet.h>
 #include <arpa/inet.h>
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -843,7 +843,7 @@
 	void *sessions = conn->sessions;
 
 	conn->sessions = NULL;
-	tdestroy(sessions, (__free_fn_t)l2tp_session_free);
+	tdestroy(sessions, (void (*)(void *))l2tp_session_free);
 	/* Let l2tp_session_free() handle the session counter and
 	 * the reference held by the tunnel.
 	 */
--- a/accel-pppd/ctrl/ipoe/arp.c
+++ b/accel-pppd/ctrl/ipoe/arp.c
@@ -13,8 +13,8 @@
 #include <netinet/ip.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
-#include <linux/if_arp.h>
-#include <linux/if_packet.h>
+#include <net/if_arp.h>
+#include <netpacket/packet.h>
 
 #include "list.h"
 #include "triton.h"
--- a/accel-pppd/include/ap_net.h
+++ b/accel-pppd/include/ap_net.h
@@ -1,5 +1,6 @@
 #ifndef __AP_NET_H
 #define __AP_NET_H
+#include <sys/socket.h>
 
 struct ap_net {
 	const char *name;
 	
 
MIPS atomic memory ops patch
Also see: https://github.com/rakshasa/rtorrent/issues/156

Code: Select all

accel-pppd: fix atomic ops on MIPS and other platforms 

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56296
__sync_add_and_fetch_8 not supported on mips
Upstream: consider using ifdef __mips__ if any concerns
https://sourceforge.net/p/predef/wiki/Architectures/

Signed-off-by: Luke McKee <hojuruku@gmail.com>

--- a/accel-pppd/include/ap_session.h
+++ b/accel-pppd/include/ap_session.h
@@ -117,9 +117,9 @@
 
 struct ap_session_stat
 {
-	unsigned int active;
-	unsigned int starting;
-	unsigned int finishing;
+	uint32_t active;
+	uint32_t starting;
+	uint32_t finishing;
 };
 
 
--- a/accel-pppd/session.c
+++ b/accel-pppd/session.c
@@ -107,7 +107,7 @@
 		ses->state = AP_STATE_STARTING;
 	}
 
-	__sync_add_and_fetch(&ap_session_stat.starting, 1);
+	__sync_add_and_fetch_4(&ap_session_stat.starting, 1);
 
 	pthread_rwlock_wrlock(&ses_lock);
 	list_add_tail(&ses->entry, &ses_list);
@@ -151,7 +151,7 @@
 
 	ses->state = AP_STATE_ACTIVE;
 	__sync_sub_and_fetch(&ap_session_stat.starting, 1);
-	__sync_add_and_fetch(&ap_session_stat.active, 1);
+	__sync_add_and_fetch_4(&ap_session_stat.active, 1);
 
 	if (ses->idle_timeout) {
 		ses->timer.expire = ap_session_timer;
@@ -276,7 +276,7 @@
 	else
 		__sync_sub_and_fetch(&ap_session_stat.starting, 1);
 
-	__sync_add_and_fetch(&ap_session_stat.finishing, 1);
+	__sync_add_and_fetch_4(&ap_session_stat.finishing, 1);
 	ses->terminating = 1;
 	ses->state = AP_STATE_FINISHING;
 
@@ -334,7 +334,7 @@
 		sid = ++seq;
 		spin_unlock(&seq_lock);
 #else
-		sid = __sync_add_and_fetch(&seq, 1);
+		sid = __sync_add_and_fetch_4(&seq, 1);
 #endif
 
 		clock_gettime(CLOCK_MONOTONIC, &ts);
 		
Post Reply