diff --git a/libc/spec/posix.td b/libc/spec/posix.td --- a/libc/spec/posix.td +++ b/libc/spec/posix.td @@ -1,22 +1,22 @@ def SigSetType : NamedType<"sigset_t">; def SigSetPtrType : PtrType; def ConstSigSetPtrType : ConstType; -def RestrictSigSetType : RestrictedPtrType; -def ConstRestrictSigSetType : ConstType; +def RestrictedSigSetType : RestrictedPtrType; +def ConstRestrictedSigSetType : ConstType; def StructSigaction : NamedType<"struct sigaction">; def StructSigactionPtr : PtrType; def ConstStructSigactionPtr : ConstType; -def RestrictStructSigactionPtr : RestrictedPtrType; -def ConstRestrictStructSigactionPtr : ConstType; +def RestrictedStructSigactionPtr : RestrictedPtrType; +def ConstRestrictedStructSigactionPtr : ConstType; def POSIX : StandardSpec<"POSIX"> { - // TODO: Change naming so that they're consistent with other files. PtrType CharPtr = PtrType; - ConstType ConstCharPtr = ConstType; RestrictedPtrType RestrictedCharPtr = RestrictedPtrType; - ConstType ConstRestrictedCharPtr = ConstType; RestrictedPtrType CharRestrictedDoublePtr = RestrictedPtrType; + ConstType ConstCharPtr = ConstType; + ConstType ConstRestrictedCharPtr = ConstType; + NamedType OffTType = NamedType<"off_t">; NamedType SSizeTType = NamedType<"ssize_t">; @@ -160,8 +160,8 @@ "sigaction", RetValSpec, [ArgSpec, - ArgSpec, - ArgSpec] + ArgSpec, + ArgSpec] >, FunctionSpec< "sigdelset", @@ -172,7 +172,7 @@ FunctionSpec< "sigprocmask", RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] + [ArgSpec, ArgSpec, ArgSpec] >, FunctionSpec< "sigemptyset", diff --git a/libc/src/string/strcat.h b/libc/src/string/strcat.h --- a/libc/src/string/strcat.h +++ b/libc/src/string/strcat.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -char *strcat(char *dest, const char *src); +char *strcat(char *__restrict dest, const char *__restrict src); } // namespace __llvm_libc diff --git a/libc/src/string/strcat.cpp b/libc/src/string/strcat.cpp --- a/libc/src/string/strcat.cpp +++ b/libc/src/string/strcat.cpp @@ -14,7 +14,8 @@ namespace __llvm_libc { -char *LLVM_LIBC_ENTRYPOINT(strcat)(char *dest, const char *src) { +char *LLVM_LIBC_ENTRYPOINT(strcat)(char *__restrict dest, + const char *__restrict src) { __llvm_libc::strcpy(dest + __llvm_libc::strlen(dest), src); return dest; } diff --git a/libc/src/string/strcpy.h b/libc/src/string/strcpy.h --- a/libc/src/string/strcpy.h +++ b/libc/src/string/strcpy.h @@ -13,7 +13,7 @@ namespace __llvm_libc { -char *strcpy(char *dest, const char *src); +char *strcpy(char *__restrict dest, const char *__restrict src); } // namespace __llvm_libc diff --git a/libc/src/string/strcpy.cpp b/libc/src/string/strcpy.cpp --- a/libc/src/string/strcpy.cpp +++ b/libc/src/string/strcpy.cpp @@ -14,7 +14,8 @@ namespace __llvm_libc { -char *LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) { +char *LLVM_LIBC_ENTRYPOINT(strcpy)(char *__restrict dest, + const char *__restrict src) { return reinterpret_cast( __llvm_libc::memcpy(dest, src, __llvm_libc::strlen(src) + 1)); } diff --git a/libc/src/string/string_utils.h b/libc/src/string/string_utils.h --- a/libc/src/string/string_utils.h +++ b/libc/src/string/string_utils.h @@ -37,8 +37,9 @@ // is found is then stored within 'context' for subsequent calls. Subsequent // calls will use 'context' when a nullptr is passed in for 'src'. Once the null // terminating character is reached, returns a nullptr. -static inline char *string_token(char *src, const char *delimiter_string, - char **saveptr) { +static inline char *string_token(char *__restrict src, + const char *__restrict delimiter_string, + char **__restrict saveptr) { cpp::Bitset<256> delimiter_set; for (; *delimiter_string; ++delimiter_string) delimiter_set.set(*delimiter_string); diff --git a/libc/src/string/strtok.h b/libc/src/string/strtok.h --- a/libc/src/string/strtok.h +++ b/libc/src/string/strtok.h @@ -11,7 +11,7 @@ namespace __llvm_libc { -char *strtok(char *src, const char *delimiter_string); +char *strtok(char *__restrict src, const char *__restrict delimiter_string); } // namespace __llvm_libc diff --git a/libc/src/string/strtok.cpp b/libc/src/string/strtok.cpp --- a/libc/src/string/strtok.cpp +++ b/libc/src/string/strtok.cpp @@ -15,9 +15,8 @@ static char *strtok_str = nullptr; -// TODO: Place restrict qualifier where necessary for this and other function -// arguments. -char *LLVM_LIBC_ENTRYPOINT(strtok)(char *src, const char *delimiter_string) { +char *LLVM_LIBC_ENTRYPOINT(strtok)(char *__restrict src, + const char *__restrict delimiter_string) { return internal::string_token(src, delimiter_string, &strtok_str); } diff --git a/libc/src/string/strtok_r.h b/libc/src/string/strtok_r.h --- a/libc/src/string/strtok_r.h +++ b/libc/src/string/strtok_r.h @@ -11,7 +11,8 @@ namespace __llvm_libc { -char *strtok_r(char *src, const char *delimiter_string, char **saveptr); +char *strtok_r(char *__restrict src, const char *__restrict delimiter_string, + char **__restrict saveptr); } // namespace __llvm_libc diff --git a/libc/src/string/strtok_r.cpp b/libc/src/string/strtok_r.cpp --- a/libc/src/string/strtok_r.cpp +++ b/libc/src/string/strtok_r.cpp @@ -13,8 +13,9 @@ namespace __llvm_libc { -char *LLVM_LIBC_ENTRYPOINT(strtok_r)(char *src, const char *delimiter_string, - char **saveptr) { +char *LLVM_LIBC_ENTRYPOINT(strtok_r)(char *__restrict src, + const char *__restrict delimiter_string, + char **__restrict saveptr) { return internal::string_token(src, delimiter_string, saveptr); }