summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorNicolas Thill <nico@openwrt.org>2010-04-16 08:48:19 +0000
committerNicolas Thill <nico@openwrt.org>2010-04-16 08:48:19 +0000
commit6b9e04991d241fdafbdf9e899e4ea1ac2c4f5cd4 (patch)
treee4b2fdeebbab2c1a6567bfb33de44d6bab22a71d /package
parentf1eb6dd095b40b5f85f92cf031c2d17414ee26b2 (diff)
downloadmtk-20170518-6b9e04991d241fdafbdf9e899e4ea1ac2c4f5cd4.zip
mtk-20170518-6b9e04991d241fdafbdf9e899e4ea1ac2c4f5cd4.tar.gz
mtk-20170518-6b9e04991d241fdafbdf9e899e4ea1ac2c4f5cd4.tar.bz2
package/busybox: add 3 upstream fixes, bump release number
SVN-Revision: 20904
Diffstat (limited to 'package')
-rw-r--r--package/busybox/Makefile2
-rw-r--r--package/busybox/patches/000-upstream-dnsd.patch27
-rw-r--r--package/busybox/patches/000-upstream-hwclock.patch151
-rw-r--r--package/busybox/patches/000-upstream-indexcgi.patch11
4 files changed, 190 insertions, 1 deletions
diff --git a/package/busybox/Makefile b/package/busybox/Makefile
index 214b7f3..9638e9c 100644
--- a/package/busybox/Makefile
+++ b/package/busybox/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=busybox
PKG_VERSION:=1.16.1
-PKG_RELEASE:=2
+PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://www.busybox.net/downloads \
diff --git a/package/busybox/patches/000-upstream-dnsd.patch b/package/busybox/patches/000-upstream-dnsd.patch
new file mode 100644
index 0000000..25458ca
--- /dev/null
+++ b/package/busybox/patches/000-upstream-dnsd.patch
@@ -0,0 +1,27 @@
+--- a/include/platform.h
++++ b/include/platform.h
+@@ -291,10 +291,12 @@ typedef unsigned smalluint;
+ #if 1 /* if needed: !defined(arch1) && !defined(arch2) */
+ # define ALIGN1 __attribute__((aligned(1)))
+ # define ALIGN2 __attribute__((aligned(2)))
++# define ALIGN4 __attribute__((aligned(4)))
+ #else
+ /* Arches which MUST have 2 or 4 byte alignment for everything are here */
+ # define ALIGN1
+ # define ALIGN2
++# define ALIGN4
+ #endif
+
+
+--- a/networking/dnsd.c
++++ b/networking/dnsd.c
+@@ -459,7 +459,8 @@ int dnsd_main(int argc UNUSED_PARAM, cha
+ unsigned lsa_size;
+ int udps, opts;
+ uint16_t port = 53;
+- uint8_t buf[MAX_PACK_LEN + 1];
++ /* Ensure buf is 32bit aligned (we need 16bit, but 32bit can't hurt) */
++ uint8_t buf[MAX_PACK_LEN + 1] ALIGN4;
+
+ opts = getopt32(argv, "vi:c:t:p:d", &listen_interface, &fileconf, &sttl, &sport);
+ //if (opts & 0x1) // -v
diff --git a/package/busybox/patches/000-upstream-hwclock.patch b/package/busybox/patches/000-upstream-hwclock.patch
new file mode 100644
index 0000000..971235d
--- /dev/null
+++ b/package/busybox/patches/000-upstream-hwclock.patch
@@ -0,0 +1,151 @@
+--- a/util-linux/hwclock.c
++++ b/util-linux/hwclock.c
+@@ -109,10 +109,53 @@ static void to_sys_clock(const char **pp
+
+ static void from_sys_clock(const char **pp_rtcname, int utc)
+ {
+-#define TWEAK_USEC 200
+- struct tm tm_time;
++#if 1
+ struct timeval tv;
++ struct tm tm_time;
++ int rtc;
++
++ rtc = rtc_xopen(pp_rtcname, O_WRONLY);
++ gettimeofday(&tv, NULL);
++ /* Prepare tm_time */
++ if (sizeof(time_t) == sizeof(tv.tv_sec)) {
++ if (utc)
++ gmtime_r((time_t*)&tv.tv_sec, &tm_time);
++ else
++ localtime_r((time_t*)&tv.tv_sec, &tm_time);
++ } else {
++ time_t t = tv.tv_sec;
++ if (utc)
++ gmtime_r(&t, &tm_time);
++ else
++ localtime_r(&t, &tm_time);
++ }
++#else
++/* Bloated code which tries to set hw clock with better precision.
++ * On x86, even though code does set hw clock within <1ms of exact
++ * whole seconds, apparently hw clock (at least on some machines)
++ * doesn't reset internal fractional seconds to 0,
++ * making all this a pointless excercise.
++ */
++ /* If we see that we are N usec away from whole second,
++ * we'll sleep for N-ADJ usecs. ADJ corrects for the fact
++ * that CPU is not infinitely fast.
++ * On infinitely fast CPU, next wakeup would be
++ * on (exactly_next_whole_second - ADJ). On real CPUs,
++ * this difference between current time and whole second
++ * is less than ADJ (assuming system isn't heavily loaded).
++ */
++ /* Small value of 256us gives very precise sync for 2+ GHz CPUs.
++ * Slower CPUs will fail to sync and will go to bigger
++ * ADJ values. qemu-emulated armv4tl with ~100 MHz
++ * performance ends up using ADJ ~= 4*1024 and it takes
++ * 2+ secs (2 tries with successively larger ADJ)
++ * to sync. Even straced one on the same qemu (very slow)
++ * takes only 4 tries.
++ */
++#define TWEAK_USEC 256
+ unsigned adj = TWEAK_USEC;
++ struct tm tm_time;
++ struct timeval tv;
+ int rtc = rtc_xopen(pp_rtcname, O_WRONLY);
+
+ /* Try to catch the moment when whole second is close */
+@@ -124,55 +167,64 @@ static void from_sys_clock(const char **
+
+ t = tv.tv_sec;
+ rem_usec = 1000000 - tv.tv_usec;
+- if (rem_usec < 1024) {
+- /* Less than 1ms to next second. Good enough */
++ if (rem_usec < adj) {
++ /* Close enough */
+ small_rem:
+ t++;
+ }
+
+- /* Prepare tm */
++ /* Prepare tm_time from t */
+ if (utc)
+ gmtime_r(&t, &tm_time); /* may read /etc/xxx (it takes time) */
+ else
+ localtime_r(&t, &tm_time); /* same */
+- tm_time.tm_isdst = 0;
++
++ if (adj >= 32*1024) {
++ break; /* 32 ms diff and still no luck?? give up trying to sync */
++ }
+
+ /* gmtime/localtime took some time, re-get cur time */
+ gettimeofday(&tv, NULL);
+
+- if (tv.tv_sec < t /* may happen if rem_usec was < 1024 */
+- || (tv.tv_sec == t && tv.tv_usec < 1024)
++ if (tv.tv_sec < t /* we are still in old second */
++ || (tv.tv_sec == t && tv.tv_usec < adj) /* not too far into next second */
+ ) {
+- /* We are not too far into next second. Good. */
+- break;
+- }
+- adj += 32; /* 2^(10-5) = 2^5 = 32 iterations max */
+- if (adj >= 1024) {
+- /* Give up trying to sync */
+- break;
++ break; /* good, we are in sync! */
+ }
+
+- /* Try to sync up by sleeping */
+ rem_usec = 1000000 - tv.tv_usec;
+- if (rem_usec < 1024) {
+- goto small_rem; /* already close, don't sleep */
++ if (rem_usec < adj) {
++ t = tv.tv_sec;
++ goto small_rem; /* already close to next sec, don't sleep */
+ }
+- /* Need to sleep.
+- * Note that small adj on slow processors can make us
+- * to always overshoot tv.tv_usec < 1024 check on next
+- * iteration. That's why adj is increased on each iteration.
+- * This also allows it to be reused as a loop limiter.
+- */
+- usleep(rem_usec - adj);
+- }
+
+- xioctl(rtc, RTC_SET_TIME, &tm_time);
++ /* Try to sync up by sleeping */
++ usleep(rem_usec - adj);
+
+- /* Debug aid to find "good" TWEAK_USEC.
++ /* Jump to 1ms diff, then increase fast (x2): EVERY loop
++ * takes ~1 sec, people won't like slowly converging code here!
++ */
++ //bb_error_msg("adj:%d tv.tv_usec:%d", adj, (int)tv.tv_usec);
++ if (adj < 512)
++ adj = 512;
++ /* ... and if last "overshoot" does not look insanely big,
++ * just use it as adj increment. This makes convergence faster.
++ */
++ if (tv.tv_usec < adj * 8) {
++ adj += tv.tv_usec;
++ continue;
++ }
++ adj *= 2;
++ }
++ /* Debug aid to find "optimal" TWEAK_USEC with nearly exact sync.
+ * Look for a value which makes tv_usec close to 999999 or 0.
+- * for 2.20GHz Intel Core 2: TWEAK_USEC ~= 200
++ * For 2.20GHz Intel Core 2: optimal TWEAK_USEC ~= 200
+ */
+- //bb_error_msg("tv.tv_usec:%d adj:%d", (int)tv.tv_usec, adj);
++ //bb_error_msg("tv.tv_usec:%d", (int)tv.tv_usec);
++#endif
++
++ tm_time.tm_isdst = 0;
++ xioctl(rtc, RTC_SET_TIME, &tm_time);
+
+ if (ENABLE_FEATURE_CLEAN_UP)
+ close(rtc);
diff --git a/package/busybox/patches/000-upstream-indexcgi.patch b/package/busybox/patches/000-upstream-indexcgi.patch
new file mode 100644
index 0000000..6f7a00b
--- /dev/null
+++ b/package/busybox/patches/000-upstream-indexcgi.patch
@@ -0,0 +1,11 @@
+--- a/networking/httpd_indexcgi.c
++++ b/networking/httpd_indexcgi.c
+@@ -315,7 +315,7 @@ int main(int argc, char *argv[])
+ if (S_ISREG(cdir->dl_mode))
+ fmt_ull(cdir->dl_size);
+ fmt_str("<td class=dt>");
+- tm = gmtime(&cdir->dl_mtime);
++ ptm = gmtime(&cdir->dl_mtime);
+ fmt_04u(1900 + ptm->tm_year); *dst++ = '-';
+ fmt_02u(ptm->tm_mon + 1); *dst++ = '-';
+ fmt_02u(ptm->tm_mday); *dst++ = ' ';