From fe149628eaae9748be08815d726cc56e8e492c73 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 26 Oct 2022 00:30:00 +0200 Subject: add initial clang support --- include/string.h | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'include/string.h') diff --git a/include/string.h b/include/string.h index c9f8839..bbf24fe 100644 --- a/include/string.h +++ b/include/string.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. @@ -38,7 +39,8 @@ extern "C" { __access(write_only, 1) __access(read_only, 2, 3) -_FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n) +_FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od, + const void * _FORTIFY_POS0 __os, size_t __n) { size_t __bd = __bos(__od, 0); size_t __bs = __bos(__os, 0); @@ -57,7 +59,8 @@ _FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n) __access(write_only, 1) __access(read_only, 2, 3) -_FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n) +_FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d, + const void * _FORTIFY_POS0 __s, size_t __n) { size_t __bd = __bos(__d, 0); size_t __bs = __bos(__s, 0); @@ -68,7 +71,7 @@ _FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n) } __access(write_only, 1) -_FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n) +_FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) { size_t __b = __bos(__d, 0); @@ -83,7 +86,7 @@ _FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n) #undef stpcpy __access(write_only, 1) __access(read_only, 2) -_FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s) +_FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s) { size_t __n = strlen(__s) + 1; @@ -102,7 +105,8 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s) #undef stpncpy __access(write_only, 1) __access(read_only, 2, 3) -_FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n) +_FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s, + size_t __n) { /* trap if pointers are overlapping but not if dst == src. * gcc seems to like to generate code that relies on dst == src */ @@ -119,7 +123,7 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n) __access (read_write, 1) __access (read_only, 2) -_FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s) +_FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s) { size_t __b = __bos(__d, 0); @@ -130,7 +134,7 @@ _FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s) __access (write_only, 1) __access (read_only, 2) -_FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s) +_FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s) { size_t __n = strlen(__s) + 1; @@ -148,7 +152,8 @@ _FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s) __access (read_write, 1) __access (read_only, 2, 3) -_FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n) +_FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s, + size_t __n) { size_t __b = __bos(__d, 0); @@ -165,7 +170,8 @@ _FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n) __access (write_only, 1) __access (read_only, 2, 3) -_FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n) +_FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d, + const char *__s, size_t __n) { /* trap if pointers are overlapping but not if dst == src. * gcc seems to like to generate code that relies on dst == src */ @@ -183,7 +189,8 @@ _FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n) #undef mempcpy __access(write_only, 1) __access(read_only, 2, 3) -_FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n) +_FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d, + const void * _FORTIFY_POS0 __s, size_t __n) { size_t __bd = __bos(__d, 0); size_t __bs = __bos(__s, 0); @@ -199,7 +206,8 @@ _FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n) #undef strlcpy __access (read_write, 1) __access (read_only, 2, 3) -_FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n) +_FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d, + const char *__s, size_t __n) { size_t __b = __bos(__d, 0); @@ -210,7 +218,8 @@ _FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n) __access (write_only, 1) __access (read_only, 2, 3) -_FORTIFY_FN(strlcpy) size_t strlcpy(char *__d, const char *__s, size_t __n) +_FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d, + const char *__s, size_t __n) { size_t __b = __bos(__d, 0); -- cgit v1.3