我有个问题.我遵循用ASM编写的x86 delphi代码.我需要将它移植到AMD64吗?
type
TCPUID = array[1..4] of Longint;
function GetCID : TCPUID; assembler; register;
asm
push ebx
push edi
mov edi, eax
mov eax, 1
dw $A20F
stosd
mov eax, ebx
stosd
mov eax, ecx
stosd
mov eax, edx
stosd
pop edi
pop ebx
end;
Run Code Online (Sandbox Code Playgroud)
我从未在汇编中编程,有没有人知道端口是什么或我将如何改变它.
我需要在单次传输中通过SPI发送10 k字节(是的,因为Linux是如此实时,如果我在两次传输中发送这些字节,我与IC的时序不匹配).
但spi_bcm2708内核模块中的最大消息大小为4096字节.如何修改此值(最好不重新编译模块)?如果我可以为模块指定参数,我需要指定哪个参数和文件?
提前致谢.
假设我们在某个外部库中定义了以下 Java 接口(因此我们无法控制它):
public interface JavaTest<R extends Something> { }
public class JavaTestImpl implements JavaTest<SomethingSpecific> {
public static final JavaTestImpl INSTANCE = ...
}
Run Code Online (Sandbox Code Playgroud)
现在我们想要编写 Scala 函数,它将采用任意实例JavaTest作为参数,并提取实例本身的类型和R泛型参数(例如,我们想要对实例类进行隐式类型类查找):
def test[A <: Something, X <: JavaTest[A]](x: X)(implicit tc: TypeClass[X]): A = {}
test(JavaTestImpl.INSTANCE) // should be [SomethingSpecific, JavaTestImpl]
Run Code Online (Sandbox Code Playgroud)
不幸的是,它的工作方式并不简单:编译器将调用test推断为 as [Nothing, JavaTestImpl],然后立即失败,因为推断的类型是错误的并且不满足约束。
有没有办法让 Scala 编译器推断相应的类型参数,而无需更改 Java 部分,也无需每次都编写大量样板文件?SomethingSpecific或者,换个方式提出问题,如果我们知道实例 ( ) 的类型,是否有办法提取泛型类型( JavaTestImpl) ?
我需要构建自己的OpenSSL二进制文件,因为Fedora-18提供的软件包没有椭圆曲线加密.我执行这些命令:
./config --prefix=/home/USERNAME/bin/ssl --openssldir=/home/USERNAME/bin/ssl/openssl -fPIC zlib no-idea no-mdc2 no-rc5
make depend
make
Run Code Online (Sandbox Code Playgroud)
但我有链接错误:
../libcrypto.a(x86_64cpuid.o): In function `OPENSSL_cleanse':
(.text+0x1a0): multiple definition of `OPENSSL_cleanse'
../libcrypto.a(mem_clr.o):mem_clr.c:(.text+0x0): first defined here
../libcrypto.a(cmll-x86_64.o): In function `Camellia_cbc_encrypt':
(.text+0x1f00): multiple definition of `Camellia_cbc_encrypt'
../libcrypto.a(cmll_cbc.o):cmll_cbc.c:(.text+0x0): first defined here
../libcrypto.a(aes-x86_64.o): In function `AES_encrypt':
(.text+0x460): multiple definition of `AES_encrypt'
../libcrypto.a(aes_core.o):aes_core.c:(.text+0x62a): first defined here
../libcrypto.a(aes-x86_64.o): In function `AES_decrypt':
(.text+0x9f0): multiple definition of `AES_decrypt'
../libcrypto.a(aes_core.o):aes_core.c:(.text+0xad0): first defined here
../libcrypto.a(aes-x86_64.o): In function `private_AES_set_encrypt_key':
(.text+0xab0): multiple definition of `private_AES_set_encrypt_key'
../libcrypto.a(aes_core.o):aes_core.c:(.text+0x0): first defined here
../libcrypto.a(aes-x86_64.o): In …Run Code Online (Sandbox Code Playgroud) 我试图在我的应用程序中实现类似模式popus的东西.为了使它们更清晰,我决定模糊整个窗口并将popus放在它前面.
问题是JavaFX模糊在应用于整个窗口时会产生伪影:
注意一个白色边框 - 它不应该存在.
我的代码是:
public void enableBlur() {
ColorAdjust adj = new ColorAdjust(0, -0.9, -0.5, 0);
GaussianBlur blur = new GaussianBlur(55); // 55 is just to show edge effect more clearly.
adj.setInput(blur)
rootPanel.setEffect(adj);
}
Run Code Online (Sandbox Code Playgroud)
因此效果将应用于根内容面板.
PS的问题是不是重复这个,因为我认为,提供的解决方案来自同一个边缘效应受到影响,但由于形式的内容是不是太黑暗这里也不是那么清晰可见.
我在使用 lockbox3 和 PHP mcrypt 时遇到了麻烦。我无法将 IV 传递给 PHP。德尔福代码:
var
Codec: TCodec;
CL: TCryptographicLibrary;
PlainStream: TStringStream;
CipherStream: TMemoryStream;
begin
PlainStream := TStringStream.Create(Edit1.Text);
CipherStream := TMemoryStream.Create;
CL := TCryptographicLibrary.Create(nil);
Codec := TCodec.Create(nil);
Codec.CryptoLibrary := CL;
Codec.ChainModeId := uTPLb_Constants.CBC_ProgId;
Codec.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId;
Codec.BlockCipherId := Format(uTPLb_Constants.AES_ProgId, [256]);
Codec.Password := Edit3.Text;
Codec.EncryptStream(PlainStream, CipherStream);
Codec.Burn;
Memo1.Text := Stream_to_Base64(CipherStream);
Memo2.Clear;
Memo2.Lines.Add(Format('Size: %d bytes', [CipherStream.Size]));
Memo2.Lines.Add(Format('Original size: %d bytes', [PlainStream.Size]));
Codec.Free;
CL.Free;
CipherStream.Free;
PlainStream.Free;
Run Code Online (Sandbox Code Playgroud)
和PHP 代码:
$ciphertext = base64_decode("zA/eeF+WFVMDsZ7+iA==");
$iv = substr($ciphertext, 0, …Run Code Online (Sandbox Code Playgroud) 我有一个查询Seq[Int]作为参数(并执行像一样的过滤WHERE x IN (...)),由于该查询的操作复杂,因此需要对其进行编译。但是,当我尝试幼稚的方法时:
Compiled((xs: Set[Int]) => someQuery.filter(_.x inSet xs))
Run Code Online (Sandbox Code Playgroud)
它失败并显示以下消息
Computation of type Set[Int] => Query[SomeTable, SomeValue, Seq] cannot be compiled (as type C)
Run Code Online (Sandbox Code Playgroud)
Slick可以编译以一组整数作为参数的查询吗?
更新:我使用PostgreSQL作为数据库,因此可以使用数组代替IN子句,但是如何?