diff options
author | Raman Tenneti <rtenneti@google.com> | 2023-02-16 09:56:36 -0800 |
---|---|---|
committer | Raman Tenneti <rtenneti@google.com> | 2023-02-16 10:12:18 -0800 |
commit | fbe210dc7a6ad87a30e5ffe928a168e621f6fcc5 (patch) | |
tree | 1f606f182924eebcb5d645c329d2a98285ff8d49 /libc/spec | |
parent | 35742743d27363dd25c6b0bde3e9fcfd8a0f2167 (diff) | |
download | llvm-fbe210dc7a6ad87a30e5ffe928a168e621f6fcc5.tar.gz |
[libc] Implement htonl and htons
Per spec:
* https://pubs.opengroup.org/onlinepubs/9699919799/functions/htonl.html
* https://pubs.opengroup.org/onlinepubs/9699919799/functions/htons.html
Also adds UInt16Type and UInt32Type to spec.td
Co-authored-by: Jeff Bailey <jbailey@google.com>
Reviewed By: sivachandra, jeffbailey, rtenneti
Differential Revision: https://reviews.llvm.org/D143795
Diffstat (limited to 'libc/spec')
-rw-r--r-- | libc/spec/posix.td | 20 | ||||
-rw-r--r-- | libc/spec/spec.td | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/libc/spec/posix.td b/libc/spec/posix.td index 43cc031953b6..a7e50ca107f2 100644 --- a/libc/spec/posix.td +++ b/libc/spec/posix.td @@ -798,6 +798,25 @@ def POSIX : StandardSpec<"POSIX"> { ] >; + HeaderSpec ArpaInet = HeaderSpec< + "arpa/inet.h", + [], // Macros + [], // Types + [], // Enumerations + [ + FunctionSpec< + "htonl", + RetValSpec<UInt32Type>, + [ArgSpec<UInt32Type>] + >, + FunctionSpec< + "htons", + RetValSpec<UInt16Type>, + [ArgSpec<UInt16Type>] + >, + ] + >; + HeaderSpec PThread = HeaderSpec< "pthread.h", [], // Macros @@ -1260,6 +1279,7 @@ def POSIX : StandardSpec<"POSIX"> { >; let Headers = [ + ArpaInet, CType, Dirent, Errno, diff --git a/libc/spec/spec.td b/libc/spec/spec.td index 017056d7d773..87bafb087d3f 100644 --- a/libc/spec/spec.td +++ b/libc/spec/spec.td @@ -64,6 +64,9 @@ def LongDoublePtr : PtrType<LongDoubleType>; def IntMaxTType : NamedType<"intmax_t">; def UIntMaxTType : NamedType<"uintmax_t">; +def UInt16Type : NamedType<"uint16_t">; +def UInt32Type : NamedType<"uint32_t">; + def OffTType : NamedType<"off_t">; def OffTPtr : PtrType<OffTType>; def SSizeTType : NamedType<"ssize_t">; |