Live data from Hacker News

Let's Destroy C

gist.github.com

21–30 of 192 posts

Re: Let's Destroy C

#21
post #2

the best thing about this was discovering https://git.sr.ht/

I love the simple and lightweight interface, but everything is hard to discover. Sourcehut? Sounds great- I'd love to replace my Gogs/gitlab instance with something more lightweight. Let's download the source and run it. I guess click on "git" on https://git.sr.ht/ ? Wait that's where I already am with no indication that that is the selected tab. Ok maybe the link for sourcehut? https://sourcehut.org/ Cool. There's s…

It sounds like you're going to the main page, expecting to download it and deploy it yourself.

It isn't surprising that the main interface is pointing you to _use_ it, rather than deploy it.

If you click on the help hub, _man_, you'll find what you're looking for straight away:

> Hacking on or deploying sourcehut yourself? Resources here.

---

> I guess click on "git" on https://git.sr.ht/? Wait that's where I already am with no indication that that is the selected tab.

That's incorrect. If you look to the left of the nav bar, you'll see some text with red highlighting exactly where you are.

> I still have no idea what language this project is written in, how to deploy or maintain it.

If you click the dev resources link, then you'll find this nice and obvious quote:

> sr.ht core is a Python package that provides shared functionality across all sr.ht services. It also contains the default templates and stylesheets that give sr.ht a consistent look and feel.

Re: Let's Destroy C

#25
post #10

GNU lambdas are incredibly evil. In order for lambdas to capture their environment and yet still be available as a function pointer, the compiler makes the stack executable and stores the trampoline code on the stack. C++ lambdas don't suffer from this problem.

GNU doesn't really have lambdas. This is an abuse of the compound statement macro.

IIRC compound statements, like I've presented, don't use trampolines. Nested functions definitely do, but that isn't quite what we're doing here.

GCC _should_ compile using descriptors for the compound statements that lambda is expanding to instead of using trampolines.

    gcc -fno-trampolines -I. examples/lambda.c
Works. There's no trampoline present.

Re: Let's Destroy C

#26
post #24

This is amazing. Are there any larger examples that uses more of the functionality of the library that I could read?

Whilst it uses an older version of CNoEvil, and I haven't updated it yet, the largest application is probably evilshell [0].

There's also all the examples [1].

[0] https://git.sr.ht/~shakna/evilshell

[1] https://git.sr.ht/~shakna/cnoevil3/tree/master/examples

Re: Let's Destroy C

#28
post #25
post #10

GNU lambdas are incredibly evil. In order for lambdas to capture their environment and yet still be available as a function pointer, the compiler makes the stack executable and stores the trampoline code on the stack. C++ lambdas don't suffer from this problem.

GNU doesn't really have lambdas. This is an abuse of the compound statement macro. IIRC compound statements, like I've presented, don't use trampolines. Nested functions definitely do, but that isn't quite what we're doing here. GCC _should_ compile using descriptors for the compound statements that lambda is expanding to instead of using trampolines. gcc -fno-trampolines -I. examples/lambda.c Works. There's no tramp…

What's `readelf -l a.out` say for GNU_STACK flags?

I'd try myself but my gcc doesn't recognize -fno-trampolines.

Re: Let's Destroy C

#30
post #25

Earlier quoted context omitted.

GNU doesn't really have lambdas. This is an abuse of the compound statement macro. IIRC compound statements, like I've presented, don't use trampolines. Nested functions definitely do, but that isn't quite what we're doing here. GCC _should_ compile using descriptors for the compound statements that lambda is expanding to instead of using trampolines. gcc -fno-trampolines -I. examples/lambda.c Works. There's no tramp…

What's `readelf -l a.out` say for GNU_STACK flags? I'd try myself but my gcc doesn't recognize -fno-trampolines.

RW
Post reply on HN