usr.sbin/sysinst: menus.mi

martin: #ifdef remove_menu_options() like all it's callers to avoid stupid
compiler warnings.

http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.sbin/sysinst/menus.mi.diff?r1=1.32&r2=1.33

@azonenberg @hazelnoot

#ifdef __ARCH_WANT_SYS_FORK
SYSCALL_DEFINE0(fork)
{
#ifdef CONFIG_MMU
struct kernel_clone_args args = {
.exit_signal = SIGCHLD,
};

return kernel_clone(&args);
#else
/* can not support in nommu mode */
return -EINVAL;
#endif
}
#endif

fork internally just calls clone with some default arguments

@nullenvk

for example:

1. think of the most orthogonal, elegant, simple way of expressing the logic you want to express
2. observe that it's not backwards compatible
3. add an ugly if at the start that handles the differences in a backwards-compatible manner, and prints a warning
4. put that in an #ifdef to see if it works without it as well

ofc implementing the old behaviour as a wrapper around the new behaviour is also good, but not always possible

@alwayscurious @ireneista Yes, the patches are one per file, and there are plenty that are small, but:

grep #ifdef * | wc -l 20

@emaste The openbsd developer who sent me a patch was doing:

int status = (ioctl(fd, DIOCGDINFO, &lab) >= 0);
*size = lab.d_secsize * lab.d_nsectors;

And mostly I'm trying to find stuff that works the same for openbsd, netbsd, and freebsd. I got pointed at the e2fsprogs #ifdef staircase which is... very large. (Currently arguing with QEMU about something else...)

sys/uvm/pmap: pmap_tlb.c

skrll: Remove some #ifdef DIAGNOSTIC / #endif by using __diagused, etc

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/uvm/pmap/pmap_tlb.c.diff?r1=1.67&r2=1.68

@soupborsh hi, this kind of AliExpress special so nothing fancy. Pretty sure it worked with volt-modded ch341a in the past (but I lost both CH341A and FT232H at some point, probably borrowed it to someone at $hacker_event) and I was left with just a stack of PiPicos instead (besides, with how slow CH341A is I wouldn’t want to use it anyway, you can lay an egg while waiting for it to finish)

The most annoying part is that I poked it with a scope (on SPI flash pins) and everything seemed fine, voltage was right, I was getting a clock signal and CS line pulled high while probing, but flash{rom,prog} wouldn’t detect the flash even at 1MHz (and it’s not the first time it happened).

At first I thought my coworker’s code was at fault (https://github.com/9elements/picoprog), but then I tried https://codeberg.org/libreboot/pico-serprog (with patch below) and it also did not work:

diff --git a/main.c b/main.c index b06f92f..9277141 100644 --- a/main.c +++ b/main.c @@ -62,7 +62,7 @@ static void pullup_cs(uint pin) { gpio_pull_up(pin); } -static void enable_spi() { +static void enable_spi(int baud) { #ifdef PICO_DEFAULT_LED_PIN /* Setup status LED */ gpio_init(PICO_DEFAULT_LED_PIN); @@ -217,7 +217,7 @@ void s_cmd_s_spi_freq() { void s_cmd_s_pin_state() { if (readbyte_blocking()) - enable_spi(); + enable_spi(baud); else disable_spi(); sendbyte_blocking(S_ACK);

@mirabilos @whitequark I have not seen a single "immense hack so that othes libcs work as expected" that someone "had to do".

Generally, the code they already had was using blatent glibcisms and was missing #ifdef __GLIBC__ around it.

@regehr Leave things implementation-defined. Let the x86s have their segmented memory models. Let the source code be machine and implementation specific. So what? We already know how to #ifdef for porting between different OSs and platforms, and the need for adaptation to different platforms will never go away. So wishing for perfect source portability on an ideal abstract machine is futile anyway. It's an invalid justification for these definedness rules.