Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147219407
D2107.id4414.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D2107.id4414.diff
View Options
Index: include/stdlib.h
===================================================================
--- include/stdlib.h
+++ include/stdlib.h
@@ -87,21 +87,21 @@
long atol(const char *);
void *bsearch(const void *, const void *, size_t,
size_t, int (*)(const void *, const void *));
-void *calloc(size_t, size_t) __malloc_like;
+void *calloc(size_t, size_t) __malloc_like __result_use_check __alloc_size(1, 2);
div_t div(int, int) __pure2;
_Noreturn void exit(int);
void free(void *);
char *getenv(const char *);
long labs(long) __pure2;
ldiv_t ldiv(long, long) __pure2;
-void *malloc(size_t) __malloc_like;
+void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);
int mblen(const char *, size_t);
size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
void qsort(void *, size_t, size_t,
int (*)(const void *, const void *));
int rand(void);
-void *realloc(void *, size_t);
+void *realloc(void *, size_t) __result_use_check __alloc_size(2);
void srand(unsigned);
double strtod(const char * __restrict, char ** __restrict);
float strtof(const char * __restrict, char ** __restrict);
@@ -155,7 +155,7 @@
* If we're in a mode greater than C99, expose C11 functions.
*/
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
-void * aligned_alloc(size_t, size_t) __malloc_like;
+void * aligned_alloc(size_t, size_t) __malloc_like __alloc_size(2);
int at_quick_exit(void (*)(void));
_Noreturn void
quick_exit(int);
@@ -170,7 +170,8 @@
int rand_r(unsigned *); /* (TSF) */
#endif
#if __POSIX_VISIBLE >= 200112
-int posix_memalign(void **, size_t, size_t); /* (ADV) */
+int posix_memalign(void **, size_t, size_t) __nonnull(1)
+ __alloc_size(3); /* (ADV) */
int setenv(const char *, const char *, int);
int unsetenv(const char *);
#endif
@@ -301,7 +302,7 @@
int (*)(void *, const void *, const void *));
int radixsort(const unsigned char **, int, const unsigned char *,
unsigned);
-void *reallocf(void *, size_t);
+void *reallocf(void *, size_t) __alloc_size(2);
int rpmatch(const char *);
void setprogname(const char *);
int sradixsort(const unsigned char **, int, const unsigned char *,
Index: sys/sys/cdefs.h
===================================================================
--- sys/sys/cdefs.h
+++ sys/sys/cdefs.h
@@ -40,6 +40,9 @@
* Testing against Clang-specific extensions.
*/
+#ifndef __has_attribute
+#define __has_attribute(x) 0
+#endif
#ifndef __has_extension
#define __has_extension __has_feature
#endif
@@ -209,6 +212,7 @@
#define __unused
#define __packed
#define __aligned(x)
+#define __alloc_size(...)
#define __section(x)
#define __weak
#else
@@ -233,6 +237,11 @@
#define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x)))
#endif
+#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3)
+#define __alloc_size(...) __attribute__((alloc_size(__VA_ARGS__)))
+#else
+#define __alloc_size(...)
+#endif
#if defined(__INTEL_COMPILER)
#define __dead2 __attribute__((__noreturn__))
#define __pure2 __attribute__((__const__))
@@ -242,7 +251,7 @@
#define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x)))
#endif
-#endif
+#endif /* lint */
#if !__GNUC_PREREQ__(2, 95)
#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
@@ -363,8 +372,10 @@
#if __GNUC_PREREQ__(3, 4)
#define __fastcall __attribute__((__fastcall__))
+#define __result_use_check __attribute__((__warn_unused_result__))
#else
#define __fastcall
+#define __result_use_check
#endif
#if __GNUC_PREREQ__(4, 1)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 10, 5:28 AM (5 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29462990
Default Alt Text
D2107.id4414.diff (3 KB)
Attached To
Mode
D2107: Add malloc-specific attributes to our standard headers
Attached
Detach File
Event Timeline
Log In to Comment