WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Tiny Core v12.0  (Read 34609 times)

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: Tiny Core v12.0
« Reply #15 on: February 20, 2021, 08:00:35 PM »
@Rich Now that you point it out, yes it does not look like the division is necessary. Based on the surrounding code it is probably for consistency but I could clean it up for speed. There is another further down that I did not post that is used as an argument to some other function so it should stay:

Code: [Select]
+ unsigned long x = ktime_get_seconds();
- epoch_min = ktime_get_seconds() / 60;
+ epoch_min = do_div(x, 60);

@curaga Yes, I believe the time type should be time64_t, but throughout this module long is used so I am going to stick with that.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11618
Re: Tiny Core v12.0
« Reply #16 on: February 20, 2021, 10:42:23 PM »
Hi andyj
Forget what I said.
... if a/c == b/c

to which my response would be:

then a == b ...
That's not true for integer math since the remainder gets discarded. I'm guessing the divide by 60 is to convert to
whole minutes and discard any fractional minute.

Offline bela.d

  • Newbie
  • *
  • Posts: 8
Re: Tiny Core v12.0
« Reply #17 on: February 22, 2021, 04:31:12 PM »
Hi all,

I get a kernel panic after updating to v12.0 in VirtualBox Version 6.1.18 amd64 (Windows host).
The VM is Tiny Core x86.

Is anybody else using TC x86 in Virtualbox?

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: Tiny Core v12.0
« Reply #18 on: February 24, 2021, 07:50:58 AM »
For the benefit of people who think TC is a minor distro and we can't create change in the world:

That's probably worth submitting upstream...

Done: https://www.spinics.net/lists/netfilter-devel/msg70361.html

Offline btlneck

  • Newbie
  • *
  • Posts: 8
Re: Tiny Core v12.0
« Reply #19 on: February 27, 2021, 05:51:13 PM »
Hi andyj.
In the original code check peer for NULL prepends peer->login_sec reference.

Code: [Select]
static inline bool
 has_logged_during_this_minute(const struct peer *peer)
 {
- return peer != NULL && peer->login_sec / 60 == ktime_get_seconds() / 60;
+ unsigned long x = ktime_get_seconds();
+ unsigned long y = peer->login_sec;
+ return peer != NULL && do_div(y, 60) == do_div(x, 60);
 }

Excuse me for maybe stupid question, but if the

peer == NULL

whould this code work:

unsigned long y = peer->login_sec;

?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11618
Re: Tiny Core v12.0
« Reply #20 on: February 27, 2021, 09:20:24 PM »
Hi btlneck
Welcome to the forum.

Nice catch. If  peer == NULL  then this will segfault:
Code: [Select]
unsigned long y = peer->login_sec;
Maybe casting the times to a long would work:
Code: [Select]
return peer != NULL && do_div((long)peer->login_sec, 60) == do_div((long)ktime_get_seconds(), 60);
« Last Edit: February 27, 2021, 09:43:12 PM by Rich »

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: Tiny Core v12.0
« Reply #21 on: February 28, 2021, 09:35:20 AM »
This is a kernel module, so I would expect it to OOPS. There is a lot of "short circuit" type logic throughout this package, so in this case it should be something like this:

Code: [Select]
- unsigned long x = ktime_get_seconds();
- unsigned long y = peer->login_sec + autoclose_time * 60;
- return peer != NULL && autoclose_time != 0 && time_after(x, y);
+ if (peer != NULL) {
+ unsigned long x = ktime_get_seconds();
+ unsigned long y = peer->login_sec + autoclose_time * 60;
+ return autoclose_time != 0 && time_after(x, y);
+ } else {
+ return 0;
+ }

I can't post the whole patch here because our forum software apparently has a few bugs.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11618
Re: Tiny Core v12.0
« Reply #22 on: February 28, 2021, 10:33:56 AM »
Hi andyj
Looks OK. This should work too:
Code: [Select]
if ((peer == NULL) || (autoclose_time == 0))
return 0;

