Commit Graph

91 Commits

Author SHA1 Message Date
Jérôme Duval
8b5cc9cf52 libroot: move memmem for POSIX.1/2024
Change-Id: I1b051586c993cd0e3d43abaa22a3722699f7134e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8517
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-04 17:55:40 +00:00
Augustin Cavalier
8bacd281ba sys/param.h: Cleanup.
* Minor tweaks to POSIX sys/param.h for style.

 * Don't redefine alignment macros in BSD sys/param.h even conditionally.
   And add a few more macros from the real BSD sys/param.h, for convenience.
   (Most of these are also declared in musl and glibc's sys/param.h)
2024-10-14 13:53:54 -04:00
Augustin Cavalier
90dca2bc8e headers: Change most remaining include guards to _DEFAULT_SOURCE.
We automatically enable _DEFAULT_SOURCE if _GNU_SOURCE is defined.
Rather than having even more optional methods undefined unless
_GNU_SOURCE manually is, just change all remaining guarts to
use _DEFAULT_SOURCE instead.

Fixes #19095.

Change-Id: I5c7baf40b7fb37913e24279589fc1ae706448a45
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8330
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-09-19 16:43:31 +00:00
Jérôme Duval
1754f053a3 pthread: add PTHREAD_MAX_NAMELEN_NP for pthread_setname_np
Change-Id: I52e9e8a672f76048e1ff0c4a6ddeeecb2d134a5a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8259
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
2024-09-09 14:41:35 +00:00
Augustin Cavalier
4944d70dd1 sys/uio.h: Use __inline instead of inline for C89 compatibility.
Fixes https://github.com/haikuports/haikuports/issues/10822.
2024-08-24 14:55:07 -04:00
Joachim Mairböck
e595b7fd4b headers/bsd: fix comments after #endif
gcc2 complains otherwise when using -ansi -pedantic-errors that
"text afer `#endif' violates ANSI standard" because it doesn't
recognize C++ comments in C mode.

Change-Id: Icb091d15a4324625ce305aa89391c44a94f4a38e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8094
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-08-23 15:16:40 +00:00
PulkoMandy
9d62be21bf gnu/sched.h: missing features.h include
Change-Id: I5032dbf08a034df77ab4b436178d08fba2137da5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7974
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-08-10 11:26:53 +00:00
Augustin Cavalier
9a4c543934 pthread: Implement pthread_timedjoin_np.
This also corrects an oversight in pthread_join() that not all
potential error codes of wait_for_thread were accounted for
(in particular EDEADLK wasn't.)

This is a non-standard extension, but is present on both Linux
and FreeBSD, at least.

Change-Id: Ie96e7a261e863ab491bee30349360df7ff3d0e80
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5099
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-07-16 19:59:39 +00:00
Jérôme Duval
4169a972ee POSIX: move getentropy(2) from libbsd
Specified in POSIX.1-2024
https://www.austingroupbugs.net/view.php?id=1134
Change-Id: Ie715a102aa6f7764bc639e0a1874a6c7f7d81019
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7846
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-07-16 16:09:00 +00:00
Jérôme Duval
c5a740cdb2 gnu: add pthread_setaffinity_np()/pthread_getaffinity_np()
* also sched_setaffinity/sched_getaffinity() added.
* add a test

Change-Id: Id8c308788f6364f5340b4991def2fbb9a05da728
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7675
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-06-10 16:34:25 +00:00
Augustin Cavalier
6b99b20692 telnet: Synchronize with FreeBSD 13.3. 2024-05-28 16:23:27 -04:00
Trung Nguyen
1834e12564 headers/bsd: Remove Haiku-specific include deps
Remove the `ByteOrder.h` and `SupportDefs.h` Haiku-specific headers
from `bsd/endian.h` on GCC >= 4 and replace them with compiler builtins.

This prevents some unwanted symbols like `type_code` causing name
clashes in ported applications.

Change-Id: Id88791ea5954c260f4e7f5e82a564f3ae6bafe69
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7642
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-05-27 22:05:09 +00:00
Jérôme Duval
f758e73fe6 libbsd: add pthread_sigqueue()
* like sigqueue() but for threads. was added recently to FreeBSD, long before to glibc.
* also include features.h in gnu/pthread.h

Change-Id: I73bca666e2c67d7ff05f341bf85d71df9ccccbe5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7659
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-05-02 18:07:23 +00:00
Jérôme Duval
142723d197 libbsd: fix timespeccmp()
Change-Id: I5c1b1e5c4c583c0758b9f1b6eee67cb83053461d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7514
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-03-07 21:40:05 +00:00
Jérôme Duval
01dc1ea4cf libbsd: add strtonum(), nitems(), timespec operation functions from FreeBSD
Change-Id: I56b677b382d17a27d243b615de19bec10f3a2810
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7426
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-02-26 14:06:29 +00:00
Augustin Cavalier
f759ab2733 headers/compatibility/bsd: Update headers to remove BSD advertising clause.
Rewrite link.h entirely.
2023-09-21 18:38:10 -04:00
Leorize
e86afc8f75 libs/bsd: add arc4random(3)
Change-Id: I86e67484f04b062a4496cb63ccb34b990868b693
Reviewed-on: https://review.haiku-os.org/c/haiku/+/32
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-08-29 19:42:27 +00:00
Augustin Cavalier
6bde05aebd libs/bsd: Implement getentropy(2).
With generic_syscall to avoid using a FD.

Change-Id: Id1702118bb673f06a861e4f0ad3401ce3d45cbd0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/31
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2023-08-29 19:42:27 +00:00
Jérôme Duval
efbeada748 gnu: add sched_getcpu()
on x86_64 implemented with rdtscp or rdpid, generically with a syscall.

Change-Id: I8f776848bf35575abec8a8c612c4a25d8550daea
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6866
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2023-08-21 17:55:16 +00:00
Augustin Cavalier
3386b8b785 libbsd: Add a basic kqueue implementation.
It only supports file descriptors and processes (threads),
and a few flags (not all) to go with them.

This has been tested extensively against libuv.

Change-Id: I6fc5930fa7273698172c9c695965842b5df44f03
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6746
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2023-07-29 15:53:15 +00:00
Trung Nguyen
f967e2c0c7 headers/bsd: Export pthread_attr_get_np
Exported `pthread_attr_get_np` under `_DEFAULT_SOURCE`. Otherwise,
the presence of this function in `libroot.so` without a definition
would confuse some configuration scripts.

Change-Id: I623ebefc98800e9528dc48859c2aefc828821f27
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6383
Reviewed-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2023-05-08 01:38:41 +00:00
Augustin Cavalier
36e200e2e0 sys/uio: Add preadv/pwritev.
Fixes #18243.

Change-Id: Ib5867f86100430f5e5c43ce4b2d6d561f546cc1e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6068
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2023-02-24 16:31:51 +00:00
vaibhavg20comp
ba9ce9c13b termios: Added cfsetspeed function.
BSD extension to set both the input and output speed of a termios
structure.

Fixes #18220.

Change-Id: I8c4a06b4be4aa55b8ce35cb7f62552fc47a8e8d0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6049
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2023-02-17 16:16:39 +00:00
David Karoly
125b262675 libroot: introduce crypt_r
Change-Id: Ieacd1b383ac078a440227c7954f5531a36fbbd62
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5827
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2023-02-10 18:00:44 +00:00
Han Pengfei
44cceee67e pthread: add pthread_{getname_np,setname_npp}
- These two functions imported for Linux/BSD compability.

Signed-off-by: Han Pengfei <pengphei@qq.com>
Change-Id: I3e9cada26f1ed043bfaed83e8185dcfff3bd71e2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5746
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2022-10-18 16:30:54 +00:00
Augustin Cavalier
045f7a5f3a headers/bsd: Rewrite link_elf.h.
Include only the APIs we are (shortly) going to actually support.

The other structures and functions declared in this file were
never supported nor used anywhere in Haiku's tree.
2022-06-28 13:07:53 -04:00
Augustin Cavalier
0afb8a1b49 Move fts.h and functions from libroot to libbsd.
These are BSD extensions, not POSIX functions. They were needed
in libroot by the previous versions of the ftw/nftw implementations,
but the musl versions do not need them, and so we can move them to
libbsd.

This is a minor ABI break, but hopefully whatever was using them
in libroot also links to libbsd. If not, that's an easy enough fix.
(These were only added to libroot in 2013.)
2022-06-09 16:30:40 -04:00
Augustin Cavalier
7ec1bedeed features.h: Define _DEFAULT_SOURCE when _GNU_SOURCE is defined.
As suggested by PulkoMandy. This was done before my commits yesterday,
but those just reverted patches that had only been in since May,
so it's not clear how much this is actually needed. Nonetheless
it seems like the more correct thing to do.
2021-11-17 13:55:50 -05:00
Augustin Cavalier
68a13ed5c3 features.h: Clean up ISOC11 definitions.
* Do not define it merely when _GNU_SOURCE is defined, that is not needed.
 * Scale back __cplusplus check to 201103L, just like the BSDs do.
2021-11-16 15:11:44 -05:00
Zoltán Mizsei
144f45a030 features.h: enable ISOC11 definitions for _GNU_SOURCE and C++17
this is needed for GCC to build after the aligned_alloc introduction

Change-Id: Ieae32a050cc000561107c4a07cf10c912a196152
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3896
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2021-05-04 05:25:52 +00:00
Jérôme Duval
0db785d66c features.h: undef before define
Change-Id: Iba98e3a8352801345acefe963917471992f70281
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3606
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-01-07 09:14:57 +00:00
Adrien Destugues
db7dcab7b1 asprintf should be available if _GNU_SOURCE is defined
As documented in the Linux manpage:
https://man7.org/linux/man-pages/man3/asprintf.3.html
Change-Id: I855b3310ae9111ddf48c13c26b9eb496c200accb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3554
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2020-12-28 23:09:21 +00:00
Jérôme Duval
b05d6f0af0 POSIX: asprintf and vasprintf are BSD/GNU extensions
fix #16259

Change-Id: Ia16bb6e1944b87b25d1a940bbdaaf6e236db1abf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3381
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-11-07 08:49:34 +00:00
Jérôme Duval
6878792ae4 C11: add aligned_alloc()
Change-Id: If648c0e27ed946874d393e8e33a4548b70c8ecdb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3377
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-11-04 21:01:42 +00:00
CodeforEvolution
5c32512076 GNU Compatibility: Implement qsort_r
This is a version of the qsort function allowing you to pass a "cookie" to the function.

Change-Id: I60c645213b9c9590e38b112634fcac1d7969b6d9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2449
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-09-18 06:25:20 +00:00
Augustin Cavalier
4639c4e898 headers: Add exp10 declarations to gnu/math.h.
These are GNU extensions so they need to be behind _GNU_SOURCE.

Fixes #16371.
2020-07-07 20:48:58 -04:00
Kacper Kasper
827f75a766 Add missing include in bsd/sys/link_elf.h
* Doesn't build without it.

Change-Id: Ia8671f1545fee6684278e688d0a16a1147e78842
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1866
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-09-18 03:40:47 +00:00
Augustin Cavalier
47a21c5c89 s/Haiku License/MIT License/g.
They are the same thing.
2019-08-30 18:16:02 -04:00
Adrien Destugues
4950607607 Add a features.h to auto enable _DEFAULT_SOURCE
Unless __STRICT_ANSI__ is defined (as it is when running the compiler in
--std=c89 or --std=c99, but not when running it without any specific
args), we can enable these by default and behave like most other
systems. I don't know why no one has done this yet despite suggesting it
multiple times and people prefer to #define _BSD_SOURCE manually
everywhere.

Remove all places in our Jamfiles and sources where it had been defined.
_DEFAULT_SOURCE is now enabled by default for all sources of Haiku, since we
let the compiler use GNU extensions (no strict C standard specified on
command line)

Use _DEFAULT_SOURCE as the define name to match current versions of
glibc. Enable it if _BSD_SOURCE is #defined in compiler flags, for
backward compatibility.

Change-Id: I6db04da5f6db437723cdfba3478f5094a69d7727
Reviewed-on: https://review.haiku-os.org/c/1633
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2019-07-29 20:26:46 +00:00
Zoltán Mizsei
3ddf0bbc29 BSD: Use elf.h from os/kernel
Platform-dependant defines for Elf_*

Change-Id: Ib86554eb497d20e60ad7c75de4321d5b516ad88c
Reviewed-on: https://review.haiku-os.org/c/1635
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-27 15:19:31 +00:00
Adrien Destugues
58db38ed74 bsd/sys/param.h: add NBBY define
This defines the number of bits in a byte and is used in tnftpd.
Once this is merged, some patches to tnftpd can be removed.

Change-Id: Ie2d0c61ce1371daeeb8549281f4210147fb77197
Reviewed-on: https://review.haiku-os.org/c/1642
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-07-22 23:43:04 +00:00
Zoltán Mizsei
c6fd6cbba4 Import link.h and link_elf.h from FreeBSD master
Add _D_BSD_SOURCE guarding
Change-Id: I6eefe207b5e7e645cd3aec3b1981aae59793fa98
Reviewed-on: https://review.haiku-os.org/c/1620
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-07-17 22:17:49 +00:00
Jérôme Duval
ba56d0a513 pthread: add pthread_getattr_np.
non standard extension, but widely available to obtain attributes for a thread.
also provides an alias for pthread_getattr_np which is the bsd equivalent.

Change-Id: I26ef8245ed2537186f48c8b8bdf3e42b03e70892
Reviewed-on: https://review.haiku-os.org/c/1172
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2019-03-08 19:50:45 +00:00
Niels Sascha Reedijk
d7b8d76a78 BSD headers: remove _BSD_SOURCE feature gate for sysexits.h
During the compilation of LLVM version 8, the build failed because it depends
on a constant in this file. In hrev49042 all BSD headers were feature-gated by
_BSD_SOURCE. This is not done (for this file) in glibc and (obviously) not in
BSD's libc.

Since this is not common practise, I would propose removing the feature gate
for this header file, as it would mean that we would have to upstream patches
for ports of other software that depends on the availability of these
constants.

Change-Id: I486f0c2e87eff489ce92d03589a6299ef1be6ca5
Reviewed-on: https://review.haiku-os.org/c/1144
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-03-03 20:49:19 +00:00
Jérôme Duval
f33f4868fe posix_spawn: add posix_spawn_file_actions_add[f]chdir_np.
see http://austingroupbugs.net/view.php?id=1208
and https://sourceware.org/bugzilla/show_bug.cgi?id=17405

* also free paths in posix_spawn_file_actions_destroy().

Change-Id: I8bed848154025bd5a25322bdc4c25aa417f86ec6
Reviewed-on: https://review.haiku-os.org/c/1010
Reviewed-by: Rene Gollent <rene@gollent.com>
2019-02-06 16:39:33 +00:00
Augustin Cavalier
a41ed241d9 headers/compatibility: Re-add missed _BSD_SOURCE guards to vis.h 2018-12-16 21:01:03 -05:00
Augustin Cavalier
324336d1ed libbsd: Update vis and unvis from FreeBSD.
Fixes #11061.
2018-12-16 18:32:55 -05:00
Zoltán Mizsei
c95db88334 sincos, sincof, sincosl declarations in gnu/math.h
Signed-off-by: Zoltán Mizsei <zmizsei@extrowerk.com>

Change-Id: I44b39e8d76dd970e18e285b5d8b9bad715608154
Reviewed-on: https://review.haiku-os.org/715
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2018-11-19 23:14:51 +00:00
Jérôme Duval
546fafa0a1 pty.h: fix typo. 2018-08-26 12:02:52 +02:00
Alexander von Gluck IV
3a747315b2 stdlib: Add common bsd mkstemps function
Change-Id: I8c54f4b42e8b41f9a769b8b53f074a307b1a054c
2018-02-26 21:46:25 +00:00