Sync 2026-04-23 03:02:20

This commit is contained in:
github-actions[bot] 2026-04-23 03:02:20 +08:00
parent 14fb5aa2c8
commit 49449029e7
16 changed files with 341 additions and 336 deletions

View File

@ -1,4 +1,5 @@
# Copyright (C) 2025 Openwrt.org
# Copyright (C) 2016 Openwrt.org
# Copyright (C) 2025 LWB1978
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
@ -6,8 +7,8 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for Timewol
PKG_VERSION:=20250407
PKG_RELEASE:=4
PKG_VERSION:=20260422
PKG_RELEASE:=5
LUCI_DEPENDS:=+luci-base +etherwake
LUCI_PKGARCH:=all

View File

@ -1,5 +1,13 @@
-- Copyright (C) 2025 LWB1978
module("luci.controller.timewol", package.seeall)
local http = require "luci.http"
local uci = require "luci.model.uci".cursor()
local sys = require "luci.sys"
local json = require "luci.jsonc"
local util = require "luci.util"
function index()
if not nixio.fs.access("/etc/config/timewol") then return end
@ -11,36 +19,42 @@ function index()
page.acl_depends = { "luci-app-timewol" }
entry({"admin", "control", "timewol", "status"}, call("status")).leaf = true
entry({"admin", "control", "timewol", "awake"}, call("awake")).leaf = true
entry({"admin", "control", "timewol", "wakeup"}, call("wakeup")).leaf = true
end
local function http_write_json(content)
http.prepare_content("application/json")
http.write(json.stringify(content or {code = 1}))
end
function status()
local e = {}
e.status = luci.sys.call("cat /etc/crontabs/root | grep -v '^[ \t]*#' | grep etherwake >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
e.status = sys.call("grep -v '^[ \t]*#' /etc/crontabs/root | grep etherwake >/dev/null") == 0
http_write_json(e)
end
function awake(sections)
lan = x:get("timewol",sections,"maceth")
mac = x:get("timewol",sections,"macaddr")
local e = {}
cmd = "/usr/bin/etherwake -D -i " .. lan .. " -b " .. mac .. " 2>&1"
local p = io.popen(cmd)
local msg = ""
if p then
while true do
local l = p:read("*l")
if l then
if #l > 100 then l = l:sub(1, 100) .. "..." end
msg = msg .. l
else
break
end
end
p:close()
function wakeup()
uci:revert("timewol")
local section = http.formvalue("section") or ""
if section == "" then
http_write_json({ success = false, msg = "Missing section" })
return
end
e["data"] = msg
luci.http.prepare_content("application/json")
luci.http.write_json(e)
local maceth = uci:get("timewol", section, "maceth") or ""
local macaddr = uci:get("timewol", section, "macaddr") or ""
if maceth == "" or macaddr == "" then
http_write_json({ success = false, msg = "Missing MAC or interface" })
return
end
local cmd = string.format(
"/usr/bin/etherwake -D -i %s %s",
util.shellquote(maceth),
util.shellquote(macaddr)
)
if sys.call(cmd) ~= 0 then
http_write_json({ success = false, msg = "Wake failed" })
return
end
http_write_json({ success = true })
end

View File

@ -1,3 +1,5 @@
-- Copyright (C) 2025 LWB1978
local sys = require "luci.sys"
local m, s, o
@ -31,6 +33,10 @@ o = s:option(Flag, "enable", translate("Enable"))
o.default = 1
o.rmempty = false
o = s:option(Value, "remark", translate("Remarks"))
o.width = "auto"
o.rmempty = false
-- Client MAC Address
o = s:option(Value, "macaddr", translate("Client MAC"))
o.rmempty = false
@ -48,13 +54,6 @@ for _, device in ipairs(sys.net.devices()) do
end
end
-- wake device
local btn = s:option(Button, "_awake",translate("Wake Up Host"))
btn.inputtitle = translate("Awake")
btn.inputstyle = "apply"
btn.disabled = false
btn.template = "timewol/awake"
-- Function to validate cron field values
local function validate_cron_field(option_name, value, min, max, default)
if value == "" then
@ -88,6 +87,14 @@ for _, opt in ipairs(schedule_options) do
end
end
o = s:option(DummyValue, "_Wake")
o.rawhtml = true
o.cfgvalue = function(self, section)
return string.format([[
<input type="button" class="btn cbi-button cbi-button-apply" onclick="WakeUP('%s')" value="%s" />]],
section, translate("Wake"))
end
-- Apply the configuration changes
m.apply_on_parse = true
function m.on_apply(self)

View File

@ -1,3 +0,0 @@
<%+cbi/valueheader%>
<input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" style="font-size: 100%;" type="button" onclick="onclick_awake(this.id)" <%=attr("name", section) .. attr("id", cbid) .. attr("value", self.inputtitle)%> />
<%+cbi/valuefooter%>

View File

@ -1,11 +1,12 @@
<%#
Copyright 2016 Chen RuiWei <crwbak@gmail.com>
Copyright (C) 2025 LWB1978
Licensed to the public under the Apache License 2.0.
-%>
<% include("cbi/map") %>
<script type="text/javascript">//<![CDATA[
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "control", "timewol", "status")%>', null,
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "control", "timewol", "status")%>', null,
function(x, result)
{
var status = document.getElementsByClassName('timewol_status')[0];
@ -14,23 +15,36 @@
status.innerHTML = result.status?'<%=translate("RUNNING")%>':'<%=translate("NOT RUNNING")%>';
}
)
function _id2section(id) {
var x = id.split(".");
return x[2];
}
function onclick_awake(id) {
var section = _id2section(id);
var btnXHR = new XHR();
btnXHR.post('<%=url([[admin]], [[control]], [[timewol]], [[awake]])%>/' + section, { token: '<%=token%>' },
function(x, data) {
if (x.responseText == "_uncommitted_") {
txt="<%:Please [Save & Apply] your changes first%>";
alert( txt.replace(new RegExp("<%:&%>", "g"), "&") );
} else {
alert( JSON.parse(x.response).data );
}
function WakeUP(section) {
var input = document.querySelector("input[name='cbid.timewol." + section + ".remark']");
var remark = input ? input.value.trim() : "";
if (!confirm("<%:Are you sure you want to wake%> " + remark + " ?")) {
return;
}
fetch('<%=luci.dispatcher.build_url("admin", "control", "timewol", "wakeup")%>?section='
+ encodeURIComponent(section))
.then(response => response.json())
.then(data => {
if (!data.success) {
alert(data.msg || "Operation failed");
}
);
});
}
//]]>
</script>
<style>
input[id*=".timewol."][id$=".minute"],
input[id*=".timewol."][id$=".hour"],
input[id*=".timewol."][id$=".day"],
input[id*=".timewol."][id$=".month"],
input[id*=".timewol."][id$=".weeks"] {
width: 45px !important;
min-width: unset !important;
max-width: unset !important;
text-align: center !important;
}
</style>

View File

@ -52,5 +52,11 @@ msgstr "星期"
msgid "Invalid value for %s: %s. Must be between %d and %d or '*'"
msgstr "%s: %s 的值无效. 必须在 %d 和 %d 之间,或为 '*'"
msgid "Awake"
msgstr "立即唤醒"
msgid "Remarks"
msgstr "备注"
msgid "Wake"
msgstr "唤醒"
msgid "Are you sure you want to wake"
msgstr "你是否要唤醒"

View File

@ -1,6 +1,8 @@
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2025 OpenWrt.org
# Copyright (C) 2015 OpenWrt-dist
# Copyright (C) 2016 fw867 <ffkykzs@gmail.com>
# Copyright (C) 2025 LWB1978
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.

View File

@ -1,257 +0,0 @@
Index: mtproxy/common/server-functions.c
===================================================================
--- mtproxy.orig/common/server-functions.c
+++ mtproxy/common/server-functions.c
@@ -35,7 +35,9 @@
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
+#ifdef __GLIBC__
#include <execinfo.h>
+#endif
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
@@ -168,6 +170,7 @@ const char *get_version_string (void) {
}
void print_backtrace (void) {
+#ifdef __GLIBC__
void *buffer[64];
int nptrs = backtrace (buffer, 64);
kwrite (2, "\n------- Stack Backtrace -------\n", 33);
@@ -178,6 +181,7 @@ void print_backtrace (void) {
kwrite (2, s, strlen (s));
kwrite (2, "\n", 1);
}
+#endif
}
pthread_t debug_main_pthread_id;
Index: mtproxy/jobs/jobs.h
===================================================================
--- mtproxy.orig/jobs/jobs.h
+++ mtproxy/jobs/jobs.h
@@ -27,6 +27,7 @@
#include "net/net-events.h"
#include "net/net-msg.h"
#include "net/net-timers.h"
+#include "common/randr_compat.h"
#define __joblocked
#define __jobref
Index: mtproxy/Makefile
===================================================================
--- mtproxy.orig/Makefile
+++ mtproxy/Makefile
@@ -56,6 +56,7 @@ DEPENDENCE_STRANGE := $(subst ${OBJ}/,${
DEPENDENCE_NORM := $(subst ${OBJ}/,${DEP}/,$(patsubst %.o,%.d,${OBJECTS}))
LIB_OBJS_NORMAL := \
+ ${OBJ}/common/randr_compat.o \
${OBJ}/common/crc32c.o \
${OBJ}/common/pid.o \
${OBJ}/common/sha1.o \
Index: mtproxy/common/randr_compat.c
===================================================================
--- /dev/null
+++ mtproxy/common/randr_compat.c
@@ -0,0 +1,121 @@
+/*
+ The GNU C Library is free software. See the file COPYING.LIB for copying
+ conditions, and LICENSES for notices about a few contributions that require
+ these additional notices to be distributed. License copyright years may be
+ listed using range notation, e.g., 2000-2011, indicating that every year in
+ the range, inclusive, is a copyrightable year that would otherwise be listed
+ individually.
+*/
+
+#include <stddef.h>
+#include "common/randr_compat.h"
+#include <stdint.h>
+
+int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) {
+ uint64_t X;
+ uint64_t result;
+
+ /* Initialize buffer, if not yet done. */
+ if (!buffer->__init == 0)
+ {
+ buffer->__a = 0x5deece66dull;
+ buffer->__c = 0xb;
+ buffer->__init = 1;
+ }
+
+ /* Do the real work. We choose a data type which contains at least
+ 48 bits. Because we compute the modulus it does not care how
+ many bits really are computed. */
+
+ X = (uint64_t) xsubi[2] << 32 | (uint32_t) xsubi[1] << 16 | xsubi[0];
+
+ result = X * buffer->__a + buffer->__c;
+
+ xsubi[0] = result & 0xffff;
+ xsubi[1] = (result >> 16) & 0xffff;
+ xsubi[2] = (result >> 32) & 0xffff;
+
+ return 0;
+}
+
+int __erand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, double *result) {
+ union ieee754_double temp;
+
+ /* Compute next state. */
+ if (__drand48_iterate (xsubi, buffer) < 0)
+ return -1;
+
+ /* Construct a positive double with the 48 random bits distributed over
+ its fractional part so the resulting FP number is [0.0,1.0). */
+
+ temp.ieee.negative = 0;
+ temp.ieee.exponent = IEEE754_DOUBLE_BIAS;
+ temp.ieee.mantissa0 = (xsubi[2] << 4) | (xsubi[1] >> 12);
+ temp.ieee.mantissa1 = ((xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4);
+
+ /* Please note the lower 4 bits of mantissa1 are always 0. */
+ *result = temp.d - 1.0;
+
+ return 0;
+}
+
+int __nrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result) {
+ /* Compute next state. */
+ if (__drand48_iterate (xsubi, buffer) < 0)
+ return -1;
+
+ /* Store the result. */
+ if (sizeof (unsigned short int) == 2)
+ *result = xsubi[2] << 15 | xsubi[1] >> 1;
+ else
+ *result = xsubi[2] >> 1;
+
+ return 0;
+}
+
+int __jrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result) {
+ /* Compute next state. */
+ if (__drand48_iterate (xsubi, buffer) < 0)
+ return -1;
+
+ /* Store the result. */
+ *result = (int32_t) ((xsubi[2] << 16) | xsubi[1]);
+
+ return 0;
+}
+
+int drand48_r (struct drand48_data *buffer, double *result) {
+ return __erand48_r (buffer->__x, buffer, result);
+}
+
+int lrand48_r (struct drand48_data *buffer, long int *result) {
+ /* Be generous for the arguments, detect some errors. */
+ if (buffer == NULL)
+ return -1;
+
+ return __nrand48_r (buffer->__x, buffer, result);
+}
+
+int mrand48_r (struct drand48_data *buffer, long int *result) {
+ /* Be generous for the arguments, detect some errors. */
+ if (buffer == NULL)
+ return -1;
+
+ return __jrand48_r (buffer->__x, buffer, result);
+}
+
+int srand48_r (long int seedval, struct drand48_data *buffer) {
+ /* The standards say we only have 32 bits. */
+ if (sizeof (long int) > 4)
+ seedval &= 0xffffffffl;
+
+ buffer->__x[2] = seedval >> 16;
+ buffer->__x[1] = seedval & 0xffffl;
+ buffer->__x[0] = 0x330e;
+
+ buffer->__a = 0x5deece66dull;
+ buffer->__c = 0xb;
+ buffer->__init = 1;
+
+ return 0;
+}
Index: mtproxy/common/randr_compat.h
===================================================================
--- /dev/null
+++ mtproxy/common/randr_compat.h
@@ -0,0 +1,72 @@
+/*
+ The GNU C Library is free software. See the file COPYING.LIB for copying
+ conditions, and LICENSES for notices about a few contributions that require
+ these additional notices to be distributed. License copyright years may be
+ listed using range notation, e.g., 2000-2011, indicating that every year in
+ the range, inclusive, is a copyrightable year that would otherwise be listed
+ individually.
+*/
+
+#pragma once
+
+#include <endian.h>
+#include <pthread.h>
+
+struct drand48_data {
+ unsigned short int __x[3]; /* Current state. */
+ unsigned short int __old_x[3]; /* Old state. */
+ unsigned short int __c; /* Additive const. in congruential formula. */
+ unsigned short int __init; /* Flag for initializing. */
+ unsigned long long int __a; /* Factor in congruential formula. */
+};
+
+union ieee754_double
+{
+ double d;
+
+ /* This is the IEEE 754 double-precision format. */
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:11;
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa0:20;
+ unsigned int mantissa1:32;
+#endif /* Big endian. */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:20;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+#endif /* Little endian. */
+ } ieee;
+
+ /* This format makes it easier to see if a NaN is a signalling NaN. */
+ struct
+ {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:11;
+ unsigned int quiet_nan:1;
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa0:19;
+ unsigned int mantissa1:32;
+#else
+ /* Together these comprise the mantissa. */
+ unsigned int mantissa1:32;
+ unsigned int mantissa0:19;
+ unsigned int quiet_nan:1;
+ unsigned int exponent:11;
+ unsigned int negative:1;
+#endif
+ } ieee_nan;
+};
+
+#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */
+
+int drand48_r (struct drand48_data *buffer, double *result);
+int lrand48_r (struct drand48_data *buffer, long int *result);
+int mrand48_r (struct drand48_data *buffer, long int *result);
+int srand48_r (long int seedval, struct drand48_data *buffer);

