From f46714c2f9eb13c12c8218f1b7c045182041fdc9 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 26 Oct 2022 00:30:00 +0200 Subject: add initial clang support Co-Authored-By: jvoisin --- include/sys/select.h | 13 +++++++++++-- include/sys/socket.h | 13 +++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'include/sys') diff --git a/include/sys/select.h b/include/sys/select.h index 1a5afbe..265c7e1 100644 --- a/include/sys/select.h +++ b/include/sys/select.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015-2016 Dimitris Papastamos + * Copyright (C) 2022 q66 * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted. @@ -27,8 +28,14 @@ __extension__ extern "C" { #endif +#ifdef __clang__ +#define _FORTIFY_FD_POS0 const __attribute__((__pass_object_size__(0))) +#else +#define _FORTIFY_FD_POS0 +#endif + static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) -void __fortify_FD_CLR(int __f, fd_set *__s) +void __fortify_FD_CLR(int __f, fd_set * _FORTIFY_FD_POS0 __s) { size_t __b = __bos(__s, 0); @@ -38,7 +45,7 @@ void __fortify_FD_CLR(int __f, fd_set *__s) } static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) -void __fortify_FD_SET(int __f, fd_set *__s) +void __fortify_FD_SET(int __f, fd_set * _FORTIFY_FD_POS0 __s) { size_t __b = __bos(__s, 0); @@ -47,6 +54,8 @@ void __fortify_FD_SET(int __f, fd_set *__s) FD_SET(__f, __s); } +#undef _FORTIFY_FD_POS0 + #undef FD_CLR #define FD_CLR(fd, set) __fortify_FD_CLR(fd, set) #undef FD_SET diff --git a/include/sys/socket.h b/include/sys/socket.h index 604d65a..7dfa71a 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2015-2016 Dimitris Papastamos + * Copyright (C) 2022 q66 * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted. @@ -33,7 +34,8 @@ extern "C" { #undef send #undef sendto -_FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl) +_FORTIFY_FN(recv) ssize_t recv(int __f, void * _FORTIFY_POS0 __s, size_t __n, + int __fl) { size_t __b = __bos(__s, 0); @@ -42,7 +44,8 @@ _FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl) return __orig_recv(__f, __s, __n, __fl); } -_FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl, +_FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void * _FORTIFY_POS0 __s, + size_t __n, int __fl, struct sockaddr *__a, socklen_t *__l) { size_t __b = __bos(__s, 0); @@ -52,7 +55,8 @@ _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl, return __orig_recvfrom(__f, __s, __n, __fl, __a, __l); } -_FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl) +_FORTIFY_FN(send) ssize_t send(int __f, const void * _FORTIFY_POS0 __s, + size_t __n, int __fl) { size_t __b = __bos(__s, 0); @@ -61,7 +65,8 @@ _FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl) return __orig_send(__f, __s, __n, __fl); } -_FORTIFY_FN(sendto) ssize_t sendto(int __f, const void *__s, size_t __n, int __fl, +_FORTIFY_FN(sendto) ssize_t sendto(int __f, const void * _FORTIFY_POS0 __s, + size_t __n, int __fl, const struct sockaddr *__a, socklen_t __l) { size_t __b = __bos(__s, 0); -- cgit v1.3