summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2025-10-31 15:55:01 +0100
committerjvoisin2025-10-31 22:16:21 +0100
commit4a26785c0cab4686e5825fe5f5e921d12e7142b7 (patch)
tree891e07545e0835b7979c3fe8627a1febc68ef4cc
parentf46714c2f9eb13c12c8218f1b7c045182041fdc9 (diff)
Add `swab`
Co-Authored-By: Sertonix <sertonix@posteo.net>
-rw-r--r--include/unistd.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/unistd.h b/include/unistd.h
index 3e5c040..4c18b73 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -158,6 +158,22 @@ _FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s,
158 return __orig_write(__f, __s, __n); 158 return __orig_write(__f, __s, __n);
159} 159}
160 160
161#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
162#undef swab
163
164_FORTIFY_FN(swab) void swab(const void * _FORTIFY_POS0 __os,
165 void * _FORTIFY_POS0 __od, ssize_t __n)
166{
167 size_t __bs = __bos(__os, 0);
168 size_t __bd = __bos(__od, 0);
169
170 if ((size_t)__n > __bs || (size_t)__n > __bd)
171 __builtin_trap();
172 return __orig_swab(__os, __od, __n);
173}
174
175#endif
176
161#ifdef __cplusplus 177#ifdef __cplusplus
162} 178}
163#endif 179#endif