summaryrefslogtreecommitdiff
path: root/include/string.h
diff options
context:
space:
mode:
authorDaniel Kolesa2022-10-26 00:30:00 +0200
committerjvoisin2023-06-25 18:26:45 +0200
commitfe149628eaae9748be08815d726cc56e8e492c73 (patch)
tree252ed41ea13504b67b3c03e648113015b8f85dda /include/string.h
parentadae76af26e498af6c3004a52a4b1de2c6fd91c3 (diff)
add initial clang support
Diffstat (limited to 'include/string.h')
-rw-r--r--include/string.h33
1 files changed, 21 insertions, 12 deletions
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 @@
1/* 1/*
2 * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> 2 * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
3 * Copyright (C) 2022 q66 <q66@chimera-linux.org>
3 * 4 *
4 * Permission to use, copy, modify, and/or distribute this software for any 5 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted. 6 * purpose with or without fee is hereby granted.
@@ -38,7 +39,8 @@ extern "C" {
38 39
39__access(write_only, 1) 40__access(write_only, 1)
40__access(read_only, 2, 3) 41__access(read_only, 2, 3)
41_FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n) 42_FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od,
43 const void * _FORTIFY_POS0 __os, size_t __n)
42{ 44{
43 size_t __bd = __bos(__od, 0); 45 size_t __bd = __bos(__od, 0);
44 size_t __bs = __bos(__os, 0); 46 size_t __bs = __bos(__os, 0);
@@ -57,7 +59,8 @@ _FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n)
57 59
58__access(write_only, 1) 60__access(write_only, 1)
59__access(read_only, 2, 3) 61__access(read_only, 2, 3)
60_FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n) 62_FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d,
63 const void * _FORTIFY_POS0 __s, size_t __n)
61{ 64{
62 size_t __bd = __bos(__d, 0); 65 size_t __bd = __bos(__d, 0);
63 size_t __bs = __bos(__s, 0); 66 size_t __bs = __bos(__s, 0);
@@ -68,7 +71,7 @@ _FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n)
68} 71}
69 72
70__access(write_only, 1) 73__access(write_only, 1)
71_FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n) 74_FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n)
72{ 75{
73 size_t __b = __bos(__d, 0); 76 size_t __b = __bos(__d, 0);
74 77
@@ -83,7 +86,7 @@ _FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n)
83#undef stpcpy 86#undef stpcpy
84__access(write_only, 1) 87__access(write_only, 1)
85__access(read_only, 2) 88__access(read_only, 2)
86_FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s) 89_FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s)
87{ 90{
88 size_t __n = strlen(__s) + 1; 91 size_t __n = strlen(__s) + 1;
89 92
@@ -102,7 +105,8 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s)
102#undef stpncpy 105#undef stpncpy
103__access(write_only, 1) 106__access(write_only, 1)
104__access(read_only, 2, 3) 107__access(read_only, 2, 3)
105_FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n) 108_FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s,
109 size_t __n)
106{ 110{
107 /* trap if pointers are overlapping but not if dst == src. 111 /* trap if pointers are overlapping but not if dst == src.
108 * gcc seems to like to generate code that relies on dst == src */ 112 * 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)
119 123
120__access (read_write, 1) 124__access (read_write, 1)
121__access (read_only, 2) 125__access (read_only, 2)
122_FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s) 126_FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s)
123{ 127{
124 size_t __b = __bos(__d, 0); 128 size_t __b = __bos(__d, 0);
125 129
@@ -130,7 +134,7 @@ _FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s)
130 134
131__access (write_only, 1) 135__access (write_only, 1)
132__access (read_only, 2) 136__access (read_only, 2)
133_FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s) 137_FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s)
134{ 138{
135 size_t __n = strlen(__s) + 1; 139 size_t __n = strlen(__s) + 1;
136 140
@@ -148,7 +152,8 @@ _FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s)
148 152
149__access (read_write, 1) 153__access (read_write, 1)
150__access (read_only, 2, 3) 154__access (read_only, 2, 3)
151_FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n) 155_FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s,
156 size_t __n)
152{ 157{
153 size_t __b = __bos(__d, 0); 158 size_t __b = __bos(__d, 0);
154 159
@@ -165,7 +170,8 @@ _FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n)
165 170
166__access (write_only, 1) 171__access (write_only, 1)
167__access (read_only, 2, 3) 172__access (read_only, 2, 3)
168_FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n) 173_FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d,
174 const char *__s, size_t __n)
169{ 175{
170 /* trap if pointers are overlapping but not if dst == src. 176 /* trap if pointers are overlapping but not if dst == src.
171 * gcc seems to like to generate code that relies on dst == src */ 177 * 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)
183#undef mempcpy 189#undef mempcpy
184__access(write_only, 1) 190__access(write_only, 1)
185__access(read_only, 2, 3) 191__access(read_only, 2, 3)
186_FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n) 192_FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d,
193 const void * _FORTIFY_POS0 __s, size_t __n)
187{ 194{
188 size_t __bd = __bos(__d, 0); 195 size_t __bd = __bos(__d, 0);
189 size_t __bs = __bos(__s, 0); 196 size_t __bs = __bos(__s, 0);
@@ -199,7 +206,8 @@ _FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n)
199#undef strlcpy 206#undef strlcpy
200__access (read_write, 1) 207__access (read_write, 1)
201__access (read_only, 2, 3) 208__access (read_only, 2, 3)
202_FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n) 209_FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d,
210 const char *__s, size_t __n)
203{ 211{
204 size_t __b = __bos(__d, 0); 212 size_t __b = __bos(__d, 0);
205 213
@@ -210,7 +218,8 @@ _FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n)
210 218
211__access (write_only, 1) 219__access (write_only, 1)
212__access (read_only, 2, 3) 220__access (read_only, 2, 3)
213_FORTIFY_FN(strlcpy) size_t strlcpy(char *__d, const char *__s, size_t __n) 221_FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d,
222 const char *__s, size_t __n)
214{ 223{
215 size_t __b = __bos(__d, 0); 224 size_t __b = __bos(__d, 0);
216 225