On Tue, 8 Sep 2020 04:12:05 -0700 (PDT), in
gmane.comp.hardware.beagleboard.user Pavel Yermolenko
<[email protected]> wrote:
>Hello,
>
>Here is an example from chapter 5 of the book "Explore BeagleBone" by Derek
>Molloy:
First or second edition? I don't find your (following) example in the
second edition -- though there /is/ a program using syscall
>
>debian@beaglebone:~/exploringbb/chp05/syscall$ g++ syscall.cpp -o syscall
>syscall.cpp: In function ‘int main()’:
>syscall.cpp:22:10: error: ‘syscall’ was not declared in this scope
Note that your source file appears to be named syscall, along with the
output executable. That may be confusing the compiler some. Especially
since the header file that appears to provide the function is syscall.h
(which could imply there is a syscall.c (or .cpp) somewhere in the system.
The example in the second edition is a file named glibcTest.cpp in a
DIRECTORY named syscall.
>Indeed, I searched for syscall declaration in the toolchain ... and didn't
>find it:
>
>debian@beaglebone:~/exploringbb/chp05/syscall$ sudo grep -rn
>/usr/include/arm-linux-gnueabihf/ -e "syscall("
The odds are good that there is a space between syscall and the (
debian@beaglebone:~$ sudo find / -iname "syscall.h"
/usr/include/syscall.h
/usr/include/arm-linux-gnueabihf/sys/syscall.h
/usr/include/arm-linux-gnueabihf/bits/syscall.h
debian@beaglebone:~$
Though it turns out to be a definition in /usr/include/unistd.h which is
invoked by /sys/syscall.h (itself invoked by /syscall.h)
#ifdef __USE_MISC
/* Invoke `system call' number SYSNO, passing it the remaining arguments.
This is completely system-dependent, and not often useful.
In Unix, `syscall' sets `errno' for all errors and most calls return -1
for errors; in many systems you cannot pass arguments or get return
values for all system calls (`pipe', `fork', and `getppid' typically
among them).
In Mach, all system calls take normal arguments and always return an
error code (zero for success). */
extern long int syscall (long int __sysno, ...) __THROW;
#endif /* Use misc. */
(NOTE the space I predicted)
debian@beaglebone:~$ sudo grep -rn /usr/include/arm-linux-gnueabihf/ -e
"syscall ("
/usr/include/arm-linux-gnueabihf/asm/unistd-common.h:4:#define
__NR_restart_syscall (__NR_SYSCALL_BASE + 0)
/usr/include/arm-linux-gnueabihf/asm/unistd-oabi.h:14:#define __NR_syscall
(__NR_SYSCALL_BASE + 113)
debian@beaglebone:~$ sudo grep -rn /usr/include/ -e "syscall ("
/usr/include/arm-linux-gnueabihf/asm/unistd-common.h:4:#define
__NR_restart_syscall (__NR_SYSCALL_BASE + 0)
/usr/include/arm-linux-gnueabihf/asm/unistd-oabi.h:14:#define __NR_syscall
(__NR_SYSCALL_BASE + 113)
/usr/include/unistd.h:1056:extern long int syscall (long int __sysno, ...)
__THROW;
debian@beaglebone:~$
--
Dennis L Bieber
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/6d3flf10s2t9vtj5v7rueacfdvnaikoa83%404ax.com.