View File

@ -1,13 +0,0 @@
Index: mtproxy/mtproto/mtproto-proxy.c
===================================================================
--- mtproxy.orig/mtproto/mtproto-proxy.c
+++ mtproxy/mtproto/mtproto-proxy.c
@@ -68,7 +68,7 @@
#define COMMIT "unknown"
#endif
-#define VERSION_STR "mtproxy-3.0.5"
+#define VERSION_STR "mtproxy-3.0.6"
const char FullVersionStr[] = VERSION_STR " compiled at " __DATE__ " " __TIME__ " by gcc " __VERSION__ " "
#ifdef __LP64__
"64-bit"

View File

@ -1,16 +1,16 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mtproxy
PKG_VERSION:=3.5.5
PKG_RELEASE:=14
PKG_NAME:=teleproxy
PKG_VERSION:=4.11.0
PKG_RELEASE:=1
PKG_MAINTAINER:=Kosntantine Shevlakov <shevlakov@132lan.ru>
PKG_LICENSE:=GPLv2
PKG_LICENSE_FILES:=LICENSE
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/GetPageSpeed/MTProxy.git
PKG_SOURCE_VERSION:=55e5f0f575c2dd5decbf5282f4c1ea1f816a7eb0
PKG_SOURCE_URL:=https://github.com/teleproxy/teleproxy.git
PKG_SOURCE_VERSION:=09b1ae9c39c456a7b91d24fdd3597ea08519ef22
PKG_SOURCE_SUBDIR:=$(PKG_NAME)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
@ -32,6 +32,4 @@ define Package/$(PKG_NAME)/install
$(1)/usr/bin/
endef
ifeq ($(ARCH),$(filter $(ARCH), x86_64))
$(eval $(call BuildPackage,$(PKG_NAME)))
endif
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -0,0 +1,20 @@
Index: teleproxy/Makefile
===================================================================
--- teleproxy.orig/Makefile
+++ teleproxy/Makefile
@@ -56,11 +56,11 @@ COMMON_CFLAGS += $(EXTRA_CFLAGS)
COMMON_LDFLAGS += $(EXTRA_LDFLAGS)
# Architecture-specific CFLAGS
-ifeq ($(HOST_ARCH), x86_64)
+ifeq ($(ARCH), x86_64)
CFLAGS := $(COMMON_CFLAGS) -mpclmul -march=core2 -mfpmath=sse -mssse3 $(BITNESS_FLAGS)
-else ifeq ($(HOST_ARCH), aarch64)
-CFLAGS := $(COMMON_CFLAGS) $(BITNESS_FLAGS)
-else ifeq ($(HOST_ARCH), arm64)
+else ifeq ($(ARCH), mipsel)
+CFLAGS := $(COMMON_CFLAGS) $(BITNESS_FLAGS) -march=mips32r2 -Wno-builtin-declaration-mismatch
+else
CFLAGS := $(COMMON_CFLAGS) $(BITNESS_FLAGS)
endif

