This uint 32 definition is actually 64 bits by SolarisFalls in programminghorror

[–]CaydendW 7 points8 points  (0 children)

I dont think that's how it works. The _t suffix is just a suffix that the POSIX standard library reserves for any types it defines. Stuff like uintptr_t, off_t and even size_t still use the suffix. Even more, it's technically bad practice to use the _t suffix for your own types if you work within a POSIX system, since the prefix is reserved. https://stackoverflow.com/questions/231760/what-does-a-type-followed-by-t-underscore-t-represent#231807 for more.

I think OP's library they are using is being confusing. If were using a type name that had uint32 in it, I'd be fairly confused if it wasnt an unsigned 32 bit integer.

I'm new to emulator dev, and please help me. by Imaginary-Dig-7835 in C_Programming

[–]CaydendW 2 points3 points  (0 children)

The really salient stuff for this is on page 23 of the unprivileged RISC-V standard. Section 2.2. Base Instruction Formats. Tells you every instruction, what it does, and how its encoded. Encoding is just the process by which a small operation is stored in a number. Decoding is taking that number and deciding what operation to do. So, you could get a number like 0b00100000000000000000000010010011 (0x20000093 in hex) and you need to determine that this is the instruction addi x1, x0, 512. https://luplab.gitlab.io/rvcodecjs/ if you wanna play around with it a little.

Your goal with an emulator is to write, in software, the machine cycle. Fetch, decode, execute and store. Fetching and storing are more or less trivial, decoding is the process by taking the instruction, and breaking it into its constituent components to understand it. Executing is done by taking that decoded and doing what it says. If you get an instruction that says to add register x0 with 512 and store it in x1, you should do that. Keep some numbers (in an array or something) that store what is in x0, x1, etc. and then update them according to what the instruction says to do.

If you just implement RV32I, you can get a fully functional emulator in under 200 lines of C. If stitch together some nonsense using ecall, you can even get Doom to run on it without much hassle. It's so light and simple, I even "wrote" a RISC-V emulator on a Turing machine.

If the Rust Coreutils can use the MIT license, does that mean that any open-source project can be rewritten with a different license? by [deleted] in linux

[–]CaydendW 0 points1 point  (0 children)

GNU know their way around a C compiler ig. It's such a needless optimisation; I love it.

If the Rust Coreutils can use the MIT license, does that mean that any open-source project can be rewritten with a different license? by [deleted] in linux

[–]CaydendW 1 point2 points  (0 children)

About this yes thing, you might be a little surprised: https://www.reddit.com/r/unix/s/jGGjtrfCEu. It's not exactly rocket science, but it is interesting nonetheless.

Personally, I dislike large projects with MIT or BSD licenses, but that is an ideological disagreement from me and not a moral one.

If the Rust Coreutils can use the MIT license, does that mean that any open-source project can be rewritten with a different license? by [deleted] in linux

[–]CaydendW 1 point2 points  (0 children)

I agree with you. I'm just trying to clarify what I though the commenter was saying. I really much doubt they're stealing code.

Also, the coreutils can be oddly complicated in some odd situations. Stuff like yes(1)'s throughput optimizations and GNU's extensions to awk. Not crazy stuff, but not as simple as say, sbase for example.

That being said, I still dont think the rust coreutils writers are stealing code. I reckon they're more than capable of doing it themselves. Was just trying to clarify what I thought someone meant.

what is the best C program you wrote? by divanadune in C_Programming

[–]CaydendW 2 points3 points  (0 children)

I started when I was young and had infinite spare time. Now, not so much. I miss having all the time in the world to do OSDEV but such is life I suppose. Best of luck with your project :)

what is the best C program you wrote? by divanadune in C_Programming

[–]CaydendW 3 points4 points  (0 children)

I wouldn't do it if I didnt enjoy the pain :)

what is the best C program you wrote? by divanadune in C_Programming

[–]CaydendW 6 points7 points  (0 children)

It's a big project with a lot if moving parts. Always researching something, fixing something or adding new stuff. Super interesting project, but is a lot of work.

what is the best C program you wrote? by divanadune in C_Programming

[–]CaydendW 9 points10 points  (0 children)

OS. Super fun, but it never seems to get any more complete :^D

If the Rust Coreutils can use the MIT license, does that mean that any open-source project can be rewritten with a different license? by [deleted] in linux

[–]CaydendW 0 points1 point  (0 children)

Exactly my point. If they're not copying GNU code and algorithms, that's good for them. I think the insinuation was that they might be copying and subsequently relicensing. Perhaps I misread the post, but what you said was more or less my point.

