1 /* { dg-do compile { target cris-*-* } } */
2 /* { dg-options "-O2" } */
3 /* { dg-final { scan-assembler "\\\.ifnc \\\$r9-\\\$r10-\\\$r11-\\\$r12" } } */
5 /* Sanity check for asm register operands in syscall failed for
6 cris-axis-linux-gnu due to regmove bug.
7 Hans-Peter Nilsson <hp@axis.com>. */
9 extern void lseek64 (int, long long, int);
10 extern int *__errno_location (void);
14 unsigned short int d_reclen
;
17 struct kernel_dirent64
20 unsigned short d_reclen
;
24 static inline int __attribute__ ((__always_inline__
))
25 __syscall_getdents64 (int fd
, char * dirp
, unsigned count
)
27 register unsigned long __sys_res
asm ("r10");
28 register unsigned long __r10
__asm__ ("r10") = (unsigned long) fd
;
29 register unsigned long __r11
__asm__ ("r11") = (unsigned long) dirp
;
30 register unsigned long __r12
__asm__ ("r12") = (unsigned long) count
;
31 register unsigned long __callno
asm ("r9") = (220);
32 asm volatile (".ifnc %1-%0-%3-%4,$r9-$r10-$r11-$r12\n\t"
37 : "r" (__callno
), "0" (__r10
), "r" (__r11
), "r" (__r12
)
39 if (__sys_res
>= (unsigned long) -4096)
41 (*__errno_location ()) = - __sys_res
;
48 __getdents64 (int fd
, char *buf
, unsigned nbytes
)
51 long long last_offset
= -1;
53 struct kernel_dirent64
*skdp
, *kdp
;
54 dp
= (struct dirent64
*) buf
;
55 skdp
= kdp
= __builtin_alloca (nbytes
);
56 retval
= __syscall_getdents64(fd
, (char *)kdp
, nbytes
);
59 while ((char *) kdp
< (char *) skdp
+ retval
)
61 if ((char *) dp
> buf
+ nbytes
)
63 lseek64(fd
, last_offset
, 0);
66 last_offset
= kdp
->d_off
;
67 __builtin_memcpy (dp
->d_name
, kdp
->d_name
, kdp
->d_reclen
- 10);
68 dp
= (struct dirent64
*) ((char *) dp
+ sizeof (*dp
));
69 kdp
= (struct kernel_dirent64
*) (((char *) kdp
) + kdp
->d_reclen
);
72 return (char *) dp
- buf
;