mastouille.fr est l'un des nombreux serveurs Mastodon indépendants que vous pouvez utiliser pour participer au fédiverse.
Mastouille est une instance Mastodon durable, ouverte, et hébergée en France.

Administré par :

Statistiques du serveur :

589
comptes actifs

#define

1 message1 participant0 message aujourd’hui
Suite du fil

So now I have a bunch of this in my code

#undef EXCEPTION_HANDLER
#define EXCEPTION_HANDLER myhandler

Then a block of code followed by

#undef EXCEPTION_HANDLER
#define EXCEPTION_HANDLER default_exception_handler

Is it jank? Yes, extremely. Does it do what I need it to do? Also yes. Do I feel embarrassed about this in any way? Not at all

A répondu dans un fil de discussion

@malwaretech Reminds me of the time when I learned to develop in C++ using the Allegro library for game programming.

Because of its Amiga roots and not daring to break existing code, all the functions with "palette" in the name had a `#define`'d alias with the spelling `pallete`.

/*
* It just makes sense when the shrinker is also MEMCG_AWARE for now,
* non-MEMCG_AWARE shrinker should not have this flag set.
*/
#define SHRINKER_NONSLAB BIT(4)

meanwhile two filesystems set this without MEMCG_AWARE

A répondu dans un fil de discussion

I'm going to start adding 8086/V30 support.

The easiest thing to do would be to have a #define for it, but that would require reuploading the sketch every time you wanted to switch CPUs. I don't like that, so I think I should auto-detect what CPU you have.

#AcademicFeministFightClub
#ESR #VSS #MetooESR

Quatre victimes ont dénoncé 4 agressions sexuelles et une « relation forcée qui a abouti sur des rapports sexuels à plusieurs reprises » par le directeur du CROUS de #Bordeaux. 3 autres victimes identifiées à #Grenoble.
"Le responsable régional du Crous est toujours en poste. « À ce stade, rien ne justifie de prendre des mesures à titre conservatoire », commente le ministère. Les services expliquent que de simples «allégations anonymes» ne permettraient pas, selon lui, de prendre de sanction."
#Define conservatoire

europesays.com/fr/105457/

France · Le directeur du Crous de Bordeaux visé par une enquête pour agressions sexuelles : que sait-on ? - France | République françaiseLa révélation est tombée vendredi 16 mai via une dépêche AFP. L’entourage du ministre de l’Enseignement supérieur a dévoilé qu’une enquête administrative
A répondu dans un fil de discussion

@ariadne the CFLAGS bit didn't seem to work. The output is nearly the same but with an extra warning:

#13 444.0 /usr/lib/perl5/core_perl/CORE/config.h:5262: warning: "USE_THREADS" redefined
#13 444.0 5262 | #define USE_THREADS /**/
#13 444.0 |
#13 444.0 <command-line>: note: this is the location of the previous definition

Not sure we can use our own modified version as you suggested. May try refactoring away Moops to ditch this module instead. Thanks for trying!

A répondu dans un fil de discussion

@thephd
This works to define rsize_t:

#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>

use “xcrun clang -dD -E file.c”, do the same thing with the broken configuration, see where things go wrong. If you do find there’s a problem with the macOS SDK, that sounds fixable

inspired by @pinskia mentioning musttail, today I learned that you can implement state machines in C such that state transitions are implemented as calls:

#include <stdlib.h>
#include <stdio.h>

#define VOID __attribute__((noinline)) void
#define JUMP [[clang::musttail]] return

static char *input;
static int acc = 0;
static int state = 0;

VOID initial_state(void);

VOID digit(void) {
acc += *(input++) - '0';
JUMP initial_state();
}
VOID separator(void) {
state = acc;
acc = 0;
input++;
JUMP initial_state();
}
VOID add(void) {
state += acc;
acc = 0;
input++;
JUMP initial_state();
}
VOID minus(void) {
state -= acc;
acc = 0;
input++;
JUMP initial_state();
}

VOID initial_state(void) {
switch (*input) {
case '0'...'9':
JUMP digit();
case ' ':
JUMP separator();
case '+':
JUMP add();
case '-':
JUMP minus();
default:
printf("result: %d\n", state);
exit(0);
}
}

int main(int argc, char **argv) {
puts("welcome to my calculator");
input = argv[1];
initial_state();
}

compiles to stuff like this, all jumps:

add:
mov eax, dword ptr [rip + acc]
add dword ptr [rip + state], eax
mov dword ptr [rip + acc], 0
inc qword ptr [rip + input]
jmp initial_state

And the security benefits are obvious! The less stack you have, the less potential for the stack pointer being hijacked! 😆

Suite du fil

I love finding a function that does nothing and is called from 100 places with a debug string.

SOMEONE TURNED OFF A #DEFINE AND THEIR COMPILER DOESN'T KNOW WHAT OPTIMIZATION IS

En réponse à Jann Horn

@jann I mean equally:

#define _GNU_SOURCE
#include <err.h>
#include <stdio.h>
#include <sys/mman.h>
int main(void) {
char *p = mmap(NULL, 0x2000, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
if (p == MAP_FAILED) err(1, "mmap");
p[0x1000] = 'X';
if (madvise(&p[0x1000], 0x1000, MADV_DONTNEED)) err(1, "madvise");
// that 'X' we just wrote... is it gone?
// nope, let's bring it back!
printf("p[0x1000]='%c'\n", p[0x1000]);
}

fun Linux fact: because MAP_SHARED|MAP_ANONYMOUS is actually a file-backed mapping under the hood, unmapping part of such a mapping does not discard the data stored in that part:

$ cat mremap.c
#define _GNU_SOURCE
#include <err.h>
#include <stdio.h>
#include <sys/mman.h>
int main(void) {
char *p = mmap(NULL, 0x2000, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
if (p == MAP_FAILED) err(1, "mmap");
p[0x1000] = 'X';
if (munmap(p+0x1000, 0x1000)) err(1, "munmap");
// that 'X' we just wrote... is it gone?
// nope, let's bring it back!
p = mremap(p, 0x1000, 0x2000, MREMAP_MAYMOVE);
if (p == MAP_FAILED) err(1, "mremap");
printf("p[0x1000]='%c'\n", p[0x1000]);
}
$ gcc -o mremap mremap.c
$ ./mremap
p[0x1000]='X'
$