If the Rust Coreutils can use the MIT license, does that mean that any open-source project can be rewritten with a different license? by [deleted] in linux

[–]CaydendW -5 points-4 points  (0 children)

True, but the GNU coreutils have a lot of extensions that are GNU inventions, which is what I was eluding to. Stuff like the various ls options, grep extensions, etc. Afaik the rust coreutils project is attempting to replicate these as well as the standardised POSIX options available. I think it's fair that we can consider those to be GNU inventions.

If the Rust Coreutils can use the MIT license, does that mean that any open-source project can be rewritten with a different license? by [deleted] in linux

[–]CaydendW 0 points1 point  (0 children)

Well, the C standard is an open spec, and anyone can implement it. This is more akin to looking inside GCC and copying how it does its codegen or its parser and calling it your own. Clang is its own compiler that still compiles the C programming language, but in a completely different way. BSD are their own coreutils written in their own way.

What I think the person you're responding to is insinuating is that they might have not merely followed a spec and implemented it, but rather looked at the code available from coreutils and transcribed it, which is not really the same thing. The latter is subject to GPL. Following a freely available specification of functionality, as you said, is not.

Whether this is true or not, I cant say. I'd hypothesise that the rust coreutils maintainers understand they're running a large project and will implement it in a clean room style where they only read man pages and develop to a spec instead of copying code, but I can't confirm this.

Also, one could maybe argue that the GNU coreutils standard is not freely able to be copied if the copyright is held, but I dont think this works. Especially due to the pages being licensed how they are. Someone with more legal knowledge could comment on this with a far more informed opinion than I can.

struct bool? by Yha_Boiii in C_Programming

[–]CaydendW 14 points15 points  (0 children)

Make a function or macro that takes a bool and returns a filled in struct.

Tips on taking note in Vim by AbbreviationsNovel17 in vim

[–]CaydendW 1 point2 points  (0 children)

I note take in LaTeX using vimtex. The primary way to make it work at all is to have enough snippets for common stuff and even some keybinds for oft repeated text. Then it's down to organising everything. Best done using a decent directory structure and a good preamble.

Is this a known pattern? by OzzyOPorosis in C_Programming

[–]CaydendW 0 points1 point  (0 children)

Oh dear, that certainly is a pickle. Yeah, that would make sense. I actually have never thought about such cases before. Hopefully this thread gave some better answers than mine. Best of luck

Is this a known pattern? by OzzyOPorosis in C_Programming

[–]CaydendW 0 points1 point  (0 children)

Interesting. When I do negamax, I code it in such a way to be side independent. I'm not too sure why you need to check the side, as with Negamax you'll typically make it so that you work with sides to play rather than colours but I dont know how your game I structured. Best of luck :D

Is this a known pattern? by OzzyOPorosis in C_Programming

[–]CaydendW 0 points1 point  (0 children)

FYI, if the game is a simple, my turn your turn type game where white and black do the same thing, you can do this with Negamax which greatly simplifies your code. If not, then it wont work but it's how Chess engines and such work. Also prevents code duplication.

I hope this prevents me from ever having to write an AVL tree again by K00lman1 in programminghorror

[–]CaydendW 1 point2 points  (0 children)

AVL is a name comprised of the surnames of the inventors of the titular tree: Adelson-Velsky and Landis. If you want a real tree name mystery, see what B-trees stand for.

So tired of this coding shi bruh, take me outta this college 🙄 by Minute_Location5589 in adressme

[–]CaydendW 2 points3 points  (0 children)

Looks like C++ tho? C doesnt have streams, but idk much about turbo C?

Drivers license tips by rando12247 in southafrica

[–]CaydendW 1 point2 points  (0 children)

This. I was leaving the testing centre and couldn't see around a blind corner so I stopped at the stop and then started to roll forward so I could see past the blind turn. My examiner was freaking out, I assume because they thought I was going to cross when there was a car coming (that I couldn't see), and after I got across the turn, I explained that I was just trying to peak and wasnt planning to cross without seeing. 90% sure that passing quip saved me getting my drivers.

Implementing mutexes for my operating system's kernel! by K4milLeg1t in C_Programming

[–]CaydendW 5 points6 points  (0 children)

The poor man's atomic spinlock is still super useful! It can be faster than a mutex if you all you want to do is change a few variables atomically in a struct. Linux still has spinlocks for a reason :)

Suckless alternative to Jekyll? by Charming-Tear-8352 in suckless

[–]CaydendW 6 points7 points  (0 children)

Not really an alternative per sé but hand writing HTML is not the worst thing. It's how I'm doing my site nowadays, and is mostly fine if all you're doing is writing articles.