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
This commit is contained in:
Axel Dörfler 2006-12-13 16:26:43 +00:00
parent caddb025c9
commit 8f813eeb9d
4 changed files with 91 additions and 0 deletions

View File

@ -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 <signal.h>
#ifdef __cplusplus
extern "C" {
#endif
int sigsetmask(int mask);
int sigblock(int mask);
#ifdef __cplusplus
}
#endif
#endif /* _BSD_SIGNAL_H_ */

View File

@ -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 <sys/param.h>
#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_ */

View File

@ -10,6 +10,7 @@ SharedLibrary libbsd.so :
getpass.c
issetugid.c
progname.c
signal.c
stringlist.c
unvis.c
vis.c

37
src/libs/bsd/signal.c Normal file
View File

@ -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 <signal.h>
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;
}