GithubHelp home page GithubHelp logo

Alignment and sizes about mrustc HOT 9 CLOSED

thepowersgang avatar thepowersgang commented on August 25, 2024
Alignment and sizes

from mrustc.

Comments (9)

glaubitz avatar glaubitz commented on August 25, 2024

m68k (gcc 8.2.0):

Type         Alignment/Bytes  Size/Bytes
int8_t       1                1
int16_t      2                2
int32_t      2                4
int64_t      2                8
__int128     not supported
uint8_t      1                1
uint16_t     2                2
uint32_t     2                4
uint64_t     2                8
float        2                4
double       2                8
long double  2                12
size_t       2                4
off_t        2                4
void*        2                4

from mrustc.

eddyp avatar eddyp commented on August 25, 2024

Does it make sense to have the alignments and sizes for other compilers than gcc/llvm?

from mrustc.

daym avatar daym commented on August 25, 2024

I don't know, you tell me. Though if the libraries these compilers create interoperate with libraries other compilers create then those alignments and sizes have to be equal between compilers anyway.

from mrustc.

glaubitz avatar glaubitz commented on August 25, 2024

Alignment sizes are dictated by the ABI which is usually independent of the compiler used.

See for example: https://wiki.osdev.org/System_V_ABI

from mrustc.

eddyp avatar eddyp commented on August 25, 2024

@glaubitz sure, but offsets are, AFAICT, implementation specific in the sense that there's no restriction to put a uint16_t in the first 2 bytes or the last ones in a struct where the uint16_t is before a uint32_t.

from mrustc.

glaubitz avatar glaubitz commented on August 25, 2024

But wouldn't that make any code compiled with a different compiler ABI-incompatible with standard Linux environments, for example?

from mrustc.

eddyp avatar eddyp commented on August 25, 2024

It would. But I mostly thinking of bare metal code and embedded systems where the problem is not that obvious and using the same compiler is the go to solution.

from mrustc.

glaubitz avatar glaubitz commented on August 25, 2024

Okay, but bare-metal code doesn't use the SysV ABI anyway, so we're talking about different things then.

from mrustc.

thepowersgang avatar thepowersgang commented on August 25, 2024

There are now assertions in the generated C code to ensure that the size+alignment match what mrustc expected.

from mrustc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.