Home | History | Annotate | Download | only in sanitizer_common
      1 //===-- sanitizer_platform_limits_posix.cc --------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file is a part of Sanitizer common code.
     11 //
     12 // Sizes and layouts of platform-specific POSIX data structures.
     13 //===----------------------------------------------------------------------===//
     14 
     15 #if defined(__linux__) || defined(__APPLE__)
     16 
     17 #include "sanitizer_internal_defs.h"
     18 #include "sanitizer_platform_limits_posix.h"
     19 
     20 #include <dirent.h>
     21 #include <pthread.h>
     22 #include <sys/utsname.h>
     23 #include <sys/types.h>
     24 #include <sys/stat.h>
     25 #include <sys/time.h>
     26 #include <sys/resource.h>
     27 #include <sys/socket.h>
     28 #include <time.h>
     29 
     30 #if defined(__linux__)
     31 #include <sys/vfs.h>
     32 #include <sys/epoll.h>
     33 #endif // __linux__
     34 
     35 namespace __sanitizer {
     36   unsigned struct_utsname_sz = sizeof(struct utsname);
     37   unsigned struct_stat_sz = sizeof(struct stat);
     38   unsigned struct_stat64_sz = sizeof(struct stat64);
     39   unsigned struct_rusage_sz = sizeof(struct rusage);
     40   unsigned struct_tm_sz = sizeof(struct tm);
     41 
     42 #if defined(__linux__)
     43   unsigned struct_rlimit_sz = sizeof(struct rlimit);
     44   unsigned struct_dirent_sz = sizeof(struct dirent);
     45   unsigned struct_statfs_sz = sizeof(struct statfs);
     46   unsigned struct_epoll_event_sz = sizeof(struct epoll_event);
     47 #endif // __linux__
     48 
     49 #if defined(__linux__) && !defined(__ANDROID__)
     50   unsigned struct_dirent64_sz = sizeof(struct dirent64);
     51   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
     52   unsigned struct_statfs64_sz = sizeof(struct statfs64);
     53 #endif // __linux__ && !__ANDROID__
     54 
     55   void* __sanitizer_get_msghdr_iov_iov_base(void* msg, int idx) {
     56     return ((struct msghdr *)msg)->msg_iov[idx].iov_base;
     57   }
     58 
     59   uptr __sanitizer_get_msghdr_iov_iov_len(void* msg, int idx) {
     60     return ((struct msghdr *)msg)->msg_iov[idx].iov_len;
     61   }
     62 
     63   uptr __sanitizer_get_msghdr_iovlen(void* msg) {
     64     return ((struct msghdr *)msg)->msg_iovlen;
     65   }
     66 
     67   uptr __sanitizer_get_socklen_t(void* socklen_ptr) {
     68     return *(socklen_t*)socklen_ptr;
     69   }
     70 }  // namespace __sanitizer
     71 
     72 COMPILER_CHECK(sizeof(__sanitizer_pthread_attr_t) >= sizeof(pthread_attr_t));
     73 
     74 #endif  // __linux__ || __APPLE__
     75