View File

@ -0,0 +1,17 @@
Index: teleproxy/src/mtproto/mtproto-proxy-stats.c
===================================================================
--- teleproxy.orig/src/mtproto/mtproto-proxy-stats.c
+++ teleproxy/src/mtproto/mtproto-proxy-stats.c
@@ -602,9 +602,9 @@ void mtfront_prepare_stats (stats_buffer
if (_quota > 0) {
sb_printf (sb, "secret_%s_quota\t%lld\n", _lbl, _quota);
}
- int _mips = tcp_rpcs_get_ext_secret_max_ips (_i);
- if (_mips > 0) {
- sb_printf (sb, "secret_%s_max_ips\t%d\n", _lbl, _mips);
+ int _mips_ips = tcp_rpcs_get_ext_secret_max_ips (_i);
+ if (_mips_ips > 0) {
+ sb_printf (sb, "secret_%s_max_ips\t%d\n", _lbl, _mips_ips);
}
int64_t _exp = tcp_rpcs_get_ext_secret_expires (_i);
if (_exp > 0) {

View File

@ -0,0 +1,86 @@
Index: teleproxy/src/common/rdtsc_32bit.h
===================================================================
--- /dev/null
+++ teleproxy/src/common/rdtsc_32bit.h
@@ -0,0 +1,14 @@
+#ifndef RDTSC_EMUL_H
+#define RDTSC_EMUL_H
+
+#if defined(__arm__) || defined(__mips__) || defined(__mipsel__)
+#include <time.h>
+
+static inline unsigned long long rdtsc(void) {
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (unsigned long long)ts.tv_sec * 1000000000ULL + ts.tv_nsec;
+}
+#endif
+
+#endif
Index: teleproxy/src/engine/engine-rpc-common.c
===================================================================
--- teleproxy.orig/src/engine/engine-rpc-common.c
+++ teleproxy/src/engine/engine-rpc-common.c
@@ -51,6 +51,7 @@
+#include "common/rdtsc_32bit.h"
#include "engine/engine.h"
#include "engine/engine-rpc-common.h"
#include "common/tl-parse.h"
Index: teleproxy/src/jobs/jobs.c
===================================================================
--- teleproxy.orig/src/jobs/jobs.c
+++ teleproxy/src/jobs/jobs.c
@@ -53,6 +53,7 @@
#include "net/net-connections.h"
#include "jobs/jobs.h"
#include "common/common-stats.h"
+#include "common/rdtsc_32bit.h"
//#include "auto/engine/engine.h"
Index: teleproxy/src/net/net-crypto-aes.c
===================================================================
--- teleproxy.orig/src/net/net-crypto-aes.c
+++ teleproxy/src/net/net-crypto-aes.c
@@ -48,6 +48,7 @@
#include "jobs/jobs.h"
#include "common/common-stats.h"
+#include "common/rdtsc_32bit.h"
#define MODULE crypto_aes
Index: teleproxy/src/common/precise-time.c
===================================================================
--- teleproxy.orig/src/common/precise-time.c
+++ teleproxy/src/common/precise-time.c
@@ -19,10 +19,11 @@
*/
#include <assert.h>
#include <sys/time.h>
+
#include <time.h>
/* unistd.h defines _POSIX_TIMERS */
#include <unistd.h>
-
+#include "rdtsc_32bit.h"
#include "precise-time.h"
__thread int now;
Index: teleproxy/src/engine/engine-rpc.c
===================================================================
--- teleproxy.orig/src/engine/engine-rpc.c
+++ teleproxy/src/engine/engine-rpc.c
@@ -25,6 +25,8 @@
Copyright 2015-2016 Telegram Messenger Inc
2015-2016 Vitaliy Valtman
*/
+#include "common/rdtsc_32bit.h"
+
#include "engine/engine-rpc.h"
#include "common/tl-parse.h"

View File

@ -0,0 +1,79 @@
Index: teleproxy/src/common/atomic_32bit.c
===================================================================
--- /dev/null
+++ teleproxy/src/common/atomic_32bit.c
@@ -0,0 +1,73 @@
+#if defined(__arm__) || defined(__mips__) || defined(__mipsel__)
+
+#include <pthread.h>
+#include <stdint.h>
+
+static pthread_mutex_t atomic_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* 64-bit atomic operations emulation */
+uint64_t __sync_fetch_and_add_8(uint64_t *ptr, uint64_t val) {
+ pthread_mutex_lock(&atomic_mutex);
+ uint64_t old = *ptr;
+ *ptr += val;
+ pthread_mutex_unlock(&atomic_mutex);
+ return old;
+}
+
+uint64_t __sync_fetch_and_sub_8(uint64_t *ptr, uint64_t val) {
+ pthread_mutex_lock(&atomic_mutex);
+ uint64_t old = *ptr;
+ *ptr -= val;
+ pthread_mutex_unlock(&atomic_mutex);
+ return old;
+}
+
+uint64_t __sync_fetch_and_or_8(uint64_t *ptr, uint64_t val) {
+ pthread_mutex_lock(&atomic_mutex);
+ uint64_t old = *ptr;
+ *ptr |= val;
+ pthread_mutex_unlock(&atomic_mutex);
+ return old;
+}
+
+uint64_t __sync_fetch_and_and_8(uint64_t *ptr, uint64_t val) {
+ pthread_mutex_lock(&atomic_mutex);
+ uint64_t old = *ptr;
+ *ptr &= val;
+ pthread_mutex_unlock(&atomic_mutex);
+ return old;
+}
+
+uint64_t __sync_add_and_fetch_8(uint64_t *ptr, uint64_t val) {
+ pthread_mutex_lock(&atomic_mutex);
+ *ptr += val;
+ uint64_t newval = *ptr;
+ pthread_mutex_unlock(&atomic_mutex);
+ return newval;
+}
+
+uint64_t __sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val) {
+ pthread_mutex_lock(&atomic_mutex);
+ *ptr -= val;
+ uint64_t newval = *ptr;
+ pthread_mutex_unlock(&atomic_mutex);
+ return newval;
+}
+
+int __sync_bool_compare_and_swap_8(uint64_t *ptr, uint64_t oldval, uint64_t newval) {
+ pthread_mutex_lock(&atomic_mutex);
+ int ret = (*ptr == oldval);
+ if (ret) *ptr = newval;
+ pthread_mutex_unlock(&atomic_mutex);
+ return ret;
+}
+
+uint64_t __sync_val_compare_and_swap_8(uint64_t *ptr, uint64_t oldval, uint64_t newval) {
+ pthread_mutex_lock(&atomic_mutex);
+ uint64_t old = *ptr;
+ if (old == oldval) *ptr = newval;
+ pthread_mutex_unlock(&atomic_mutex);
+ return old;
+}
+
+#endif /* 32bits arch */

View File

@ -0,0 +1,12 @@
Index: teleproxy/Makefile
===================================================================
--- teleproxy.orig/Makefile
+++ teleproxy/Makefile
@@ -92,6 +92,7 @@ DEPENDENCE_STRANGE := $(subst ${OBJ}/,${
DEPENDENCE_NORM := $(subst ${OBJ}/,${DEP}/,$(patsubst %.o,%.d,${OBJECTS}))
LIB_OBJS_NORMAL := \
+ ${OBJ}/src/common/atomic_32bit.o \
${OBJ}/src/common/crc32c.o \
${OBJ}/src/common/pid.o \
${OBJ}/src/common/sha1.o \

View File

@ -0,0 +1,22 @@
Index: teleproxy/src/engine/engine.c
===================================================================
--- teleproxy.orig/src/engine/engine.c
+++ teleproxy/src/engine/engine.c
@@ -612,8 +612,15 @@ void engine_startup (engine_t *E, server
precise_now_diff = get_utime_monotonic () - get_double_time ();
#ifdef __linux__
- assert (SIGRTMAX == OUR_SIGRTMAX);
- assert (SIGRTMAX - SIGRTMIN >= 20);
+ #ifdef __mips__
+ if (SIGRTMAX != OUR_SIGRTMAX) {
+ vkprintf(0, "MIPS: SIGRTMAX mismatch (libc=%d, expected=%d), continuing\n",
+ SIGRTMAX, OUR_SIGRTMAX);
+ }
+ #else
+ assert(SIGRTMAX == OUR_SIGRTMAX);
+ #endif
+ assert(SIGRTMAX - SIGRTMIN >= 20);
#endif
E->sfd = 0;