unsigned long x = ktime_get_seconds();
unsigned long y = peer->login_sec + autoclose_time * 60;
return time_after(x, y);

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: Tiny Core v12.0
« Reply #23 on: February 28, 2021, 11:12:31 AM »
That section of code doesn't have the original presenting problem of long division so it doesn't actually need the check anyway because the short circuit would work in that case, and thanks to trying to avoid our forum bug with patches I didn't post the part I should have:

Code: [Select]
static inline bool       
has_logged_during_this_minute(const struct peer *peer)
{                         
        if (peer != NULL) {
                unsigned long x = ktime_get_seconds(), y = peer->login_sec;
                return do_div(y, 60) == do_div(x, 60);
        } else {                     
                return 0;
        }             
}                         

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11618
Re: Tiny Core v12.0
« Reply #24 on: February 28, 2021, 11:31:57 AM »
Hi andyj
... and thanks to trying to avoid our forum bug with patches I didn't post the part I should have: ...
That explains it. I thought maybe I'd missed something. :)

The compiler won't add any code because of it, but the  return 0;  doesn't need to be wrapped in an  else  clause.

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: Tiny Core v12.0
« Reply #25 on: February 28, 2021, 12:39:03 PM »
There are always different ways to code to get the same end result. In most cases I have learned to prefer towards the solution that reads most naturally and explains what is happening so I won't have to figure it out again the next time I look at it. How many times did I do this in my youth:



Or worse, come behind someone else?

Offline asm

  • Newbie
  • *
  • Posts: 1
Re: Tiny Core v12.0
« Reply #26 on: June 01, 2021, 05:52:30 PM »
There are always different ways to code to get the same end result. In most cases I have learned to prefer towards the solution that reads most naturally and explains what is happening so I won't have to figure it out again the next time I look at it.

Hi, I don't know how I got here, but I suffer from XKCD 386 syndrome so when I saw this I felt the need to point out that there are very good reasons to prefer the early return approach: https://softwareengineering.stackexchange.com/questions/18454/should-i-return-from-a-function-early-or-use-an-if-statement

It's one of those things in programming I feel very strongly about.  :P

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14812
Re: Tiny Core v12.0
« Reply #27 on: July 05, 2021, 04:53:34 AM »
Please note that glibc has been recompiled using uname_hack to force it to compile for i486.

rootfs.gz and the *Core* iso's have been replaced with ones containing the new glibc - as there is no corresponding change to CorePure, the version number has not been changed.

There is no need to update unless you have an i486 or similar.

Offline gadget42

  • Hero Member
  • *****
  • Posts: 787
Re: Tiny Core v12.0
« Reply #28 on: July 05, 2021, 03:25:08 PM »
Please note that glibc has been recompiled using uname_hack to force it to compile for i486.

rootfs.gz and the *Core* iso's have been replaced with ones containing the new glibc - as there is no corresponding change to CorePure, the version number has not been changed.

There is no need to update unless you have an i486 or similar.

downloaded, good md5sum, good cd burn(boots fine in other machines), still fails on the amd k6-2 166mhz machine. using debug i get:

traps: wbar[1181] trap invalid opcode ip:b7ac0484 sp:bf97ad58 error:0 in libgcc_s.so.1[b7ac0000+16000]

sorry to be the bearer of bad news.
The fluctuation theorem has long been known for a sudden switch of the Hamiltonian of a classical system Z54 . For a quantum system with a Hamiltonian changing from... https://forum.tinycorelinux.net/index.php/topic,25972.msg166580.html#msg166580

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14812
Re: Tiny Core v12.0
« Reply #29 on: July 07, 2021, 04:35:15 AM »
libgcc_s.so.1 and libstdc++.so.6.0.28 have been recompiled using uname_hack to force i486.

rootfs.gz and the *Core* iso's have been replaced with ones containing the new gcc files - as there is no corresponding change to CorePure64, the version number has not been changed.

There is no need to update unless you have an i486 or similar.