xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/darwin-align-cast.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc typedef long unsigned int __darwin_size_t;
4*f4a2713aSLionel Sambuc typedef long __darwin_ssize_t;
5*f4a2713aSLionel Sambuc typedef __darwin_size_t size_t;
6*f4a2713aSLionel Sambuc typedef __darwin_ssize_t ssize_t;
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc struct cmsghdr {};
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc #if 0
11*f4a2713aSLionel Sambuc This code below comes from the following system headers:
12*f4a2713aSLionel Sambuc sys/socket.h:#define CMSG_SPACE(l) (__DARWIN_ALIGN(sizeof(struct
13*f4a2713aSLionel Sambuc cmsghdr)) + __DARWIN_ALIGN(l))
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc i386/_param.h:#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(p)
16*f4a2713aSLionel Sambuc + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES)
17*f4a2713aSLionel Sambuc #endif
18*f4a2713aSLionel Sambuc 
sendFileDescriptor(int fd,void * data,size_t nbytes,int sendfd)19*f4a2713aSLionel Sambuc ssize_t sendFileDescriptor(int fd, void *data, size_t nbytes, int sendfd) {
20*f4a2713aSLionel Sambuc   union {
21*f4a2713aSLionel Sambuc     char control[(((__darwin_size_t)((char *)(sizeof(struct cmsghdr)) + (sizeof(__darwin_size_t) - 1)) &~ (sizeof(__darwin_size_t) - 1)) + ((__darwin_size_t)((char *)(sizeof(int)) + (sizeof(__darwin_size_t) - 1)) &~ (sizeof(__darwin_size_t) - 1)))];
22*f4a2713aSLionel Sambuc   } control_un;
23*f4a2713aSLionel Sambuc   return 0;
24*f4a2713aSLionel Sambuc }
25*f4a2713aSLionel Sambuc 
26