aboutsummaryrefslogtreecommitdiff
path: root/include/wchar.h
diff options
context:
space:
mode:
authorDavid Schultz <das@FreeBSD.org>2009-01-31 18:27:02 +0000
committerDavid Schultz <das@FreeBSD.org>2009-01-31 18:27:02 +0000
commit544048ecef8fd8480d850fe80ba04ab9d7f8bdef (patch)
tree86563ca98ba62d850839a916a23d185416bda1b7 /include/wchar.h
parent13fd4d21637e98c03983ed6c5972695dfa232fe9 (diff)
downloadsrc-544048ecef8fd8480d850fe80ba04ab9d7f8bdef.tar.gz
src-544048ecef8fd8480d850fe80ba04ab9d7f8bdef.zip
Add a function attribute called `__malloc_like', which informs gcc
that the annotated function returns a pointer that doesn't alias any extant pointer. This results in a 50%+ speedup in microbenchmarks such as the following: char *cp = malloc(1), *buf = malloc(BUF); for (i = 0; i < BUF; i++) buf[i] = *cp; In real programs, your mileage will vary. Note that gcc already performs this optimization automatically for any function called `malloc', `calloc', `strdup', or `strndup' unless -fno-builtins is used.
Notes
Notes: svn path=/head/; revision=187961
Diffstat (limited to 'include/wchar.h')
-rw-r--r--include/wchar.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/wchar.h b/include/wchar.h
index 2326b1debb50..4fc6c8cb03b2 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -214,7 +214,7 @@ int wcwidth(wchar_t);
wchar_t *fgetwln(struct __sFILE * __restrict, size_t * __restrict);
size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
size_t, mbstate_t * __restrict);
-wchar_t *wcsdup(const wchar_t *);
+wchar_t *wcsdup(const wchar_t *) __malloc_like;
size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
size_t, mbstate_t * __restrict);
size_t wcslcat(wchar_t *, const wchar_t *, size_t);