Click Here
home features news forums classifieds faqs links search
6071 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
6 crawler(s) on-line.
 105 guest(s) on-line.
 1 member(s) on-line.


 OlafS25

You are an anonymous user.
Register Now!
 OlafS25:  30 secs ago
 dreamlandfantasy:  9 mins ago
 cip060:  28 mins ago
 amigatronics:  34 mins ago
 amigakit:  43 mins ago
 zipper:  1 hr 22 mins ago
 CosmosUnivers:  1 hr 51 mins ago
 pavlor:  2 hrs 40 mins ago
 Rob:  3 hrs 40 mins ago
 agami:  6 hrs 22 mins ago

/  Forum Index
   /  Amiga General Chat
      /  Amiga Inc. Loses U.S. Trademarks
Register To Post

PosterThread
Georg 
Re: Cloanto acquire Amiga Inc Trademark
Posted on 24-Apr-2021 7:12:06
#1 ]
Regular Member
Joined: 14-May-2003
Posts: 451
From: Unknown

@michalsc

Quote:

More then you think. The most common case is working with binary data of any form. Imagine some simple check of a header of some binary file:

if (data8[0] == 'E' && data8[1] == 'L' && data8[2] == 'F')


I don't understand. This code is endianess safe no matter if compiler optimizes it into 32 bit check or not.

 Status: Offline
Profile     Report this post  
 Top | Parent

Replies
SubjectPosterDate
      Re: Cloanto acquire Amiga Inc Trademarkmichalsc24-Apr-2021 10:00:50
          Re: Cloanto acquire Amiga Inc TrademarkGeorg24-Apr-2021 15:43:20
              Re: Cloanto acquire Amiga Inc Trademarkmichalsc24-Apr-2021 16:23:19


PosterThread
tygre 
Re: Cloanto acquire Amiga Inc Trademark
Posted on 23-Apr-2021 2:54:06
#1 ]
Regular Member
Joined: 23-Mar-2011
Posts: 279
From: Montreal, QC, Canada

@michalsc

Thank you so much! This is the first and best explanation I never had about endianness and the problems that it brings! I can only repeat: More!

(I don't want to despair Number6... but let's be honest: this discussion about endianness is much more interesting than the endless one about the lawsuit(s). I truly appreciate Number6's posts and contributions; it's the never-ending follow-up "discussions" about who's right and who's wrong that I find tedious.)

Quote:

Quote:
1) How often would C code do something like that


More often then I would like to. Last example is the Capstone project which I use to disassemble aarch64 and m68k instructions in my Emu68 project. Capstone is written with endianess in mind, but still it failed for me. Since I am using AArch64 in big endian mode, capstone was showing float numbers incorrectly. Surprisingly enough, all integers and double numbers were displayed properly. Why?

After checking the source code I have noticed that the immediate operands of instructions are stored in a union like this one:

typedef union {
uint64_t i_num;
double d_num;
float f_num;
} immediate;

When analysing the opcodes, capstone was promoting all integer immediates to 64bit form and stored in i_num field. For floating point numbers it was reading the number as integer (either uint32_t or uint64_t) and storing into i_num directly without any further processing of the number.
On little endian CPUs all went just ok. Fetching any value was correct, because the data begins from the lowest address for every type. In big endian mode on AArch64 it failed, because the 32bit float number was in wrong half of the 64-bit wide field.

So you see, even if you try to be endian aware, issues can just pop out in unexpected moments :)


So "unions" are evil! (Joke intended!)

Quote:

Quote:
2) What are other "typical" C code that is not "endianness-safe"?


More then you think. The most common case is working with binary data of any form. Imagine some simple check of a header of some binary file:

if (data8[0] == 'E' && data8[1] == 'L' && data8[2] == 'F')

Compiler may optimize it to a 32bit number check (with ignoring data[3] through a mask) instead of testing one byte after another. For big endian machine such optimization could look like this:

if ((data32[0] & 0xffffff00) == 'ELF\0')

where on little endian machine it would be rather something like

if ((data32[0] & 0x00ffffff) == '\0FLE')

Thereby you have no control over it what the compiler will "optimize" for you and what not. Alone for this reason coexistence of big- and little-endian binaries and programms in a fully open OS environment as it is in case of AmigaOS and derivates is not possible. It does not work since after compilation the information about structure of the data is lost.


Ouch! I see... In such a case, is the problem only coming from the compiler optimisation? As you wrote in other posts above, would recompiling with the proper "endian" parameter remove the problem entirely?

Besides unions that should be carefully checked and binary data... are there other "constructs" that could mess up endianness?

I'm really curious

_________________
Tygre
Scientific Progress Goes Boing!

 Status: Offline
Profile     Report this post  
 Top | Parent

Replies
SubjectPosterDate
      Re: Cloanto acquire Amiga Inc Trademarkmichalsc23-Apr-2021 6:46:14


PosterThread
number6 
Re: Cloanto acquire Amiga Inc Trademark
Posted on 22-Apr-2021 11:54:22
#1 ]
Elite Member
Joined: 25-Mar-2005
Posts: 11589
From: In the village

@thread that used to be about trademarks

A500 under examination

#6

_________________
This posting, in its entirety, represents solely the perspective of the author.
*Secrecy has served us so well*

 Status: Offline
Profile     Report this post  
 Top | Parent

Replies
SubjectPosterDate
      Re: Cloanto acquire Amiga Inc Trademarknumber622-Apr-2021 12:00:38
          Re: Cloanto acquire Amiga Inc Trademarkmatthey22-Apr-2021 22:08:30
              Re: Cloanto acquire Amiga Inc Trademarkaria23-Apr-2021 1:54:15
                  Re: Cloanto acquire Amiga Inc Trademarkmatthey23-Apr-2021 5:19:37
                      Re: Cloanto acquire Amiga Inc Trademarknumber623-Apr-2021 12:33:28
                          Re: Cloanto acquire Amiga Inc TrademarkTrixie23-Apr-2021 15:56:48
                              Re: Cloanto acquire Amiga Inc Trademarknumber623-Apr-2021 16:15:55
                                  Re: Cloanto acquire Amiga Inc TrademarkRose23-Apr-2021 16:48:29
                              Re: Cloanto acquire Amiga Inc Trademarknumber627-Apr-2021 15:30:23
                          Re: Cloanto acquire Amiga Inc Trademarkmatthey23-Apr-2021 19:41:22
                              Re: Cloanto acquire Amiga Inc Trademarknumber623-Apr-2021 19:55:40
          Re: Cloanto acquire Amiga Inc Trademarknumber612-May-2021 13:08:34
      Re: Cloanto acquire Amiga Inc TrademarkA120022-Apr-2021 15:17:09
          Re: Cloanto acquire Amiga Inc Trademarknumber622-Apr-2021 15:34:07
              Re: Cloanto acquire Amiga Inc TrademarkA120022-Apr-2021 16:26:37
          Re: Cloanto acquire Amiga Inc TrademarkF0L22-Apr-2021 16:20:03



[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle