On Tuesday, September 8, 2020 at 4:24:26 PM UTC+2, Dennis Bieber wrote:
>
> On Tue, 8 Sep 2020 04:12:05 -0700 (PDT), in
> gmane.comp.hardware.beagleboard.user Pavel Yermolenko
> <[email protected] <javascript:>> 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
>
2nd Ed. I cloned the source from github.com/derekmolloy/exploringbb.git
This link is proposed in the 2nd edidtion of the book (p. xxxiv)
>
>
> >
> >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.
>
Here is content of syscall subfolder:
debian@beaglebone:~/exploringbb/chp05/syscall$ ls -l *.cpp
-rw-r--r-- 1 debian debian 931 Sep 2 13:26 callchmod.cpp
-rw-r--r-- 1 debian debian 1234 Sep 2 13:26 glibcTest.cpp
-rw-r--r-- 1 debian debian 1345 Sep 2 13:26 syscall.cpp
debian@beaglebone:~/exploringbb/chp05/syscall$
So, there are both: *glibcTest.cpp* and *syscall.cpp*
Also there is build file:
debian@beaglebone:~/exploringbb/chp05/syscall$ more build
#!/bin/bash
g++ syscall.cpp -o syscall
g++ callchmod.cpp -o callchmod
debian@beaglebone:~/exploringbb/chp05/syscall$
Obviously Derek Molloy tried his code and undoubtedly he succeeded
> >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)
>
Ok
>
> 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
>
>
Anyway, what seems to work at Derek Molloy is not working with my toolchain.
Thanks.
--
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/fa6ca044-07c3-4955-a581-9c62870bb0bbo%40googlegroups.com.