From d969788b935456d7fb704716522900dce564c810 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 22 Aug 2018 11:24:07 +0100 Subject: [PATCH] syscall_exec16: Rework close_on_exec a bit to fix SDCC crap code generation --- Kernel/syscall_exec16.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Kernel/syscall_exec16.c b/Kernel/syscall_exec16.c index 58fc0e00..876258ec 100644 --- a/Kernel/syscall_exec16.c +++ b/Kernel/syscall_exec16.c @@ -5,10 +5,14 @@ static void close_on_exec(void) { - int j; + /* Keep the mask separate to stop SDCC generating crap code */ + uint16_t m = 1 << (UFTSIZE - 1); + int8_t j; + for (j = UFTSIZE - 1; j >= 0; --j) { - if (udata.u_cloexec & (1 << j)) + if (udata.u_cloexec & m) doclose(j); + m >>= 1; } udata.u_cloexec = 0; } -- 2.34.1