From c14d7fa3b8dfbdedd8ac7672ed537a67be956721 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 10 Jul 2017 21:28:55 +0200 Subject: [PATCH] Fix namespace pollution for strict C. --- kernel/include/sortix/signal.h | 8 -------- libc/include/signal.h | 31 ++++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/kernel/include/sortix/signal.h b/kernel/include/sortix/signal.h index 23c4c85a..7c0df05d 100644 --- a/kernel/include/sortix/signal.h +++ b/kernel/include/sortix/signal.h @@ -22,10 +22,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - #define SIGHUP 1 /* Hangup */ #define SIGINT 2 /* Interrupt */ #define SIGQUIT 3 /* Quit */ @@ -69,8 +65,4 @@ extern "C" { #define SIG_DFL ((void (*)(int)) 0) #define SIG_IGN ((void (*)(int)) 1) -#ifdef __cplusplus -} /* extern "C" */ -#endif - #endif diff --git a/libc/include/signal.h b/libc/include/signal.h index 373ab257..43ef3644 100644 --- a/libc/include/signal.h +++ b/libc/include/signal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, 2013, 2014, 2016 Jonas 'Sortie' Termansen. + * Copyright (c) 2011, 2012, 2013, 2014, 2016, 2017 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -22,28 +22,32 @@ #include +#if __USE_SORTIX || __USE_POSIX #include +#endif +#if __USE_SORTIX || __USE_POSIX #if !defined(__is_sortix_libk) && !defined(__is_sortix_kernel) #include <__/pthread.h> #endif +#endif +#include + +#if __USE_SORTIX || __USE_POSIX #include #include #include -#include -#include #include #include #include #include #include #include - -#ifdef __cplusplus -extern "C" { #endif +#if __USE_SORTIX || __USE_POSIX + #ifndef __uid_t_defined #define __uid_t_defined typedef __uid_t uid_t; @@ -72,22 +76,31 @@ typedef __pthread_attr_t pthread_attr_t; typedef __pthread_t pthread_t; #endif -#endif +#endif /* !defined(__is_sortix_libk) && !defined(__is_sortix_kernel) */ #define NSIG __SIG_MAX_NUM +#endif /* __USE_SORTIX || __USE_POSIX */ + typedef int sig_atomic_t; #define MINSIGSTKSZ 2048 #define SIGSTKSZ 8192 +#ifdef __cplusplus +extern "C" { +#endif + +int raise(int sig); +void (*signal(int, void (*)(int)))(int); + +#if __USE_SORTIX || __USE_POSIX int kill(pid_t, int); int killpg(pid_t, int); void psiginfo(const siginfo_t*, const char*); void psignal(int, const char*); /* TODO: int pthread_kill(pthread_t, int); */ int pthread_sigmask(int, const sigset_t* __restrict, sigset_t* __restrict); -int raise(int sig); int sigaction(int, const struct sigaction* __restrict, struct sigaction* __restrict); int sigaddset(sigset_t*, int); int sigaltstack(const stack_t* __restrict, stack_t* __restrict); @@ -97,7 +110,6 @@ int sigemptyset(sigset_t*); int sigfillset(sigset_t*); int sigisemptyset(const sigset_t*); int sigismember(const sigset_t*, int); -void (*signal(int, void (*)(int)))(int); int signotset(sigset_t*, const sigset_t*); int sigorset(sigset_t*, const sigset_t*, const sigset_t*); int sigpending(sigset_t*); @@ -108,6 +120,7 @@ int sigsuspend(const sigset_t*); const struct timespec* __restrict); */ /* TODO: int sigwait(const sigset_t* __restrict, int* __restrict); */ /* TODO: int sigwaitinfo(const sigset_t* __restrict, siginfo_t* __restrict); */ +#endif #ifdef __cplusplus } /* extern "C" */