From 8f813eeb9d455e58e647f355cd583d284e297059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 13 Dec 2006 16:26:43 +0000 Subject: [PATCH] More tweaks to the libbsd.so compatibility library: * added sigsetmask(), and sigblock() * added ALIGN(), ALIGNBYTES, and howmany() macros git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19493 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/compatibility/bsd/signal.h | 23 +++++++++++++++++ headers/compatibility/bsd/sys/param.h | 30 ++++++++++++++++++++++ src/libs/bsd/Jamfile | 1 + src/libs/bsd/signal.c | 37 +++++++++++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 headers/compatibility/bsd/signal.h create mode 100644 headers/compatibility/bsd/sys/param.h create mode 100644 src/libs/bsd/signal.c diff --git a/headers/compatibility/bsd/signal.h b/headers/compatibility/bsd/signal.h new file mode 100644 index 0000000000..a9ef3abf1b --- /dev/null +++ b/headers/compatibility/bsd/signal.h @@ -0,0 +1,23 @@ +/* + * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _BSD_SIGNAL_H_ +#define _BSD_SIGNAL_H_ + + +#include_next + + +#ifdef __cplusplus +extern "C" { +#endif + +int sigsetmask(int mask); +int sigblock(int mask); + +#ifdef __cplusplus +} +#endif + +#endif /* _BSD_SIGNAL_H_ */ diff --git a/headers/compatibility/bsd/sys/param.h b/headers/compatibility/bsd/sys/param.h new file mode 100644 index 0000000000..37858057bf --- /dev/null +++ b/headers/compatibility/bsd/sys/param.h @@ -0,0 +1,30 @@ +/* + * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _BSD_SYS_PARAM_H_ +#define _BSD_SYS_PARAM_H_ + + +#include_next + + +#ifndef _ALIGNBYTES +# define _ALIGNBYTES 7 +#endif +#ifndef _ALIGN +# define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) +#endif + +#ifndef ALIGNBYTES +# define ALIGNBYTES _ALIGNBYTES +#endif +#ifndef ALIGN +# define ALIGN(p) _ALIGN(p) +#endif + +#ifndef howmany +# define howmany(x, y) (((x) + ((y) - 1)) / (y)) +#endif + +#endif /* _BSD_SYS_PARAM_H_ */ diff --git a/src/libs/bsd/Jamfile b/src/libs/bsd/Jamfile index e1147491d9..65f9e2c032 100644 --- a/src/libs/bsd/Jamfile +++ b/src/libs/bsd/Jamfile @@ -10,6 +10,7 @@ SharedLibrary libbsd.so : getpass.c issetugid.c progname.c + signal.c stringlist.c unvis.c vis.c diff --git a/src/libs/bsd/signal.c b/src/libs/bsd/signal.c new file mode 100644 index 0000000000..2e58618bb9 --- /dev/null +++ b/src/libs/bsd/signal.c @@ -0,0 +1,37 @@ +/* + * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, axeld@pinc-software.de + */ + + +#include + + +int +sigsetmask(int mask) +{ + sigset_t set = mask; + sigset_t oset; + + if (sigprocmask(SIG_SETMASK, &set, &oset) < 0) + return -1; + + return (int)oset; +} + + +int +sigblock(int mask) +{ + sigset_t set = mask; + sigset_t oset; + + if (sigprocmask(SIG_BLOCK, &set, &oset) < 0) + return -1; + + return (int)oset; +} +