testptp.c 是否可以为其他人编译?

testptp.c 是否可以为其他人编译?

我正在尝试编译一个脚本来帮助我测试 LinuxPTP。 testptp.c 文件是帮助执行此操作的脚本。它内置于 Linux 内核中。但是,我无法编译它。这只是我吗?我看到很多人在谈论这个实用程序脚本,但我看到的唯一在线教程是:https://docs.nvidia.com/networking/display/NVIDIA5TTechnologyUserManualv10/Testptp

它告诉您使用 gcc 编译 testptp.c。我使用以下命令进行编译,在只有 testptp.c: 的目录中gcc testptp.c -o testptp。我还从 git 中提取了 Linux 内核并进入tools/testing/selftests/ptp并运行make。两者产生相同的结果。

这是我的输出:

Makefile:10: warning: overriding recipe for target 'clean'
../lib.mk:130: warning: ignoring old recipe for target 'clean'
gcc -I../../../../usr/include/    testptp.c  -lrt -o testptp
testptp.c: In function ‘main’:
testptp.c:295:15: error: ‘struct ptp_clock_caps’ has no member named ‘adjust_phase’
  295 |           caps.adjust_phase);
      |               ^
testptp.c:429:28: error: ‘PTP_PEROUT_DUTY_CYCLE’ undeclared (first use in this function)
  429 |    perout_request.flags |= PTP_PEROUT_DUTY_CYCLE;
      |                            ^~~~~~~~~~~~~~~~~~~~~
testptp.c:429:28: note: each undeclared identifier is reported only once for each function it appears in
testptp.c:430:18: error: ‘struct ptp_perout_request’ has no member named ‘on’
  430 |    perout_request.on.sec = pulsewidth / NSEC_PER_SEC;
      |                  ^
testptp.c:431:18: error: ‘struct ptp_perout_request’ has no member named ‘on’
  431 |    perout_request.on.nsec = pulsewidth % NSEC_PER_SEC;
      |                  ^
testptp.c:434:28: error: ‘PTP_PEROUT_PHASE’ undeclared (first use in this function); did you mean ‘PTP_PEROUT_REQUEST’?
  434 |    perout_request.flags |= PTP_PEROUT_PHASE;
      |                            ^~~~~~~~~~~~~~~~
      |                            PTP_PEROUT_REQUEST
testptp.c:435:18: error: ‘struct ptp_perout_request’ has no member named ‘phase’
  435 |    perout_request.phase.sec = perout_phase / NSEC_PER_SEC;
      |                  ^
testptp.c:436:18: error: ‘struct ptp_perout_request’ has no member named ‘phase’
  436 |    perout_request.phase.nsec = perout_phase % NSEC_PER_SEC;
      |                  ^
make: *** [<builtin>: testptp] Error 1

我运行的是 Ubuntu 20.04。 Linux 内核版本:5.15.0-53-generic

这对其他人有用吗?

答案1

/usr/include/linux/ptp_clock.h覆盖文件以下文件似乎对我有用。

相关内容